lueschem / edi-cl

This repository contains an edi project configuration for Compulab embedded devices.
https://www.get-edi.io
Other
10 stars 2 forks source link

resizefs on first boot not working #22

Closed nils-ossenbrink closed 8 months ago

nils-ossenbrink commented 8 months ago

First of all thanks for this great framework. This is exactly what i was looking for!

I had success building the image for the iot gateway and booting it. Unfortunately the resize script was failing on first boot because the command sfdisk was missing. I tried adding fdisk to the "playbook" but had no success with it. After installing it "by hand" on the device and executing the script the resize was successfull. What do I have to di to get fdisk installed during the image build process? Thanks! Nils

lueschem commented 8 months ago

Many thanks for reporting this bug! It seems to affect only new devices and therefore the automated tests did not discover the glitch. I will take a look at it as soon as possible.

lueschem commented 8 months ago

I need to verify the change on a new setup and eventually backport it to Debian bullseye.

lueschem commented 8 months ago

What do I have to do to get fdisk installed during the image build process?

The typical workflow in this case looks as follows:

  1. An initial image gets created: sudo edi -v image create iot-gate-imx8.yml
  2. A bug like the one reported gets detected.
  3. A fix gets implemented.
  4. The developer removes artifacts that shall get re-created: sudo edi -v image create --recursive-clean 4 iot-gate-imx8.yml
  5. A new image gets created: sudo edi -v image create iot-gate-imx8.yml
  6. The new image gets applied via OTA update or by flashing e.g. a USB stick.
  7. The developer makes sure that the bug has disappeared.

Explanation of step 4:

The --recursive-clean is done according to the command pipeline. As the above change is a simple addition of a package we do not need to re-create the entire LXD container. Instead we can keep it and just run the Ansible playbooks on it again. This will make sure that fdisk gets installed. If substantial changes are done on the container then a --recursive-clean 5 might be a safe bet as this will remove the LXD container and the Ansible playbooks will be applied again on a fresh container. A --recursive-clean 10 will delete all artifacts including the ones that got created using debootstrap. On fundamental playbook changes it is also advisable to start the image build using the --debug option: sudo edi -v --debug image create iot-gate-imx8.yml. Using this option it is possible to change playbooks on the fly as soon as they hit an error.

edi does not even try to be smart about what needs to be re-created because of a certain project configuration change. However, the developer can easily decide:

lueschem commented 8 months ago

Now also fixed on Debian bullseye:

compulab@iot-gate-imx8:~$ sudo systemctl status edi-resize-rootfs
● edi-resize-rootfs.service - resize root file system
     Loaded: loaded (/lib/systemd/system/edi-resize-rootfs.service; enabled; vendor preset: enabled)
     Active: inactive (dead) since Sat 2023-10-28 21:26:40 UTC; 46s ago
    Process: 334 ExecStart=/usr/bin/edi-resize-rootfs (code=exited, status=0/SUCCESS)
   Main PID: 334 (code=exited, status=0/SUCCESS)
        CPU: 524ms

Oct 28 21:26:30 iot-gate-imx8 edi-resize-rootfs[416]: Re-reading the partition table failed.: Device or resource busy
Oct 28 21:26:30 iot-gate-imx8 edi-resize-rootfs[416]: The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or partx(8).
Oct 28 21:26:30 iot-gate-imx8 edi-resize-rootfs[416]: Syncing disks.
Oct 28 21:26:31 iot-gate-imx8 edi-resize-rootfs[447]: resize2fs 1.46.2 (28-Feb-2021)
Oct 28 21:26:40 iot-gate-imx8 edi-resize-rootfs[447]: Filesystem at /dev/sda3 is mounted on /; on-line resizing required
Oct 28 21:26:40 iot-gate-imx8 edi-resize-rootfs[447]: old_desc_blocks = 1, new_desc_blocks = 1
Oct 28 21:26:40 iot-gate-imx8 edi-resize-rootfs[447]: The filesystem on /dev/sda3 is now 931328 (4k) blocks long.
Oct 28 21:26:40 iot-gate-imx8 edi-resize-rootfs[334]: disk layout of sda successfully changed
Oct 28 21:26:40 iot-gate-imx8 systemd[1]: edi-resize-rootfs.service: Succeeded.
Oct 28 21:26:40 iot-gate-imx8 systemd[1]: Finished resize root file system.
compulab@iot-gate-imx8:~$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/root       3.5G  407M  3.0G  12% /
devtmpfs        989M     0  989M   0% /dev
tmpfs           991M     0  991M   0% /dev/shm
tmpfs           397M  6.2M  390M   2% /run
tmpfs           5.0M     0  5.0M   0% /run/lock
/dev/sda1       104M   32K   95M   1% /boot/firmware
/dev/sda2       224M   60K  206M   1% /data
tmpfs           199M     0  199M   0% /run/user/2000
compulab@iot-gate-imx8:~$ sudo systemctl status edi-resize-rootfs
● edi-resize-rootfs.service - resize root file system
     Loaded: loaded (/lib/systemd/system/edi-resize-rootfs.service; enabled; vendor preset: enabled)
     Active: inactive (dead) since Sat 2023-10-28 21:26:40 UTC; 46s ago
    Process: 334 ExecStart=/usr/bin/edi-resize-rootfs (code=exited, status=0/SUCCESS)
   Main PID: 334 (code=exited, status=0/SUCCESS)
        CPU: 524ms

Oct 28 21:26:30 iot-gate-imx8 edi-resize-rootfs[416]: Re-reading the partition table failed.: Device or resource busy
Oct 28 21:26:30 iot-gate-imx8 edi-resize-rootfs[416]: The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or partx(8).
Oct 28 21:26:30 iot-gate-imx8 edi-resize-rootfs[416]: Syncing disks.
Oct 28 21:26:31 iot-gate-imx8 edi-resize-rootfs[447]: resize2fs 1.46.2 (28-Feb-2021)
Oct 28 21:26:40 iot-gate-imx8 edi-resize-rootfs[447]: Filesystem at /dev/sda3 is mounted on /; on-line resizing required
Oct 28 21:26:40 iot-gate-imx8 edi-resize-rootfs[447]: old_desc_blocks = 1, new_desc_blocks = 1
Oct 28 21:26:40 iot-gate-imx8 edi-resize-rootfs[447]: The filesystem on /dev/sda3 is now 931328 (4k) blocks long.
Oct 28 21:26:40 iot-gate-imx8 edi-resize-rootfs[334]: disk layout of sda successfully changed
Oct 28 21:26:40 iot-gate-imx8 systemd[1]: edi-resize-rootfs.service: Succeeded.
Oct 28 21:26:40 iot-gate-imx8 systemd[1]: Finished resize root file system.
compulab@iot-gate-imx8:~$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/root       3.5G  407M  3.0G  12% /
devtmpfs        989M     0  989M   0% /dev
tmpfs           991M     0  991M   0% /dev/shm
tmpfs           397M  6.2M  390M   2% /run
tmpfs           5.0M     0  5.0M   0% /run/lock
/dev/sda1       104M   32K   95M   1% /boot/firmware
/dev/sda2       224M   60K  206M   1% /data
tmpfs           199M     0  199M   0% /run/user/2000
nils-ossenbrink commented 8 months ago

Many thanks for the detailed explanantion! I will dig deeper into the "edi-world" in the next weeks to get a clearer understanding how everything works together...

Cheers Nils