Manual setup raid, encryption and lvm with Linux

Updated . Posted . Visible to the public.

This is done with Gentoo Linux. I assuming a correct kernel configuration.

  1. Create Partitions

In this example I use /dev/sdd1, /dev/sdc1 and /dev/sdf1. You need at least two partitions.

  1. Clear superblock

mdadm --zero-superblock /dev/sdd1 /dev/sdc1 /dev/sdf1
  1. Create RAID (I make a RAID 0 because I don't need fault tolerance)

`mdadm --create --verbose /dev/md0 --level=0 --raid-devices=3 /dev/sd[cdf]1

I don't know why RAID autodetect doesn't work at my configuration so I create a /etc/mdadm.conf

mdadm --detail --scan >> /etc/mdadm.conf

This should look like this:

ARRAY /dev/md/fuckup:0 metadata=1.2 name=fuckup:0 UUID=a4c0e855:442adaa9:88c9d408:9h347541

Now check if RAID is working with cat /proc/mdstat this shuld output something like this:

Personalities : [raid0] [raid1] [raid10]
md0 : active raid0 sdd1[1] sdc1[0] sdf1[2]
5860532736 blocks super 1.2 512k chunks

unused devices: <none>
  1. Encrypt your RAID Device

cryptsetup -c twofish-xts-essiv:sha256 -y -s 512 -h sha1 luksFormat /dev/md0

You can check the available cryptographic algorithms with cat /proc/crypto

Open your encrypted device

cryptsetup luksOpen /dev/md0 storage00
  1. Add LVM to the encrypted device to be flexible

Initialize physical volume(s) for use by LVM

pvcreate /dev/mapper/storage00

Create a volume group

vgcreate vg_storage00 /dev/mapper/storage00 

Create a logical volume (here I create a logical volume named lv0_stoage00 which is 5.45TB big)

lvcreate -nlv_storage00 -L5.45T lv0_storage00
  1. Create filesystem on your logical volume

mkfs.ext4 /dev/vg_storage00/lv0_storage00 
  1. Add your Device to fstab (use noauto because you have to open the device before you can mount it)

/dev/mapper/lv_storage00	/var/media	ext4	noauto,noatime	0 0
  1. And finally mount it

mount /var/media
MookiE
Last edit
Posted by MookiE to MookiE's Cards (2011-10-13 13:53)