All Articles

Support Articles

Table of Contents

Login from Live Disk (Chroot)

Login from Live Disk (Chroot)

It is possible to mount an OS drive and log into the installed OS with root access. This is called gaining "chroot" (change to root) access. This process is used for a variety of things. rescuing files, fixing package manager issues, resetting forgotten user passwords, etc.

You'll need a Live OS Environment from which to mount your drive, and log in. This can be done from a live USB, or, on Pop!_OS, from the recovery partition. Boot the computer while holding down the boot menu key for your system, or the SPACE bar to access Systemd, and the Pop!_OS Recovery partition.

Once booted into the Live Environment, press SUPER+T to open a terminal (Pop!_OS), or CTRL+ALT+T (Ubuntu) then type this command:

lsblk

This will show you the name of the main internal drive, which will have 4 partitions (Pop!_OS), or 3 (Ubuntu) on it. We will be working with the 3rd partition. If the main drive is an NVMe drive, it will be called /dev/nvme0n1p3 (p2 on Ubuntu) and if the drive is a SATA or regular M.2 drive, it will be called /dev/sda3 (sda2 on Ubuntu).

NOTE: The rest of these instructions assume a Pop!_OS install, for partition labelling. The instructions are otherwise the same. Change the partition number accordingly.

Next, run this command:

SATA DrivesNVMe Drives
sudo mount /dev/sda3 /mntsudo mount /dev/nvme0n1p3 /mnt

If the command fails and says mount: /mnt: unknown filesystem type 'crypto_LUKS', then the hard drive has been encrypted, and additional commands are needed to unlock it.

Encrypted Disk

To get access to an encrypted disk, these additional commands need to be run in order to unlock the disk. Please use the lsblk command described above to determine the correct drive and partition.

SATA DrivesNVMe Drives
sudo cryptsetup luksOpen /dev/sda3 cryptdatasudo cryptsetup luksOpen /dev/nvme0n1p3 cryptdata
sudo lvscan
sudo vgchange -ay

Note: Pay attention to what the cryptdata group is called. If it is named something other than data-root, substitute the correct info into this next command. Make sure that -root is on the end:

sudo mount /dev/mapper/data-root /mnt

And now the existing hard drive can be accessed by going to the /mnt folder. To use the Files program, go to '+ Other Locations' -> 'Computer' and then click on the /mnt folder.

Chroot

chroot is the way to run commands as if the existing operating system had been booted. Once these commands are run, then package manager (apt) and other system-level commands can be run.

The EFI partition is the next partition to be mounted. To help identify it, this partition is usually around 512MB, and is labeled as /boot/efi.

SATA DrivesNVMe Drives
sudo mount /dev/sda1 /mnt/boot/efisudo mount /dev/nvme0n1p1 /mnt/boot/efi
for i in /dev /dev/pts /proc /sys /run; do sudo mount -B $i /mnt$i; done
sudo cp -n /etc/resolv.conf /mnt/etc/
sudo chroot /mnt

With this last command, you will have root access to your installed system. Once the drive is accessed, commands for maintenance can be run on the installed system. For example, package manager repair commands. You can also access your files with Files via "+ Other Locations" -> "Computer" -> "mnt."

After Chroot

Once you are done accessing files or running commands in your installed OS, you can exit from chroot and reboot the computer, by running these commands:

exit
reboot