如何将 /var/log/ 挂载到单独的分区?

如何将 /var/log/ 挂载到单独的分区?

我在新服务器上安装了 Ubuntu 18.04,我需要挂载/var/log到单独的分区。我用 创建了一个新分区,手动挂载它可以正常工作。如果我在启动期间通过 挂载,ext4服务器将无法启动。/var/logfstab

/var/log/syslog:Nov 21 18:52:54 server kernel: [ 2126.966538] EXT4-fs (nvme2n1p1): mounted filesystem with ordered data mode. Opts: (null)
/var/log/syslog:Nov 21 18:53:18 server systemd[1]: Stopping Session 1 of user root.
/var/log/syslog:Nov 21 18:53:18 server systemd[1]: Stopping Session 5 of user USERNAME.
/var/log/syslog:Nov 21 18:53:18 server systemd[1]: Closed Load/Save RF Kill Switch Status /dev/rfkill Watch.
/var/log/syslog:Nov 21 18:53:18 server systemd[1]: Stopping Availability of block devices...
/var/log/syslog:Nov 21 18:53:18 server systemd[1]: Stopping Session 3 of user root.
/var/log/syslog:Nov 21 18:53:18 server systemd[1]: Stopped target Graphical Interface.
/var/log/syslog:Nov 21 18:53:18 server systemd[1]: Stopped target Multi-User System.
/var/log/syslog:Nov 21 18:53:18 server systemd[1]: Stopping The PHP 7.2 FastCGI Process Manager...
/var/log/syslog:Nov 21 18:53:18 server systemd[1]: Stopping The Apache HTTP Server...
/var/log/syslog:Nov 21 18:53:18 server systemd[1]: Stopping The PHP 5.6 FastCGI Process Manager...
/var/log/syslog:Nov 21 18:53:18 server systemd[1]: Stopped Wait until snapd is fully seeded.
/var/log/syslog:Nov 21 18:53:18 server systemd[1]: Stopping D-Bus System Message Bus...
/var/log/syslog:Nov 21 18:53:18 server systemd[1]: Stopping The PHP 7.1 FastCGI Process Manager...
/var/log/syslog:Nov 21 18:53:18 server systemd[1]: Stopping The PHP 7.3 FastCGI Process Manager...
/var/log/syslog:Nov 21 18:53:18 server systemd[1]: Stopping System Logging Service...
/var/log/syslog:Nov 21 18:53:18 server systemd[1]: Stopping Unattended Upgrades Shutdown...
/var/log/syslog:Nov 21 18:53:18 server systemd[1]: Stopping LSB: Record successful boot for GRUB...
/var/log/syslog:Nov 21 18:53:18 server systemd[1]: Stopping Deferred execution scheduler...
/var/log/syslog:Nov 21 18:53:18 server systemd[1]: Stopping LSB: set CPUFreq kernel parameters...
/var/log/syslog:Nov 21 18:53:18 server blkdeactivate[13934]: Deactivating block devices:
/var/log/syslog:Nov 21 18:53:18 server systemd[1]: Stopped target Timers.
/var/log/syslog:Nov 21 18:53:18 server systemd[1]: Stopped Clean PHP session files every 30 mins.
/var/log/syslog:Nov 21 18:53:18 server systemd[1]: Stopped Message of the Day.

/var/log/unattended-upgrades/unattended-upgrades-shutdown.log:2019-11-21 18:53:18,394 WARNING - SIGTERM or SIGHUP received, stopping unattended-upgradesonly if it is running

/dev/nvme2n1p1将是目标分区。在启动时安装单独分区的正确方法是什么/var/log

我的fstab

/dev/md/0 / ext4 noatime 0 1
#/dev/nvme2n1p1 /var/log ext4 noatime 0 2
/dev/md/1 /home ext4 noatime 0 2
/dev/md/2 /tmp ext4 noatime 0 2
/dev/md/3 /var/www ext4 noatime 0 2
/dev/nvme2n1p2 /var/backup ext4 noatime 0 2
proc /proc proc defaults 0 0

答案1

我必须在 fstab 中使用 UUID。如果没有它们,每次启动时,它都会将 nvme1n1p1 与 nvme2n1p1 交换,反之亦然,因此分区总是很忙,无法挂载。我以前从未见过这样的行为。我使用 UUID 进行了无数次重启,现在它运行正常

相关内容