有没有办法确保在启动时自动将具有 ext4 文件系统的新分区挂载到 /var 目录?
答案1
打开终端并执行:sudo blkid
... 搜索您想要在启动操作系统时自动挂载的分区的 UUID。现在向文件添加一个条目fstab
。
打开终端并执行: 。从命令 gksudo gedit /etc/fstab
中添加 UUID 。blkid
例子 :
sudo blkid
/dev/sda1: LABEL="data" UUID="5B9C797F2C733C9B" TYPE="ntfs" PARTUUID="e5c27785-4883-42d7-bd79-e27109e9f3a1"
/dev/sda2: LABEL="media" UUID="066265146F41F90F" TYPE="ntfs" PARTUUID="0de341ec-9dda-485a-8fe6-6603e10913a9"
/dev/sda3: LABEL="rescue" UUID="4D244C6A5C3C5310" TYPE="ntfs" PARTUUID="e9d08be2-d5b0-4bbd-aef4-330414b7b3ba"
/dev/sda4: LABEL="system" UUID="126F544516701913" TYPE="ntfs" PARTUUID="819cbefb-c483-41ea-a6ca-970ba757e608"
/dev/sdb1: UUID="7381-B73F" TYPE="vfat" PARTUUID="4af6ebbc-eb8d-4cbe-af28-de7ac03b0c37"
/dev/sdb2: UUID="4ccb0a38-686c-4045-bf53-5ad7a1fa7d90" TYPE="swap" PARTUUID="04188846-f2b0-44de-b19d-6a7d761aba68"
/dev/sdb3: UUID="057d688c-008b-4682-aabf-ee2e0762fc26" TYPE="ext4" PARTUUID="80298a8b-cc2a-4798-b9ef-ecd2bb474e79"
/dev/sdb4: LABEL="virtual" UUID="65077e7a-4bd6-47ea-8014-01e06655cc31" TYPE="ext4" PARTUUID="99807be9-fa3e-451e-b2a9-c95ebb0b2c8e"
在示例中sdb4
,应在系统启动时安装到/var
目录 - 必须添加以下内容:
UUID=65077e7a-4bd6-47ea-8014-01e06655cc31 /var/virtual ext4 defaults 0 2
保存所做的更改...现在fstab
文件将如下所示:
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sdb3 during installation
UUID=057d688c-008b-4682-aabf-ee2e0762fc26 / ext4 errors=remount-ro 0 1
# /boot/efi was on /dev/sdb1 during installation
UUID=7381-B73F /boot/efi vfat umask=0077 0 1
# swap was on /dev/sdb2 during installation
UUID=4ccb0a38-686c-4045-bf53-5ad7a1fa7d90 none swap sw 0 0
#
UUID=65077e7a-4bd6-47ea-8014-01e06655cc31 /var/virtual ext4 defaults 0 2
您也可以使用nano
命令行编辑器,但是当您想要使用 GUI 编辑器时,请使用以下gksudo
命令打开 gedit。如果尚未安装,请打开终端并执行:
sudo apt-get update
sudo apt-get install gksu
注意:默认挂载目录是/media/<user>/<partition-label>
。您可能要考虑将分区挂载到此目录,或者挂载到/mnt
目录。