How to properly automount a drive in Ubuntu Linux

Do you need to create a suitable fstab entry to automatically mount a drive in Linux? Find out how here.

How to automatically mount a drive in Ubuntu Linux
Do you need to create a suitable fstab entry to automatically mount a drive in Linux? Find out how here.
  http://www.techrepublic.com/

If you have servers or desktops, running Ubuntu Linux (or a derivative), you may need to add additional drives for storage, backups, or any number of reasons . Surely you can connect that unit, open your file manager and click to mount it. But what happens if it is a headless server or if you just want to make sure that the disk is always mounted at boot (without its interaction)?

Fortunately, it is a fairly simple task to perform. But doing it correctly requires some additional steps that you may not know. I will show you the correct way to configure the automatic mounting of a drive in Linux, specifically, Pop! _OS 19.04 (a derivative of Ubuntu Desktop).

SEE: Choosing your Windows 7 exit strategy: four options (TechRepublic Premium)

What you need

For this to work, you will need the following:

  • One instance Ubuntu Server (or a derivative).
  • A hard drive attached to mount.
  • A user account with sudo privileges.

With those things ready, get to work.

Locate the partition to mount

The first thing to do is locate the partition you want to mount. In this case, we will work with a complete disk. To do this, open a terminal window and issue the command:

  sudo fdisk -l 

You should see a complete list of all units connected to the system ( Figure A ).

  mounta.jpg

Figure A: Some of the drives connected to a Linux system.

Let's say we found that the disk we want to mount is in / dev / sdj. With that information in hand, we are ready to continue.

Locate the UUID

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

  sudo blkid 

This will show each UUID associated with each storage device connected to your machine ( Figure B ).

  mountb.jpg mountbjpg “/>

Figure B: UUID of the unit in /dev/sdj.[19659031▪http://wwwtechrepubliccom/"height="465"width="620[19659023[WenowhaveOurunitnameandUUIDWiththisinformationwecancreateanautomaticmountentryinfstab

Create a mount point

Before adding the entry to fstab, we must first create a mount point for the unit. The mount point is the directory where users will access the data in the unit (since they cannot access / dev / sdj). So we create a directory called data with the command:

  sudo mkdir / data 

You will also want to change the ownership of the group in that directory, so that users can access it. For this, you can create a group called data and then add users to the new group. This could be done with the commands:

  sudo groupadd data
sudo usermod -aG data USERNAME (where USERNAME is the name of the user to be added) 

After doing so, you can change the ownership of the mount point with the command:

  sudo chown -R: data / data 

Automatic mount entry

To create the automatic mount entry, issue the command:

  sudo nano / etc / fstab 

At the bottom of that file, we will add an entry containing the information We have discovered. The entry will look like this:

  UUID = 14D82C19D82BF81E / data auto nosuid, nodev, nofail, x-gvfs-show 0 0 

Breaking that line, we have:

  • UUID = 14D82C19D82BF81E : It is the UUID of the unit. You do not have to use the UUID here. You can simply use / dev / sdj, but it is always safer to use the UUID since that will never change (while the device name might).
  • / data – is the mounting point for the device.
  • auto – automatically mounts the partition at boot
  • nosuid : specifies that the file system cannot contain established user ID files . This prevents root escalation and other security problems.
  • nodev – specifies that the file system cannot contain special devices (to prevent access to random device hardware).
  • nofail : eliminates error checking.
  • x-gvfs-show : Displays the mount option in the file manager. If this is on a server without a GUI, this option will not be necessary.
  • 0 – determines which file systems need to be dumped (0 is the default).
    19659013] 0 : Determines the order in which the file system checks are performed at boot time (0 is the default).

Save and close the file.

Entry test

Before restarting the machine, you must test your new fstab entry. To do this, issue the command:

  sudo mount -a 

If you see no errors, the fstab entry is correct and you can safely restart.

Congratulations, you just created an appropriate fstab input for your connected unit. Your unit will mount automatically every time the machine starts.

See also

  linuxhero.jpg linuxhero.jpg [19659069font> Image: Jack Wallen

For More Updates Check out Blog, Windows Softwares Drivers, Antivirus, Ms Office, Graphic Design Don’t Forget to Look Our Facebook Page Get Into Pc like us & follow on Twitter- @getinpc

Please Note: This content is provided and hosted by a 3rd party server. Sometimes these servers may include advertisements. igetintopc.com does not host or upload this material and is not responsible for the content.