Moving files between Linux and GhostBSD and back

Add your Tips and tricks to configure and tweak your GhostBSD System here.
Post Reply
ASX
Posts: 988
Joined: Wed May 06, 2015 12:46 pm

Moving files between Linux and GhostBSD and back

Post by ASX »

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.
geffers
Posts: 24
Joined: Sat Feb 15, 2020 1:27 pm

Re: Moving files between Linux and GhostBSD and back

Post by geffers »

That is very interesting and a useful tip.

Guessing on a home network a NAS will probably be convenient, most modern routers have a USB socket that can be used for this purpose.

Geoff
Post Reply