Recently, I plan to automatically mount the data disk when it is turned on, so as not to have to mount it manually every time. The summary steps are as follows:
-
Enter the following command to list all partitions in the system:
sudo fdisk -l
Find the partition you want to mount, and you can distinguish it by its capacity. Of course, it may not be easy to distinguish. You can directly
其他位置(other locations)
see the relevant information in the directory.
-
Enter the following command to view the mounted points
lsblk
or
df -h
You can also see the corresponding mount point. For example, here I need to automatically mount/media/chh3213/MECHREVO
the directory when booting up. You can see that its partition isnvme0n1p1
. -
Use
sudo blkid
the command to query the UUID and file system format of the corresponding disk partition, which will be used later.
For example, if I plan to boot and mountnvme0n1p1
a partition, then query the partition information:sudo blkid /dev/nvme0n1p1
You can view
nvme0n1p1
the relevant information of the partition (very important, will be used later) -
config
/etc/fstab
file
viasudo gedit /etc/fstab
Open the fstab file and add the following content in it:
UUID=84B03D67B03D60BA /media/chh3213/MECHREVO ntfs defaults 0 2
The parameters are described as follows:
- The first column is
UUID
, fill in the disk partitions queried beforeUUID
. - The second column is the disk partition
挂载目录
, which is the path you want to mount. - The third column is the file system format of the disk partition, which is displayed in the partition information
TYPE
. - The fourth column is the mount option of the disk partition, which is usually set here
defaults
. - Column 5 is
Linux dump
the backup option.
0
: Indicates that Linux dump is not used for backup. Dump backup is usually not used now, it0
can be set here .
1
: Indicates to use Linux dump backup. - Column 6 is
fsck
an option, that is, whether to use fsck to check the disk when booting.
0
: Indicates no inspection;
1
: Fill in the partition whose mount point is (/
) the root directory1
;
for other partitions2
, the system will check the numbers in ascending order from the beginning.
- The first column is
-
Restart the system to take effect