1

I downloaded an image (.iso) to write it to a USB flash drive. The flash drive was connected to a USB hub, and I also had an external hard drive connected to the USB port of the laptop. After finishing the process, the image was written to the external hard drive instead of the USB flash drive. What could have happened?

I have already read that many people have had problems with USB hubs and Ubuntu, and this might fit into the same category. My USB hub is unpowered.

The listing of lsblk (before the problem, sdb had an XFS partition on it):

NAME   TRAN   TYPE RM   SIZE MOUNTPOINT
sdb    usb    disk  0 931.5G
└─sdb1        part  0    16G [SWAP]
sr0    sata   rom   1  1024M
sdc    usb    disk  1   3.7G
└─sdc1        part  1   3.7G /media/user/D609-ADCE
sda    sata   disk  0 298.1G
├─sda2        part  0 227.7G /home
├─sda3        part  0     2G [SWAP]
└─sda1        part  0  68.4G /

The command used to write the iso file was this:

sudo dd bs=4M if=/home/user/lnximg.iso of=/dev/sdc
Zanna
  • 70,465
  • ... or you made a typo in the command? – muru Nov 27 '17 at 04:17
  • 2
    Or you did not understand how Linux identifies drives / partitions. dd wrote where you told it to :0 – Panther Nov 27 '17 at 04:49
  • I checked this in the history of commands, and it was ok. Somehow, what should be written in /dev/sdc was written to /dev/sdb. – ProgAndPlay Nov 27 '17 at 05:17
  • 2
    Please post (in your question) the output of
    lsblk -o NAME,TRAN,TYPE,RM,SIZE,MOUNTPOINT
    – ubfan1 Nov 27 '17 at 05:25
  • I guess that I have used Unetbootin one day to write another iso image and it worked – ProgAndPlay Nov 27 '17 at 05:30
  • 1
    dd is a very powerful but also a very dangerous tool. It does what you tell it to do without any question. So if you tell it to overwrite your family pictures it will do it, and a minor typing error is enough for it to happen. It deserves the nickname 'Data Destroyer'. - Please use a tool with a final checkpoint, so that you can double-check that you are pointing to the correct target device. Unetbootin is such a tool. Other tools are the Ubuntu Startup Disk Creator, Disks (alias gnome-disks), mkusb, and in Windows Rufus and Win32 Disk Imager. – sudodus Nov 27 '17 at 07:00
  • Your output from lsblk does not indicate that /dev/sdb contains the content of a cloned Ubuntu iso file and I would not expect any other iso file to contain only a swap partition; The result might change after rebooting the computer. Or did you do something else with /dev/sdb between cloning with dd and running lsblk? -- Are there valuable data, that you want to recover? – sudodus Nov 27 '17 at 07:15
  • voting to close as the OP has not posted the commands s/he ran – Panther Nov 27 '17 at 15:05
  • It was the backup of data that I also have on my laptop, so, there was no data loss, fortunately. My xfs partition was gone and a fat32 partition with all the files of the iso image appeared there. There is a swap on the external hd now because I felt a little hesitation about using the device as a backup again. – ProgAndPlay Nov 27 '17 at 15:18
  • What if I had forgotten to unmount the pendrive that day? Reading the tutorials again, they say to unmount the flash drive before using dd. I wonder if this could be the issue. – ProgAndPlay Nov 27 '17 at 15:29

1 Answers1

2

Backup

I would encourage you to backup your data regularly, and a USB hard disk drive is a good alternative to store the backup data. So use the drive, that was overwritten by dd or another drive for backup.

You can check the S.M.A.R.T. status of a hard disk drive (HDD) or solid state drive (SSD) with Disks alias gnome-disks according to this link,

S.M.A.R.T. information of HDD and SSD

Responding to your original question and to your comments

  • I'm glad that there was no data loss - no need to recover any data :-)

  • But I think that the drive, that was overwritten by dd is still good. You can use gparted to create a new partition table and file system.

    I would use the ext4 file system for a backup drive, because it is well known, debugged and polished, and it works well with most versions of most linux distros (of course including Ubuntu).

  • No file system (partition) on the target device (the USB flash drive) should be mounted, when you clone to it, because something might be written automatically by some other process, and that would corrupt the USB boot system, that you want to create. (But it would still clone to the same target device.)

  • It is possible that the flash drive was not connected. It is also possible that it was connected. The block devices /dev/sda /dev/sdb /dev/sdc ... are assigned automatically to the drives and the order may change. You can never be sure which drive (physical device), that is identified as a certain block device, for example /dev/sdb. For that reason you must use a tool to identify the devices in the actual case, when you intend to write to it.

    This can be done with the following commands

    sudo parted -ls
    
    sudo lsblk -f
    sudo lsblk -m
    

    This is done automatically in several tools to create USB boot drives, for example mkusb, and you can double-check to be sure to write to the correct device.

  • Generally it is a good idea to disconnect USB drives for backup, when you intend to create a USB boot drive, and particularly if you use the dangerous dd.

sudodus
  • 46,324
  • 5
  • 88
  • 152