Chroot into encrypted partition

Hi mate, also struggling with the same issue. But can’t seem to get it working. Here is my output.

Any help would be appreciated, cheers.

╭─garuda@garuda in ~ as 🧙 
 ╰─λ lsblk -f
NAME    FSTYPE FSVER LABEL            UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
loop0   squash 4.0                                                               0   100% /run/miso/sfs/livefs
loop1   squash 4.0                                                               0   100% /run/miso/sfs/mhwdfs
loop2   squash 4.0                                                               0   100% /run/miso/sfs/desktopfs
loop3   squash 4.0                                                               0   100% /run/miso/sfs/rootfs
sda                                                                                       
├─sda1  ntfs                          307CC93C7CC8FE1A                                    
├─sda2  vfat   FAT32                  48E2-7C54                                           
├─sda3                                                                                    
├─sda4                                                                                    
└─sda5  ntfs                          4E28335A28333FEF                                    
sdb     iso966 Jolie GARUDA_GNOME_RAPTOR
                                      2023-03-19-16-49-22-00                              
├─sdb1  iso966 Jolie GARUDA_GNOME_RAPTOR
│                                     2023-03-19-16-49-22-00                     0   100% /run/miso/bootmnt
└─sdb2  vfat   FAT12 MISO_EFI         B49B-B214                                           
zram0                                                                                     [SWAP]
nvme1n1                                                                                   
├─nvme1n1p1
│       vfat   FAT32                  497C-2B30                                           
└─nvme1n1p2
        crypto 1                      f2314da2-7bb3-4bfa-83ba-9a58d102e216                
nvme0n1                                                                                   
├─nvme0n1p1
│       vfat   FAT32                  1228-F410                                           
├─nvme0n1p2
│                                                                                         
└─nvme0n1p3

Here is what happens after attempting to chroot it.

 ╭─garuda@garuda in ~ as 🧙 
 ╰─λ lsblk -f
NAME    FSTYPE FSVER LABEL            UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
loop0   squash 4.0                                                               0   100% /run/miso/sfs/livefs
loop1   squash 4.0                                                               0   100% /run/miso/sfs/mhwdfs
loop2   squash 4.0                                                               0   100% /run/miso/sfs/desktopfs
loop3   squash 4.0                                                               0   100% /run/miso/sfs/rootfs
sda                                                                                       
├─sda1  ntfs                          307CC93C7CC8FE1A                                    
├─sda2  vfat   FAT32                  48E2-7C54                                           
├─sda3                                                                                    
├─sda4                                                                                    
└─sda5  ntfs                          4E28335A28333FEF                                    
sdb     iso966 Jolie GARUDA_GNOME_RAPTOR
                                      2023-03-19-16-49-22-00                              
├─sdb1  iso966 Jolie GARUDA_GNOME_RAPTOR
│                                     2023-03-19-16-49-22-00                     0   100% /run/miso/bootmnt
└─sdb2  vfat   FAT12 MISO_EFI         B49B-B214                                           
zram0                                                                                     [SWAP]
nvme1n1                                                                                   
├─nvme1n1p1
│       vfat   FAT32                  497C-2B30                                           
└─nvme1n1p2
        crypto 1                      f2314da2-7bb3-4bfa-83ba-9a58d102e216                
nvme0n1                                                                                   
├─nvme0n1p1
│       vfat   FAT32                  1228-F410                                           
├─nvme0n1p2
│                                                                                         
└─nvme0n1p3
                                                                                          

 ╭─garuda@garuda in ~ as 🧙 took 19ms
 ╰─λ sudo mkdir -p /mnt/broken

 ╭─garuda@garuda in ~ as 🧙 took 7ms
 ╰─λ sudo mount /dev/sdb2 /mnt/broken

 ╭─garuda@garuda in ~ as 🧙 took 26ms
 ╰─λ sudo garuda-chroot /mnt/broken/@
==> ERROR: Can't create chroot on non-directory /mnt/broken/@

 ╭─garuda@garuda in ~ as 🧙 took 19ms
[⚡] × sudo mount /dev/sdb1 /mnt/broken
mount: /mnt/broken: WARNING: source write-protected, mounted read-only.

 ╭─garuda@garuda in ~ as 🧙 took 10ms
 ╰─λ sudo garuda-chroot /mnt/broken/@
==> ERROR: Can't create chroot on non-directory /mnt/broken/@

 ╭─garuda@garuda in ~ as 🧙 took 18ms
