Software & AppsOperating SystemLinux

How To Permanently Mount a Partition in Ubuntu

Ubuntu 18

In this guide, we will walk you through the process of permanently mounting a partition in Ubuntu. This can be useful when you have a separate partition that you want to access regularly, and you want to avoid the hassle of manually mounting it every time you boot your system.

Quick Answer

To permanently mount a partition in Ubuntu, you need to identify the partition using the blkid command, create a mount point using the mkdir command, modify the /etc/fstab file to add an entry for the partition, and then test the configuration using the mount -a command. This will ensure that the partition is automatically mounted every time you boot your system.

Prerequisites

Before you start, ensure you have the following:

  • A system running Ubuntu.
  • Root or sudo access to the system.

Step 1: Identify the Partition

The first step is to identify the partition you want to mount permanently. You can do this by using the blkid command, which prints the block device (partitions and storage devices) attributes like UUID and file system type. Run the following command:

sudo blkid

This will display a list of all partitions along with their UUIDs and file system types. Identify the partition you want to mount and note down its UUID or device path (/dev/sda1, /dev/sdb2, etc.) and file system type (ext4, ntfs, etc.).

Step 2: Create a Mount Point

Next, you need to create a mount point. This is a directory where the partition will be mounted. You can create a directory using the mkdir command. For example, to create a directory named “works” under “/media”, you would run:

sudo mkdir -p /media/works

In this command, -p ensures that the directory is created along with its parent directories if they do not already exist.

Step 3: Modify the /etc/fstab File

The /etc/fstab file is used to define how disk partitions, various other block devices, or remote filesystems should be mounted into the filesystem. To mount a partition permanently, you need to add an entry for it in this file.

Open the file using a text editor with root privileges:

sudo nano /etc/fstab

At the end of the file, add a new line in the following format:

UUID=<UUID_of_partition> /media/works <filesystem_type> defaults 0 2

Here, replace <UUID_of_partition> with the UUID you noted down in step 1 and <filesystem_type> with the appropriate file system type. The defaults option sets the default mount options, 0 means the system won’t attempt to dump the filesystem, and 2 means the filesystem will be checked but not as frequently as the root filesystem.

Save the changes and exit the text editor.

Step 4: Test the Configuration

After modifying the /etc/fstab file, it’s important to test the configuration to ensure there are no errors. You can do this by either rebooting your system or using the mount -a command, which mounts all filesystems mentioned in /etc/fstab.

sudo mount -a

If there are no errors, your partition is now permanently mounted and will be automatically mounted every time you boot your system.

Conclusion

In this guide, we have shown you how to permanently mount a partition in Ubuntu. This can be a great way to ensure easy access to a separate partition or an external storage device. However, be cautious when modifying the /etc/fstab file, as incorrect entries can cause boot issues. Always make a backup of this file before making any changes.

For more information on the fstab file and its options, you can check the official Ubuntu documentation.

Remember, understanding your system’s structure and how it works is key to effectively managing your Ubuntu system. Happy computing!

Can I mount multiple partitions permanently in Ubuntu?

Yes, you can mount multiple partitions permanently in Ubuntu. Simply follow the steps mentioned in this guide for each partition you want to mount.

Can I mount a partition with a different mount point?

Yes, you can choose a different mount point for your partition. Instead of creating the mount point under "/media", you can create it in any directory of your choice.

What if I don’t know the UUID of my partition?

If you don’t know the UUID of your partition, you can use the device path (/dev/sda1, /dev/sdb2, etc.) instead. Simply replace <UUID_of_partition> in the /etc/fstab entry with the appropriate device path.

Can I mount a partition with non-default mount options?

Yes, you can specify custom mount options for your partition in the /etc/fstab entry. Replace defaults with your desired mount options. Be sure to refer to the appropriate documentation for the available options and their syntax.

How can I unmount a partition that has been permanently mounted?

To unmount a partition that has been permanently mounted, you can use the umount command followed by the mount point. For example, sudo umount /media/works. This will unmount the partition until it is manually mounted again or the system is rebooted.

Leave a Comment

Your email address will not be published. Required fields are marked *