5

I do

$ df -h
...
/dev/sdc1       1,5G  1,5G     0 100% /media/username/Ubuntu 17.04 amd64

$ umount /dev/sdc1

$ df -h
...
#sdc1 now not listed

$ sudo dd if=./memtest86-usb.img of=sdc
307200+0 records in
307200+0 records out
157286400 bytes (157 MB, 150 MiB) copied, 2,78627 s, 56,5 MB/s

but flashdrive remain unchanged.

what is wrong?

CodeBy
  • 253
  • 3
    @user68186 read the hover text on the downvote arrow. It doesn't say anything about whether something is a "common mistake". – hobbs Aug 01 '18 at 13:25
  • df only lists mounted partitions, so of course it would not show up in the output after unmounting. – Sergiy Kolodyazhnyy Aug 01 '18 at 13:31
  • 1
    Also, when writing image to a disk, it's often necessary to specify the block size, something like bs=4M. Also makes dd run a bit faster, iirc – Sergiy Kolodyazhnyy Aug 01 '18 at 13:33
  • 5
    You should be more careful when typing dd commands. That you make a mistake at all is an indication that you are not giving dd the respect it deserves. There's a reason seasoned *nix folks call it disk destroyer. – FourOhFour Aug 01 '18 at 16:44
  • 1
    @user68186 what was your point? Common mistakes shouldn't be downvoted? On the contrary, common mistakes are the ones most eligible for downvoting, because the downvoting tooltip says: "This question does not show any reasearch effort", and if it were indeed that common, basic research would have uncovered the mistake. – muru Aug 01 '18 at 18:00
  • @SergiyKolodyazhnyy, It is a good idea to specify the block size, bs=4096 or more will make the cloning with dd faster than with the default block size (bs=512 ). But I would not say that it is necessary. – sudodus Aug 01 '18 at 22:05
  • @sudodus It's not required usually, but I think with Raspberry Pi I had couple times when image wouldn't load properly without the flag. But yeah, not a requirement – Sergiy Kolodyazhnyy Aug 01 '18 at 23:30
  • @muru withdrawn. – user68186 Aug 02 '18 at 10:29

2 Answers2

31

Your command creates a file named sdc in the current directory. You want of=/dev/sdc.

So the complete correct command is:

sudo dd if=./memtest86-usb.img of=/dev/sdc

Run sync afterwards to synchronize cached writes to disk or use the conv=fsync option with dd.

pLumo
  • 26,947
  • 4
    Note that you'll also want to sync after dd but before removing the flash drive. – marcelm Aug 01 '18 at 14:46
  • 1
    (or use the conv=fsync option with dd) – muru Aug 02 '18 at 00:29
  • @muru I think oflag=sync would be more equivalent to a single sync command run afterwards? – detly Aug 02 '18 at 00:49
  • @detly the way I understand it, oflag=sync forces every write to be synchronized, but conv=fsync forces synchronization only at the end. So the former would have more consistent write speeds, perhaps, but the latter is more like a sync command run afterwards. – muru Aug 02 '18 at 00:55
  • @muru Ah you're right, I had it completely backwards. – detly Aug 02 '18 at 00:57
6

I support @RoVo's answer - it is a correct and good answer to the question.


I would like to add that dd is risky, and has caused problems for many users, because it will do what you tell it to do without any question. A minor typing error can make it overwrite an internal drive or a backup drive with important files.

You can play safer by using a [cloning] tool with a final checkpoint, that will give you a second chance to double-check and also display information about the available target devices.

  • Disks alias gnome-disks

  • mkusb

Link with more details: Cloning tools with a final checkpoint

sudodus
  • 46,324
  • 5
  • 88
  • 152