Saturday, August 22, 2009

RENAMING A LOGICAL VOLUME

RENAMING A LOGICAL VOLUME

Step 1: Identify the Logical Volume that needs to be changed

# vgdisplay -v /dev/vg01 | grep "LV Name"

LV Name /dev/vg01/lvol01

# bdf /dev/vg01/lvol01

Filesystem kbytes used avail %used Mounted on

/dev/vg01/lvol01 102400 1133 94945 1% /opt/test

# umount /opt/test

# ll /dev/vg01

total 0

crw------- 1 root sys 64 0x010000 Nov 5 12:18 group

brw------- 1 root sys 64 0x010001 Nov 5 12:19 lvol01

crw------- 1 root sys 64 0x010001 Nov 5 12:19 rlvol01

# cd /dev/vg01

# mv lvol01 lvol01_renamed

# mv rlvol01 rlvol01_renamed

# vgdisplay -v /dev/vg01 | grep "LV Name"

LV Name /dev/vg01_renamed/lvol01_renamed

VGEXPORT & VGIMPORT

VGEXPORT & VGIMPORT

Following example shows, how vgexport/vgimport can be used to change the Volume Group Names

# bdf /opt/test

Filesystem kbytes used avail %used Mounted on

/dev/vg01/lvol01 102400 1133 94945 1% /opt/test

# umount /opt/test

Step 1: Create a mapfile in the preview mode

# vgexport -p -v -s -m /tmp/vg01.map /dev/vg01

Beginning the export process on Volume Group "/dev/vg01".

Volume group "/dev/vg01" is still active.

/dev/dsk/c0t9d0

# vgchange -a n /dev/vg01

Volume group "/dev/vg01" has been successfully changed.

Step 2: Export the Volume Group

# vgexport /dev/vg01

# ll /dev/*/group

crw-r----- 1 root sys 64 0x000000 Oct 31 13:15 /dev/vg00/group

# mkdir /dev/vg01_renamed

# mknod /dev/vg01_renamed/group c 64 0x010000

Step 2: Import the Volume Group with a new name

# vgimport -v -s -m /tmp/vg01.map /dev/vg01_renamed

Beginning the import process on Volume Group "/dev/vg01_renamed".

Logical volume "/dev/vg01_renamed/lvol01" has been successfully created

with lv number 1.

Volume group "/dev/vg01_renamed" has been successfully created.

# vgchange -a y /dev/vg01_renamed

Activated volume group

Volume group "/dev/vg01_renamed" has been successfully changed.

# vgdisplay -v | grep "VG Name"

VG Name /dev/vg00

VG Name /dev/vg01_renamed

REMOVING A LOGICAL VOLUME

REMOVING A LOGICAL VOLUME

Step 1: Identify the Logical Volume(s) to remove

# bdf /opt/test

Filesystem kbytes used avail %used Mounted on

/dev/vg01/lvol01 102400 1133 94945 1% /opt/test

# umount /opt/test

# vgdisplay -v vg01 | grep "LV Name"

LV Name /dev/vg01/lvol01

# lvremove /dev/vg01/lvol01

The logical volume "/dev/vg01/lvol01" is not empty;

do you really want to delete the logical volume (y/n) : y

Logical volume "/dev/vg01/lvol01" has been successfully removed.

Volume Group configuration for /dev/vg01 has been saved in /etc/lvmconf/vg01.conf

REDUCING A LOGICAL VOLUME

REDUCING A LOGICAL VOLUME

[CAUTION : DATA LOSS WILL OCCUR]

Step 1: Check the current size of the Logical Volume

# lvdisplay /dev/vg01/lvol01

--- Logical volumes ---

LV Name /dev/vg01/lvol01

VG Name /dev/vg01

LV Permission read/write

LV Status available/syncd

Mirror copies 0

Consistency Recovery MWC

Schedule parallel

LV Size (Mbytes) 120

Current LE 30

Allocated PE 30

Stripes 0

Stripe Size (Kbytes) 0

Bad block on

Allocation strict

IO Timeout (Seconds) default


# bdf /dev/vg01/lvol01

Filesystem kbytes used avail %used Mounted on

/dev/vg01/lvol01

122880 1133 114145 1% /opt/test

^

|

# fsadm -b 100m -F vxfs /opt/test

fsadm: /dev/vg01/rlvol01 is currently 122880 sectors - size will be reduced

# lvreduce -L 100 /dev/vg01/lvol01

When a logical volume is reduced useful data might get lost;

do you really want the command to proceed (y/n) : y

Logical volume "/dev/vg01_renamed/lvol01" has been successfully reduced.

Volume Group configuration for /dev/vg01_renamed has been saved in /etc/lvmconf/vg01_renamed.conf

# bdf /opt/test

Filesystem kbytes used avail %used Mounted on

/dev/vg01_renamed/lvol01

102400 1133 94945 1% /opt/test

^


# lvdisplay /dev/vg01/lvol01

--- Logical volumes ---

LV Name /dev/vg01/lvol01

VG Name /dev/vg01

LV Permission read/write

LV Status available/syncd

Mirror copies 0

Consistency Recovery MWC

Schedule parallel

LV Size (Mbytes) 100

Current LE 25