[⚡] × 

You shouldn’t chroot into the USB partition /dev/sdb2 but into /dev/nvme1n1p2 (probably, I guess this is where your system is located), which is encrypted, so requires further steps. I’m not a super expert of this use case, but it should be:

sudo cryptsetup open /dev/nvme1n1p2 crypto_LUKS
sudo mount /dev/mapper/crypto_LUKS /mnt/broken
sudo garuda-chroot /mnt/broken/@
mount /dev/nvme1n1p1 /boot/efi
...

I’m also assuming /dev/nvme1n1p1 is your EFI system partition.
If not working, please open a new topic.

2 Likes

Thanks very much, got it to mount the drive at least. Does this look correct?

 ╭─garuda@garuda in ~ as 🧙 took 4ms
 ╰─λ sudo cryptsetup open /dev/nvme1n1p2 crypto_LUKS
Enter passphrase for /dev/nvme1n1p2: 


 ╭─garuda@garuda in ~ as 🧙 took 4s
 ╰─λ 

 ╭─garuda@garuda in ~ as 🧙 took 4s
 ╰─λ sudo mount /dev/mapper/crypto_LUKS  /mnt/broken

 ╭─garuda@garuda in ~ as 🧙 took 85ms
 ╰─λ sudo garuda-chroot /mnt/broken/@
sh-5.2# mount /dev/nvme1n1p1 /boot/efi

 ╭─garuda@garuda in ~ as 🧙 took 4ms
 ╰─λ sudo cryptsetup open /dev/nvme1n1p2 crypto_LUKS
Enter passphrase for /dev/nvme1n1p2: 


 ╭─garuda@garuda in ~ as 🧙 took 4s
 ╰─λ 

 ╭─garuda@garuda in ~ as 🧙 took 4s
 ╰─λ sudo mount /dev/mapper/crypto_LUKS  /mnt/broken

 ╭─garuda@garuda in ~ as 🧙 took 85ms
 ╰─λ sudo garuda-chroot /mnt/broken/@
sh-5.2# mount /dev/nvme1n1p1 /boot/efi
sh-5.2# ^C
sh-5.2# garuda-update
:: Synchronizing package databases...
error: failed to synchronize all databases (unable to lock database)
:: Synchronizing package databases...
error: failed to synchronize all databases (unable to lock database)
mkdir: cannot create directory '/var/log/garuda/': No space left on device
sh-5.2# pacman -S linux-zen linux-zen-headers
error: failed to init transaction (unable to lock database)
error: could not lock database: No space left on device
sh-5.2# 

Inside chroot try

rm /var/lib/pacman/db.lck

Before

garuda-update 

And kernel reinstallation.
Moved to a new topic.
Although the problem might be the same, it is for sure a different case.
Try also to free up some disk space there.
Or it could be a read-only file system, so a different and more severe problem.

2 Likes

Hi mate, just gives an error. Sadly I’m no Linux wizard so I’m about as useful as a chocolate fireguard. But here is the result.

Is it looking like I gotta backup my data and reinstall?

sh-5.2# rm /var/lib/pacman/db.lck
rm: cannot remove '/var/lib/pacman/db.lck': No such file or directory
sh-5.2# 

Hold on a little bit.
As said, I’m no expert in encrypted systems.
Hopefully someone more knowledgable will jump in.
:smiling_face:

2 Likes

This is quite clear, I think. How does df -h tell?

1 Like

No problem mate, I appreciate your help. Thanks kindly ! Hopefully somebody helps resolve this as I have too much to backup.

sh-5.2# df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/crypto_LUKS  466G  424G   42G  92% /
udev                      16G     0   16G   0% /dev
shm                       16G     0   16G   0% /dev/shm
run                       16G     0   16G   0% /run
tmp                       16G  4.0K   16G   1% /tmp
overlay                   23G  342M   23G   2% /etc/resolv.conf
/dev/nvme1n1p1           300M  732K  299M   1% /boot/efi
sh-5.2# 

I think you are missing subvolume mounts from BTRFS. Try a mount -a, unsure whether it helps.

2 Likes
sh-5.2# mount -a
mount: /home: special device /dev/mapper/luks-f2314da2-7bb3-4bfa-83ba-9a58d102e216 does not exist.
       dmesg(1) may have more information after failed mount system call.
mount: /root: special device /dev/mapper/luks-f2314da2-7bb3-4bfa-83ba-9a58d102e216 does not exist.
       dmesg(1) may have more information after failed mount system call.
