[systemd-devel] Finding a block device quickly with libblkid
Eric Curtin
ecurtin at redhat.com
Fri Mar 1 18:30:15 UTC 2024
Hi Guys,
We are looking into optimizing the boot sequence of a device with many
partitions.
On boot in the default systemd implementation, all the block devices
are queried via libblkid and the various symlinks are set up in
/dev/disk/* from the results of those queries. The problem is on a
device with many partitions this can delay the boot by hundreds of
milliseconds, which is not ideal, especially when in many cases all
you really care about is mounting the block device that represents the
rootfs partition. We can sort of guess "/dev/sde38" is the correct
one, but that's not deterministic.
So we started digging and came across blkid_find_dev_with_tag and
blkid_dev_devname, which you can call like this:
blkid_dev_devname(blkid_find_dev_with_tag(cache, "PARTLABEL", "system_a")))
blkid_dev_devname(blkid_find_dev_with_tag(cache, "PARTLABEL", "system_b")))
On first glance this looks useful as you don't have to loop through
all the devices to use.
But this function only seems to work if the data is already cached, so
it's not so useful on boot.
Has anyone any ideas on how we can optimize the identification of a
block device via UUID, LABEL, PARTUUID, PARTLABEL, etc.? Because the
current implementations don't scale well when you have many block
devices.
I suspect we may not be the first to encounter this, so just probing
to see if anyone had ideas on how to solve this in the past.
Is mise le meas/Regards,
Eric Curtin
More information about the systemd-devel
mailing list