I am able to login to root terminal and then create tar zip file by running the command tar -zcvf dspace_tar.gz /home/dspace in a root terminal.

But I am not able to copy using the command

cp -av dspace_tar.gz /dev/sdb1

which is my external hard disk.

I get two errors: stat error and no such file or root directory.

  • 1
    Please you should be doing cp -av dspace_tar.gz /media/username/external_hdd_name Dec 29 '16 at 7:49
  • 1
    Do sudo lsblk -f to see the address of the device when its plugged in. Dec 29 '16 at 7:56
  • @George I suggest writing an answer here
    – Zanna
    Jan 3 '17 at 8:30
  • @Zanna done that. Jan 3 '17 at 8:49

Do not try to write to a device file (/dev/sdxY) - you should write to the mount point (/media/username/drive_name)

Since your trying to copy as root you should be doing:

cp -av dspace_tar.gz /media/username/external_hdd_name

If you don't know the mount point of the device, first plug it in then do this to get the address:

lsblk -f

The options:

  • -f option provided more information about the filesystems.
  • -a : used when copying archives
  • -v : displays the process in the terminal

the command "man cp" states that cp copies files and directories. This is a file system based operation. You try to copy a file direct - without using a file system - so a device (/dev/sdb1). Here are some options to meet your needs:

1. make a file system on /dev/sdb1 and copy the file with cp, in the way you tried it alread:
mkfs -t ext4 /dev/sdb1
mount /dev/sdb1 /mnt/mydisk1
cp -av dspace_tar.gz /mnt/mydisk1/


2. use tar to write the data direct to sdb1
tar czvf /dev/sdb1 dspace_tar.gz

there are also other options, but I think this are the 2 major ways. Usual way is to use a file system on a disk device.

  • Only when he is trying to format the HDD should he be doing mkfs -t ext4 /dev/sdb1 doing that will destroy any data he has there Dec 29 '16 at 7:51
  • Bad idea. He has filed in the gas.
    – anna328p
    Jan 3 '17 at 8:03

You are trying to overwrite your hard drive. I frequently use similar commands to write images.

If your hard drive is mounted somewhere try copying your file to the mount point. To do that run the command lsblk and look at the right side of the output.

If it isn't mounted you will have to mount it by first creating a directory for the mount point, then running sudo mount /dev/sdb1 <path to folder>. (Replace with the path to your folder). Then you can copy the file onto the hard drive, which appears as the folder.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.