Skip to content

Support btrfs as /usr filesystem#11

Merged
pothos merged 4 commits intoflatcar-masterfrom
kai/btrfs-support
Jul 28, 2021
Merged

Support btrfs as /usr filesystem#11
pothos merged 4 commits intoflatcar-masterfrom
kai/btrfs-support

Conversation

@pothos
Copy link
Copy Markdown
Member

@pothos pothos commented Jul 14, 2021

  • postinstall: support btrfs as /usr filesystem

    When btrfs is used to fit more content into the partition, mounting
    fails because ext2/3 was hardcoded.
    Also try to mount as btrfs if mounting as ext2/3 fails. The
    norecovery options makes sure that the filesystem isn't touched even if
    the it is corrupted.

  • utils: support btrfs

    With btrfs it's not possible in general to find a single underlying
    block device because there could be many, but still it is possible for
    our case since we have a single partition. However, rootdev failed to
    find it because it uses the device minor and major pair from a "stat"
    syscall on the mount point. This doesn't work with btrfs because it
    gives a logical pair instead of one belonging to a block device.

    Instead of using the minor and major pair, find the underlying block
    device of a mount point by looking it up in /proc/mounts. The existing
    traversal code to find the lowest backing device is kept in place by
    getting the minor and major pair for the found block device.

    Based on the new code in seismograph's rootdev under src/rootdev/main.c from rootdev: support btrfs seismograph#6

How to use/Testing done

This was built and tested with the coreos-overlay branch kai/bootengine-verity-hashoffset from flatcar-archive/coreos-overlay#1106 and flatcar-scripts branch kai/btrfs-usr-oem from flatcar/scripts#131 in http://jenkins.infra.kinvolk.io:8080/job/os/job/manifest/3029/cldsv/ where the Flatcar image that has a btrfs /usr partition and OEM partition.
While the actual switch to a btrfs filesystem on the /usr partition is only possible when all changes are part of a Stable release because update-engine needs to know how to handle the new filesystem when updating, we can already do the switch for the OEM partition.

@pothos pothos requested a review from a team July 14, 2021 19:19
@pothos
Copy link
Copy Markdown
Member Author

pothos commented Jul 14, 2021

(CI fails until flatcar/seismograph#6 is merged)

@tormath1
Copy link
Copy Markdown
Contributor

(CI fails until kinvolk/seismograph#6 is merged)

CI will fail anyway - see: flatcar/Flatcar#282 (comment) :)

@pothos pothos force-pushed the kai/btrfs-support branch from 8a5b4e2 to b515a1d Compare July 15, 2021 10:21
@pothos
Copy link
Copy Markdown
Member Author

pothos commented Jul 15, 2021

Hm, I need to find why update-engine still doesn't find the right partition ( utils.cc:420] rootdev found a device name with no device node)

@pothos pothos marked this pull request as draft July 15, 2021 10:38
@pothos
Copy link
Copy Markdown
Member Author

pothos commented Jul 15, 2021

Testing locally didn't run into that message but into the problem that conceptually two identical filesystems can't be mounted at the same time, this prevents testing to update from the same version because update-engine has to mount the new partition to copy the kernel over to /boot. Updating to the same image is a no-op and one could add a workaround to use ' /usr' directly instead.

@vbatts
Copy link
Copy Markdown
Member

vbatts commented Jul 20, 2021 via email

@pothos
Copy link
Copy Markdown
Member Author

pothos commented Jul 22, 2021

The temporary mounting to run the postinstall hook is done without setting up dm-verity

@pothos pothos marked this pull request as ready for review July 23, 2021 11:00
@pothos pothos force-pushed the kai/btrfs-support branch from 34aa96b to e0272b8 Compare July 28, 2021 10:12
pothos added 3 commits July 28, 2021 12:13
When btrfs is used to fit more content into the partition, mounting
fails because ext2/3 was hardcoded.
Also try to mount as btrfs if mounting as ext2/3 fails. The
norecovery options makes sure that the filesystem isn't touched even if
the it is corrupted.
With btrfs it's not possible in general to find a single underlying
block device because there could be many, but still it is possible for
our case since we have a single partition. However, rootdev failed to
find it because it uses the device minor and major pair from a "stat"
syscall on the mount point. This doesn't work with btrfs because it
gives a logical pair instead of one belonging to a block device.

Instead of using the minor and major pair, find the underlying block
device of a mount point by looking it up in /proc/mounts. The existing
traversal code to find the lowest backing device is kept in place by
getting the minor and major pair for the found block device.

Based on the new code in seismograph's rootdev under src/rootdev/main.c
When trying to mount an identical btrfs image twice because the old
and new partition are identical, the kernel refuses because same UUIDs
are linked to having a btrfs filesystem spread over multiple devices.
Since the same image is used, we can run the postinstall action from
the old/current partition.
@pothos pothos force-pushed the kai/btrfs-support branch from e0272b8 to 2241ede Compare July 28, 2021 10:13
With an outdated package list the download failed.
Update the package list before downloading packages for installation.
@pothos pothos merged commit d21808a into flatcar-master Jul 28, 2021
@pothos pothos deleted the kai/btrfs-support branch July 28, 2021 11:20
pothos added a commit to flatcar-archive/coreos-overlay that referenced this pull request Jul 28, 2021
t-lo pushed a commit to flatcar/scripts that referenced this pull request Apr 17, 2023
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.

4 participants