Partitioning scheme
Partition | Filesystem | Size | Description |
---|---|---|---|
sd*1 | ext2 (md/raid1) | 256 MiB | boot (kernel etc.) |
sd*2 | sw (md/raid1) | 4 GiB | swap |
sd*3 | Btrfs (raid1) | * | Btrfs |
-
Create GPT partition table on each disk:
parted -a optimal unit MiB mklabel gpt mkpart primary 1 256 mkpart primary 256 4352 mkpart primary btrfs 4352 -1 set 1 legacy_boot on quit
-
Create Btrfs filesystem in raid1 mode on the third partitions, create subvolume for / and mount it into /mnt/gentoo:
mkfs.btrfs -L btrfsvol -d raid1 -m raid1 /dev/sda3 /dev/sdb3 mkdir /mnt/btrfs mount -t btrfs -o defaults,noatime,compress=lzo,autodefrag -L btrfsvol /mnt/btrfs btrfs subvolume create /mnt/btrfs/root umount /mnt/btrfs mount -t btrfs -o defaults,noatime,compress=lzo,autodefrag,subvol=root -L btrfsvol /mnt/gentoo
-
Create md raid1 array with ext2 filesystem on the first partitions and mount it to /mnt/gentoo/boot:
mdadm --create /dev/md0 --name boot --level 1 --metadata 1.0 --raid-devices=2 /dev/sda1 /dev/sdb1 mkfs.ext2 -L boot /dev/md0 mkdir -p /mnt/gentoo/boot mount /dev/md0 /mnt/gentoo/boot
Note: extlinux cannot boot from md with metadata v1.2 (read here)!
-
Create md raid1 array with swap on the second partitions:
mdadm --create /dev/md1 --name swap --level 1 --metadata 1.2 --raid-devices=2 /dev/sda2 /dev/sdb2 mkswap -L swap /dev/md1
Read handbook ;)
-
Install busybox and mdadm with USE="static", and btrfs-progs:
USE="static -pam" emerge -av sys-apps/busybox USE="static" emerge -av sys-fs/mdadm emerge -av sys-fs/btrfs-progs
-
Create directory /usr/src/initramfs and copy files
initramfs_list
andinit
into it. -
Generate mdadm.conf:
mdadm --detail --scan > /usr/src/initramfs/mdadm.conf
-
Build initramfs:
cd /usr/src/linux make -C /usr/src/linux/usr/ gen_init_cpio ./scripts/gen_initramfs_list.sh -o /boot/initrd.cpio.gz /usr/src/initramfs/initramfs_list
-
Install syslinux package:
emerge -va sys-boot/syslinux
-
Copy extlinux MBR for GPT to physical disks (not partions!):
cat /usr/share/syslinux/gptmbr.bin > /dev/sda cat /usr/share/syslinux/gptmbr.bin > /dev/sdb
-
Install extlinux to /boot/extlinux:
mkdir -p /boot/extlinux extlinux --raid --install /boot/extlinux
-
Copy provided extlinux.conf to /boot/extlinux/ and modify path of the kernel file if needed.