Skip to content

Instantly share code, notes, and snippets.

@coltenkrauter
Last active March 14, 2023 20:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coltenkrauter/15482fb81cceca64bb739a39a7987e8f to your computer and use it in GitHub Desktop.
Save coltenkrauter/15482fb81cceca64bb739a39a7987e8f to your computer and use it in GitHub Desktop.
Permanently mount HDD to Ubuntu / Automount partition in Linux / How to mount a drive in Linux bash/sh/zsh
# Make a directory to mount the drive to
sudo mkdir /mnt/drive1
# First step of getting the UUID of the drive is to get the device path (ex: /dev/sdb2)
lsblk -e7 -e11 # e7 to hide loop devices and e11 to hide cdrom drives
# This is the way to mount in a non-permanent way (goes away after reboot)
# sudo mount /dev/sdb2 /mnt/drive1
# Get the UUID of the drive to mount
sudo blkid /dev/sdb2
# Update fstab with the drive data for mounting
# nobootwait will allow the system to boot even if the mount fails
# Update the UUID and the drive type (exfat may need to be ext4 or something else)
echo "UUID=<value> /mnt/drive1 exfat,nobootwait defaults 0 0" | sudo tee -a /etc/fstab
# Verify fstab updated properly
cat /etc/fstab
# Reboot and verify that your drive automounted
sudo reboot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment