Skip to content

Instantly share code, notes, and snippets.

@jojomi
Last active September 8, 2016 04:51
Show Gist options
  • Save jojomi/94d09ed82c46fd97d647 to your computer and use it in GitHub Desktop.
Save jojomi/94d09ed82c46fd97d647 to your computer and use it in GitHub Desktop.
Chrooting into an encrypted disk
#!/usr/bin/env bash
set -e
DISK_ENCRYPTED=/dev/sda2
DISK_BOOT=/dev/sda1
VG_NAME=cryptVG
echo 'chrooting'
lsblk
cryptsetup open $DISK_ENCRYPTED root
ls -la /dev/mapper/
ls -la /dev/mapper/root
mkdir --parents /mnt/arch
pacman -Syy
pacman -S gnome-disk-utility lvm2
modprobe dm-mod
lsmod | grep dm_crypt
vgscan
vgchange -ay $VG_NAME
ls /dev/mapper/
mount /dev/mapper/$VG_NAME-root /mnt/arch/
mount $DISK_BOOT /mnt/arch/boot/
cd /mnt/arch
mount -t proc proc proc/
mount --rbind /sys sys/
mount --rbind /dev dev/
cp /etc/resolv.conf etc/resolv.conf
chroot /mnt/arch /bin/bash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment