I'm setting up bcache on ubuntu 20.04.
Booting from install CD, I created a bcache dirve by:
#modprobe bcache
#make-bcache -B /dev/mapper-vgubuntu-root
#make-bcache -C /dev/sdb
Just after that #fdisk -l
showed /dev/bcache0
.
Then #mkfs.ext4 /dev/bcache0
and put all the files back from the backup.tar to the root of /dev/bcache
.
Editted /etc/fstab like:
UUID=------- / ext4 erros=remount-ro 0 1
Then I updated grub by:
#mount -t ext4 /dev/bcache /mnt
#munt -B /dev /mnt/dev
#mount -B /proc /mnt/proc
#mount -B /sys /mnt/sys
#grub-install --recheck /dev/sda
#update-grub
Then I tried to restart the system from the new root /dev/bcache0
.
However, it fell into grub-rescue>
,
saying "unknown file system UUID=-----".
I restarted the system from the install CD and checked whether or not the system recognized /dev/bcahe0
.
#fdisk -l
showed that the system didin't recognize it after boot.
Then
#modprobe bcache
#echo /dev/dm-0 > /sys/fs/bcache/register
#echo /dev/sdb > /sys/fs/bcache/register
With these commands fdisk -l
showed /dev/bcache0
.
/dev/mapper/vgubuntu-root
is recognized as /dev/dm-0
.
From the situation mentioned above, I think I have to update the initrd.img to execute the above scripts before the file system is mounted.
So I added bcache in /etc/initramfs-tools/modules
and wrote the following script to a file in /etc/initramfs-tools/scripts/init-premount/:
#! /bin/sh
echo /dev/dm-0 > /sys/fs/bcache/register
echo /dev/sdb > /sys/fs/bcache/register
I named the file 10_bcache.
Finally I update-initramfs
and then restarted the system, however, the system still doesn't recognize /dev/bcache0
and falls into grub rescue mode.
How should I update-initramfs to recognize the bcache device before the system mounts the file system.