Fix "/host unmount failure" during reboot (#4558)

This commit is contained in:
rkdevi27 2020-05-20 23:48:11 +05:30 committed by GitHub
parent cdfb1ced44
commit 32f58b5864
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 42 additions and 0 deletions

View File

@ -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/

View 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

View 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