Talk:Partitioning RAID / LVM on RAID
(Created page with 'I recently had to play musical extents on a massive LVM-on-RAID(s) volume and I wrote down the steps so I'd have them if I had to do it again. I think this wiki would be a good …') |
(forgot --dataalignment 1024k in pvcreate line at the end) |
||
Line 97: | Line 97: | ||
write the configuration for your new md device to mdadm.conf so it gets reassembled on boot | write the configuration for your new md device to mdadm.conf so it gets reassembled on boot | ||
− | pvcreate <PhysicalVolumePath> | + | pvcreate <PhysicalVolumePath> --dataalignment 1024k |
e.g. | e.g. | ||
− | pvcreate /dev/md8 | + | pvcreate /dev/md8 --dataalignment 1024k |
make the new volume an LVM Physical Volume | make the new volume an LVM Physical Volume | ||
Revision as of 14:41, 14 April 2010
I recently had to play musical extents on a massive LVM-on-RAID(s) volume and I wrote down the steps so I'd have them if I had to do it again. I think this wiki would be a good place to post these steps, but I'm not sure where in the wiki exactly to put it. Any thoughts? Gregory.dulin 14:04, 14 April 2010 (UTC)
pvmove <PhysicalVolumePath> e.g. pvmove /dev/md2
moves Physical Extents (PE) off the Physical Volume (PV) you'll be rebuilding, and onto free PEs on other PVs in the VG.
vgreduce <VolumeGroupName> <PhysicalVolumePath> e.g. vgreduce VolGroup00 /dev/md2
remove the PV from the VG
pvremove <PhysicalVolumePath> e.g. pvremove /dev/md2
remove the PV from LVM entirely.
cat /proc/mdstat > currentRAIDsetup.txt
make a note of which drives belong to which md devices (really useful if there are lots of md's)
cat /proc/mdstat | grep <PhysicalVolumePath> e.g. cat /proc/mdstat | grep /dev/md2
make a note of the specific partitions we're working with
mdadm --stop <PhysicalVolumePath> e.g. mdadm --stop /dev/md2
stop the RAID device
- Repeated for each Disk *****
fdisk -lu <DiskPath> e.g. fdisk -lu /dev/sdc
determine the start sector of the partition we want to align
determine the proper sector to start the partition on using this (excel) formula: =2048-(MOD(A1,2048))+A1 Put your current starting sector in cell A1 The output should be greater than the original start sector, and divisible by 2048
cat /proc/mdstat | grep <PartitionPath w/o /dev/> e.g. cat /proc/mdstat | grep sdc2
make damn sure we're not going to be messing with anything live NOTE: Do NOT use /dev/ in front of your partition in this line (This command should NOT give you any output. If it does, then the partition you're about to fiddle with is still in use and bad things will happen.)
parted <DiskPath> e.g. parted /dev/sdc
I don't like fdisk
unit s
Change units to sectors
Note the partition number and the End Sector for the partition we're fiddling with
rm <partition number> e.g. rm 2
deletes the partition
mkpart <partition type> <aligned start sector>s <original end sector>s e.g. mkpart primary 2109440s 976768064s
create a new partition with the beginning aligned along a 1MiB (2048 sector) boundary (end alignment doesn't matter as far as I can figure). DON'T FORGET THE "s" !!!
set <partition number> raid on e.g. set 2 raid on
sets the RAID flag to ON. Not necessary, but it doesn't hurt.
quit
exits the parted program
- End of Repeated for each Disk *****
cat currentRAIDsetup.txt
so you can see what partitions to reassemble
mdadm --create <PhysicalVolumePath> --level=<desired RAID level> --raid-devices=<number of drives> <device 1> <device 2> <device n...> e.g. mdadm --create /dev/md8 --level=5 --raid-devices=6 /dev/sdj2 /dev/sdr2 /dev/sdz2 /dev/sdah2 /dev/sdap2 /dev/sdb2
recreate the array with the newly aligned partitions
gedit /etc/mdadm.conf
comment (#) out the line referring to your newly aligned md device (the UUID will be wrong) save the file and kill gedit
mdadm --detail --scan | grep <PhysicalVolumePath> >> /etc/mdadm.conf e.g. mdadm --detail --scan | grep /dev/md8 >> /etc/mdadm.conf
write the configuration for your new md device to mdadm.conf so it gets reassembled on boot
pvcreate <PhysicalVolumePath> --dataalignment 1024k e.g. pvcreate /dev/md8 --dataalignment 1024k
make the new volume an LVM Physical Volume
vgextend <VolumeGroupName> <PhysicalVolumePath> e.g. vgextend VolGroup00 /dev/md8
Adds the newly aligned volume back into the VG
Repeat as necessary Gregory.dulin 14:04, 14 April 2010 (UTC)