Allocated PE 25

Stripes 0

Stripe Size (Kbytes) 0

Bad block on

Allocation strict

IO Timeout (Seconds) default

MIRRORING A LOGICAL VOLUME

MIRRORING A LOGICAL VOLUME

Step 1: Check whether there are sufficient disks for mirroring

# vgdisplay -v /dev/vg01 | grep "PV Name"

PV Name /dev/dsk/c0t9d0

PV Name /dev/dsk/c0t10d0

# lvdisplay /dev/vg01/lvol01 | grep Mirror

Mirror copies 0

# lvextend -m 1 /dev/vg01/lvol01

The newly allocated mirrors are now being synchronized. This operation will take some time. Please wait ....

Logical volume "/dev/vg01/lvol01" has been successfully extended.

Volume Group configuration for /dev/vg01 has been saved in /etc/lvmconf/vg01.conf

Step 2: Check Mirror Copies

# lvdisplay /dev/vg01/lvol01 | grep Mirror

Mirror copies 1

EXTENDING A LOGICAL VOLUME

EXTENDING A LOGICAL VOLUME

Step 1: Identify whether there are Free Physical Extents available to extend the Logical Volume

# vgdisplay /dev/vg01_renamed | grep "Free PE"

Free PE 483

Step 2: Check the current size of the Logical Volume

# lvdisplay /dev/vg01/lvol01 | grep “LV Size”

LV Size (Mbytes) 100

# lvextend -L 120 /dev/vg01/lvol01

Logical volume "/dev/vg01/lvol01" has been successfully extended.

Volume Group configuration for /dev/vg01_renamed has been saved in /etc/lvmconf/vg01.conf

[Note : Always mention the new Logical Volume size to extend]

# lvdisplay /dev/vg01/lvol01 | grep "LV Size"

LV Size (Mbytes) 120

Step 3: Extend the Filesystem

# bdf /opt/test

Filesystem kbytes used avail %used Mounted on

/dev/vg01_renamed/lvol01

102400 1133 94945 1% /opt/test

# fsadm -b 120m -F vxfs /opt/test

fsadm: /dev/vg01_renamed/rlvol01 is currently 102400 sectors - size will be increased

EXTENDING A VOLUME GROUP

EXTENDING A VOLUME GROUP

Step 1: Confirm that the free disk identified is not in any of the already volume groups

# strings /etc/lvmtab > /tmp/lvm

# grep c0t10d0 /tmp/lvm

Step 2: Initialize the Physical Volume which has been identified as free

# pvcreate /dev/rdsk/c0t10d0

Physical volume "/dev/rdsk/c0t10d0" has been successfully created.

Step 3: Extend the Volume group to the initialized disk

# vgextend /dev/vg01 /dev/dsk/c0t10d0

Volume group "/dev/vg01" has been successfully extended.

Volume Group configuration for /dev/vg01 has been saved in /etc/lvmconf/vg01.conf

Step 4: Check the disk has been added to the Volume Group

# vgdisplay -v /dev/vg01 | grep "PV Name"

PV Name /dev/dsk/c0t9d0

PV Name /dev/dsk/c0t10d0

CREATING A LOGICAL VOLUME AND FILESYSTEM

CREATING A LOGICAL VOLUME AND FILESYSTEM

Step 1: Identify whether the Volume group has sufficient space to create a logical volume

#vgdisplay -v vg01

--- Volume groups ---

VG Name /dev/vg01

VG Write Access read/write

VG Status available

Max LV 255

Cur LV 0

Open LV 0

Max PV 16

Cur PV 1

Act PV 1

Max PE per PV 1016

VGDA 4

PE Size (Mbytes) 4

Total PE 508

Alloc PE 0

Free PE 508

Total PVG 0

Total Spare PVs 0

Total Spare PVs in use 0


#lvcreate -L 100 -n lvol01 /dev/vg01

Logical volume "/dev/vg01/lvol01" has been successfully created with

character device "/dev/vg01/rlvol01".

Logical volume "/dev/vg01/lvol01" has been successfully extended.

Volume Group configuration for /dev/vg01 has been saved in /etc/lvmconf/vg01.conf

#newfs -F vxfs /dev/vg01/rlvol01

version 3 layout

102400 sectors, 102400 blocks of size 1024, log size 1024 blocks

unlimited inodes, 102400 data blocks, 101280 free data blocks

4 allocation units of 32768 blocks, 32768 data blocks

last allocation unit has 4096 data blocks

first allocation unit starts at block 0

overhead per allocation unit is 0 blocks

#cp -p /etc/fstab /etc/fstab.$(date +%d%h%y)

[Note : Make a backup copy of /etc/fstab file before modifying it]

# ll /etc/fstab*

-rw-r--r-- 1 root sys 412 Nov 5 12:05 /etc/fstab

-rw-r--r-- 1 root sys 412 Nov 5 12:05 /etc/fstab.05Nov08

# echo "/dev/vg01/lvol01 /opt/test vxfs delaylog 0 2" >> /etc/fstab

#mount /opt/test

#bdf /opt/test

Filesystem kbytes used avail %used Mounted on

/dev/vg01/lvol01 102400 1133 94945 1% /opt/test