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
10
  • ... or you made a typo in the command?
    – muru
    Nov 27, 2017 at 4:17
  • 2
    Or you did not understand how Linux identifies drives / partitions. dd wrote where you told it to :0
    – Panther
    Nov 27, 2017 at 4: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. Nov 27, 2017 at 5:17
  • 2
    Please post (in your question) the output of lsblk -o NAME,TRAN,TYPE,RM,SIZE,MOUNTPOINT
    – ubfan1
    Nov 27, 2017 at 5:25
  • 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, 2017 at 7:00

1 Answer 1

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .