Fix "/host unmount failure" during reboot (#4558)
This commit is contained in:
parent
cdfb1ced44
commit
32f58b5864
@ -224,6 +224,11 @@ sudo cp $IMAGE_CONFIGS/rsyslog/rsyslog.conf.j2 $FILESYSTEM_ROOT_USR_SHARE_SONIC_
|
||||
sudo cp $IMAGE_CONFIGS/rsyslog/rsyslog.d/* $FILESYSTEM_ROOT/etc/rsyslog.d/
|
||||
echo "rsyslog-config.service" | sudo tee -a $GENERATED_SERVICE_FILE
|
||||
|
||||
# Copy syslog override files
|
||||
sudo mkdir -p $FILESYSTEM_ROOT/etc/systemd/system/syslog.socket.d
|
||||
sudo cp $IMAGE_CONFIGS/syslog/override.conf $FILESYSTEM_ROOT/etc/systemd/system/syslog.socket.d/override.conf
|
||||
sudo cp $IMAGE_CONFIGS/syslog/host_umount.sh $FILESYSTEM_ROOT/usr/bin/
|
||||
|
||||
# Copy logrotate.d configuration files
|
||||
sudo cp -f $IMAGE_CONFIGS/logrotate/logrotate.d/* $FILESYSTEM_ROOT/etc/logrotate.d/
|
||||
|
||||
|
31
files/image_config/syslog/host_umount.sh
Executable file
31
files/image_config/syslog/host_umount.sh
Executable file
@ -0,0 +1,31 @@
|
||||
#!/bin/bash
|
||||
# This script is invoked at the closure of syslog socket during reboot
|
||||
# This will stop journal services, unmount /var/log and delete loop device
|
||||
# associated to /host to ensure proper unmount of /host
|
||||
|
||||
journal_stop() {
|
||||
systemctl stop systemd-journald.service
|
||||
systemctl stop systemd-journald.socket
|
||||
systemctl stop systemd-journald-audit.socket
|
||||
systemctl stop systemd-journald-dev-log.socket
|
||||
}
|
||||
|
||||
delete_loop_device() {
|
||||
umount /var/log
|
||||
if [[ $? -ne 0 ]]
|
||||
then
|
||||
exit 0
|
||||
fi
|
||||
losetup -d /dev/loop1
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
journal_stop|delete_loop_device)
|
||||
$1
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {journal_stop|delete_loop_device}" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
6
files/image_config/syslog/override.conf
Normal file
6
files/image_config/syslog/override.conf
Normal file
@ -0,0 +1,6 @@
|
||||
[Unit]
|
||||
After=var-log.mount host.mount
|
||||
|
||||
[Socket]
|
||||
ExecStopPre=/usr/bin/host_umount.sh journal_stop
|
||||
ExecStopPost=/usr/bin/host_umount.sh delete_loop_device
|
Loading…
Reference in New Issue
Block a user