Monday, November 23, 2015

Install Software RAID to existing Proxmox PVE installation

This is my notes of commands I have executed in Proxmox hardware node to add Software RAID capability to any Proxmox PVE existing installation:


apt-get update 
apt-get upgrade
apt-get dist-upgrade

apt-get install mdadm

modprobe raid1
                        (do not need to add to /etc/modules)


cat /proc/mdstat


Prepare partitions to Linux Raid Auto-Detect:

fdisk -l
fdisk /dev/sdb
    type fd  (change partition type to linux auto raid)


Copy partition from one drive to another

sfdisk -d /dev/sdb | sfdisk --force /dev/sdc



Remove previous RAID data if any:
mdadm --zero-superblock /dev/sdb1
mdadm --zero-superblock /dev/sdc1


Create the array with missing disk
mdadm --create /dev/md0 --level=1 --raid-disks=2 missing /dev/sdb1


Create the array with both disk
mdadm --create /dev/md0 --level=1 --raid-disks=2 /dev/sdb1 /dev/sdc1


To Add Secondary Drive Later do
mdadm --manage /dev/md0 --add /dev/sdc1

-----------------------------------  (if using LVM use this section below) -------------------------------


umount /mnt/md0
cat /proc/mdstat

pvcreate /dev/md0
vgcreate vglocalmd0 /dev/md0

lvcreate -n localmd0 -l 90%FREE vglocalmd0
-or-
lvcreate -n localmd0 -l 100%FREE vglocalmd0   (allocate 100% - but backup using snapshot will fail)

mkfs.ext4 /dev/vglocalmd0/localmd0

blkid      (to get and copy the uuid)

nano /etc/fstab

UUID=<uuid> /mnt/md0 ext4 defaults,noatime,nodiratime,noacl,data=writeback,barrier=0,nobh,errors=remount-ro 0 2

rm -rf /mnt/md0/*
chmod 777 /mnt/md0

mount -a

df -h /mnt/md0      (just to check and make sure the mount is there and okay)


-----------------------------------  (if using NON-LVM (just ext4) use this section below) -------------------------------

Create the filesystem
mkfs.ext4 /dev/md0

Double check to make sure all okay:
cat /proc/mdstat

Create mount target
mkdir /mnt/md0
chmod -R 777 /mnt/md0


---------------------- end of (LVM / Ext4 configuration -----------------

Edit fstab
blkid

nano /etc/fstab
UUID=<UUID> /mnt/md0 ext4 defaults,noatime,nodiratime,noacl,data=writeback,barrier=0,nobh,errors=remount-ro 0 2

mount -a

reboot

No comments:

Post a Comment