You are not logged in.

#1 2016-09-26 19:35:30

nicovell3
Member
Registered: 2015-06-12
Posts: 11
Website

Installation with RAID10 and LUKS

Hello everyone,

I'm installing ArchLinux another time (I've been using it with different configurations for years) but this time I want to build this system:
RAID10 with LUKS encryption

To build it I've configured all the partitions from my current installation, so the drive letters are moved:

#Three hard drives: sdb with 320GB and sdc and sdd with 250GB. Goal: RAID 10 with encrypted data and Xen kernel
gdisk -l /dev/sdc | grep "sectors," # get sectors count
gdisk /dev/sdb
o
Y
n
1
2048
488397134 #(sectors count)+2048
fd00
n
2

+512M
ef00
n
3

+2G
8300
w
Y



gdisk /dev/sdc
o
Y
n
1
2048
488397134 #41943040
fd00
w
Y
gdisk /dev/sdd
o
Y
n
1
2048
488397134
fd00
w
Y
mkfs.fat -F32 /dev/sdb2 #partition the efi as fat 32
mkfs.ext4 /dev/sdb3 #partition the boot as ext4
mdadm --create /dev/md0 --level=10 --raid-devices=3 /dev/sdb1 /dev/sdc /dev/sdd
yes
#If need to mount again, mdadm --assemble /dev/md0 /dev/sda1 /dev/sdb /dev/sdc
cryptsetup luksFormat /dev/md0
YES
password
password
cryptsetup open --type luks /dev/md0 LUKS
vgcreate LVM /dev/mapper/LUKS
lvcreate -L 16G LVM -n swap
lvcreate -L 100G LVM -n arch
lvcreate -l 100%FREE LVM -n home
mkfs.ext4 /dev/LVM/arch
mkfs.ext4 /dev/LVM/home
mkswap /dev/LVM/swap

# Summary:
# /dev/sdb2     -> /boot/efi
# /dev/sdb3     -> /boot
# /dev/LVM/arch -> /
# /dev/LVM/home -> /home
# /dev/LVM/swap -> swapon

And to perform the installation, I've run these commands:

cryptsetup open --type luks /dev/md0 LUKS
password
mount /dev/LVM/arch /mnt
mkdir /mnt/boot /mnt/home
mount /dev/LVM/home /mnt/home
mount /dev/sdb3 /mnt/boot
mkdir /mnt/boot/efi
mount /dev/sdb2 /mnt/boot/efi

swapon /dev/LVM/swap
pacstrap /mnt base base-devel
genfstab -U -p /mnt >> /mnt/etc/fstab
arch-chroot /mnt /usr/bin/pacman -S --noconfirm grub efibootmgr intel-ucode
cat /mnt/etc/mkinitcpio.conf | sed -r 's/(^HOOKS=".*)"$/\1 mdadm_udev keymap encrypt lvm2"/g' > /mnt/etc/mkinitcpio.conf #add encrypt and lvm2 in HOOKS
arch-chroot /mnt /usr/bin/mkinitcpio -p linux
head -n 3 /mnt/etc/default/grub > /tmp/beginGrub
tail -n 43 /mnt/etc/default/grub > /tmp/endGrub
cp /tmp/beginGrub /mnt/etc/default/grub
echo "GRUB_CMDLINE_LINUX_DEFAULT=\"quiet md=0,/dev/sda1,/dev/sdb,/dev/sdc cryptdevice=/dev/md0:LVM root=/dev/mapper/LVM-arch\"" >> /mnt/etc/default/grub
cat /tmp/endGrub >> /mnt/etc/default/grub

arch-chroot /mnt /usr/bin/grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=XenServer
arch-chroot /mnt /usr/bin/grub-mkconfig -o /boot/grub/grub.cfg
arch-chroot /mnt /usr/bin/passwd
password
password

cd
umount -R /mnt

If you are trying to test in Qemu (as me) and don't want to add EFI support, I use this commands to install the BIOS boot partition (suposing sdb is now sda inside qemu):

gdisk /dev/sda
n


