comparison content/Linux/software-raid-setup.md @ 98:1d9382b0329b

Specify the syntax on markdown blocks to avoid broken output that has class=err
author Dirk Olmes <dirk@xanthippe.ping.de>
date Thu, 19 Dec 2019 10:04:33 +0100
parents abc2401e9958
children
comparison
equal deleted inserted replaced
97:e99db3bc53c1 98:1d9382b0329b
7 7
8 One goal of the new setup is to remain bootable even if one of the drives fails. I had trouble accomplishing this in earlier setups so this time I tested the process locally on a virtual machine before setting up the real iron. 8 One goal of the new setup is to remain bootable even if one of the drives fails. I had trouble accomplishing this in earlier setups so this time I tested the process locally on a virtual machine before setting up the real iron.
9 9
10 The first step of the setup is partitioning the drives. The [handbook](https://wiki.gentoo.org/wiki/Handbook:AMD64/Installation/Disks) suggests adding a small partition at the beginning of the drive to enable booting from a gpt partitioned drive. The `/boot` partition will be formatted using [ext4](https://en.wikipedia.org/wiki/Ext4) because the filesystem will remain bootable even if one of the drives is missing. The rest of the disk will be formatted using [xfs](https://en.wikipedia.org/wiki/XFS). To recap the layout: 10 The first step of the setup is partitioning the drives. The [handbook](https://wiki.gentoo.org/wiki/Handbook:AMD64/Installation/Disks) suggests adding a small partition at the beginning of the drive to enable booting from a gpt partitioned drive. The `/boot` partition will be formatted using [ext4](https://en.wikipedia.org/wiki/Ext4) because the filesystem will remain bootable even if one of the drives is missing. The rest of the disk will be formatted using [xfs](https://en.wikipedia.org/wiki/XFS). To recap the layout:
11 11
12 :::shell
12 Number Start End Size File system Name Flags 13 Number Start End Size File system Name Flags
13 1 1.00MiB 3.00MiB 2.00MiB grub bios_grub 14 1 1.00MiB 3.00MiB 2.00MiB grub bios_grub
14 2 3.00MiB 95.0MiB 92.0MiB boot 15 2 3.00MiB 95.0MiB 92.0MiB boot
15 3 95.0MiB 8191MiB 8096MiB rootfs raid 16 3 95.0MiB 8191MiB 8096MiB rootfs raid
16 17
17 The second drive is partitioned exactly the same. 18 The second drive is partitioned exactly the same.
18 19
19 Now let's create a RAID 1 for the boot partition: 20 Now let's create a RAID 1 for the boot partition:
20 21
22 :::shell
21 mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sdb2 /dev/sdc2 23 mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sdb2 /dev/sdc2
22 24
23 and for the rootfs: 25 and for the rootfs:
24 26
27 :::shell
25 mdadm --create /dev/md1 --level=1 --raid-devices=2 /dev/sdb3 /dev/sdc3 28 mdadm --create /dev/md1 --level=1 --raid-devices=2 /dev/sdb3 /dev/sdc3
26 29
27 To maintain the RAID device numbering even after reboot, the RAID config has to be saved. This will be done by 30 To maintain the RAID device numbering even after reboot, the RAID config has to be saved. This will be done by
28 31
32 :::shell
29 mdadm --detail --scan >> /etc/mdadm.conf 33 mdadm --detail --scan >> /etc/mdadm.conf
30 34
31 Then create an ext4 filesystem on `/dev/md0` and an xfs filesystem on `/dev/md1`. Nothing noteworthy here. 35 Then create an ext4 filesystem on `/dev/md0` and an xfs filesystem on `/dev/md1`. Nothing noteworthy here.
32 36
33 The observant reader will have noticed from the device names above that I'm testing my installation from a running system on `/dev/sda`. To save the hassle of going through the entire stage3 setup process I'm simply copying the running system to the newly created RAID filesystems. 37 The observant reader will have noticed from the device names above that I'm testing my installation from a running system on `/dev/sda`. To save the hassle of going through the entire stage3 setup process I'm simply copying the running system to the newly created RAID filesystems.
34 38
35 After chrooting into the new system some changes have to be made to the [genkernel](https://wiki.gentoo.org/wiki/Genkernel) config in order to produce a RAID enabled initramfs. In `/etc/genkernel.conf` set 39 After chrooting into the new system some changes have to be made to the [genkernel](https://wiki.gentoo.org/wiki/Genkernel) config in order to produce a RAID enabled initramfs. In `/etc/genkernel.conf` set
36 40
41 :::shell
37 MDADM="yes" 42 MDADM="yes"
38 MDADM_CONFIG="/etc/mdadm.conf" 43 MDADM_CONFIG="/etc/mdadm.conf"
39 44
40 Now we're set to build the kernel. 45 Now we're set to build the kernel.
41 46
42 While it's compiling, edit `/etc/default/grub` (I'm of course using [grub2](https://www.gnu.org/software/grub/manual/grub.html) for booting) and add 47 While it's compiling, edit `/etc/default/grub` (I'm of course using [grub2](https://www.gnu.org/software/grub/manual/grub.html) for booting) and add
43 48
49 :::shell
44 GRUB_CMDLINE_LINUX="domdadm" 50 GRUB_CMDLINE_LINUX="domdadm"
45 51
46 Setup grub on both devices individually using `grub-install /dev/sdb` and `grub-install /dev/sdc`. 52 Setup grub on both devices individually using `grub-install /dev/sdb` and `grub-install /dev/sdc`.
47 53
48 After the kernel has finished compiling, generate the proper grub config using `grub-mkconfig -o /boot/grub/grub.cfg`. 54 After the kernel has finished compiling, generate the proper grub config using `grub-mkconfig -o /boot/grub/grub.cfg`.