Make Software Raid on Existing GTP LVM

Do NOT use “consumer grade” drives to create your array, use “server grade” drives!

larger disks have a higher data density on the platter’s surface, the chance for failure is higher.

apt-get install initramfs-tools mdadm

reboot

cat /proc/mdstat
Personalities : [linear] [multipath] [raid1] [raid0] [raid6] [raid5] [raid4] [raid10]
unused devices:

GPT fdisk (consisting of the gdisk, cgdisk, sgdisk, and fixparts programs) is a set of text-mode partitioning tools for Linux, FreeBSD, Mac OS X, and Windows.
sudo apt-get install gdisk

Copy sdb’s partition to sda and change guid
sgdisk -R /dev/sdb /dev/sda
sgdisk -G /dev/sdb
mkfs -t fat /dev/sdb1
mkfs -t ext2 /dev/sdb1

delete old raids
mdadm –zero-superblock /dev/sdb1
mdadm –zero-superblock /dev/sdb2
mdadm –zero-superblock /dev/sdb3

create our RAID arrays /dev/md0, /dev/md1, and /dev/md2.
mdadm –create /dev/md0 –level=1 –raid-disks=2 missing /dev/sdb1
mdadm –create /dev/md1 –level=1 –raid-disks=2 missing /dev/sdb2
mdadm –create /dev/md2 –level=1 –raid-disks=2 missing /dev/sdb3

cat /proc/mdstat
We have three degraded RAID arrays ([_U] or [U_] means that an array is degraded while [UU] means that the array is ok)

apt-get install exfat-fuse exfat-utils
mkfs.vfat -F 32 /dev/md0
mkfs.ext2 /dev/md1

Use the pvcreate command to initialize a block device to be used as a physical volume. for example :pvcreate /dev/sdd1 /dev/sde1 /dev/sdf1
pvcreate /dev/md2
dd /dev/md2 to our volume group cernet-szu-cetyp-vg
vgextend cernet-szu-cetyp-vg /dev/md2
vgdisplay
pvdisplay
Rove bad or missing volumne
vgreduce –removemissing –force cernet-szu-cetyp-vg

Reformat /dev/sdb1 to FAT32
mdadm –detail /dev/md0
mdadm –zero-superblock /dev/sdb1
mkfs.vfat -F 32 /dev/sdb1
mdadm –create /dev/md0 –level=1 –raid-disks=2 missing /dev/sdb1
mkfs.vfat -F 32 /dev/md0

cp /etc/mdadm/mdadm.conf /etc/mdadm/mdadm.conf_orig
mdadm –examine –scan >> /etc/mdadm/mdadm.conf

blkid /dev/sda1
/dev/sda1: UUID=”4CD7-9220″ TYPE=”vfat”
blkid /dev/sda2
/dev/sda2: UUID=”03cebd54-1248-47ed-971d-79d2d6e464a7″ TYPE=”ext2″
Replace /dev/sda1 with /dev/md0 in /etc/fstab.
replace /dev/sda1,/dev/sda2 with /dev/md0 ,/dev/md1 in /etc/mtab

To move the contents of our LVM partition /dev/sda2 to our LVM RAID array /dev/md2
pvmove /dev/sda3:0-715174 /dev/md1
vgreduce cernet-szu-cetyp-vg /dev/sda3
pvremove /dev/sda3

mdadm –add /dev/md2 /dev/sda3

mkdir /mnt/md1
mount /dev/md1 /mnt/md1
cd /boot
cp -dpRx . /mnt/md1

mkdir /mnt/efi
mount /dev/sda /mnt/efi
cd /mnt/efi
cp -dpRx . /mnt/md1

mdadm –add /dev/md0 /dev/sda1
mdadm –add /dev/md1 /dev/sda2

cp /etc/mdadm/mdadm.conf_orig /etc/mdadm/mdadm.conf
mdadm –examine –scan >> /etc/mdadm/mdadm.conf

reboot

发表评论

电子邮件地址不会被公开。 必填项已用*标注