如何將/var/log/掛載到單獨的分割區?

如何將/var/log/掛載到單獨的分割區?

我在新伺服器上安裝了 Ubuntu 18.04,我需要安裝/var/log到單獨的分割區。我創建了一個新的分區ext4並手動安裝它工作正常。如果我/var/log在啟動期間通過掛載,伺服器不會啟動fstab

/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 進行了無數次重啟,現在一切正常

相關內容