copying Dir to a usb thumb drive
I want to copy my /home to a USB thumb drive recursively.
I've wrestled with this for a few hours now and continue to spin my wheels. The device is listed in my Disk Utility as /dev/sdc. However a little further down it is listed as /dev/sdc1 ? Anyway, I relabeled the volume as usb stick and formatted it to Ext4. I mounted it at /media/usb stick Do I have to enter this drive into the fstab? If so, how? what do I write? Using the command : cp -R (what follows... I want to copy /home recursively to the usb thumb drive.) Your help is appreciated. Matthew |
Some hints:
- /dev/sdc is the actual device, while /dev/sdc1 is the partition on it. Keep in mind that you have to mount the partition, not the device - using file-names that contain spaces is not a good idea on Linux, because you will have to escape the space every time you type it. That means you have to write the name of the directory like this usb\ stick. So to copy your home directory you have to write Code:
cp -R /home /media/usb\ stick |
Using the copy command "cp" the option -R simply asks for a recursive copy of folder and sub-folders.
Consider using the --archive or -a option. According to my man page, --archive results in: Code:
--no-dereference ..... never follow symbolic links in the SOURCE path Another way to do this involves using tar into a pipe instead of a file. The pipe then uses tar again to read the pipe. tar is somewhat smarter than cp when it comes to duplicating complex trees of files and folders. ~~~ 0;-Dan |
Many thanks, TobisGD and SaintDanBert.
I've had some success. I changed the volume name to get rid of the SPACE. I was able to create a dir on the USB /bkhome. But I'm mussing something and keep getting Err. Msg.s. Code:
root@mjh-desktop:~# cp -R /home/media/usbstick/ |
You don't specify the right path. You have created the directory bkhome on your stick, which is mounted on /media/usbstick. So the correct path is /media/usbstick/bkhome. Also consider the -a option recommended by SaintDanBert.
So your correct command should be: Code:
cp -aR /home /media/usbstick/bkhome |
The --archive(-a) option includes --recursive(-R).
Also, one reason to pipe tar to tar involves the issues of target folders. tar seems to deal with folder creation with fewer troubles while cp wants the targets to exist in some cases. ~~~ 0;-Dan |
Hi drmjh
This is not what you asked for..... but I think you should know this. Putting a journaling FS on a pendrive seems bad, because FS will use a part of the pendrive for journaling (many read/write cycles on the journaling block), flash memory cells will "die" faster this way. |
TobisSGD, vielen Dank!
SaintDanBert, many thanks, I will make notes on this now for future reference. Peter1234, I didn't know that and will keep it in mind. Basically, I just wanted a quick place to keep my data while I updated the OS. My next task is to set up Unison, synchronize my laptop and desktop and store a copy on the Ubuntu cloud. Matthew |
All times are GMT -5. The time now is 01:01 AM. |