LINUX, FOSS AND LIBRARY TECHNOLOGY ENTHUSIAST

Thursday, December 12, 2019

Creating Bootable USB Stick via Linux Command

0 comments
We usually create a bootable USB using any GUI programs like  Brasero, Nero, Xfburn, etc in Linux or PowerISO, UltraISO, Rufus, etc in Windows, Here I list the command for formatting and creating a bootable USB stick using the terminal, this will be useful for advanced Linux users.

1. First of all, Insert your USB drive into your system.

2. Open the terminal. (CTRL + ALT + T)

3. Look for the USB drive you want to format, by running:

You can use either df or lsblk

The command above will display the directory path of your various drives. Take note of the drive you wish to format.

mahesh@mahesh-server:~$ df
Filesystem     1K-blocks     Used Available Use% Mounted on
udev             1829088        0   1829088   0% /dev
tmpfs             372824     1532    371292   1% /run
/dev/sda8      400531824  9285936 370830300   3% /
tmpfs            1864116   111024   1753092   6% /dev/shm
tmpfs               5120        0      5120   0% /run/lock
tmpfs            1864116        0   1864116   0% /sys/fs/cgroup
/dev/loop0         23040    23040         0 100% /snap/snapd/5643
/dev/loop3         45312    45312         0 100% /snap/gtk-common-themes/1353
/dev/loop4         55936    55936         0 100% /snap/core18/1279
/dev/loop2        160512   160512         0 100% /snap/gnome-3-28-1804/110
/dev/loop1        428928   428928         0 100% /snap/libreoffice/160
/dev/sda6        2819104    96152   2560036   4% /boot
/dev/sda2          98304    30741     67563  32% /boot/efi
tmpfs             372820        8    372812   1% /run/user/1000
/dev/sda5      240821244 21773628 219047616  10% /media/mahesh/Local Dick
/dev/sdb4       29998976  2345504  27653472   8% /media/mahesh/MAHESH

3. Unmount drive using the syntax below:

sudo umount /dev/drivename

mahesh@mahesh-server:~$ sudo umount /dev/sdb4

4. Now run this command to format drive 

sudo mkfs.vfat -n 'Usbname' -I /dev/drivename

mahesh@mahesh-server:~$ sudo mkfs.vfat -n 'MAHESH' -I /dev/sdb4

Understanding the above command

mkfs

mkfs is used to build a Linux filesystem on a device, usually a hard disk partition. The device argument is either the device name (e.g. /dev/hda1, /dev/sdb2), or a regular file that shall contain the filesystem. The size argument is the number of blocks to be used for the filesystem.

vfat

Formats the drive to FAT32, other formats available are mkfs.bfs, mkfs.ext2, mkfs.ext3, mkfs.ext4, mkfs.minix, mkfs.msdos, mkfs.vfat, mkfs.xfs, mkfs.xiafs etc.

-n

Volume-name sets the volume name (label) of the file system. The volume name can be up to 11 characters long. The default is no label. In this tutorial my volume-name is Ubuntu.

-I

It is typical for fixed disk devices to be partitioned so by default, you are not permitted to create a filesystem across the entire device.

Running $ df will show formatted USB without name along with other drives

You are done and your pen drive has successfully been formatted.

Now Create a Bootable USB Stick 

5. Go to your directory where your iso file is downloaded

mahesh@mahesh-server:~$ cd Downloads

mahesh@mahesh-server:~/Downloads$ ls
Zorin-OS-15-Lite-64-bit.iso

mahesh@mahesh-server:~/Downloads$ sudo dd if=Zorin-OS-15-Lite-64-bit.iso of=/dev/sdb bs=4M
572+1 records in
572+1 records out
2401763328 bytes (2.4 GB, 2.2 GiB) copied, 311.976 s, 7.7 MB/s

OR

mahesh@mahesh-server:~/Downloads$ sudo dd bs=4M if=Zorin-OS-15-Lite-64-bit.iso of=/dev/sdX status=progress && sync

That's all you have created USB stick using the command


No comments:

Post a Comment