Moving files between Linux and GhostBSD and back

Configuring and tweaking your GhostBSD System.

Moderator: Developer

Moving files between Linux and GhostBSD and back

Postby ASX » Fri May 13, 2016 9:09 am

These USB storage sticks are widely used for temporary storage and to move data between computers, but sometimes this simple thing is challenging.

Different OSes uses different filesystem, and interoperability is not guaranteed; even when commonly known filesystems are supported from both the source and the destination systems, the commands to access/read/write the device might not be immediatley known, generally resulting in ... frustration.

Knowing that, and experiencing the issue myself, I have found the simplest way to transfer files between different Unix/Linux flavours is the good old 'tar' command,. (yes it is a short for Tape ARchive).

How is that ? Simple, 'tar' doesn't need a filesystem to operate, it can write to any raw storage device.

In Linux, the USB stick storage will be recognised as /dev/sdX, where X is the letter indicating the real device,
usually /dev/sda is the first disk, /dev/sdb is the second and so on, and there USB sticks are treated exactly like disks.

In FreeBSD/GhostBSD, USB sticks are named differently from disks, they will be named /dev/da0, /dev/da1 and so on.

In both system you can use "dmesg | tail" after plugging in the stick to check for the correct device name.

Then you can use 'tar' along with the -f option to read/write from/to a specific device, examples:

Linux:
Code: Select all
# write /home dir to a USB stick device:
tar cvf /dev/sdb /home

#list the content of the USB stick
tar tvf /dev/sdb

#extract the content of the stick into the current working directory:
tar xvf /dev/sdb



in GhostBSD
Code: Select all
# write /home dir to a USB stick device:
tar cvf /dev/da0 /home

#list the content of the USB stick
tar tvf /dev/da0

#extract the content of the stick into the current working directory:
tar xvf /dev/da0


you may notice that there is no use of specific partitions on the USB devices, in fact 'tar' is using the sticks like raw blocks devices, and that doesn't need partitions, nor filesystems, resulting in the desired compatibility.

WARNING: if a USB stick is already formatted, it's content will be completely destroyed by writing using 'tar', and after completing the file transfer you may need to repartition/reformat your USB device.
ASX
Developer
 
Posts: 208
Joined: Wed May 06, 2015 3:46 pm
Location: ITALY

Moving files between Linux and GhostBSD and back


Return to Tips and Tricks

Who is online

Users browsing this forum: No registered users and 0 guests