Support > About cloud server > How to permanently mount the hard disk in Ubuntu system
How to permanently mount the hard disk in Ubuntu system
Time : 2025-10-23 14:40:35
Edit : Jtti

When using a cloud server, manually mounting data storage drives, backup drives, or frequently used additional storage devices at every boot is impractical. Permanent automatic mounting not only improves productivity but is also a key step in building a stable server environment.

The key to achieving this goal lies in understanding and correctly configuring the `/etc/fstab` file. This system configuration file contains information about all file systems to be mounted at boot time. Mastering fstab configuration means you can ensure that specific hard drives or partitions are automatically mounted at designated locations every time the system boots.

Before modifying your system configuration, it's a good idea to back up your existing fstab file. This way, even if errors occur during configuration, you can quickly restore the system to a normal state.

sudo cp /etc/fstab /etc/fstab.bak

The first step is to identify the hard drive or partition to be mounted. Use the `fdisk` command to list all connected disks and partitions.

sudo fdisk -l

After finding the target hard drive's device path (e.g., /dev/sdb1 ) from the command output, you need to obtain the partition's unique identifier, the UUID. Using the UUID rather than the device path (e.g., /dev/sdb1 ) to configure the mount is more reliable, as the device path may change between system reboots.

sudo blkid /dev/sdb1

This command will return something like `UUID="b72a8f66-73d9-42d0-92cc-ae24bee6a309" TYPE="ext4"`. Note this UUID; you'll need it in the following steps.

Next, you need to create the mount point directory. A mount point is essentially an empty directory that serves as a gateway to the hard drive's contents. Typically, these folders are created in the `/mnt` or `/media` directories, but you can choose any location to suit your needs.

sudo mkdir /mnt/mydata

Now we come to the crucial step: editing the fstab file. Use any familiar text editor, such as nano or vim.

sudo nano /etc/fstab

Add a new line to the end of the file and fill in the mount information using the fstab-specific format. A typical configuration line looks like this:

UUID=b72a8f66-73d9-42d0-92cc-ae24bee6a309 /mnt/mydata ext4 defaults 0 2

This configuration line consists of several fields, each with a specific meaning. The first field specifies the device to be mounted (using a UUID in this case); the second field defines the path to the mount point directory; the third field specifies the file system type (e.g., ext4, NTFS, XFS, etc.); the fourth field sets the mount options; `defaults` specifies the default combination of options (including read/write permissions, automatic mounting, etc.); the fifth field is the `dump` tool backup flag, typically set to 0; and the final field controls the order in which file systems are checked at boot: the root directory should be set to 1, and other partitions are typically set to 2 or 0.

For specific file systems that require special permissions, such as NTFS, you can add more detailed parameters in the mount options field.

UUID=123456ABCDEFG /mnt/windows ntfs auto,dmask=007,fmask=117,utf8 0 0

After editing the fstab file, you can test the configuration without rebooting the system. Use the `-a` option with the `mount` command to immediately mount all devices configured in fstab.

sudo mount -a

If this command does not display any error messages, the syntax in the fstab file is correct. To confirm that the mount was successful, run the `df -h` command to view all mounted file systems, or check that the mount point directory contains the files on the target drive.

It is important to note that the fstab file format is extremely strict. Each field must be separated by a space or tab, and all fields must be in place. Any formatting errors may cause the mount to fail during system startup, or even prevent the system from booting properly.

For file systems that support ACLs (Access Control Lists), such as ext4, if you need to set granular access permissions for different users, you can add the `acl` parameter to the mount options.

In addition to manually editing the fstab file, Ubuntu also provides graphical tools such as the "Disks" utility for configuring automatic mounts. However, for server environments or administrators who value efficiency, mastering the command line is still essential. Ensuring that disks are properly configured for permanent automatic mounting not only simplifies system management but also ensures that services and applications can access required data more reliably after restarts.

Relevant contents

Commonly used security scanning core methods for overseas cloud servers Common requirements for renting ASP website virtual host Hong Kong cloud server memory capacity planning for backup purposes for SMEs How to optimize Hong Kong cloud server bandwidth usage? Traffic monitoring and restriction strategy What to do if Hong Kong CN2 VPS has high latency? Line detection and optimization solutions Hong Kong VPS hosting quantity analysis: from hardware configuration to optimization strategy A deep dive into network latency: a comparison between CN2 and standard lines Can't log in to the Pagoda Panel on the Hong Kong Cloud Server? This article will teach you how to fix it. Is the CPU usage of US cloud servers too high? Performance optimization and monitoring suggestions Implementation method of data isolation protection in multi-tenant environment
Go back

24/7/365 support.We work when you work

Support