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


Recommended Posts

tarifa

 

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

 

 

Link to post
Share on other sites

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.