Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[Solved] bcache and block device enumeration in initramfs
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
Etal
Veteran
Veteran


Joined: 15 Jul 2005
Posts: 1932

PostPosted: Thu Jun 25, 2020 3:07 pm    Post subject: [Solved] bcache and block device enumeration in initramfs Reply with quote

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
View user's profile Send private message
Goverp
Advocate
Advocate


Joined: 07 Mar 2007
Posts: 2201

PostPosted: Thu Jun 25, 2020 3:17 pm    Post subject: Reply with quote

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
View user's profile Send private message
Etal
Veteran
Veteran


Joined: 15 Jul 2005
Posts: 1932

PostPosted: Thu Jun 25, 2020 4:41 pm    Post subject: Reply with quote

Perfect, thanks!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum