how to create a bootable Linux USB Drive in Terminal - on Command Line


Recommended Posts

 

dear community, 


i am wanting to create a bootable Linux-USB-Drive on the commmandline. I do not like etcher and the win-tools.  what i am wondering is the question why on earth the USB image maker out there (on any distro) use up all the entire space on a USB stick to make any Live Linux, say MX-Linux, or OpenSuse or Debian, or my beloved Puppy  or the ubuntu or Mint or whatsoever system, etc.

well - that said:  Most other distros create a live-usb with a simple "dd" copy of the iso file. 

 

the advantage here: This copies the iso file byte by byte onto the usb storage device. The iso file (according the documentation) has got a read-only iso9660 files system so the usb device gets a read-only iso9660 file-system. So whats the  fuzz  why do some systems take the whole usb-stick. 


To avoid these downsides i want to create a bootable Linux USB Drive in Terminal - on Command Line This makes the rest of the usb-stick useless for anything else because in order to make use of the remainder of the it you would need to create a partition table at the beginning but this is space is already used up be the iso filesystem and bootloader.

That said: well i guess that we can do the creation of a USB flash installation i think that create a bootable Linux USB stick from the command line the usage of the dd tool could be a good idea.
This tool is available on all Linux systems.


i think the steps are the following: 

 

Insert the USB flash drive into the USB port.

Next step, we ought to find out the name of the USB drive. for this step and job i think we can use  lsblk:

 

lsblk

lsblk

 

The output will look something like this:

 

NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda           8:0    0 999.8G  0 disk 
└─sda1        8:1    0 565.8G  0 part /data
sdy           8:16   1   7.5G  0 disk 
└─sdy1        8:17   1   7.5G  0 part /run/media/linuxize/Kingston
ndrive1     259:0    0 232.9G  0 disk 
├─ndrive1p1 259:1    0   512M  0 part /boot
├─ndrive1p2 259:2    0    16G  0 part [SWAP]
└─ndrive1p3 259:3    0 216.4G  0 part /

 


In our case the name of the USB device is /dev/sdy but this may vary on your system.  On most Linux distributions the USB flash drive will be automatically mounted when inserted.
Before flashing the image we should see if it is  needed to unmount the USB device.  To do so were able to use the umount command followed by either the mount point or the device name:

 

sudo umount /dev/sdy1

 

and now we re ready to flash the ISO image to the USB drive.  We need to make sure to replace /dev/sdy with our drive and do not append the partition number. 
Also, we need to make sure we are using the correct path to the ISO file.

 

sudo dd bs=4M if=/path/to/debian-10.0.0-amd64-netinst.iso of=/dev/sdx status=progress oflag=sync

 

 
with the use of oflag=sync and yes with the use of the famous dd-command - like so ... but other articles like itsfoss guide me to use sync:

 

sudo dd bs=4M if=/path/to/debian-10.0.0-amd64-netinst.iso of=/dev/sdx status=progress && sync

 

the question is: Which one is the better way: the

oflag=sync option to dd,

 

i think  that dd does not really bypasses kernel disk caches when writing to device. Generally spoken: Both sync command and oflag=sync will do the same job.
that sync command will write to disk all caches from all disks so,  when a machine is pretty busy writing to other disks drives
then i guess it will have a slower response for other commands.

 

well the question is: Which one is the better way: the oflag=sync option to dd ?
 

 

in that context i have the following question: I wonder whether oflag's direct does the syncing automatically or if it is explicitly required:

 

dd bs=10M oflag=direct,sync of=ofile.bin

 

Also what is the difference in saying 

 oflag=sync and conv=sync and conv=fsync?

 

What impact does it have if I change the code to the line below?

 

dd bs=10M conv=fsync oflag=direct of=ofile.bin

 

 

  • 8 months later...

I would suggest Ventoy (ventoy.net) instead (which has a version for Linux) as it's much easier and as a bonus one just has to copy the ISO files to the USB stick and boot to the USB stick in either UEFI or BIOS mode and then select the ISO you want to load and that's that ;)

 

even updating Ventoy is easy to.

Just use:

 

$ sudo dd bs=4M if=input.iso of=pathToYourUsbDrive

 

And be done with it. Don't try being all technical. There's no reason for it.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Kind of an unrelated rant, but... As someone with kids, who as of a few years ago were young enough that I wanted some of these family safety features. I have to say, any good intention MS had was completely RUINED by how absolutely awful the parental interface is. There was the family portal with limited settings, but more detailed settings were scattered is completely unintuitive ways. There was a child details page where you could configure the 100+ features, but, the features in the "gaming" section only applied the extremely limited list of Windows Store games that were not XBox branded. For anything with XBox branded, you had to find the XBox parental consent portal, which had another 100+ features to dig through and try to figure out what was blocking your two kids from playing Minecraft together. To make the experience even more infuriating, MS implemented their same signature documentation we find for 365 and Azure, that it is very easy to find documents talking about how easy it is to use any given dashboard or portal, but without including a link to said resource...you might have to 20-30 results deep on Google before you find that answer, it was nearly impossible to simply find a portal by searching for it.
    • ^ Found the PR spokesperson for Apple!
    • Like many, I'm not buying and expensive items until the tariff nonsense is resolved. I wonder if that has something to do with (along with the notes others are making)?
    • Only option I want is to disable the system tray overflow menu and always show icons, W11 added option to hide the menu but then icons will still go there instead of the tray.
  • Recent Achievements

    • Week One Done
      Helen Shafer earned a badge
      Week One Done
    • First Post
      emptyother earned a badge
      First Post
    • Week One Done
      Crunchy6 earned a badge
      Week One Done
    • One Month Later
      KynanSEIT earned a badge
      One Month Later
    • One Month Later
      gowtham07 earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      660
    2. 2
      ATLien_0
      269
    3. 3
      Michael Scrip
      218
    4. 4
      Steven P.
      162
    5. 5
      +FloatingFatMan
      159
  • Tell a friend

    Love Neowin? Tell a friend!