Auto mount settings (fstab)

Prev Next

Available in Classic

This document describes how to use fstab, an automatic mount setting file in NAVER Cloud Platform Linux server.

fstab file

The /etc/fstab file stores the volume information that should be mounted when rebooting a server. The following are some examples of an fstab file.

#
# /etc/fstab
# Created by anaconda on Tue Oct 25 16:27:45 2022
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=8ce3c9de-8217-4378-8b70-b63ce4d6c6a2 /                       xfs     defaults        0 0
UUID=45a9df56-7731-479c-8c8f-f0280b387749 /boot                   xfs     defaults        0 0
/dev/vdb /mnt/a xfs defaults 0 0

Each row of fstab files is made of 6 items, each of which is classified by a Tab or Space.

Device name

The name of the volume owned by the user. In the above examples, the device name is expressed with UUID and /dev/vdb (device name).

  • The blkid command allows you to view the UUID of a volume.

Mount point

Sets the location to mount the volume. / and /boot, /mnt/a, /mnt/b are the mount points in the above examples.

  • The mount point must be specified as an absolute path.

File system

The file system used to format the volume. In the above examples, all file systems are xfs.
The file system varies according to the server OS.

  • CentOS 6: ext4
  • CentOS 7: xfs
  • Ubuntu: ext4

Mount option

Sets the available options when mounting a volume. In the above examples, all used the defaults option.
The available mount options are as follows: Multiple options must be separated by commas (,) with no space.

Mount option Description
defaults Option that includes all of auto, rw, nouser, exec, and suid
auto Auto-mounting upon booting
noauto Does not mount automatically upon booting
rw Mount so that reading and writing are both available
ro Read only
nouser Only the root account can be mounted
user Regular accounts can also be mounted
exec Permits file to run
suid Permits SetUID and SetGID
nofail An option to allow booting even if an error occurs. If mounting failed due to a typo, it boots by excluding the volume with the error
Note

If unnecessary quotation marks or a typo such as "default" is included in UUID, an error occurs. However, if you set the nofail option, it boots normally by excluding the volume with the error.

dump settings

Sets if the file system can be dumped. In the above examples, all are set to 0.
The settable values are as follows:

  • 0: the file system cannot be dumped
  • 1: the file system can be dumped for backup

fsck settings

Sets whether to check the file system through fsck when booting. In the above examples, all are set to 0.
The settable values are as follows:

  • 0: fsck not run when booting
  • 1: checks the root file system when booting
  • 2: checks file systems other than root when booting

fstab setting procedure

You can set the automatic mount through the fstab setting example.
The following describes how to set fstab to mount the /dev/xvdb1 device on /mnt/b.

  1. Open the /etc/fstab file in the vi editor.

    $> vi /etc/fstab
    
  2. Enter the auto mount settings.

    For # CentOS 6.x
    /dev/xvdb1 /mnt/b ext4 defaults 0 0 
    For # CentOS 7.x
    /dev/xvdb1 /mnt/b xfs defaults 0 0
    For # Ubuntu Server / Desktop
    /dev/xvdb1 /mnt/b ext4 defaults 0 0
    
  3. Save the file and exit.

  4. Enter the following command to check the consistency.

    $> mount -av
    
    • As a result of running the command, the volumes registered on fstab are mounted. If it fails to mount, it outputs an error message.

Troubleshooting fstab

If the fstab setting has an error, booting fails and emergency mode is activated. The following describes how to solve the problem.

  1. In the Classic environment of the NAVER Cloud Platform console, navigate to i_menu > Services > Compute > Server.
  2. Click the Server menu.
  3. Check the server list to see if it has failed to restart.
    compute-classic-fstab-troubleshoting-console1_ko
  4. Click to select the server, and then click [Server connection console].
  5. Check the Emergency Mode status in the server connection console window, and enter the password to access the server.
    compute-classic-fstab-troubleshoting-console2_ko
  6. Take the following actions according to the cause of booting failure.
Note

If rebooting fails but the [Server connection console] button is not activated, contact Customer support.

When the mount option is wrong

The following shows how to resolve when the mount option is wrong.

  1. Enter the following command to mount manually.
    $> mount -av
    
  2. Check the result of manual mounting.
    • <example> When there is a mount option typo in /dev/xvdb1 (defaults is incorrectly written as default)
      compute-classic-fstab-example3

      compute-classic-fstab-example4

  3. Open the /etc/fstab file in the vi editor to annotate the wrong line or edit the settings and save.
    • It is best to annotate it.
    • If an error occurs in the root partition line of the fstab contents, the /etc/fstab file cannot be edited because all files under root(/) are changed to read-only mode. In this case, contact Customer support for single-mode booting support, or remount the root partition in read-write mode with the mount -o remount,rw command, and then open the /etc/fstab file to correct the incorrect settings.
  4. Run the reboot command in the server connection console window or force stop the server in the NAVER Cloud Platform console, and then click [Start] to restart it.
  5. If it boots normally, check the syntax/options of the line annotated in /etc/fstab.
Note

Oracle Linux 6.10 and RHEL 6.10 can perform booting normally without entering emergency mode even with incorrect fstab settings. You can check related logs in the /var/log/messages.

# ('defaults' 'default')
Aug 5 18:25:05 test-server kernel: [ 2.077285] xvdb: xvdb1
Aug 5 18:25:06 test-server kernel: [ 11.118531] EXT4-fs (xvdb1): Unrecognized mount option "default" or missing value

When the registered file system format is wrong

The following shows how to resolve when the registered file system format is wrong.

  1. Open the /etc/fstab file in the vi editor to edit the file system format.
    • <example> Change the fstab settings wrongly entered as xfs to ext4
      compute-classic-fstab-troubleshoting-console3

      compute-classic-fstab-troubleshoting-console4

  2. In the Classic environment of the NAVER Cloud Platform console, navigate to i_menu > Services > Compute > Server.
  3. Click to select the server in the server list, and then click the [Server connection console] button.
    • Or, click to select the server and click the [Force stop] button.
  4. Run the reboot command in the server connection console window.
    • Click the [Start] button to restart the forcibly stopped server.
  5. Check if the server status has recovered to Running on the NAVER Cloud Platform Console.