Blame dracut-fadump-init-fadump.sh
|
Kairui Song |
96a3fc |
#!/bin/sh
|
|
Kairui Song |
96a3fc |
export PATH=/usr/bin:/usr/sbin
|
|
Kairui Song |
96a3fc |
export SYSTEMD_IN_INITRD=lenient
|
|
Kairui Song |
96a3fc |
|
|
Kairui Song |
96a3fc |
[ -e /proc/mounts ] ||
|
|
Kairui Song |
96a3fc |
(mkdir -p /proc && mount -t proc -o nosuid,noexec,nodev proc /proc)
|
|
Kairui Song |
96a3fc |
|
|
Kairui Song |
96a3fc |
grep -q '^sysfs /sys sysfs' /proc/mounts ||
|
|
Kairui Song |
96a3fc |
(mkdir -p /sys && mount -t sysfs -o nosuid,noexec,nodev sysfs /sys)
|
|
Kairui Song |
96a3fc |
|
|
Kairui Song |
96a3fc |
grep -q '^none / ' /proc/mounts || grep -q '^rootfs / ' /proc/mounts && ROOTFS_IS_RAMFS=1
|
|
Kairui Song |
96a3fc |
|
|
Kairui Song |
96a3fc |
if [ -f /proc/device-tree/rtas/ibm,kernel-dump ] || [ -f /proc/device-tree/ibm,opal/dump/mpipl-boot ]; then
|
|
Kairui Song |
96a3fc |
mkdir /newroot
|
|
Kairui Song |
96a3fc |
mount -t ramfs ramfs /newroot
|
|
Kairui Song |
96a3fc |
|
|
Kairui Song |
96a3fc |
if [ $ROOTFS_IS_RAMFS ]; then
|
|
Kairui Song |
96a3fc |
for FILE in $(ls -A /fadumproot/); do
|
|
Kairui Song |
96a3fc |
mv /fadumproot/$FILE /newroot/
|
|
Kairui Song |
96a3fc |
done
|
|
Kairui Song |
96a3fc |
exec switch_root /newroot /init
|
|
Kairui Song |
96a3fc |
else
|
|
Kairui Song |
2b7f08 |
mkdir /newroot/sys /newroot/proc /newroot/dev /newroot/run /newroot/oldroot
|
|
Kairui Song |
2b7f08 |
|
|
Kairui Song |
2b7f08 |
grep -q '^devtmpfs /dev devtmpfs' /proc/mounts && mount --move /dev /newroot/dev
|
|
Kairui Song |
2b7f08 |
grep -q '^tmpfs /run tmpfs' /proc/mounts && mount --move /run /newroot/run
|
|
Kairui Song |
96a3fc |
mount --move /sys /newroot/sys
|
|
Kairui Song |
2b7f08 |
mount --move /proc /newroot/proc
|
|
Kairui Song |
2b7f08 |
|
|
Kairui Song |
96a3fc |
cp --reflink=auto --sparse=auto --preserve=mode,timestamps,links -dfr /fadumproot/. /newroot/
|
|
Kairui Song |
96a3fc |
cd /newroot && pivot_root . oldroot
|
|
Kairui Song |
96a3fc |
|
|
Kairui Song |
96a3fc |
loop=1
|
|
Kairui Song |
96a3fc |
while [ $loop ]; do
|
|
Kairui Song |
96a3fc |
unset loop
|
|
Kairui Song |
96a3fc |
while read -r _ mp _; do
|
|
Kairui Song |
96a3fc |
case $mp in
|
|
Kairui Song |
2b7f08 |
/oldroot/*) umount -d "$mp" && loop=1 ;;
|
|
Kairui Song |
96a3fc |
esac
|
|
Kairui Song |
96a3fc |
done
|
|
Kairui Song |
96a3fc |
done
|
|
Kairui Song |
2b7f08 |
umount -d -l oldroot
|
|
Kairui Song |
96a3fc |
|
|
Kairui Song |
96a3fc |
exec /init
|
|
Kairui Song |
96a3fc |
fi
|
|
Kairui Song |
96a3fc |
else
|
|
Kairui Song |
96a3fc |
exec /init.dracut
|
|
Kairui Song |
96a3fc |
fi
|