Skip to content

Instantly share code, notes, and snippets.

@samschlegel
Last active July 19, 2018 21:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samschlegel/4dcd743355060147843cdd8a80064d54 to your computer and use it in GitHub Desktop.
Save samschlegel/4dcd743355060147843cdd8a80064d54 to your computer and use it in GitHub Desktop.
chrooting on LVM-on-LUKS
#!/usr/bin/env bash
# Enter chroot
cryptsetup luksOpen /dev/nvme0n1p5 system
mkdir -p /mnt/root
mount /dev/mapper/system-root /mnt/root
mount /dev/mapper/system-boot /mnt/root/boot
mount /dev/mapper/system-home /mnt/root/home
mount /dev/nvme0n1p2 /mnt/root/boot/efi
mount --bind /dev /mnt/root/dev
mount --bind /run /mnt/root/run
chroot /mnt/root
# Setup once in chroot
mount --types=proc proc /proc
mount --types=sysfs sys /sys
# Do what you need
refreshgrub
# Exit and cleanup
exit
umount -R /mnt/root
vgchange -an system
cryptsetup luksClose system
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment