Programming
Mount Encrypted Linux System from Live Disk
Fabian Jost
Fabian Jost
September 20, 2023
2 min
Make sure to subscribe to my newsletter and be the first to know the news.

Table Of Contents

01
Introduction
02
References
03
Install Linux on a Live Disk
04
Identify Volume Group
05
Mount Encrypted System
Mount Encrypted Linux System from Live Disk

Introduction

During upgrading my linux kernel on my Ubuntu installation I encoutered an error while generating initramfs after the installation. Instead of looking into the error more precisely, I simply restarted my system and ended up with a broken boot setup. The issue was that my bootmanager did not correctly recognize my encrypted partition and therefore did not show the decryption screen, where I would normally enter my password for the partition decryption.

Fortunately there is a way to mount your system via a live disk and reconfigure the initramfs and there is no need to reinstall the whole operating system. As it turned out there were not a lot of resources finding this online and it had cost me several hours finding a solution. This guide is for everyone who might come accross the same issue.

References

This guide is based on the following blog post: https://unix.stackexchange.com/questions/688707/how-do-i-get-linux-to-find-the-root-filesystem-on-an-encrypted-partition

Thanks to John Freeman for saving me from losing a bunch of work.

Install Linux on a Live Disk

First find a linux distro you like and install it on a USB live disk. I simply used Xubuntu, because it has a fairly small iso size, but it really does not matter. Once that is done, restart your broken PC or Laptop and boot from the newly created live disk.

Identify Volume Group

Now that we are up an running on our live disk, first open a partition manager tool (e.g. gparted, KDE partition manager, etc.) and identify your encrypted disk (probably the largest one). Normally you should see the name of your volume group already, if not simply double click in the partition and enter your decryption password (do not do this if you see the name already, because you need to restart if you do this). In my case this was vgkubuntu.

partition manager

If you needed to decrypt your partition to see the name, you might need to restart and boot into the live disk again.

Mount Encrypted System

Now we have all the pieces together and can mount the system with the following commands. Simply replace vgkubuntu with the name of your volume group.

sudo -i
cryptsetup luksOpen /dev/nvme0n1p3 vgkubuntu
vgchange -ay
mkdir /mnt/root
mount /dev/mapper/vgkubuntu /mnt/root
mount /dev/nvme0n1p2 /mnt/root/boot
mount /dev/nvme0n1p1 /mnt/root/boot/efi
mount --bind /dev /mnt/root/dev
mount --bind /run /mnt/root/run
chroot /mnt/root
mount -t proc proc /proc
mount -t sysfs sys /sys

With that we mounted our root system and can execute any command we would be able to if we “normally” booted into our system. In my case this enabled me to reconfigure my initramfs with the following command:

update-initramfs -c -k all

Now restart your system, enter your decryption password and enjoy!


Tags

linux
Fabian Jost

Fabian Jost

CEO of LYTE Vapes

I am the CEO of LYTE Vapes and I want to give something back to the people out there, things I wish I knew way earlier. Welcome to my blog.

Expertise

CEO LYTE Vapes
B.Sc. Mechatronics

Social Media

lytevapesinstagramlinkedinfacebooktwitter

Related Posts

Ethereum Smart Contracts Cheat Sheet
Ethereum Smart Contracts Cheat Sheet
June 23, 2022
3 min
© 2023, All Rights Reserved.
Made with    by
Webdesk Designs

Quick Links

About MeContact Me

Social Media