desultory / ugrd

A minimalistic initramfs generator, designed for FDE
GNU General Public License v2.0
31 stars 11 forks source link

RuntimeError: 'btrfs' not found in PATH #77

Open P-reducible opened 5 days ago

P-reducible commented 5 days ago

I am doing a fresh Gentoo install as explained here. My EFI partition is at /dev/nvme0n1p1, my ext4 /boot partition is at /dev/nvme0n1p2, and /dev/nvme0n1p3 is a password-protected LUKS volume containing /dev/mapper/root with a single subvolume named /home. After the kernel (gentoo-sources-6.10.12) has been built, executing ugrd-1.22.0 with no parameters causes this error. Is this a bug, or I genuinely missed something?

Many thanks.

desultory commented 5 days ago

you may be missing btrfs-progs 

---- On Fri, 04 Oct 2024 00:08:28 -0500 @.*** wrote ----

I am doing a fresh Gentoo install as explained here. My EFI partition is at /dev-nvme0n1p1, my ext4 /boot partition is at /dev-nvme0n1p2, and /dev-nvme0n1p3 is a password-protected LUKS volume containing /dev/mapper/root with a single subvolume named /home. After the kernel (gentoo-sources-6.10.12) has been built, executing ugrd-1.22.0 with no parameters causes this error. Is this a bug, or I genuinely missed something?

Many thanks.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.

desultory commented 5 days ago

Reading the log, it says your / mount is btrfs?

_mounts:
  /:
    device: /dev/mapper/root
    fstype: btrfs
    options:
      - rw
      - relatime
      - ssd
      - space_cache=v2
      - subvolid=5
      - subvol=/
_blkid_info:
  /dev/mapper/root:
    uuid: e453674b-b040-488a-8efd-03b28e1a9d60
    label: rootfs
    type: btrfs

It tries to pull btrfs programs to ensure they are mounted/detected correctly, this is usually part of the btrfs-progs package.

P-reducible commented 5 days ago

@desultory, thank you for replying. The /etc/mtab shows

/dev/mapper/root / btrfs rw,realtime,ssd,space_cache=v2,subvolid=5,subvol=/ 0 0

As you suggested, I installed btrfs-progs, and it fixed the problem. My new log is here.

One suggestion, if I may. Your code checks if btrfs is present, and if so, executes it. There is an opinion that doing it this way creates a security risk. (Not to mention an obvious race condition). Would it make sense to just run btrfs straight away? Same argument as when you want to open a file: you just go for it without worrying if the file exists.

Thx again.

desultory commented 5 days ago

@desultory, thank you for replying. The /etc/mtab shows

/dev/mapper/root / btrfs rw,realtime,ssd,space_cache=v2,subvolid=5,subvol=/ 0 0

As you suggested, I installed btrfs-progs, and it fixed the problem. My new log is here.

One suggestion, if I may. Your code checks if btrfs is present, and if so, executes it. There is an opinion that doing it this way creates a security risk. (Not to mention an obvious race condition). Would it make sense to just run btrfs straight away? Same argument as when you want to open a file: you just go for it without worrying if the file exists.

Thx again.

I don't think the build system runs it. The error you saw came from it trying to copy the btrfs program from the root filesystem into the build environment, and since it was not present, it raised an exception. The btrfs program is listed as a dependency in the ugrd.fs.btrfs module, which can be loaded manually, but is automatically loaded at run time if a mount with the btrfs type is added.

There is an opt_dependencies type of dependency in ugrd which allows for an image to be created if the requested binary cannot be found, but in this case something is wrong if btrfs is being used but btrfs utilities aren't present.