Please, a little help about a btrfs-raid boot configuration with HA
by camerabambai from LinuxQuestions.org on (#5H2TB)
With ZFS is too easy, create two pools, use two identical efi, boot pools are raid1, and the system can boot from disk1 or disk2.
Unfortunately Slackware mkinitrd has not zfs support, I have tried with btrfs, maybe has not all features of zfs, but is more fast on Linux than zfs.
My configuration is this: a virtual machine with slackware-current, two virtual disk virtio driver, of 50GB, the partition scheme is this
Code:root@slackware:~# fdisk -l /dev/vda
Disk /dev/vda: 50 GiB, 53687091200 bytes, 104857600 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 7715105B-51CD-9A45-9D05-E2C8161E51E9
Device Start End Sectors Size Type
/dev/vda1 2048 1050623 1048576 512M EFI System
/dev/vda2 1050624 9439231 8388608 4G Linux swap
/dev/vda3 9439232 11536383 2097152 1G Linux RAID
/dev/vda4 11536384 104857566 93321183 44.5G Linux filesystem
Code:root@slackware:~# fdisk -l /dev/vdb
Disk /dev/vdb: 50 GiB, 53687091200 bytes, 104857600 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 7715105B-51CD-9A45-9D05-E2C8161E51E9
Device Start End Sectors Size Type
/dev/vdb1 2048 1050623 1048576 512M EFI System
/dev/vdb2 1050624 9439231 8388608 4G Linux swap
/dev/vdb3 9439232 11536383 2097152 1G Linux RAID
/dev/vdb4 11536384 104857566 93321183 44.5G Linux filesystemI use Linux Raid for boot(classical mdadm+ext4) because grub can boot btrfs raid in / but non on /boot
this is the fstab
Code:LABEL=SWAP swap swap defaults 0 0
LABEL=ROOT / btrfs defaults,degraded 1 1
LABEL=BOOT /boot ext4 defaults 1 2
/dev/vda1 /boot/efi vfat defaults 1 2
devpts /dev/pts devpts gid=5,mode=620 0 0
proc /proc proc defaults 0 0
tmpfs /dev/shm tmpfs nosuid,nodev,noexec 0 0this is the /etc/default/grub
Code:GRUB_DEFAULT=0
GRUB_HIDDEN_TIMEOUT_QUIET=false
GRUB_TIMEOUT=10
GRUB_DISTRIBUTOR=$( sed 's/Slackware /Slackware-/' /etc/slackware-version )
GRUB_ENABLE_CRYPTODISK=y
GRUB_CMDLINE_LINUX_DEFAULT=""
GRUB_CMDLINE_LINUX="console=tty1 console=ttyS0,115200 cryptdevice=/dev/disk/by-uuid/b97cbe7d-c5e5-432e-adc4-659ed80dd65f:luksvda4 cryptdevice=/dev/disk/by-uuid/ec4fd069-0bd2-4b53-90e2-e493c50070f1:luksvdb4 rootflags=degraded,subvol=@"
GRUB_TERMINAL="console serial"finally the mkinitrd.conf
Code:SOURCE_TREE="/boot/initrd-tree"
CLEAR_TREE="1"
OUTPUT_IMAGE="/boot/initrd.gz"
KERNEL_VERSION="$(ls /var/log/packages/kernel-generic-*-x86_64-* |cut -d - -f 3)"
KEYMAP="it"
MODULE_LIST="btrfs:ext4:vfat:xhci-hcd:hid:usbhid:ochi-hcd:uhci-hcd:uhci-hcd:ehci-hcd:virtio-net:virtio-ring:virtio-blk:virtio-pci"
LUKSDEV="/dev/disk/by-uuid/b97cbe7d-c5e5-432e-adc4-659ed80dd65f:/dev/disk/by-uuid/ec4fd069-0bd2-4b53-90e2-e493c50070f1"
ROOTDEV="/dev/vda4"
ROOTFS="btrfs"
RESUMEDEV="/dev/disk/by-label/SWAP"
RAID="1"
LVM="0"
UDEV="1"After did
Code:mkinitrd -B -F
grub-mkconfig -o /boot/grub/grub.cfgi reboot and...
Code:insmod /lib/modules/5.10.32/kernel/drivers/virtio/virtio_pci.ko
[ 4.410080] virtio_blk virtio4: [vda] 104857600 512-byte logical blocks (53.7 GB/50.0 GiB)
[ 4.412469] vda: detected capacity change from 0 to 53687091200
[ 4.429500] vda: vda1 vda2 vda3 vda4
[ 4.439567] virtio_blk virtio7: [vdb] 104857600 512-byte logical blocks (53.7 GB/50.0 GiB)
[ 4.441603] vdb: detected capacity change from 0 to 53687091200
[ 4.447420] vdb: vdb1 vdb2 vdb3 vdb4
insmod /lib/modules/5.10.32/kernel/crypto/af_alg.ko
[ 4.456888] NET: Registered protocol family 38
[ 4.462413] md/raid1:md127: active with 2 out of 2 mirrors
insmod /lib/modules/5.10.32/kernel/crypto/algif_skcipher.ko
[ 4.463983] md127: detected capacity change from 0 to 1071644672
insmod /lib/modules/5.10.32/kernel/drivers/md/dm-bufio.ko
insmod /lib/modules/5.10.32/kernel/drivers/md/dm-snapshot.ko
/boot/initrd.gz: Loading 'it' keyboard mapping:
Unlocking LUKS encrypted device '/dev/disk/by-uuid/b97cbe7d-c5e5-432e-adc4-659ed80dd65f' as luks mapped device 'luksb97cbe7d-c5e5-432e-adc4-659ed80dd65f':
[ 14.135464] BTRFS: device label ROOT devid 1 transid 75 /dev/dm-0 scanned by udevd (376)
Unlocking LUKS encrypted device '/dev/disk/by-uuid/ec4fd069-0bd2-4b53-90e2-e493c50070f1' as luks mapped device 'luksec4fd069-0bd2-4b53-90e2-e493c50070f1':
[ 20.319485] BTRFS: device label ROOT devid 2 transid 75 /dev/dm-1 scanned by udevd (450)
Scanning for Btrfs filesystems
Trying to resume from /dev/vdb2
[ 20.536483] BTRFS info (device dm-0): allowing degraded mounts
[ 20.539095] BTRFS info (device dm-0): disk space caching is enabled
[ 20.540154] BTRFS info (device dm-0): has skinny extents
mount: mounting /dev/dm-1 on /mnt failed: No such file or directory
ERROR: No /sbin/init found on rootdev (or not mounted). Trouble ahead.
You can try to fix it. Type 'exit' when things are done.
/bin/sh: can't access tty; job control turned off
/ # :(from this console I did mount /dev/dm-1(or dm-0) /mnt and..boot!
But on every boot it fail and I have to mount my btrfs raid manually(sic!)
Where I fail? I have tried to use /dev/disk/by-uuid.. on ROOTDEV in mkinitrd.conf, tried to edit fstab and use uuid or blockdev instead of labels
but nothing change.


Unfortunately Slackware mkinitrd has not zfs support, I have tried with btrfs, maybe has not all features of zfs, but is more fast on Linux than zfs.
My configuration is this: a virtual machine with slackware-current, two virtual disk virtio driver, of 50GB, the partition scheme is this
Code:root@slackware:~# fdisk -l /dev/vda
Disk /dev/vda: 50 GiB, 53687091200 bytes, 104857600 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 7715105B-51CD-9A45-9D05-E2C8161E51E9
Device Start End Sectors Size Type
/dev/vda1 2048 1050623 1048576 512M EFI System
/dev/vda2 1050624 9439231 8388608 4G Linux swap
/dev/vda3 9439232 11536383 2097152 1G Linux RAID
/dev/vda4 11536384 104857566 93321183 44.5G Linux filesystem
Code:root@slackware:~# fdisk -l /dev/vdb
Disk /dev/vdb: 50 GiB, 53687091200 bytes, 104857600 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 7715105B-51CD-9A45-9D05-E2C8161E51E9
Device Start End Sectors Size Type
/dev/vdb1 2048 1050623 1048576 512M EFI System
/dev/vdb2 1050624 9439231 8388608 4G Linux swap
/dev/vdb3 9439232 11536383 2097152 1G Linux RAID
/dev/vdb4 11536384 104857566 93321183 44.5G Linux filesystemI use Linux Raid for boot(classical mdadm+ext4) because grub can boot btrfs raid in / but non on /boot
this is the fstab
Code:LABEL=SWAP swap swap defaults 0 0
LABEL=ROOT / btrfs defaults,degraded 1 1
LABEL=BOOT /boot ext4 defaults 1 2
/dev/vda1 /boot/efi vfat defaults 1 2
devpts /dev/pts devpts gid=5,mode=620 0 0
proc /proc proc defaults 0 0
tmpfs /dev/shm tmpfs nosuid,nodev,noexec 0 0this is the /etc/default/grub
Code:GRUB_DEFAULT=0
GRUB_HIDDEN_TIMEOUT_QUIET=false
GRUB_TIMEOUT=10
GRUB_DISTRIBUTOR=$( sed 's/Slackware /Slackware-/' /etc/slackware-version )
GRUB_ENABLE_CRYPTODISK=y
GRUB_CMDLINE_LINUX_DEFAULT=""
GRUB_CMDLINE_LINUX="console=tty1 console=ttyS0,115200 cryptdevice=/dev/disk/by-uuid/b97cbe7d-c5e5-432e-adc4-659ed80dd65f:luksvda4 cryptdevice=/dev/disk/by-uuid/ec4fd069-0bd2-4b53-90e2-e493c50070f1:luksvdb4 rootflags=degraded,subvol=@"
GRUB_TERMINAL="console serial"finally the mkinitrd.conf
Code:SOURCE_TREE="/boot/initrd-tree"
CLEAR_TREE="1"
OUTPUT_IMAGE="/boot/initrd.gz"
KERNEL_VERSION="$(ls /var/log/packages/kernel-generic-*-x86_64-* |cut -d - -f 3)"
KEYMAP="it"
MODULE_LIST="btrfs:ext4:vfat:xhci-hcd:hid:usbhid:ochi-hcd:uhci-hcd:uhci-hcd:ehci-hcd:virtio-net:virtio-ring:virtio-blk:virtio-pci"
LUKSDEV="/dev/disk/by-uuid/b97cbe7d-c5e5-432e-adc4-659ed80dd65f:/dev/disk/by-uuid/ec4fd069-0bd2-4b53-90e2-e493c50070f1"
ROOTDEV="/dev/vda4"
ROOTFS="btrfs"
RESUMEDEV="/dev/disk/by-label/SWAP"
RAID="1"
LVM="0"
UDEV="1"After did
Code:mkinitrd -B -F
grub-mkconfig -o /boot/grub/grub.cfgi reboot and...
Code:insmod /lib/modules/5.10.32/kernel/drivers/virtio/virtio_pci.ko
[ 4.410080] virtio_blk virtio4: [vda] 104857600 512-byte logical blocks (53.7 GB/50.0 GiB)
[ 4.412469] vda: detected capacity change from 0 to 53687091200
[ 4.429500] vda: vda1 vda2 vda3 vda4
[ 4.439567] virtio_blk virtio7: [vdb] 104857600 512-byte logical blocks (53.7 GB/50.0 GiB)
[ 4.441603] vdb: detected capacity change from 0 to 53687091200
[ 4.447420] vdb: vdb1 vdb2 vdb3 vdb4
insmod /lib/modules/5.10.32/kernel/crypto/af_alg.ko
[ 4.456888] NET: Registered protocol family 38
[ 4.462413] md/raid1:md127: active with 2 out of 2 mirrors
insmod /lib/modules/5.10.32/kernel/crypto/algif_skcipher.ko
[ 4.463983] md127: detected capacity change from 0 to 1071644672
insmod /lib/modules/5.10.32/kernel/drivers/md/dm-bufio.ko
insmod /lib/modules/5.10.32/kernel/drivers/md/dm-snapshot.ko
/boot/initrd.gz: Loading 'it' keyboard mapping:
Unlocking LUKS encrypted device '/dev/disk/by-uuid/b97cbe7d-c5e5-432e-adc4-659ed80dd65f' as luks mapped device 'luksb97cbe7d-c5e5-432e-adc4-659ed80dd65f':
[ 14.135464] BTRFS: device label ROOT devid 1 transid 75 /dev/dm-0 scanned by udevd (376)
Unlocking LUKS encrypted device '/dev/disk/by-uuid/ec4fd069-0bd2-4b53-90e2-e493c50070f1' as luks mapped device 'luksec4fd069-0bd2-4b53-90e2-e493c50070f1':
[ 20.319485] BTRFS: device label ROOT devid 2 transid 75 /dev/dm-1 scanned by udevd (450)
Scanning for Btrfs filesystems
Trying to resume from /dev/vdb2
[ 20.536483] BTRFS info (device dm-0): allowing degraded mounts
[ 20.539095] BTRFS info (device dm-0): disk space caching is enabled
[ 20.540154] BTRFS info (device dm-0): has skinny extents
mount: mounting /dev/dm-1 on /mnt failed: No such file or directory
ERROR: No /sbin/init found on rootdev (or not mounted). Trouble ahead.
You can try to fix it. Type 'exit' when things are done.
/bin/sh: can't access tty; job control turned off
/ # :(from this console I did mount /dev/dm-1(or dm-0) /mnt and..boot!
But on every boot it fail and I have to mount my btrfs raid manually(sic!)
Where I fail? I have tried to use /dev/disk/by-uuid.. on ROOTDEV in mkinitrd.conf, tried to edit fstab and use uuid or blockdev instead of labels
but nothing change.