> ## Content Index
> Fetch the complete content index at: https://developerinsider.co/llms.txt
> Use this file to discover other available public pages before exploring further.

# Auto Mount Drive in Ubuntu Server 22.04 at Startup
- URL: https://developerinsider.co/auto-mount-drive-in-ubuntu-server-22-04-at-startup/
- Published: 2022-09-30T16:36:40.000Z
- Updated: 2026-01-19T12:08:01.000Z
- Author: Vineet Choudhary
- Tags: Wiki, Ubuntu, Linux, DevOps

When we connect an external drive, by default, Linux OS (or Ubuntu Server) doesn't automount the external drive at startup. We can mount it very easily using the `mount` command but we want to enable automount feature on startup. So, we don't need to mount the drive again after restarting or logging into Linux OS. Here are steps to auto mount drive at startup -

## 1\. Create the Mount Point

First, we need to create a directory which will be our mount point for a drive

```sh
sudo mkdir /media/USB1

```

## 2\. Get Drive UUID and Type

Now, we need to get the drive UUID and File System Type. This information we need in the next step. So, to find the drive's UUID and File System Type, run the following command -

```sh
lsblk -o NAME,FSTYPE,UUID,MOUNTPOINTS

```

This will return something like what we have below. Here you can see, sd2 is type exfat and doesn't have any mount point. So, we need to mount this sda2 on `/media/USB1`. There UUID for this is `632D-7154` and File System Type is `exfat`. So, Copy the UUID and File System Type from the disk.

```log
NAME   FSTYPE   UUID                                 MOUNTPOINTS
sda                                                  
├─sda1 vfat     67E3-17ED                            
└─sda2 exfat    632D-7154
sdb                                                  
├─sdb1 vfat     D7E2-9D99                            /boot/firmware
└─sdb2 ext4     b09bb4c8-de4d-4ce6-a93f-30c4c9241a58 /

```

## 3\. Edit fstab

To edit the fstab file run the following command (note I'm using nano here but use whatever editor you prefer)

```sh
sudo nano /etc/fstab

```

You'll see something like this -

```log
LABEL=writable  /       ext4    discard,errors=remount-ro       0 1
LABEL=system-boot       /boot/firmware  vfat    defaults        0       1

```

Here we need to add one more entry for our drive. The format for adding a new entry is something like this -

```log
<file system> <mount point>   <type>  <options>       <dump>  <pass>
UUID=<UUID> <PATH_TO_MOUNT> <DRIVE_TYPE>  defaults        0       0

```

### 3.1\. Mount drive as root user

To mount the drive as root user we need to add an entry like this -

```log
# USB1
UUID=632D-7154 /media/USB1   exfat    defaults        0       0

```

### 3.2\. Mount drive safely

To safely mount an external drive on system boot a way that won't delay or break the boot process even if the drive is unplugged or unavailable then we should configure `/etc/fstab` carefully using these safe, boot-tolerant options.

```
# USB1
UUID=632D-7154 /media/USB1   exfat    defaults,nofail,x-systemd.device-timeout=10s        0       0

```

If the drive doesn't mount at startup, try increasing the timeout to 30 or 60 seconds. Also, add `noatime` to improve performance by skipping access time updates.

### 3.3\. Mount drive for a specific user

If we want to mount the drive with specific user and group then we need to add an entry like this -

```log
# USB1
UUID=632D-7154 /media/USB1   exfat    defaults,nofail,x-systemd.device-timeout=10s,uid=1000,gid=1000,umask=022        0       0

```

### 3.4\. Mount drive on First Access

Instead of mounting at boot, you can have the system mount the drive only when accessed

```
# USB1
UUID=632D-7154 /media/USB1   exfat    noauto,x-systemd.automount,nofail,x-systemd.device-timeout=10s        0       0

```

Here, uid=1000 is the user id, gid=1000 is the group id, and umask=022 is to set permissions so that the owner has read, write, execute. Group and Others will have read and execute permission.

You can run the `id` command to get all users and group ids.

```sh
id

```

## 4\. Test fstab

Now we'll test the `fstab` before rebooting because an invalid `fstab` can render a disk unbootable. So, for the test, run the following command and check if there is any error or warnings. Do not reboot your Ubuntu Server / Linux OS without resolving those errors or warnings (if any).

```sh
sudo findmnt --verify

```

## 5\. Restart Ubuntu Server / Linux OS

If the last step doesn't show any error or warnings then restart Ubuntu Server / Linux OS using the following command -

```sh
sudo reboot

```

## 6\. Test the Mount Point

Run the same command which we run in Step 2 to check if our drive is mounted to its mount point.

```sh
lsblk -o NAME,FSTYPE,UUID,MOUNTPOINTS

```

```log
NAME   FSTYPE   UUID                                 MOUNTPOINTS
sda                                                  
├─sda1 vfat     67E3-17ED                            
└─sda2 exfat    632D-7154                            /media/USB1
sdb                                                  
├─sdb1 vfat     D7E2-9D99                            /boot/firmware
└─sdb2 ext4     b09bb4c8-de4d-4ce6-a93f-30c4c9241a58 /

```

Here you can see, `sda2` is now mounted to `/media/USB1`.