Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

repartition: Correctly detect rootfs on loop device #407

Merged
merged 1 commit into from
Jun 3, 2024

Conversation

wjt
Copy link
Member

@wjt wjt commented Jun 1, 2024

After resizing the main partition, we have the following logic to invoke partprobe if it is on a loop device:

# Loop devices need a prod
if [ -n "$using_loop" ]; then
  partprobe $root_disk
  udevadm settle
fi

But empirically this block does not run on a fresh dual-boot installation: the kernel still believed the partition has its old size until I manually ran partprobe. As a result eos-firstboot fails to grow the main partition:

eos-firstboot[528]: resize2fs 1.47.0 (5-Feb-2023)
eos-firstboot[528]: The filesystem is already 11053568 (4k) blocks long.  Nothing to do!

$using_loop is conditionally set as follows:

case ${orig_root_part} in
  /dev/loop?p?)
    using_loop=1
    ;;
esac

$orig_root_part is set as follows:

  orig_root_part=$(systemctl show -p What sysroot.mount)
  orig_root_part=${orig_root_part#What=}

I ran this command once the system had booted and the output is:

What=/dev/disk/endless-image3

This is not too surprising because eos-image-boot-generator has the following:

cat <<EOF >${GENERATOR_DIR}/sysroot.mount
[Unit]
Before=initrd-root-fs.target
Requires=systemd-fsck-root.service
After=systemd-fsck-root.service
[Mount]
What=/dev/disk/endless-image3
Where=/sysroot
Options=$rwflag
EOF

So the fix is to follow any symbolic links so we can inspect the real device path. Conveniently we already do this:

# Identify root partition device node and parent disk
root_part=$(readlink -f "${orig_root_part}")

https://phabricator.endlessm.com/T35432

After resizing the main partition, we have the following logic to invoke
`partprobe` if it is on a loop device:

    # Loop devices need a prod
    if [ -n "$using_loop" ]; then
      partprobe $root_disk
      udevadm settle
    fi

But empirically this block does not run on a fresh dual-boot
installation: the kernel still believed the partition has its old size
until I manually ran partprobe. As a result eos-firstboot fails to grow
the main partition:

    eos-firstboot[528]: resize2fs 1.47.0 (5-Feb-2023)
    eos-firstboot[528]: The filesystem is already 11053568 (4k) blocks long.  Nothing to do!

$using_loop is conditionally set as follows:

    case ${orig_root_part} in
      /dev/loop?p?)
        using_loop=1
        ;;
    esac

$orig_root_part is set as follows:

      orig_root_part=$(systemctl show -p What sysroot.mount)
      orig_root_part=${orig_root_part#What=}

I ran this command once the system had booted and the output is:

    What=/dev/disk/endless-image3

This is not too surprising because eos-image-boot-generator has the
following:

    cat <<EOF >${GENERATOR_DIR}/sysroot.mount
    [Unit]
    Before=initrd-root-fs.target
    Requires=systemd-fsck-root.service
    After=systemd-fsck-root.service
    [Mount]
    What=/dev/disk/endless-image3
    Where=/sysroot
    Options=$rwflag
    EOF

So the fix is to follow any symbolic links so we can inspect the real
device path. Conveniently we already do this:

    # Identify root partition device node and parent disk
    root_part=$(readlink -f "${orig_root_part}")

https://phabricator.endlessm.com/T35432
@wjt wjt requested a review from dsd June 1, 2024 07:42
@dsd dsd merged commit fb07157 into master Jun 3, 2024
2 checks passed
@dsd dsd deleted the T35432-fix-growing-root-partition-on-dual-boot branch June 3, 2024 04:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants