KVM Host Guest Filesystem Images
Configuring disks for the KVM Guests Filesystem Images according to the disk layout.
Raid
Configure the raid1
# mdadm --create --level 1 --raid-devices 2 /dev/md2 /dev/sdc1 /dev/sdd1
Find the UUID for /dev/md2
# mdadm --detail /dev/md2 /dev/md2: Version : 1.2 Creation Time : Sat Oct 7 15:57:11 2017 Raid Level : raid1 Array Size : 1946025984 (1855.88 GiB 1992.73 GB) Used Dev Size : 1946025984 (1855.88 GiB 1992.73 GB) Raid Devices : 2 Total Devices : 2 Persistence : Superblock is persistent Intent Bitmap : Internal Update Time : Sat Oct 7 23:13:13 2017 State : clean Active Devices : 2 Working Devices : 2 Failed Devices : 0 Spare Devices : 0 Name : kvm02:2 (local to host kvm02) UUID : a78f7c84:5491a0d6:d5c5390d:8b97863f Events : 5069 Number Major Minor RaidDevice State 0 8 33 0 active sync /dev/sdc1 1 8 49 1 active sync /dev/sdd1
Add the array to /etc/mdadm/mdadm.conf
ARRAY /dev/md/2 metadata=1.2 UUID=a78f7c84:5491a0d6:d5c5390d:8b97863f name=kvm02:2
Update the initrd
# update-initramfs -u
Encrypting the Raid
Format the Raid with luks
# cryptsetup luksFormat /dev/md2
Open the Luks Device.
# cryptsetup luksOpen /dev/md2 md2_crypt
Create a Key.
# echo -n "uptime" | md5sum | dd of=/root/install/luks/keyfile_md2 bs=1 count=32 # cryptsetup luksAddKey /dev/md2 /root/install/luks/keyfile_md2
Find the UUID for /dev/md2
# blkid /dev/md2: UUID="d62d227d-6d94-4055-b2df-b9477293b5d6" TYPE="crypto_LUKS"
Add the key to /etc/crypttab
md2_crypt UUID=d62d227d-6d94-4055-b2df-b9477293b5d6 /root/install/luks/keyfile_md2 luks
Update the initrd.
# update-initramfs -u
Create the LVM volume.
# pvcreate /dev/mapper/md2_crypt # vgcreate vg2 /dev/mapper/md2_crypt