jump to navigation

Creating a new Linux RAID1 device and extending an existing LVM Volume onto it. RHEL/Centos 5 13 June 2009

Posted by Maulvi Bakar in : Linux,System , add a comment

I’m seriously into server consolidation and virtualization.  I’m going to eliminate my other VMWare server and just concentrate on one.

First order of the day is to upgrade the RAM and Available HDD space. Upgrading the RAM is simple enough, just add/replace the modules.

Expanding the available space is another matter.  This is actually an extension of my previous posting – New HDD, enlarging Red Hat/Centos ext3/lvm partition, but there’s another factor in the equation, RAID1 (Mirroring) devices.

The existing root partition resides in an LVM partition which in turn resides in a RAID1 (Mirroring) Multi-Disk (MD) partition which is based on a twin 400GB HDD configuration.

I’ve acquired a pair of 500GB HDDs. Now to extend the existing LVM ontothe newly acquired disks in a RAID1 configuration.

Step 1 is to create Software RAID partitions on the said disks –
# fdisk /dev/sdc
# fdisk /dev/sdd

Create a new ‘sdc1’ and ‘sdd1’ partitions using type FD, which is Linux RAID Autodetect.

Next, we need to create the Multi-Disk Volume –
# mdadm --create /dev/md2 --level=1 --raid-devices=2 /dev/sdc1 /dev/sdd1
Since I already have ‘md0’ for my ‘/boot’ and ‘md1’ is the existing volume with the existing LVM that was the intended target for expansion, thus naturally I’m using ‘md2’.

Basically, I am creating ‘md2’ device in RAID1 configuration using 2 devices namely ‘/dev/sdc1’ and ‘/dev/sdd1’.

You can monitor the status of your RAID devices using ‘/proc/mdstat’ –
# cat /proc/mdstat
Personalities : [raid1]
md2 : active raid1 sdd1[1] sdc1[0]
487331648 blocks [2/2] [UU]
[>....................] resync = 1.9% (9622656/487331648) finish=90.0min speed=88417K/sec

The steps here onwards are basically the same as previously mentioned here, the only difference is the ‘/dev/md2’ device is the target.

To start, we need to create a Physical Volume within the newly created ‘/dev/md2’ RAID device.
# pvcreate /dev/md2

After that we will extend the existing volume ‘VolGroup00? onto the newly created physical volume.
# vgextend VolGroup00 /dev/md2

Once done, the next step is to extend the Logical Volume within the volume group to use the free space newly made available when you extend the volume group previously.
# lvextend /dev/VolGroup00/LogVol00 /dev/md2
Here is the difference where I did not specify the space size to extend as the default will be to use all available spaces.

And finally, we’ll enlarge the ext3 partition to make use of the newly available free space in the logical volume.
# resize2fs /dev/VolGroup00/LogVol00

Enjoy!

HPUX Breaking Mirror and Extending LVM 2 June 2009

Posted by Maulvi Bakar in : Unix,Work , add a comment

I’m learning new things nowadays..  Particularly HPUX.  Not really my cup of tea since it not open-source but interesting enough though.

We had one machine with mirrored harddisks with one being faulty that needs removal.

Break mirror procedure..

1. Remove the mirror on the Logical Volume affected within the Volume Group
lvreduce -m 0 /dev/vg01/lvol1 /dev/dsk/c2t0d0
lvreduce -m 0 /dev/vg01/lvol2 /dev/dsk/c2t0d0

2. Now remove the Volume Group from the Physical Volume that is targeted for removal
vgreduce /dev/vg01 /dev/dsk/c2t0d0

3. Finally remove the Physical Volume from the Physical Disk
pvremove /dev/rdsk/c2t0d0
Please note the ‘r’.. ‘r’ stands for physical disk, while the one without is the physical volume..

Restore mirror procedure…

1. First, let’s verify things
ioscan -funC disk
pvdisplay /dev/dsk/c1t0d0        # get lvm info of existing disk.
pvdisplay /dev/dsk/c2t0d0        # get err, no lvm def on it, raw disk.

2. Now we create the Physical Volume within the Physical Disk and extend the Volume Group onto it.
pvcreate /dev/rdsk/c2t0d0        # add physical disk to be used by LVM
vgextend /dev/vg01 /dev/dsk/c2t0d0    # incorporate new disk to existing vg00

2a. If you’re recreating a bootable disk, the commands below must be used instead –

pvcreate -B /dev/rdsk/c2t0d0        # add physical disk to be used by LVM and make it bootable
vgextend /dev/vg01 /dev/dsk/c2t0d0    # incorporate new disk to existing vg00
mkboot -a "hpux -lq /stand/vmunix" /dev/dsk/c2t0d0     # install the bootloader

3. Check and verify!
strings /etc/lvmtab            # see new disk used by lvm

4. The next steps will actually perform the mirror, and it will fail if -m mirroring option is not activated with valid license
lvextend -m 1 /dev/vg01/lvol1 /dev/dsk/c2t0d0    # add mirror for lvol1
lvextend -m 1 /dev/vg01/lvol2 /dev/dsk/c2t0d0    # add mirror for lvol2

Enjoy!

π