我因在 ubuntu 12.04 服务器中输入错误 fstab 文件而将其破坏。
有人知道我该如何使用正确的值恢复它吗?
答案1
默认情况下,Ubuntu 在安装时会在 fstab 中使用 uuid。
要显示已创建的分区,请在终端中以用户身份键入以下命令:
ls -l /dev/disk/by-uuid
它将输出如下内容:
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
下一步是将 UUID 分区输入到 /etc/fstab。
在引导过程中,/etc/fstab 中列出的文件系统将自动挂载,但包含 noauto 的条目除外。此文件包含以下格式的条目:
设备/挂载点 fstype 选项 dumpfreq passno
设备
An existing device name, by default Ubuntu uses uuid
挂载点
An existing directory on which to mount the file system.
文件系统类型
The file system type to pass to mount. The default Ubuntu file system is ext4.
选项
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.
转储频率
Used by dump to determine which file systems require dumping. If the field is missing, a value of zero is assumed.
密码
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.
要将其添加到您的 fstab 文件,请使用具有 root 权限的文本编辑器:
sudo -i
nano /etc/fstab
例子:
# <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
Control + O,保存文件
Control +X,关闭纳米
计算机重新启动后,文件系统将自动挂载。
除非需要某些特殊选项,否则没有必要在 fstab 中列出 /proc 和 /sys。启动系统将始终挂载它们。