The steps to mount a new hard disk and realize automatic mount on the power-on are as follows: 1. Use lsblk, fdisk -l or blkid to confirm the device path and UUID of the new hard disk. It is recommended to use UUID to ensure stability; 2. Create a mount point directory, such as /mnt/data, and set appropriate permissions; 3. Edit the /etc/fstab file and add a line of configuration, the format is UUID=hard disk UUID Mount point file system type defaults 0 2, note that the sixth column of the XFS file system is 0; 4. Use sudo mount -a and df -h to confirm that it is correct to avoid errors after restart; 5. If there is a problem, check the file system type, mount point exists or enter recovery mode to repair according to the error message. The entire process needs to be operated with caution to prevent system startup failure or data loss.
Mounting a new hard disk and automatically mounting it on, the main thing is to modify the /etc/fstab
file. The key is to correctly identify the device, configure the mount point and file system type to avoid system startup failure or data loss.
Confirm new hard drive information
Before editing fstab, you must first confirm the device path and file system type of the new hard disk. You can usually view it through the following commands:
-
lsblk
: List all block devices and you can see the hard disk and partition status -
fdisk -l
orparted -l
: View disk partition table information -
blkid
: Displays the UUID and file system type of the device
For example, if you add a new hard disk, it may be in the form of /dev/sdb
or /dev/nvme0n1
. If you have formatted this hard disk, you should be able to see its UUID and type from the blkid
output (for example, ext4, xfs).
Tip : It is recommended to use UUID instead of
/dev/sdX
to identify the device, because the device name may change after restarting, and the UUID is more stable.
Create a mount point directory
The mount point is where you access the contents of this hard disk. For example, if you want to hang the hard disk to /mnt/data
, you need to create this directory first:
sudo mkdir /mnt/data
Of course, it can also be other paths, such as /data
and /storage
, which are determined according to your needs.
Suggestion : Try to make sense as much as possible to facilitate future management; pay attention to setting appropriate owners and permissions in terms of permissions.
Edit /etc/fstab file
The next step is the most critical step: modify /etc/fstab
to automatically mount the hard disk every time the system boots.
Open the file:
sudo nano /etc/fstab
Add a line like this:
UUID=Your hard disk UUID /mnt/data ext4 defaults 0 2
The fields are described as follows:
Fields | meaning |
---|---|
The first column | Device ID (UUID or device path) |
Second column | Mount Point Directory |
The third column | File system type (such as ext4, xfs) |
Column 4 | Mounting options, usually use defaults |
Column 5 | dump tool backup flag, 0 means no backup |
Column 6 | fsck check order, the root partition is set to 1, the others are set to 2, and those that do not require inspection are set to 0 |
Notice :
- If you are not sure about the mount option,
defaults
is a safe choice.- The XFS file system does not support the check of column 6, so it is best to write 0 for that column.
- Before modification, it is recommended to back up fstab:
sudo cp /etc/fstab /etc/fstab.bak
Test whether the configuration is effective
Don't restart directly after modifying fstab, test it manually first:
sudo mount -a
This command attempts to mount all unmounted entries in fstab. If there is no error, it means there is no problem with the configuration.
Then run:
df -h
Check whether your mount point appears and whether the capacity is correct.
Frequently Asked Questions :
- Report an error "wrong fs type": Check whether the file system type in fstab is written correctly
- Report an error "mount failed": Check whether the mount point exists and whether the device is available
- The startup is stuck: it may be that the fstab is written incorrectly, you can enter recovery mode to repair it
Basically these steps. The configuration of fstab is not complicated, but the details are prone to errors, especially the device identification and mount points must be accurate. As long as you take it step by step, it can usually be done.
The above is the detailed content of How to mount a new disk permanently in /etc/fstab?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

After experimenting with mounting options to prohibit the execution of set bit programs and binary programs [root@localhost~]#vi/etc/fstab/# after adding /dev/sdc1/varext3defaults,noexec12[root@localhost~]#mount-oremount/var After the system restarts, it is found that /dev/sdc1 cannot be entered and can only enter the character interface. I want to delete that line, but when saving the file, it prompts the read-only attribute Read-onlyfilesystem. I have tried using (1) chmod+w/etc/fstab (2):w! The file is still read-only and cannot be modified. Method#

When my Linux automatically mounts the NTFS partition, it always reports an error with some files when I decompress the folder. I used the ls-lia command to check the permissions and found that the owner of the automatically mounted NTFS partition is root and belongs to the plugdev group. Although I can still copy, remove, and edit files freely, decompression always reports an error. I tried to use chmod and chown to change the owner of the files and folders in the entire NTFS partition to me, and the modification permissions were 777. Although the program prompts that the execution is successful, when executing the ls-lia command, it is found that these two commands have no effect at all. Using sudovim/etc/fstab, we found that the configuration is like this. UUI

fstab (FileSystemTable) is a configuration file in the Linux system, used to define the rules for mounting file systems when the system starts. The fstab file is located in the /etc directory and can be created manually or modified by an editor. Each line specifies a file system to be mounted. Each line has six fields, and their meanings are as follows: The file system device file or UUID can be used to specify the device of the file system to be mounted. The UUID is a unique identifier. The UUID of the device can be obtained through the blkid command. 2. Mount point: Specify the directory to which the file system is to be mounted, which can be an absolute path (such as /mnt/data) or a relative path (such as ../data). 3. File system class

TTArtisan has unveiled a cute 35mm film canister LED light with a removable magnetically-attached hot shoe mount. The BG01B can be attached to a strap for use as a keychain light or to any camera hot shoe for use in illuminating photo and video subje

The steps to mount a new hard disk and realize automatic mount on the computer are as follows: 1. Use lsblk, fdisk-l or blkid to confirm the device path and UUID of the new hard disk. It is recommended to use UUID to ensure stability; 2. Create a mount point directory, such as /mnt/data, and set appropriate permissions; 3. Edit the /etc/fstab file, add a line of configuration, the format is UUID=hard disk UUID mount point file system type defaults02, note that the sixth column of the XFS file system is 0; 4. Use sudomount-a and df-h to confirm that it is correct to avoid errors after restart; 5. If there is a problem, check the file system type, mount point exists or enter reco based on the error message.

TTArtisan has unveiled a cute 35mm film canister LED light with a removable magnetically-attached hot shoe mount. The BG01B can be attached to a strap for use as a keychain light or to any camera hot shoe for use in illuminating photo and video subje

The method to automatically mount disk partitions in Linux is to edit the /etc/fstab file. Each line of the file contains six fields: 1) filesystem (it is recommended to use a UUID instead of a device name to ensure stability); 2) mountpoint (specify the mount directory such as /mnt/data); 3) type (file system type such as ext4); 4) options (mount options such as defaults); 5) dump (replacement generally fills in 0 for backup flags); 6) pass (fsck check order root partition is 1, others are 2 or 0). Operation steps include: 1) Use blkid to confirm device information; 2) Create a mount directory such as sudomkdir/mnt

In Docker, mount volumes mainly use the -v or --mount flags. The former is simple in syntax and suitable for basic scenarios, while the latter is more flexible and suitable for advanced uses. 1. Use the -v flag to quickly mount the host directory to the container, the format is dockerrun-d-v[host_path]:[container_path][image_name], such as dockerrun-d-v/mydata:/app_datamy_app; you can also set read-only permissions by adding:ro. 2. Use the --mount flag to provide finer granular control, the format is dockerrun-d-mounttype=volume,source=[v
