Skip to content

Instantly share code, notes, and snippets.

@tankibaj
Created January 26, 2021 21:03
Show Gist options
  • Save tankibaj/6f7218d721359c07f9e06d473f331ea0 to your computer and use it in GitHub Desktop.
Save tankibaj/6f7218d721359c07f9e06d473f331ea0 to your computer and use it in GitHub Desktop.

Attach USB to System

Insert a USB drive into your system and identify your USB drive correctly. This is the step you need to take care, because you may format the wrong disk if not correctly identify your disk.

lsblk

Output:

NAME                MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda                   8:0    0 111.8G  0 disk
├─sda1                8:1    0   512M  0 part /boot/efi
└─sda2                8:2    0 111.3G  0 part
  ├─vgubuntu-root   253:0    0 110.3G  0 lvm  /
  └─vgubuntu-swap_1 253:1    0   980M  0 lvm  [SWAP]
sdb                   8:16   1  58.4G  0 disk
└─sdb1                8:17   1  58.4G  0 part
df -h

Output

Filesystem                 Size  Used Avail Use% Mounted on
udev                       1.9G     0  1.9G   0% /dev
tmpfs                      381M  1.9M  379M   1% /run
/dev/mapper/vgubuntu-root  109G   11G   93G  11% /
tmpfs                      1.9G     0  1.9G   0% /dev/shm
tmpfs                      5.0M  4.0K  5.0M   1% /run/lock
tmpfs                      1.9G     0  1.9G   0% /sys/fs/cgroup
/dev/sda1                  511M   16M  496M   4% /boot/efi
tmpfs                      381M   20K  381M   1% /run/user/1000
/dev/sdb1                   59G   67M   59G   1% /media/naim/24FE0D9D29511F6A

Now, You can see that the USB drive is attached as /dev/sdb device. Which is mounted on /media/naim/24FE0D9D29511F6A.

Wipe USB Drive

Whenever we attach a USB drive in Ubuntu, it automatically mounted to the system. We can not wipe any disk on linux systems which are already mounted. So first un-mount /dev/sdb1 USB drive on your system.

sudo umount /dev/sdb1

Now wipe /dev/sdb

sudo wipefs --all /dev/sdb

ISO to USB

DD

sudo dd bs=4M if=/home/sana/Downloads/ubuntu-18.04.2-live-server-amd64.iso of=/dev/sdb status=progress oflag=sync

CP

sudo cp /home/sana/Downloads/ubuntu-18.04.2-live-server-amd64.iso /dev/sdb

Cat

sudo cat /home/sana/Downloads/ubuntu-18.04.2-live-server-amd64.iso > /dev/sdb

Tee

sudo tee < path/to/archlinux.iso > /dev/sdb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment