默认情况下,Ubuntu 在安装时在 fstab 中使用 uuid。
要显示创建的分区,请在终端中以用户身份键入以下命令:
ls -l /dev/disk/by-uuid
Run Code Online (Sandbox Code Playgroud)
它会输出如下:
lrwxrwxrwx 1 root root 10 2007-05-27 23:42 348ea9e6-7879-4332-8d7a-915507574a80 -> ../../sda1
lrwxrwxrwx 1 root root 10 2007-05-27 23:42 610aaaeb-a65e-4269-9714-b26a1388a106 -> ../../sda2
lrwxrwxrwx 1 root root 10 2007-05-27 23:42 857c5e63-c9be-4080-b4c2-72d606435051 -> ../../sda5
lrwxrwxrwx 1 root root 10 2007-05-27 23:42 a83b8ede-a9df-4df6-bfc7-02b8b7a5f1f2 -> ../../sda6
lrwxrwxrwx 1 root root 10 2007-05-27 23:42 ad662d33-6934-459c-a128-bdf0393e0f44 -> ../../sda7
Run Code Online (Sandbox Code Playgroud)
下一步是将 UUID 分区输入到 /etc/fstab。
在引导过程中,/etc/fstab 中列出的文件系统会自动挂载,但包含 noauto 的条目除外。此文件包含以下格式的条目:
设备/挂载点 fstype 选项 dumpfreq passno
设备
An existing device name, by default Ubuntu uses uuid
Run Code Online (Sandbox Code Playgroud)
挂载点
An existing directory on which to mount the file system.
Run Code Online (Sandbox Code Playgroud)
类型
The file system type to pass to mount. The default Ubuntu file system is ext4.
Run Code Online (Sandbox Code Playgroud)
选项
Either rw for read-write file systems, or ro for read-only file systems, followed by any other options that may be needed. A common option is noauto for file systems not normally mounted during the boot sequence.
Run Code Online (Sandbox Code Playgroud)
转储频率
Used by dump to determine which file systems require dumping. If the field is missing, a value of zero is assumed.
Run Code Online (Sandbox Code Playgroud)
通行证
Determines the order in which file systems should be checked. File systems that should be skipped should have their passno set to zero. The root file system needs to be checked before everything else and should have its passno set to one. The other file systems should be set to values greater than one. If more than one file system has the same passno, fsck will attempt to check file systems in parallel if possible.
Run Code Online (Sandbox Code Playgroud)
要将其添加到您的 fstab 文件中,请使用具有 root 权限的文本编辑器:
sudo -i
nano /etc/fstab
Run Code Online (Sandbox Code Playgroud)
例子:
# <device file system> <mount point> <type> <options> <dump> <pass>
UUID=ad662d33-6934-459c-a128-bdf0393e0f44 / ext4 defaults 1 1
UUID=30ebb8eb-8f22-460c-b8dd-59140274829d /home ext4 defaults 1 1
UUID=7014f66f-6cdf-4fe1-83da-9cab7b6fab1a swap swap defaults 0 0
Run Code Online (Sandbox Code Playgroud)
Control + O,保存文件
Control +X,关闭nano
重新启动计算机后,文件系统将自动挂载。
除非需要一些特殊选项,否则没有必要在 fstab 中列出 /proc 和 /sys。引导系统将始终挂载它们。
| 归档时间: |
|
| 查看次数: |
10665 次 |
| 最近记录: |