mount: /srv: special device /dev/mapper/luks-f2314da2-7bb3-4bfa-83ba-9a58d102e216 does not exist.
       dmesg(1) may have more information after failed mount system call.
mount: /var/cache: special device /dev/mapper/luks-f2314da2-7bb3-4bfa-83ba-9a58d102e216 does not exist.
       dmesg(1) may have more information after failed mount system call.
mount: /var/log: special device /dev/mapper/luks-f2314da2-7bb3-4bfa-83ba-9a58d102e216 does not exist.
       dmesg(1) may have more information after failed mount system call.
mount: /var/tmp: special device /dev/mapper/luks-f2314da2-7bb3-4bfa-83ba-9a58d102e216 does not exist.
       dmesg(1) may have more information after failed mount system call.
sh-5.2# 

What are /etc/fstab contents?
In chroot terminal, run cat /etc/fstab

2 Likes

I went to another drive whilst waiting, upon booting back in to the live USB, I’m getting this printout trying to chroot again.

 ╭─garuda@garuda in ~ as 🧙 took 1ms
 ╰─λ lsblk -f
NAME FSTYPE FSVER LABEL UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
loop0
     squash 4.0                                                    0   100% /run/miso/sfs/livefs
loop1
     squash 4.0                                                    0   100% /run/miso/sfs/mhwdfs
loop2
     squash 4.0                                                    0   100% /run/miso/sfs/desktopfs
loop3
     squash 4.0                                                    0   100% /run/miso/sfs/rootfs
sda                                                                         
├─sda1
│    ntfs               307CC93C7CC8FE1A                                    
├─sda2
│    vfat   FAT32       48E2-7C54                                           
├─sda3
│                                                                           
├─sda4
│                                                                           
└─sda5
     ntfs               4E28335A28333FEF                                    
sdb  iso966 Jolie GARUDA_GNOME_RAPTOR
                        2023-03-19-16-49-22-00                              
├─sdb1
│    iso966 Jolie GARUDA_GNOME_RAPTOR
│                       2023-03-19-16-49-22-00                     0   100% /run/miso/bootmnt
└─sdb2
     vfat   FAT12 MISO_EFI
                        B49B-B214                                           
zram0
                                                                            [SWAP]
nvme1n1
                                                                            
├─nvme1n1p1
│    vfat   FAT32       497C-2B30                                           
└─nvme1n1p2
     crypto 1           f2314da2-7bb3-4bfa-83ba-9a58d102e216                
  └─luks-f2314da2-7bb3-4bfa-83ba-9a58d102e216
     btrfs              d06acea6-ea8c-4f8f-941c-00a29881dbad   41.7G    91% /run/media/garuda/d06acea6-ea8c-4f8f-941c-00a29881dbad
nvme0n1
                                                                            
├─nvme0n1p1
│    vfat   FAT32       1228-F410                                           
├─nvme0n1p2
│                                                                           
└─nvme0n1p3
                                                                            

 ╭─garuda@garuda in ~ as 🧙 took 5ms
 ╰─λ sudo mount /dev/mapper/crypto_LUKS  /mnt/broken
mount: /mnt/broken: mount point does not exist.
       dmesg(1) may have more information after failed mount system call.

 ╭─garuda@garuda in ~ as 🧙 took 7ms
[🔴] × 

The live environment is not persistent. You basically start over from scratch every time to boot to it. If you want to use this same mount point, you will have to create it again.

That said, it looks like you have unlocked and mounted the LUKS device anyway–probably by clicking on it and typing in the passphrase.

You didn’t post your /etc/fstab, but it looks like /dev/mapper/luks-f2314da2-7bb3-4bfa-83ba-9a58d102e216 is the mapping you want based on the failed mount command:

That is to say, you can try mounting again now that you have the device unlocked with the expected mapping.

Better yet, try using the chroot tool to set up the mounts and chroot for you.

garuda-chroot -a
2 Likes

fstab results

