It is possible to emulate a running system via chroot on a live booted system. The steps primarily include booting a LiveCD and mount file systems AND MOST IMPORTANTLY mount the /etc/resolv.conf into the temporary chroot which resolves DNS (translates human-friendly domain names into the numeric IP addresses that are required for access to resources on the local area network or the Internet or something like that).

Boot into a live system and then drop into a terminal root shell:

Without LUKS

List the disk partitions like below:

root@localhost: ~ # /sbin/fdisk -l
Disk /dev/sda: 465.8 GiB, 500107862016 bytes, 976773168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: FCF6DF37-A156-41E9-A9CF-D031C3FE956F

Device         Start       End   Sectors   Size Type
/dev/sda1       2048 586133503 586131456 279.5G Linux filesystem
/dev/sda2  586133504 587110399    976896   477M EFI System

you can see, here /dev/sda1 is the root partition (where Debian is installed into) and /dev/sda2 is the EFI boot partition. You might have some other partitions too like an extra home partition etc. So now you need to mount those partitions to the running Live session. It can be done by the following way (very similar):

root@localhost: ~ # mount /dev/sda1 /mnt  (Mounted the rootfs)
root@localhost: ~ # mount /dev/sda2 /mnt/boot/efi/  (Mounted the EFI boot partition)
root@localhost: ~ # mount /dev/sdaX /mnt/home (Only if you have separate partitions for /HOME)

just assume /mnt as new / for now and everything will be fall under /mnt/var, /mnt/tmp, /mnt/home like that. You also need to bind mounts of /dev (device nodes), /proc (process information pseudo-file system), and /sys (kernel objects file system). For that, just issue the following loop:

root@localhost: ~ # for name in proc sys dev ; do mount --bind /$name /mnt/$name; done

also for getting your network work inside chroot environment, just mount /etc/resolve.conf into chroot by following way:

root@localhost: ~ # mount --bind /etc/resolv.conf /mnt/etc/resolv.conf

now you are almost done and you can access/operate your locally installed system from live cd and make changes to it. For that, just type:

root@localhost: ~ # chroot /mnt/ /bin/bash

from here, do whatever you want, reinstall packages, DE or somewhat else. After you are done, just upgrade the grub and regenerate initramfs if necessary (most probably you don't have to).

root@chroot: ~ # apt install network-manager-gnome
root@chroot: ~ # update-initramfs -uv; update-grub
root@chroot: ~ # exit

With LUKS encryption

The procedure is very similar to the one without LUKS. However, the partitions look slightly different and you have to decrypt it first.

root@localhost: ~ # /sbin/fdisk -l
Disk /dev/nvme0n1: 953.87 GiB, 1024209543168 bytes, 2000409264 sectors
Disk model: WD PC SN810 SDCQNRY-1T00-1201           
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 4B2727BA-9E33-4BA6-B587-28F1F472C747

Device           Start        End    Sectors   Size Type
/dev/nvme0n1p1    2048    1050623    1048576   512M EFI System
/dev/nvme0n1p2 1050624    2050047     999424   488M Linux filesystem
/dev/nvme0n1p3 2050048 2000408575 1998358528 952.9G Linux filesystem

In this case, /dev/nvme0n1p3 is the root partition and the one we have to decrypt:

root@localhost: ~ # cryptsetup luksOpen /dev/nvme0n1p2 luks

The mounts also look slightly different (check the output of lsblk if the names don't match):

root@localhost: ~ # mount /dev/mapper/main-root /mnt
root@localhost: ~ # mount /dev/mapper/main-home /mnt/home
root@localhost: ~ # mount /dev/nvme0n1p1 /mnt/boot
root@localhost: ~ # swapon /dev/mapper/main-swap

The rest is the same as without LUKS (see first section):


CategorySystemRescue