+1M
ef002
w
Y
#Bios boot partition will be created
arch-chroot . usr/bin/grub-install --target=i386-pc --recheck /dev/sda

And that would work if the GRUB recognized my RAID as /dev/md0, but it doesn't. Instead, my RAID10 appears as /dev/md127 and if I change my grub configuration to /dev/md127 it works. My only question is how do I configure my RAID in GRUB to be detected as md0? I don't understand that md127 so I don't feel confortable with it...

Offline

#2 2016-09-26 19:40:23

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: Installation with RAID10 and LUKS

mdadm.conf


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#3 2016-09-26 19:43:05

nicovell3
Member
Registered: 2015-06-12
Posts: 11
Website

Re: Installation with RAID10 and LUKS

jasonwryan wrote:

mdadm.conf

mdadm.conf is placed in etc, which is inside root. I think I need to perform that configuration from the GRUB files, because the etc folder is not accessible at boot time. Am I confused?

Offline

#4 2016-09-27 16:12:27

R00KIE
Forum Fellow
From: Between a computer and a chair
Registered: 2008-09-14
Posts: 4,734

Re: Installation with RAID10 and LUKS

This 'md=0,/dev/sda1,/dev/sdb,/dev/sdc' will only work with metadata version 0 or 0.9 I believe[1], at most it might work with metadata version 1.0 since the superblock is also at the end of the device[2] but I really doubt it.

As jasonwryan hinted, you will have to include a proper mdadm.conf in the initramfs and not use the md= parameter.

[1] https://www.kernel.org/doc/Documentation/md.txt
[2] https://raid.wiki.kernel.org/index.php/ … ck_formats


R00KIE
Tm90aGluZyB0byBzZWUgaGVyZSwgbW92ZSBhbG9uZy4K

Offline

#5 2016-09-27 17:13:52

nicovell3
Member
Registered: 2015-06-12
Posts: 11
Website

Re: Installation with RAID10 and LUKS

R00KIE wrote:

This 'md=0,/dev/sda1,/dev/sdb,/dev/sdc' will only work with metadata version 0 or 0.9 I believe[1], at most it might work with metadata version 1.0 since the superblock is also at the end of the device[2] but I really doubt it.

As jasonwryan hinted, you will have to include a proper mdadm.conf in the initramfs and not use the md= parameter.

[1] https://www.kernel.org/doc/Documentation/md.txt
[2] https://raid.wiki.kernel.org/index.php/ … ck_formats

So, if I've understood you, the only thing I must do is to configure my RAID array in mdadm.conf and copy it to the initramfs? I didn't know that image was configurable, there are a lot of things I need to learn yet...

Then, commands I would need to make my system work are these:

echo "ARRAY /dev/md0 devices=/dev/sda1,/dev/sdb,/dev/sdc" > /mnt/etc/mdadm.conf
arch-chroot /mnt mkinitcpio -p linux

I'll try them when I get home, but if you know something will fail, I'd appreciate too much if you told me.

Thanks for your answer wink

Offline

#6 2016-09-27 22:17:51

R00KIE
Forum Fellow
From: Between a computer and a chair
Registered: 2008-09-14
Posts: 4,734

Re: Installation with RAID10 and LUKS

Most probably you want to read the wiki page on mkinitcpio[1] before you proceed, all the info you need should be there.

[1] https://wiki.archlinux.org/index.php/Mkinitcpio


R00KIE
Tm90aGluZyB0byBzZWUgaGVyZSwgbW92ZSBhbG9uZy4K

Offline

#7 2016-09-29 18:11:02

nicovell3
Member
Registered: 2015-06-12
Posts: 11
Website

Re: Installation with RAID10 and LUKS

R00KIE wrote:

Most probably you want to read the wiki page on mkinitcpio[1] before you proceed, all the info you need should be there.

[1] https://wiki.archlinux.org/index.php/Mkinitcpio


I ran those two commands and it worked perfectly. I'm now reading that page and finding it very interesting to understand my favorite distro.

Thank you very much for your help wink

Offline

Board footer

Powered by FluxBB