In all operating systems including Ubuntu, the drives require mounting before users can access them. The Windows OS automatically mounts the drives but in Ubuntu, they are not. However, Ubuntu does facilitate the users with the manual and automatic mounting features.

In Ubuntu, users enjoy more freedom of having their drives work according to their requirements. For instance, a user wants to mount a read-only drive for specific users or give write permissions to a group of users.

This post describes the methods to “Mount a Drive on Ubuntu 22.04”.

Covered Content

Let’s begin!

How to Manually/Temporarily Mount a Drive in Ubuntu 22.04?

When you have connected the drive to the system and you cannot access it, it means the drive needs mounting. Manual mounting is temporary, and you must re-mount the drive to access the data. To “Manually Mount a Drive in Ubuntu 22.04”, follow these steps:

Step 1: List Drives

Before mounting a drive, users must know the drive’s path. To view the connected drive’s details run the “fdisk” command with the “-l” flag, as follows:

sudo fdisk -sudo fdisk -l

The above snippet displays the information about all the drives and here:

  • The “sdb” represents the external drives connected to the system and “/dev/sdb1” is the actual drive’s path.

Step 2: Create a Mount Point

In Ubuntu or any other Linux distro, the OS mounts the drives to a specific directory. Let’s create a new directory (/mnt/usb-mount) using the “mkdir” command, as seen below:

sudo mkdir /mnt/usbmount

Note: On Ubuntu, users must create a mount point within the “/mnt” folder. Any directory in the “/mnt” folder can be a mount point.

Step 3: Mount the Drive

Use the below-stated syntax to mount the drive:

sudo mount <drive-path> <path-to-mount-directory>

Here,

  • mount” invokes the mount command.
  • The “drive-path” represents the drive’s path to mount.
  • The “path-to-mount-directory” specifies the directory to mount the drive.

Below is the practical application of using the “mount” command to mount the “/dev/sdb1” to “mnt/usb-mount”:

sudo mount /dev/sdb1 /mnt/usbmount

If no output is seen, the mount was successful. However, some users may face the error “unclean file system”, that arises because the drive is formatted in Windows OS. The “unclean file system” means “NTFS” file format and it is automatically fixed by the mount command.

Step 4: Verify the Mount

After mounting, run the “mount” command with the “grep” command to verify the drive’s mounting:

sudo mount | grep sdb1

The above command shows the mounted drive’s details (drive path, mount directory, type, permissions, owner, and more). If it outputs the information such as the above, the mount is successful. If it is blank there is an error like the one below.

Fixing Drive Mounting Error

While mounting the drive on Ubuntu 22.04, users reported the “bad fs type, bad option…”. It occurs because the drive had a corrupt file system, as seen below:

To fix it, run the “fsck” command and replace “/dev/sdb1” with your drive’s path:

sudo fsck /dev/sdb1

Here:

  • The “fsck” invokes the “File System Check” command that finds and repairs the errors in the drive’s file system.
  • The “/dev/sdb1” is the drive’s path.

Unmount the Drive

The following syntax of the “umount” command unmounts the mounted drive:

sudo umount <drive-path>

Let’s unmount the “/dev/sdb1” as a practical example:

sudo umount /dev/sdb1

The above command mounts the drive and shows no error/message if it is successful. 

How to Automatically/Permanently Mount a Drive in Ubuntu 22.04?

Automatic mounting makes specified drives available when connected and users don’t have to re-mount the drives again. The process of the automatic/permanent mounting of the drive in Ubuntu 22.04 is as follows:

Step 1: Open the “fstab” File

The “fstab” file in Ubuntu allows the users to manage the mounted drives on the system. To open the “fstab” file, run:

sudo nano /etc/fstab

Step 2: Automatically/Permanently Mount a Drive

In the “/etc/fstab” file, use the following format to “Automatically/Permanently Mount a Drive” on Ubuntu 22.04:

<drive-path> <path-to-mount-directory> <options> <dump-value> <pass-value>

Here:

  • The “drive-path” is the drive to mount.
  • The “<path-to-mount-directory” is the directory to mount the drive.
  • The “options” are a bunch of flags for customizing the mount process.
  • The “dump” utility uses the “dump-value” and based on the value, it determines whether to create a backup of the file system. Use “1” for creating a backup and “0” for not. It is mandatory to specify the “dump-value” in the “/etc/fstab” file.
  • The “pass-value” lets the users specify the order in which the file systems are checked (file consistency check). The root file system “1” has the top priority while the other file systems are specified with “2”. To make the “fsck” utility ignore the file consistency check, use “0”.

