Why does cpio deny access when copying to a USB stick?

54 views Asked by At

I want to make a copy of /home on my USB. To do this I am running this command: sudo find /home | cpio -o > /dev/sdb while Im logged as root user.

I have previously made sure that /dev/sdb is the directory associated with the USB using: sudo fdisk -l

But when I run the command it has no output, it shows nothing and there is no new file on the USB. I understand that copying /home will take a few minutes (although I have a practically new Ubuntu installation), any idea why it's not copying anything?

1

There are 1 answers

1
commanderdata On BEST ANSWER

/dev/sdb is the device, which in the Unix/Linux world is an abstraction for the actual hardware device (a USB drive in your case). In order to write data (in this case an archive of /home) to this type of device, you'll need to do the following. Maybe you've already completed some of these steps, but for completeness I'll list each below:

  1. Partition the device. You can check existing partition information with command line tools like fdisk and parted. If you need to partition the USB drive yourself, these commands will also be useful.
  2. Format the partition(s) on your device. You can check existing partitions with parted. On Ubuntu (and most flavors of Linux) ext4 is a common filesystem format, and you can use the mkfs.ext4 command to format a partition for ext4.
  3. Create mount point (just a normal directory) and mount your partition using the mount command. You can also use the mount and df commands to check existing mounts on your system. Note you may need to adjust the permissions and/or ownership on your mount point to allow reading and writing by the appropriate user.

You should be ready to write to your USB at this point via the directory where your device partition is now mounted. Note that for the commands I listed above you'll need to research the flags and options that are available for each.