1

I have found various ways of creating a bootable USB flash drive for (L)ubuntu and Debian.

  1. https://askubuntu.com/a/377561 says to create a bootable Ubuntu USB flash drive from terminal, run

    sudo dd bs=4M if=path/to/input.iso of=/dev/sd<?> conv=fdatasync  status=progress
    
  2. https://www.debian.org/releases/stable/amd64/ch04s03.en.html says

    The CD or DVD image you choose should be written directly to the USB stick, overwriting its current contents. For example, when using an existing GNU/Linux system, the CD or DVD image file can be written to a USB stick as follows, after having made sure that the stick is unmounted:

    # cp debian.iso /dev/sdX
    # sync
    
  3. debian: Creating a Bootable Debian USB Flashdrive says

    To create a bootable USB drive from Windows, Mac OS, or a preexisting GNU/Linux installation, a reliable choice is to use Rufus.

  4. Lubuntu: Writing/burning the Image says:

    For writing images to USB drives on Linux, we recommend mkusb a tool developed by a Lubuntu team member, or the USB creator shipped with Lubuntu Startup Disk Creator .

I was wondering if the first way by dd which works at block level can work in all the cases? Is it the universal way?

Why can the second way use cp which works at file level not block level?

What are the benefits of the other ways compared to the first way of using dd? Can I achieve the same of the other ways, by using dd or some other commands along using dd?

Thanks.

GAD3R
  • 66,769
Tim
  • 101,790
  • There is no point in using dd, cp will do the job as well. What does on block level mean for you? – Arkadiusz Drabczyk Apr 09 '20 at 12:22
  • Related https://unix.stackexchange.com/questions/12532/dd-vs-cat-is-dd-still-relevant-these-days – Arkadiusz Drabczyk Apr 09 '20 at 12:23
  • Some tools like mkusb or rufus have an option to create a secondary partition for persistent storage (doesn't work with all distros). You can of course do this manually, i.e. partition your USB stick, create a persistence.conf if needed, etc. – Freddy Apr 09 '20 at 12:33
  • You have to define what "working at block level" and "working at file level" mean here. –  Apr 09 '20 at 21:43
  • @mosvy partition/device level and file system level. – Tim Apr 09 '20 at 22:01
  • One can also use cat debian.iso > /dev/sdX which is what I do when creating bootable USBs – Nasir Riley Apr 11 '20 at 22:47
  • @NasirRiley Thanks. What is special about Startup Disk Creator, Rufus and mksub? – Tim Apr 11 '20 at 23:13
  • They are just GUI (or in the case of mkusb, interactive) tools for people who prefer to do it that way. Think of it as the difference between gparted and parted in the terminal. Same thing, different ways. – Nasir Riley Apr 12 '20 at 00:21
  • This is actually a great question, and is one of the top hits on google when you search for this problem. It's sad that the format of StackExchange is such that difficult problems have no place here. No one has linked a genuine duplicate of this question for reference of seekers.

    I have never, not a single time, had 'cp', 'dd', or any other copy method actually work in creating a bootable USB. Computers ditched standard CD drives almost 10 years ago, and creating a bootable USB is still a headache. I'm not an idiot. I know how to dispatch 'cp' and 'sync' commands. But, it doesn't work IRL!

    – downbeat Mar 08 '22 at 14:39

1 Answers1

2

In Unix/Linux, a device is handled just like a regular file. If you place data on the device by using cp(1), or dd(1), or program > /dev/sdb makes no real difference. Just that e.g. dd has options for writing out in different sized chunks, that can be more efficient if the block size matches some hardware defined size.

vonbrand
  • 18,253