From c9db056a86c5b26c2a82c9c54d8e026422507550 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Charaoui?= Date: Mon, 9 May 2022 10:58:14 -0400 Subject: [PATCH] use envvars in remount procedure Document the chroot remount procedure with environment variables instead of hardcoding all the paths, making it easier to use this in different hardware environments. Also, assume that the "rebuild grub" set of commands occur within the chroot as this is the expected result of the previous set of commands. --- howto/new-machine-cymru.md | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/howto/new-machine-cymru.md b/howto/new-machine-cymru.md index d2725800..a6052d1b 100644 --- a/howto/new-machine-cymru.md +++ b/howto/new-machine-cymru.md @@ -146,27 +146,33 @@ point it becomes a bit too complicated. ### remount procedure If you need to do something post-install, this should bring you a -working shell in the `chroot`: +working shell in the `chroot`. - cryptsetup luksOpen /dev/sda3 crypt_dev_sda3 && +First, set some variables according to the current environment: + + export BOOTDEV=/dev/sda2 CRYPTDEV=/dev/sda3 ROOTFS=/dev/mapper/vg_ganeti-root + +Then setup and enter the `chroot`: + + cryptsetup luksOpen "$CRYPTDEV" "crypt_dev_${CRYPTDEV##*/}" && vgchange -a y ; \ - mount /dev/mapper/vg_ganeti-root /mnt && - for fs in /run /sys /dev /proc; do mount -o bind $fs /mnt$fs; done && - mount /dev/sda2 /mnt/boot && + mount "$ROOTFS" /mnt && + for fs in /run /sys /dev /proc; do mount -o bind $fs "/mnt${fs}"; done && + mount "$BOOTDEV" /mnt/boot && chroot /mnt /bin/bash -This will rebuild grub: +This will rebuild grub from within the `chroot`: - chroot /mnt update-grub && - chroot /mnt grub-install /dev/sda + update-grub && + grub-install /dev/sda -And this will cleanup the rest: +And this will cleanup after exiting `chroot`: umount /mnt/boot && - for fs in /dev /sys /run /proc; do umount /mnt$fs; done && + for fs in /dev /sys /run /proc; do umount "/mnt${fs}"; done && umount /mnt && vgchange -a n && - cryptsetup luksClose crypt_dev_sda3 + cryptsetup luksClose "crypt_dev_${CRYPTDEV##*/}" ### Extra firmware -- GitLab