Mounting a USB drive
lil guide for how tf to mount stuff on linux, as it was missing from my notes. based on this article
Connect, then identify the drive
The lsblk
command provides a simple list of all block devices known to the system.
Scan the output from lsblk
and look for a /dev/sdX device close to the drive size you expect – that’s
likely your USB drive. Make a note of the full device name like /dev/sdb1
.
For more details, the fdisk
utility provides a better overview and more information:
sudo fdisk -l
Now that we know the device node, such as /dev/sdb1
, we need a mount point – the specific
directory where we‘ll attach the drive.
Mounting the drive
The Linux Filesystem Hierarchy Standard recommends /media
for removable media. We can create a
subdirectory there like:
sudo mkdir /media/USBDRIVE
Note: as is done above, you have to create the mountpoint as a folder.
Use the mount command to attach your drive to the desired mountpoint:
sudo mount /dev/sda1 /media/THICK
Note: the numeral after sdX
is important; it might specify the partition? The command will
probably fail without that—it did just now.
Unmounting the drive safely
sudo umount /dev/sda1
Automatically mounting the drive
Linux can automatically mount our exFAT drive whenever it’s connected.
The easiest and universal method is adding an entry to your /etc/fstab
file. It contains a
list of disks and partitions along with their mount points and options.
The basic syntax for a new entry of /etc/fstab
:
# my THICK usb drive (1.8TB)
UUID="5018-37D7" /media/THICK exfat defaults 0 0
Let‘s break this down:
- UUID=DRIVE_UUID – A unique ID assigned to the drive partition
- /media/THICK – The directory to mount to
- exfat – The filesystem type
- defaults – Common mount options (rw, suid, dev, exec, auto, nouser, async)
- 0 0 – Dump and pass numbers. Always 0 for removable media
To get the UUID, run:
sudo blkid