sh-5.2# cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a device; this may
# be used with UUID= as a more robust way to name devices that works even if
# disks are added and removed. See fstab(5).
#
# <file system>             <mount point>  <type>  <options>  <dump>  <pass>
UUID=497C-2B30                            /boot/efi      vfat    defaults,noatime 0 2
/dev/mapper/luks-f2314da2-7bb3-4bfa-83ba-9a58d102e216 /              btrfs   subvol=/@,defaults,noatime,compress=zstd 0 0
/dev/mapper/luks-f2314da2-7bb3-4bfa-83ba-9a58d102e216 /home          btrfs   subvol=/@home,defaults,noatime,compress=zstd 0 0
/dev/mapper/luks-f2314da2-7bb3-4bfa-83ba-9a58d102e216 /root          btrfs   subvol=/@root,defaults,noatime,compress=zstd 0 0
/dev/mapper/luks-f2314da2-7bb3-4bfa-83ba-9a58d102e216 /srv           btrfs   subvol=/@srv,defaults,noatime,compress=zstd 0 0
/dev/mapper/luks-f2314da2-7bb3-4bfa-83ba-9a58d102e216 /var/cache     btrfs   subvol=/@cache,defaults,noatime,compress=zstd 0 0
/dev/mapper/luks-f2314da2-7bb3-4bfa-83ba-9a58d102e216 /var/log       btrfs   subvol=/@log,defaults,noatime,compress=zstd 0 0
/dev/mapper/luks-f2314da2-7bb3-4bfa-83ba-9a58d102e216 /var/tmp       btrfs   subvol=/@tmp,defaults,noatime,compress=zstd 0 0
tmpfs                                     /tmp           tmpfs   defaults,noatime,mode=1777 0 0
sh-5.2# 


sh-5.2# cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a device; this may
# be used with UUID= as a more robust way to name devices that works even if
# disks are added and removed. See fstab(5).
#
# <file system>             <mount point>  <type>  <options>  <dump>  <pass>
UUID=497C-2B30                            /boot/efi      vfat    defaults,noatime 0 2
/dev/mapper/luks-f2314da2-7bb3-4bfa-83ba-9a58d102e216 /              btrfs   subvol=/@,defaults,noatime,compress=zstd 0 0
/dev/mapper/luks-f2314da2-7bb3-4bfa-83ba-9a58d102e216 /home          btrfs   subvol=/@home,defaults,noatime,compress=zstd 0 0
/dev/mapper/luks-f2314da2-7bb3-4bfa-83ba-9a58d102e216 /root          btrfs   subvol=/@root,defaults,noatime,compress=zstd 0 0
/dev/mapper/luks-f2314da2-7bb3-4bfa-83ba-9a58d102e216 /srv           btrfs   subvol=/@srv,defaults,noatime,compress=zstd 0 0
/dev/mapper/luks-f2314da2-7bb3-4bfa-83ba-9a58d102e216 /var/cache     btrfs   subvol=/@cache,defaults,noatime,compress=zstd 0 0
/dev/mapper/luks-f2314da2-7bb3-4bfa-83ba-9a58d102e216 /var/log       btrfs   subvol=/@log,defaults,noatime,compress=zstd 0 0
/dev/mapper/luks-f2314da2-7bb3-4bfa-83ba-9a58d102e216 /var/tmp       btrfs   subvol=/@tmp,defaults,noatime,compress=zstd 0 0
tmpfs                                     /tmp           tmpfs   defaults,noatime,mode=1777 0 0
sh-5.2# garuda-chroot -a
sh: garuda-chroot: command not found
sh-5.2# garuda-chroot -a
sh: garuda-chroot: command not found
sh-5.2# 


This command is only available in the live environment–not if you are booted to another distro or already in a chroot. :grin:

If you set up the chroot another way (besides garuda-chroot) you will need to manually mount the subvolumes before updating the chrooted system.

3 Likes

You would have to explain in cave man terms to me, I’m still newish to Linux :smiley:

So from the USB live environment, you want me to run garuda-update?

Caveman terms

Yes, in the chroot.

Slightly more evolved terms

Honestly it’s unclear what the issue actually is because you have not provided any information about what is happening yet, except to say “also struggling with the same issue” on another topic that may or may not be related. We are kind of operating under the assumption that you have the same issue as the other person, but so far there isn’t any evidence to suggest that is actually the case.

If you have the same problem as the other person like you say, bringing your system fully up to date and reinstalling the kernel is likely to resolve the issue (as it did for the other person). If you can’t boot to your system normally you will need to do it from the live environment in a chroot.

3 Likes

The sh-5.2# prompt shows that you were already inside a chroot here, so in the installed system, where garuda-chroot is not available (as explained it is available only on the live USB).
Repeat again the chroot steps to try the garuda-update and kernel reinstallation.
If the problem persists, have you tried restoring the latest working snapshot? See: Restoring snapshots to get the system back to working state | Garuda Linux wiki

2 Likes