Below is a practical example of automatically/permanently mounting a drive in Ubuntu 22.04

/dev/sdb1 /mnt/usb-mount ntfs defaults 0 0

By configuring the “/etc/fstab” file like the above, users can mount the drive to a specific directory. Here, the “/dev/sdb1” mounts to “/mnt/usb-mount”. The file system is “ntfs”, options are set to “defaults” and the dump & pass” values are set to “0”.

Additional Info For Step 2

Alternatively, users can make use of a better approach which is using the “UUID” of the drive. Each drive gets a unique “UUID” and it is permanent. This mitigates the risk of mounting the wrong drive. To use the “UUID” instead of the drive paths, find the “UUID” of the drives using:

sudo blkid

In the above snippet, the “UUID” against the “/dev/sdb1” drive is “3E96-7B2D”. Let’s use it for mounting the drive using the below format:

UUID=3E96-7B2D /mnt/usb-mount ntfs defaults 0 0

Step 3: Mount a Drive With Restrictions for Other Users (Optional)

To mount a drive with read-only permissions for other users and read, write, and execute permissions for the current user/group, find the “uid” and “gid” via the “id” command as follows:

id

From the above snippet, the uid is “1000” and the gid is “1000”. Let’s use it to grant permissions to the current user, the current user’s group, and other users:

/dev/sdb1 /mnt/usb-mount ntfs defaults,uid=1000,gid=1000,umask=002 0 0

From the above snippet we have:

  • The “uid=1000” grants the current user read, write, and execute permissions.
  • The “uid=1000” grants the current user group with the read, write, and execute permissions.
  • The “umask=002” grants the “other users” with the read and execute permissions.

Additional Info For Step 3

The “UUID” can be used as the replacement for the drive’s path as seen below:

UUID=3E96-7B2D /mnt/usb-mount ntfs defaults,uid=1000,gid=1000,umask=002 0 0

In the above snippet, the drive mounts using the “UUID” with the “ntfs” file format and the specified permissions.

Step 4: Mount a Drive With Read-Only Permissions for All Users (Optional)

Below is the use of the “/etc/fstab” file to “Mount a Drive With Read-Only” permissions for all users except the current (user) or owner:

/dev/sdb1 /mnt/usb-mount ntfs ro,user 0 0

The above snippet uses the “ro” option for mounting the specified drive with read-only permissions to other users. These changes are not effective for the owner.

Additional Info For Step 4:

By replacing the drive’s path with its “UUID” in the above step, we get:

UUID=3E96-7B2D /mnt/usb-mount ntfs ro,user 0 0

In the above snippet, the “UUID” mounts the drive with “ro” or “read-only” permissions to other users.

Step 5: Verify the Drive’s Mount

Run the below-stated command to verify the drive’s mount before rebooting (permanent mount requires a system reboot). The command outputs if there is a configuration error. If a warning message such as the one below comes up, it should be ignored because it is classified as a bug:

sudo findmnt --verify

The output of the above command shows that the configuration is correct and for the changes to take effect, reboot the system using the:

sudo reboot

The drive will be permanently mounted once the system reboots.

Warning: Do not mess up the “/etc/fstab” file as it contains critical system information. Invalid configurations in the “/etc/fstab” file could result in boot failure and severe data loss.

How to Mount a Drive Using the GUI in Ubuntu 22.04?

Ubuntu 22.04 offers the command line and the Graphical User Interface or GUI to manage its operations. For mounting and other operations on the drives via the GUI, Ubuntu offers the “Disks” utility. To use the “Disks” utility, open it via the “Activities”:

From the “Disks” GUI, select the drive, and use the “?” button to mount the drive:

It shows the drive’s mount directory. To unmount the drive, use the “?” button:

The above image shows the “unmount” button and the directory where the drive is mounted. This directory is set by the OS.

Final Words

In Ubuntu, users must mount the drives before they can access them because the drives are only connected to the system. The mounting allows the users to access the contents of the drive. In Ubuntu, users can use the “mount” command to temporarily mount the drives. For permanent mounting, users must configure the “/etc/fstab” file, which is explained above. For GUI lovers, Ubuntu comes with the “Disks” utility to mount or unmount the drives with ease. This guide has discussed the methods to mount a drive on Ubuntu 22.04.