parent
7da8c6301c
commit
779f1a4e58
@ -0,0 +1,57 @@
|
||||
#! /bin/bash
|
||||
|
||||
echo ""
|
||||
echo "Updating local packages..."
|
||||
errors=`apt-add-repository universe >/dev/null 2>/dev/null && apt update 2>&1 >/dev/null`
|
||||
if [ "$?" = "0" ]; then
|
||||
echo "Done."
|
||||
else
|
||||
echo "Failed to add universal repository, update apt repository - $errors"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "Importing boot pool and main OS pool..."
|
||||
errors=$(zfs export -a 2>&1 1>/dev/null && zfs import -N -R /mnt rpool 2>&1 1>/dev/null && zfs import -N -R /mnt bpool 2>&1 1>/dev/null && zfs mount rpool/ROOT/ubuntu 2>&1 1>dev/null && zfs mount -a 2>&1 1>/dev/null)
|
||||
if [ "$?" = "0" ]; then
|
||||
echo "Done."
|
||||
else
|
||||
echo "Failed to mount bpool or rpool - $errors"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
|
||||
echo ""
|
||||
echo "Binding mounts..."
|
||||
errors=`mount --rbind /dev /mnt/dev 2>&1 1>/dev/null && mount --rbind /proc /mnt/proc 2>&1 1>/dev/null && mount --rbind /sys /mnt/sys 2>&1 1>/dev/null`
|
||||
if ! [ "$?" = "0" ]; then
|
||||
echo "Failed to bind mounts - $errors"
|
||||
exit 4
|
||||
fi
|
||||
echo "Done."
|
||||
|
||||
echo ""
|
||||
echo "Entering chroot..."
|
||||
echo "Please execute \"mount /boot\" to access boot partition, type exit to leave:"
|
||||
echo ""
|
||||
chroot /mnt /bin/bash --login
|
||||
|
||||
if ! [ "$?" = "0" ]; then
|
||||
echo "Chroot failed with an error"
|
||||
exit $?
|
||||
fi
|
||||
|
||||
|
||||
|
||||
echo ""
|
||||
echo "Unbinding mounts..."
|
||||
errors=$(mount | grep -v zfs | tac | awk '/\/mnt/ {print $3}' | xargs -i{} umount -lf {} 2>&1 1>/dev/null && zpool export -a 2>&1 1>/dev/null)
|
||||
if ! [ "$?" = "0" ]; then
|
||||
echo "Failed to unbind mounts - $errors"
|
||||
exit 4
|
||||
fi
|
||||
echo "Done."
|
||||
echo ""
|
||||
|
||||
|
||||
exit 0
|
||||
Loading…
Reference in new issue