Versionen im Vergleich

Schlüssel

  • Diese Zeile wurde hinzugefügt.
  • Diese Zeile wurde entfernt.
  • Formatierung wurde geändert.

...

Note: You can find the screenshots at the bottom of this site.

Getting Started

When partitioning and formatting is done, it should be appear on your File Manager application. In my case (I'm using Cinnamon), it's called Nemo.

...

The fstab file is read by the mount command, which happens automatically at boot time to determine the overall file system structure, and thereafter when a user executes the mount command to modify that structure. We will edit this file to make our new disk automatically mounted at boot.

Identify Disk/Partition

The first thing to be done is to locate the partition you want to mount. In this case, we'll be working with an entire drive. To do this, open a terminal window and issue the command:

...

Let's say we figured out the disk we want to mount is on /dev/sdb1. With that bit of information in hand, we're ready to continue on.

Get Device UUID

Next we need to find the UUID (Universal Unique Identifier) of the drive. To do that, issue the command:

...

It will display all UUIDs associated with all storage device attached to your machine. Pay attention to your partition UUID which you'd like to be automounted at boot. We'll need it to create a new fstab entry. We are using /dev/sdb1 in this article, so we'll use its UUID which is edc5affc-350e-451b-b64c-94cd237d538a.

Mount Point Creation

Before we add the entry to fstab, we must first create a mount point for the drive. The mount point is the directory where users will access the data on the drive (as they can't access /dev/sdb1 itself). So let's create a directory called data with the command:

...

$ sudo chown -R :data /data

New fstab Entry


In order to create the automount entry, issue the command:

...

  • UUID=edc5affc-350e-451b-b64c-94cd237d538a - the UUID of the partition. You don't have to use the UUID here. You could just use /dev/sdb1, but it's always safer to use the UUID as that will never change (whereas the device name could).
  • /data - the mount point for the device.
  • auto - automatically detect partition type.
  • nosuid - specifies that the filesystem cannot contain set userid files. This prevents root escalation and other security issues.
  • nodev - specifies that the filesystem cannot contain special devices (to prevent access to random device hardware).
  • nofail - removes the error checking.
  • x-gvfs-show - show the mount option in the file manager. If this is on a GUI-less server, this option won't be necessary.
  • 0 - determines which filesystems need to be dumped (0 is the default).
  • 0 - determine the order in which filesystem checks are done at boot time (0 is the default).

Save and close the file.

Test and Verify

Before you reboot the machine, you need to test your new fstab entry. To do this, issue the command:

...

Congratulations, you've just created a proper fstab entry for your connected drive. Your drive will automatically mount every time the machine boots.

Final Words

I hope that you now know how to automount a partition at boot Linux. If you run into any issues or have any feedback feel free to drop a comment below.

...