snapd
snapd copied to clipboard
snap-bootstrap: add scan-disk subcommand
This command is expected to be called from udev. This creates
symlinks /dev/ubuntu/ubuntu-{seed,boot,data,save}.
Then we can bind snap-bootstrap initramfs-mounts to
dev-ubuntu-ubuntu-seed.device.
This works with snapcore/core-initrd#107
Would it be possible to get the same information just by running blkid instead of using the library?
We cannot list partitions from blkid.
Given SEED is ESP; and we bind the initramfs-mounts unit to the SEED; i am wondering if we can instead turn on / patch the systemd's gpt-auto-generator which can create esp mount in /efi and use that instead?
Looking more at this, I actually don't quite like the behaviour of gpt-auto-generator. Because the good bits of it are not what we need here.
Ideally we would only read efi_loader_get_device_part_uuid (aka LoaderDevicePartUUID) and generate .device unit for it, and bind initramfs-mounts service unit to it. Before any drives appear.
Thus without waiting udev to exec scan-disk to process them all either.
Ideally we would only read efi_loader_get_device_part_uuid (aka LoaderDevicePartUUID) and generate .device unit for it, and bind initramfs-mounts service unit to it. Before any drives appear.
Thus without waiting udev to exec scan-disk to process them all either.
So almost what I have done, but a symlink on the whole disk rather than the partitions?
@valentindavid can the description or some comment in the code include the actual udev rules that this will be used from? it's a bit unclear just from the code how things go from the code in scan-disk to have /dev/ubuntu/disk symlinked?
What's the plan for testing the cmd_scan_disk code?
@valentindavid can the description or some comment in the code include the actual udev rules that this will be used from? it's a bit unclear just from the code how things go from the code in scan-disk to have /dev/ubuntu/disk symlinked?
Sure. We could even add the rules to snapd and install them into core-initrd.
What's the plan for testing the cmd_scan_disk code?
I think I will need to mock libblkid somehow to test it.
Loop devices need root to be setup, and I do not think there is as this point any nice user land block devices. I think only character devices can be emulated with CUSE. Not block.
What's the plan for testing the cmd_scan_disk code?
I have added tests.
I still have to add tests for the changes in cmd_initramfs_mounts.go (when /dev/ubuntu/disk exists). But that should be straight forward.
Codecov Report
Attention: Patch coverage is 62.35294% with 96 lines in your changes are missing coverage. Please review.
Project coverage is 78.84%. Comparing base (
f7fea7f) to head (6ee943e). Report is 44 commits behind head on master.
:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@ Coverage Diff @@
## master #12006 +/- ##
==========================================
- Coverage 78.88% 78.84% -0.04%
==========================================
Files 1037 1039 +2
Lines 132881 133744 +863
==========================================
+ Hits 104817 105454 +637
- Misses 21523 21692 +169
- Partials 6541 6598 +57
| Flag | Coverage Δ | |
|---|---|---|
| unittests | 78.84% <62.35%> (-0.04%) |
:arrow_down: |
Flags with carried forward coverage won't be shown. Click here to find out more.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.