laurent85v / archuseriso

A set of bash script programs to create bootable Arch Linux images and to create bootable USB flash drives with a desktop environment.
GNU General Public License v3.0
228 stars 30 forks source link

Chroot #53

Closed cab-1729 closed 11 months ago

cab-1729 commented 11 months ago

Any idea how to chroot into this from an existing arch setup? Simple arch-chroot doesn't work.

laurent85v commented 11 months ago

Please post more details about what you are trying to do exactly, the commands used and the error messages received.

cab-1729 commented 11 months ago

Suppose I create an encrypted, persistent device using this script. With the device attached to my current device, which is running arch, how do I chroot into the portable device. I know the encryption can be managed with:

cryptsetup luksOpen device name
mount /dev/mapper/name /mnt/mountpoint

After that how do I chroot into the device? Normal arch-chroot doesn't work.

laurent85v commented 11 months ago

It's an orverlay filesystem.
https://wiki.archlinux.org/title/Overlay_filesystem

I will post an example with the commands needed to successfully chroot

cab-1729 commented 11 months ago

The mount command given in the archwiki doesn't work for some reason:

[cab1729@arch ~]$ doas mount -t overlay overlay -o upperdir=/mnt/ssd/persistent_AUICO_m6x/x86_64/upperdir,workdir=/mnt/ssd/persistent_AUICO_m6x/x86_64/workdir /mnt/merged/
mount: /mnt/merged: wrong fs type, bad option, bad superblock on overlay, missing codepage or helper program, or other error.
       dmesg(1) may have more information after failed mount system call.
laurent85v commented 11 months ago

The lowerdir is missing. Mount the squashfs image airootfs.sfs located in the first partition. Example, assuming usb device /dev/sdb:

$ sudo mkdir /mnt/p1 /mnt/squashfs
$ sudo mount -o ro /dev/sdb1 /mnt/p1
$ sudo mount -o ro,loop /mnt/p1/arch/x86_64/airootfs.sfs /mnt/squashfs

Mount the overlay filesystem :

$ sudo mount -t overlay overlay -o lowerdir=/mnt/squashfs,upperdir=/mnt/ssd/persistent_AUICO_m6x/x86_64/upperdir,workdir=/mnt/ssd/persistent_AUICO_m6x/x86_64/workdir /mnt/merged

Mount the boot partition:

sudo mount /dev/sdb2 /mnt/merged/boot

Chroot:

$ sudo arch-chroot /mnt/merged
cab-1729 commented 11 months ago

Niiiiiiice. Thanks.