(Modified 2024 Jul 19)
Disk mounts using fstab
Suppose I have two hard drives in my Ubuntu machine, one with the OS and one with data. Automatically mounting the second drive took a bit of fiddling.
Instructions:
Get partition name for appropriate disk:
sudo fdisk -l
Get volume ID (for, say, /dev/sdb2):
blkid /dev/sdb2 # without any arguments will list all devices
Alternatively, you can list disk contents by UUID (source): ls -l /dev/disk/by-uuid/
In the past, there used to be a command: vol_id -u /dev/sdb2
Go to /etc and copy fstab to a backup filename.
Add the following lines to fstab:
# UUID=1abcd234-5678-9112-e345-6fg7hi892123 /data ext4 defaults,errors=remount-ro 0 2
where the syntax for the columns is:
# <UUID> <mount_point> <type> <options> <dump> <pass>
The <pass> column sets in what order fs check is executed, where 0 signifies unchecked.
This page is Lynx-enhanced