Jip-Hop / sedunlocksrv-pba

Conveniently unlock your Self Encrypting Drive on startup (via HTTPS) without the need to attach monitor and keyboard
GNU General Public License v3.0
36 stars 8 forks source link

Building fails on Debian Bookworm as GRUB is too large #20

Closed kennethso168 closed 6 months ago

kennethso168 commented 6 months ago

Hi there. I tried to build the image on a Debian Bookworm VM (as I prefer using Debian instead of Ubuntu). However, there was an error during the build process and the final image could not be successfully booted.

The full build log is attached here: build_log.txt

I noticed that there was an error saying "No space left on device"

+ mount /dev/loop0p1 /home/kenneth/sedunlocksrv-pba/img.uwXVth/img
+ grub-install --no-floppy --boot-directory=/home/kenneth/sedunlocksrv-pba/img.uwXVth/img/boot --target=i386-pc /dev/loop0
Installing for i386-pc platform.
Installation finished. No error reported.
+ grub-install --removable --boot-directory=/home/kenneth/sedunlocksrv-pba/img.uwXVth/img/boot --target=x86_64-efi --efi-directory=/home/kenneth/sedunlocksrv-pba/img.uwXVth/img/ /dev/loop0
Installing for x86_64-efi platform.
Installation finished. No error reported.
+ grub-install --removable --boot-directory=/home/kenneth/sedunlocksrv-pba/img.uwXVth/img/boot --target=i386-efi --efi-directory=/home/kenneth/sedunlocksrv-pba/img.uwXVth/img/ /dev/loop0
Installing for i386-efi platform.
Installation finished. No error reported.
+ cat
+ cp -r /home/kenneth/sedunlocksrv-pba/img.uwXVth/fs/boot /home/kenneth/sedunlocksrv-pba/img.uwXVth/img/
cp: error writing '/home/kenneth/sedunlocksrv-pba/img.uwXVth/img/boot/corepure64.gz': No space left on device
+ cleanup
+ umount /home/kenneth/sedunlocksrv-pba/img.uwXVth/img
+ losetup -d /dev/loop0
+ rm -rf /home/kenneth/sedunlocksrv-pba/img.uwXVth

I tested the outputted *.img image in a VM on Proxmox. It resulted in a kernel panic: 2024-03-13 00_40_11-pve1 - Proxmox Virtual Environment — Mozilla Firefox

I tried building with previous commits. 93143b3c316658cb5bb981b20d7e0a8b2be757a5 worked. The 'No space left on device' error appeared with 5d91408db3b731bfbe408aa9e07941a8bd5cce76.

I also increased GRUBSIZE to 25 and added df -h commands before and after the copy command in build.sh on master to diagnose the issue. The image was built successfully and bootable. Here are the df -h outputs:

+ df -h
Filesystem                             Size  Used Avail Use% Mounted on
udev                                   981M     0  981M   0% /dev
tmpfs                                  199M  512K  198M   1% /run
/dev/sda1                              7.8G  2.2G  5.2G  30% /
tmpfs                                  992M     0  992M   0% /dev/shm
tmpfs                                  5.0M     0  5.0M   0% /run/lock
/dev/sda15                             124M   12M  113M  10% /boot/efi
tmpfs                                  199M     0  199M   0% /run/user/1000
/dev/loop0p1                            50M   20M   30M  40% /home/kenneth/sedunlocksrv-pba/img.UHHTMy/img
+ cp -r /home/kenneth/sedunlocksrv-pba/img.UHHTMy/fs/boot /home/kenneth/sedunlocksrv-pba/img.UHHTMy/img/
+ df -h
Filesystem                             Size  Used Avail Use% Mounted on
udev                                   981M     0  981M   0% /dev
tmpfs                                  199M  512K  198M   1% /run
/dev/sda1                              7.8G  2.2G  5.2G  30% /
tmpfs                                  992M     0  992M   0% /dev/shm
tmpfs                                  5.0M     0  5.0M   0% /run/lock
/dev/sda15                             124M   12M  113M  10% /boot/efi
tmpfs                                  199M     0  199M   0% /run/user/1000
/dev/loop0p1                            50M   46M  4.0M  92% /home/kenneth/sedunlocksrv-pba/img.UHHTMy/img
+ sync

The GRUB image occupies around 26M. Without increasing GRUBSIZE, the whole loop device is only around 41M in size which is too small.

I saw that in 5d91408db3b731bfbe408aa9e07941a8bd5cce76, you've changed from downloading Ubuntu's deb to a direct install (should be from system GRUB package). I also believed that you should have built successfully on Ubuntu with this change and tested that the image built with Ubuntu works. Therefore, I believe that this should be a Debian-specific problem. Maybe Debian's GRUB is somehow larger than Ubuntu's

I think that there are three ways out:

  1. Increase GRUBSIZE from 15 to 25. The final image will increase from around 41MB to 51MB in size. I believe that this should work as the size limit of the PBA image should be 128MB, according to https://github.com/Drive-Trust-Alliance/sedutil/issues/293.
  2. Revert to downloading and extracting Ubuntu's GRUB deb files in the script
  3. Specifically state that building on Debian is not supported on README.md and keep the GRUBSIZE as is.

@Jip-Hop What do you think?

Jip-Hop commented 6 months ago

The 4th way out would be to build using docker on any host (VM or otherwise), right? Building with docker is my preferred build method. It works on my Mac and should work on your Debian host too.

kennethso168 commented 6 months ago

Yes sure that will be. But I still prefer to build directly on the VM as the docker image could be quite large.

I'll take it more like the 3rd way out and build again with an Ubuntu VM instead

I'll close the issue for now. Maybe consider adding this info to the README?