View previous topic :: View next topic |
Author |
Message |
Etal Veteran
Joined: 15 Jul 2005 Posts: 1932
|
Posted: Thu Jun 25, 2020 3:07 pm Post subject: [Solved] bcache and block device enumeration in initramfs |
|
|
I have my rootfs on bcache. In order to boot from it, I need to register the backing and cache devices (/dev/sda2 and /dev/sdc). I have a small initramfs to perform the necessary steps.
The problem is that if I connect any other storage device (even a flash drive), the enumeration would change (sdb becomes sdc) and it will fail to register.
Anyone know if there's a way to find the device name for a specific disk in initramfs, similar to /dev/disk/by-* that udev creates?
Here's a slightly simplified version of my initramfs init script:
Code: | #!/bin/busybox sh
mount -t sysfs none /sys
mount -t proc none /proc
mount -t devtmpfs none /dev
echo /dev/sda2 > /sys/fs/bcache/register
echo /dev/sdb > /sys/fs/bcache/register
mount -t xfs -o ro /dev/bcache0 /mnt/root
mount --move /sys /mnt/root/sys
mount --move /dev /mnt/root/dev
mount --move /proc /mnt/root/proc
exec switch_root /mnt/root /sbin/init |
Last edited by Etal on Thu Jun 25, 2020 4:41 pm; edited 1 time in total |
|
Back to top |
|
|
Goverp Advocate
Joined: 07 Mar 2007 Posts: 2201
|
Posted: Thu Jun 25, 2020 3:17 pm Post subject: |
|
|
Add some code calling findfs in your initramfs init script. It will let you identify devices by labels or UUIDs. Busybox contains a version of findfs, assuming you use that for your initramfs script _________________ Greybeard |
|
Back to top |
|
|
Etal Veteran
Joined: 15 Jul 2005 Posts: 1932
|
Posted: Thu Jun 25, 2020 4:41 pm Post subject: |
|
|
Perfect, thanks! |
|
Back to top |
|
|
|