Skip to content

Instantly share code, notes, and snippets.

@almirbraggio
Created December 9, 2023 16:58
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 almirbraggio/f3824f6ca6fca0c810ba0ad5dc2ac29a to your computer and use it in GitHub Desktop.
Save almirbraggio/f3824f6ca6fca0c810ba0ad5dc2ac29a to your computer and use it in GitHub Desktop.
Fstab Auto-Mounting Partition

Using a fstab file we can mounting and linking an extra partition in an elegant way. To adding the partition on fstab file, you need to find the correct UUID from the partition you want to add.

List the by-uuid file for finding out:

$ ls -lh /dev/disk/by-uuid
lrwxrwxrwx 1 root root 842db29e-56d8-4ccf-b857-44e039bb065f -> ../../sda1
lrwxrwxrwx 1 root root f57a0952-0a96-4140-8aa1-b2df924e3389 -> ../../sdb1

Now, I know the right UUID: the second in the list (sdb1). Edit fstab file:

$ sudo vim /etc/fstab
UUID=f57a0952-0a96-4140-8aa1-b2df924e3389 /media/extra ext4 defaults 0 2

This will automount the partition in the location /media/extra, using the default options. Don't forget to create this directory and set the right permissions for your user:

$ mkdir /media/extra
$ chown -R USER.GROUP /media/extra

Then, to test your settings, run:

$ sudo mount -a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment