How do I disable automatic mounting on startup in Linux?
To disable the automatic mounting of the Linux system at startup, you can follow these steps:
- Open the terminal and login to the system as an administrator.
- Open the /etc/fstab file with a text editor like vi or nano, which records the devices that need to be mounted when the system starts up.
- Please open the file /etc/fstab using the command “sudo vi”.
- Locate the corresponding line in the file that needs to be unmounted automatically. Typically, these lines contain the UUID or device name (e.g. /dev/sda1) of the device.
- Add a hashtag (#) at the beginning of these lines to comment them out. This way, the system will not automatically mount these devices at startup.
- For example, to replace the original line:
- Use the unique identifier xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx to mount /mnt/xxx with the ext4 file system using default settings.
- Change to: Make adjustments to
- # Universally Unique Identifier (UUID) = xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx, mounted at /mnt/xxx with ext4 file system, default settings, and options 0 and 2.
- Save and close the file.
- Restart the computer to apply the changes.
After completing the above steps, the canceled automatic mounting will take effect upon the next system startup.