0

I tried to copy all the files from my USB drive using the "dd" command. Output shows success, equal in and out# of records, and less total GB available on HDD where I saved them to, but files are nowhere to be found. Ubuntu os.

dd if=/dev/sdx bs=16M of=/home/directory/foldername

where sdx = sdb = files to copy from USB; of =destination on hdd. directory = comp name; I created folder to put image in.

I mounted usb as "read-only".

I found my files, the image. How can I tell if it is corrupt?

closed as unclear what you're asking by Kusalananda Aug 12 at 20:38

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    cp (or rsync) should be used unless you need a dd specific feature, what exact command did you use? – user1133275 Aug 11 at 15:36
  • 1
    There is not enough info in the question. Tell us the dd command that you used. And/or do you know the names of the files? – ctrl-alt-delor Aug 11 at 15:44
  • 1
    If you use of=/dev/sda (as mentioned in a previous comment), you would overwrite your machine's filesystem with that of the USB drive. Don't do that. It would lead to not being able to boot, and to loss of data. You seem to not know the difference between a device file and a file on a device. – Kusalananda Aug 11 at 16:49
  • 1
    You are copying a USB image, not the files on the USB. Do you understand the difference? – roaima Aug 12 at 15:11
  • 1
    You've got the filesystem mounted and you're copying the live filesystem from the raw device. This is a really bad idea because the filesystem as written on the USB itself can be changed while you're still copying it, meaning you end up with an inconsistent view of the filesystem, which can lead to corruption in the copied image. Simple answer: stop copying the USB image and instead copy the files on the USB. – roaima Aug 12 at 15:12
3

You have copied an image of your USB stick. Instead, just copy the files:

cp -a /media/... ~/foldername  # Replace "..." with the rest of the path to the mounted USB stick

If you're not sure where your system has mounted the USB stick you can find out with either of these commands

df -h                          # List all the mounted filesystems; look for the one you want

mount | awk '/sdx/ {print $4}' # List of mounted filesystems, match "sdx", print mountpoint

I would strongly recommend that until become more familiar with UNIX/Linux systems you forget you have ever heard of the dd command. Really. (Why? Because there are very few situations where it's actually needed. Often for a raw copy cat is actually faster - and certainly no slower. And here, cp is the correct command to use.)

  • I've used the dd command before, didn't have a problem. – hddfsck777 Aug 11 at 16:00
  • @hddfsck777 You may well have, but to copy the files on a USB device, you would not use dd to make a dump of the device drive itself. – Kusalananda Aug 11 at 16:06
  • @hddfsck777: Incidentally, what you achieved with dd could also be achieved with cp: cp /dev/sdx /home/directory/foldername – Arkadiusz Drabczyk Aug 11 at 16:10
-2

Must use correct path to get the image accessible after it is copied over. /home/John/Desktop/anyfilename worked. However, file seems to be encrypted (101010). If I need to transfer the image back to flash drive, should the original flash drive image get damaged, don't know if the encryption will be an issue. Thanks to all who contributed.

  • 2
    I have no clue what you are talking about. It's not an encrypted file. It's an image of your USB stick. – Kusalananda Aug 11 at 20:10
  • @kusa well, when it copied over to the hdd, the file was locked, and had 1's and 0's on 'face' of the file as it sat in desktop folder (I did not try to open the file), I thought that stood for encryption. – hddfsck777 Aug 12 at 10:46
  • I'm assuming that icon just meant "binary file", which would be correct. I don't know what you mean by "locked". If you had wanted to copy the files from the USB stick, you would have mounted it and copied them with cp as ordinary files. – Kusalananda Aug 12 at 10:58
  • @kusa Well, I need to use a data recovery tool and was told to copy by blocks. Will a binary file open with root password? – hddfsck777 Aug 12 at 11:12
  • Your question never mentions anything about data recovery. It say "I want to copy all files". The image file that you created with dd is not locked or encrypted and I don't know where you got that idea from. I still don't know what it is you're actually wanting to do. – Kusalananda Aug 12 at 11:22

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