Wednesday 4 January 2012

AIX LVM - Remove Logical Volume copy

Remove LV copy
Using rmlvcopy we can remove the lvcopy from the PV’s
If we want to remove testlv copy from hdisk0

#rmlvcopy testlv 3 hdisk0

After executing the above command third copy of the testlv removed from PV hdisk0, like this we can remove

Unmount FS

Using umount or unmount command we can umount the file system i.e. file system is moved to off line.
#umount /newfs


After this you run the lsfs –a command it wont display /newfs file system details.
#lsfs –a

AIX - User and Group Management


In user management, we can perform the below operations:


1. Create user
2. List user
3. Change user
4. Remove user
5. Set password for users

AIX -Extend Volume Group

Extend VG

We can increase VG size by adding Pv into existing VG, example: extendvg command

#lsvg –p datavg
Hdisk4
Hdisk5

datavg has 2 PV’s now we want to extend datavg, then your command will be

#extendvg datavg hdisk6
After executed command hdisk6 pv added with datavg


#lsvg –l datavg
Hdisk4
Hdisk5
Hdisk6

AIX - LVM - Extend Logical Volume

If we want to increase LV size using extendlv command
#lslv newlv

The above command shows LV size, no of LP’s and some other information about LV,
suppose LV has 10 LP’s and usage is up to 95% full,
that time we can increase the LV size online by adding no of LP’s in newlv i.e.

#extendlv newlv 5
After executing the above command 5 PP’s added with newlv,
then some additional space will available in newlv.
Suppose you want to see this changes again use the lslv command

#lslv newlv (it will show no of LV’s is 15 and some additional space)

AIX - Create LV copy

We can create LV content copy to another PV, after this same LV content is available in Lvcopy configured PV.

#lspv
Hdisk0
Hdisk1
Hdisk2


#lspv –l hdisk1
Assume testlv available in hdisk1, now we will make testlv copy to hdisk2, using
After this testlv data available in both PV, hdisk1 and hdisk2, If hdisk1 is fail, we can recover testlv data from hdisk2


#mklvcopy testlv 2 hdisk2
Testlv –lv name
2- No of copies, (we can make 3 copies also; this case you put 3 and mention hdisk0 then third copy will be available in hdisk0)


#mklvcopy testlv 3 hdisk0 ( It will make third lvcopy on hdisk0
After executing above command testlv is copied to hdisk2
If you want to confirm, execute the following command


#lslv –m testlv (it will show lvcopy details for testlv)
Hdiks1 hdisk2 hdisk0
Testlv (copy1) testlv (copy2) testlv (copy3)

AIX - LVM - VarryOn Volume Group

Varryon VG

This is just for VG activation; some times clients want to deactivate VG for project restriction. After that we want to activate the VG for further data access

Suppose we want to activate testvg, then your command will be

#lsvg
Rootvg
Datavg
Testvg

The above command shows what are VG’s available

#lsvg –o
Rootvg
Datavg

The above commands shows only online VG’s because testvg is offline so we have to activate testvg

#varryonvg testvg

#lsvg –o
Rootvg
Datavg
Testvg

Now above command is display the testvg.

AIX - Varryoff VG

This is just for VG deactivation; some clients want to deactivate VG for project Restriction.
Suppose customer want deactivate testvg then your command will be

#lsvg –o
Rootvg
Datavg
Testvg

#Varryoff testvg

#lsvg –o
Rootvg
Datavg

The above command display only two online VG’s and it will not show testvg because testvg is offline VG.

AIX LVM - Remove Logical Volume copy

Remove LV copy
Using rmlvcopy we can remove the lvcopy from the PV’s
If we want to remove testlv copy from hdisk0

#rmlvcopy testlv 3 hdisk0


After executing the above command third copy of the testlv removed from PV hdisk0, like this we can remove

AIX - LVM - Change Physical Volumes

If we have three PV’s, like hdisk0, hdisk1, hdisk2, now you want to deactivate the hdisk2,

#chpv -vr hdisk2  : To deactivate the hdisk2
#chpv –va hdisk2  : To activate the hdisk2
#chpv –an hdisk2  : hdisk2 is not allocatable
#chpv –ay hdisk2  : hdisk2 is allocatable
#chpv –hn hdisk2  : hotspare no
#chpv –hy hdisk2  : Hotspare yes
#chpv –c hdisk2   : To clear the boot image

AIX - Reduce VG

We can remove the VG using reducevg command, if we want remove testvg and testvg has one pv hdisk9
#lsvg –p testvg
Hdisk9


Now we will remove the pv from testvg
#reducevg –f testvg hdisk9

f- option is used to force reduce, you have data in pv hdisk9,
that time I will not any questions, directly it will remove the pv from testvg.
Suppose 2 PV’s available in testvg then one by one we can reduce the PV’s

AIX - Add, change, and delete:

Volume groups
Logical volumes
Physical volumes
Describe mirroring
Describe striping


Logical Volume Manager

# smit lvm

Logical Volume Manager
Move cursor to desired item and press Enter.

Volume Groups
Logical Volumes
Physical Volumes
Paging Space

F1=Help F2=Refresh F3=Cancel F8=Image
F9=Shell F10=Exit Enter=Do


Volume Groups

Physical Volume (PV)
-Hard disk

Volume Group (VG)
-Collection of related disks (PVs)

SMIT Volume Groups Menu


# smit vg

Volume Groups
Move cursor to desired item and press Enter.

-List All Volume Groups
-Add a Volume Group
-Set Characteristics of a Volume Group
-List Contents of a Volume Group
-Remove a Volume Group
-Activate a Volume Group
-Deactivate a Volume Group
-Import a Volume Group
-Export a Volume Group
-Mirror a Volume Group
-Unmirror a Volume Group
-Synchronize LVM Mirrors
-Back Up a Volume Group
-Remake a Volume Group
-Preview Information about a Backup
-Verify the Readability of a Backup (Tape only)
-View the Backup Log
-List Files in a Volume Group Backup
-Restore Files in a Volume Group Backup

F1=Help F2=Refresh F3=Cancel F8=Image
F9=Shell F10=Exit Enter=Do

List All Volume Groups
# lsvg
rootvg
payrollvg
# lsvg -o
rootvg

List Volume Group Contents

# lsvg rootvg

VOLUME GROUP: rootvg VG IDENTIFIER: 000bc6fd00004c00000000e10fdd7f52
VG STATE: active PP SIZE: 16 megabyte(s)
VG PERMISSION: read/write TOTAL PPs: 1084 (17344 megabytes)
MAX LVs: 256 FREE PPs: 1032 (16512 megabytes)
LVs: 11 USED PPs: 52 (832 megabytes)
OPEN LVs: 10 QUORUM: 2
TOTAL PVs: 2 VG DESCRIPTORS: 3
STALE PVs: 0 STALE PPs: 0
ACTIVE PVs: 2 AUTO ON: yes
MAX PPs per VG: 32512
MAX PPs per PV: 1016 MAX PVs: 32
LTG size (Dynamic): 256 kilobyte(s) AUTO SYNC: no
HOT SPARE: no BB POLICY: relocatable

List Volume Group Information (Physical Volumes)
# lsvg -p rootvg
rootvg:
PV_NAME PV STATE TOTAL PPs FREE PPs FREE DISTRIBUTION
hdisk0 active 159 52 24..00..00..00..28
hdisk1 active 159 78 32..02..00..12..32

List Volume Group Information (Logical Volumes)
# lsvg -l rootvg
rootvg:
LVNAME TYPE LPs PPs PVs LV STATE MOUNT POINT
hd6 paging 8 8 1 open/syncd N/A
hd5 boot 1 1 1 closed/syncd N/A
hd8 jfslog 1 1 1 open/syncd N/A
hd9var jfs 1 1 1 open/syncd /var
hd4 jfs 1 1 1 open/syncd /
hd2 jfs 77 77 1 open/syncd /usr
hd3 jfs 3 3 1 open/syncd /tmp
hd1 jfs 11 11 1 open/syncd /home
hd10opt jfs 2 2 1 open/syncd /opt
lv00 jfs2 1 2 2 open/syncd /home/john
lv01 jfs2 4 4 2 open/syncd /home/fred

AIX - Reduce Volume Group

Reduce VG
We can remove the VG using reducevg command, if we want remove testvg and testvg has one pv hdisk9


#lsvg –p testvg
Hdisk9

Now we will remove the pv from testvg
#reducevg –f testvg hdisk9

f- option is used to force reduce, you have data in pv hdisk9,
that time I will not any questions, directly it will remove the pv from testvg.
Suppose 2 PV’s available in testvg then one by one we can reduce the PV’s

AIX - Quorum - LVCB (Logical Volume control block)

LVCB (Logical Volume control block)

Logical volume control block (LVCB) contains important information about the
Logical volume, such as the number of the logical partitions or disk allocation
Policy. Its architecture and location on the disk depends on the type of the
Volume group it belongs to. For standard volume groups, the LVCB resides on
The first block of user data within the LV. For big volume groups there is
Additional LVCB information in VGDA on the disk. For scalable volume groups
All relevant logical volume control information is kept in the VGDA as part of
The LVCB information area and the LV entry area.


***************************************************************************************************************************
***************************************************************************************************************************

-- AIX - Quorum - VGDA (Volume Group Descriptor Area)


Volume group descriptor area (VGDA) is an area on the disk that contains
Information pertinent to the volume group that physical volume belongs to. It
Also includes information about properties and status of all physical and
Logical volumes that are part of the volume group. The information from VGDA
is used and updated by LVM commands. There is at least one VGDA per
Physical volume. Information from VGDAs of all disks that are part of the
Same volume group must de identical. VGDA internal architecture and location on the disk depends on the type of the volume group (original, big, or
Scalable).


**************************************************************************************************************************
***************************************************************************************************************************

-- VGSA (Volume Group Status Area)


Volume group status area (VGSA) is used to describe the state of all physical
Partitions from all physical volumes within a volume group. The VGSA
indicates if a physical partition contains accurate or stale information. VGSA
Is used for monitoring and maintained data copies synchronization. The
VGSA is essentially a bitmap and its architecture and location on the disk
Depends on the type of the volume group.

AIX - Quorum

The following commands change the quorum for the volume group testvg. This
Attribute determines if the volume group will be varied off or not after losing the
Simple majority of its physical volumes.


To turn off the quorum use the command:
#chvg -Qn testvg


To turn on the quorum use the command:
# chvg -Qy testvg


Quorum is used for data integrity. When we activate quorum in VG it will recover 51% of data in VG
If we have DATAVG, This DATAVG has two PV’s hdisk1, hdisk2.
First PV hdisk1 has 2 * VGDA and 1 *VGSA
Second PV hdisk2 has 1* VGDA and 1*VGSA
Each VGDA has 33% of data, so hdisk1 has 2 VGDA, it will protect 66% of data and Second PV hdisk2 has 1 VGDA, it will protect only 33% data.

AIX - LVM - VarryOn Volume Group

Varryon VG
This is just for VG activation; some times clients want to deactivate VG for project restriction.
After that we want to activate the VG for further data access
Suppose we want to activate testvg, then your command will be

#lsvg
Rootvg
Datavg
Testvg

The above command shows what are VG’s available

#lsvg –o
Rootvg
Datavg

The above commands shows only online VG’s because testvg is offline so we have to activate testvg

#varryonvg testvg

#lsvg –o
Rootvg
Datavg
Testvg


Now above command is display the testvg.

AIX - Varryoff VG

This is just for VG deactivation; some clients want to deactivate VG for project Restriction.
Suppose customer want deactivate testvg then your command will be

#lsvg –o
Rootvg
Datavg
Testvg

#Varryoff testvg
#lsvg –o
Rootvg
Datavg


The above command display only two online VG’s and it will not show testvg because testvg is offline VG

AIX - LVM - Unmirror Volume Group

Using Unmirror command we can Unmirror the VG
#unmirrorvg rootvg hdisk1

PV hdisk1 is removed from rootvg mirror.

AIX - LVM - Synchronize Volume Group

Using Syncvg command we can sync the mirrored Vg and LV copy information’s
If we want to sync lvcopy
#syncvg –l lvname
#syncvg –l testlv


After executing the above command, testlv copy get sync with lv copied PV
If we want to sync mirrored PV’s
#syncvg –v rootvg


The above sync the mirrored PV’s in rootvg

AIX - LVM - Repair File System

Using fsck command we can repair the problematic FS or corrupted FS
If you want check /data FS
#fsck /data


Or directly we can repair the LV
#fsck –Y n /dev/datalv (To fsck the FS associated to /dev/datalv assuming response “Yes”
#fsck –p /dev/datalv (To restore superblock from backup superblock)

AIX - LVM - Remove Logical Volume

If we want to LV testlv from server
#rmlv testlv (If data is available in testlv It will ask confirmation)
#rmlv –f testlv (It won’t ask any confirmation, directly it will delete the data)


After executing the above command testlv removed from the server.

AIX - LVM - Remove File System

Remove FS
Using rmfs command we can remove the file systems
#lsfs –a
/testfs


Before removing the /testfs. That file system should be unmounted.
#umount /testfs
#rmfs /testfs (Deletes FS /newfs and associated LV)


After executing the above command /testfs is removed.
#rmfs –r /testfs (Deletes FS /newfs its mount point and associated LV)

AIX - LVM - Mount File System

After creating the file system, we should mount the file system, without file system mount
we cannot access the file system using mount command we can mount the file system.
Before mount lsfs command is wont display the /newfs file system
#lsfs –a


That /newfs file system detail is not available
#mount /newfs


Now you execute lsfs command, it will show the /newfs details
#lsfs –a

AIX - LVM - Mirror Volume Group

We can do mirroring in AIX, using mirrorvg command and we can create max of three copy of mirror.
If we have two PV’s in rootvg, now we want mirror, Data and OS installed in hdisk0 and now we want to mirror hdisk0 to hdisk1. Then your command will be

#mirrorvg –S –m rootvg hdisk1

S – Backgroup mirror
-m - exact (force) mirror

NOTE: in mirrored VG quorum should be off line because quorum is not recommended for mirror.

AIX - LVM - Migrate Logical Volume

Using migratepv command we can migrate lv from PV to PV
If we want to migrate single LV

#migratepv –l testlv hdisk1 hdisk2
After executing above command testlv LV is moved hdisk2.


Using migratepv command we can move full PV data or single LV from one PV to another PV. This is not copy just cut and past method
If we want to migrate data from PV to PV

#migratepv hdisk1 hdisk2
After executing above command hdisk1 data is moved to hdisk2.

AIX - List LV

Suppose we want see what are the Lv’s available in datavg, then your command will be
#lsvg –l datavg

It will login list LV details
newlv
Now we want see newlv properties, then your command will be
#lslv newlv


The above command is used to display the newlv properties, i.e. available pp’s mount pint, label name, stale partitions. Etc.
#lslv –m newlv – To display the lvcopy information’s

IBM - AIX - List File System

We can list file system details using lsfs command

#lsfs        :  List all filesystems in the /etc/filesystems entry
#lsfs –q     :  List all filesystems with detailed info
#lsfs –a     :  list all filesystems (default)
#lsfs –l     :  specify the output in the list format
#lsfs –c     :  specify the output in the column format
#lsfs –v jfs :  List all jfs filesystems

AIX - LVM - Import Volume Group

Using importvg command we can import the DATAVG to ServerB

First you should connect hdisk3, hdisk4, in ServerB then, run the
#cfgmgr (for hard disk detection)


Then check the PV’s installed or not using lspv command
#lspv (it will display the installed PV’s) if hdisk3, hdisk4 is available then PV’s are configured properly.


Then run the command importvg for import the DATAVG
#importvg –y DATAVG hdisk3 (VG information is added in ODM)
#importvg –y DATAVG hdisk4 (VG information is added in ODM)


NOTE:

If ServerB has VG with same name DATAVG, This case we can rename the importing VG DATAVG to other name,
#importvg –y NEWDATAVG hdisk3
#importvg –y NEWDATAVG hdisk4

Like this we can import.
After importing the DATAVG, we no need to Varryon DATAVG, automatically it will Varryon while importing.

AIX - LVM - Extend Logical Volume

If we want to increase LV size using extendlv command
#lslv newlv

The above command shows LV size, no of LP’s and some other information about LV,
suppose LV has 10 LP’s and usage is up to 95% full, that time we can increase the LV size online by adding no of LP’s in newlv i.e.
#extendlv newlv 5


After executing the above command 5 PP’s added with newlv, then some additional space will available in newlv.
Suppose you want to see this changes again use the lslv command
#lslv newlv (it will show no of LV’s is 15 and some additional space)

AIX - LVM - Export Volume Group

Using exportvg command we can export VG (including all the PV’s) from one server to another server.
If you have ServerA, in this server has DATAVG with two PV’s. Now we want export DATAVG to ServerB
Before exporting the DATAVG, we should Varryoff the DATAVG, i.e. DATAVG is moved to offline.

#varryoff DATAVG (Varryoff the DATAVG)
#exportvg DATAVG (VG information removed from ODM)


Now DATAVG is exported from the ServerA, after this run the following command to verify the export.
#lsvg


It won’t show DATAVG name. Because DATAVG is exported.
Then you should remove PV from the configuration

#rmdev –dl hdisk3
#rmdev –dl hdisk4


After that we can remove the PV’s from ServerA for import DATAVG to ServerB.

AIX - Create LV

All the File systems belongs to individual LV, after creating the VG’s we should create the LV using mklv command
Suppose you want to create LV name as newlv

#mklv –y newlv –t jfs2 datavg 5 hdisk4

-y for confirmation
-t type mentioning the filesystem type i.e. jfs or jfs2,
Datavg – lv created on datavg
5 – 5 PP’s allocated for newlv ( 1 pp size 32MB the newlv size is 32MB*5 = 160MB)
Hdisk4 – that newlv is belongs to PV hdisk4

AIX - Create LV copy

We can create LV content copy to another PV, after this same LV content is available in Lvcopy configured PV.

#lspv
Hdisk0
Hdisk1
Hdisk2

#lspv –l hdisk1

Assume testlv available in hdisk1, now we will make testlv copy to hdisk2, using
After this testlv data available in both PV, hdisk1 and hdisk2, If hdisk1 is fail, we can recover testlv data from hdisk2

#mklvcopy testlv 2 hdisk2

Testlv –lv name
2- No of copies, (we can make 3 copies also; this case you put 3 and mention hdisk0 then third copy will be available in hdisk0)

##mklvcopy testlv 3 hdisk0 ( It will make third lvcopy on hdisk0)

After executing above command testlv is copied to hdisk2
If you want to confirm, execute the following command

#lslv –m testlv (it will show lvcopy details for testlv)
Hdiks1 hdisk2 hdisk0
Testlv (copy1) testlv (copy2) testlv (copy3)

AIX - LVM - Create File System

Create FS
Using crfs command we can create a file system. File systems belongs to LV’s
Whenever we create the file system we should mention the LV name
#crfs –v jfs2 –d testlv –m /newfs (Normal creation)


The /newfs file system created on testlv.
#crfs –v jfs2 –g testvg –a size=64465 –m /newfs (Directly we can create /fs from VG

This case lv name will be lv00 or lv01 like this after that also we can rename the lv name)

AIX - LVM - Change Logical Volume

In this change LV option we can change LV name and permissions for the LV using chlv command.
#chlv –n newlvname oldlvname
#lslv testlv


Output is some details about testlv
#chlv –n newlv testlv

After executing the above command the testlv renamed to newlv
#lslv testlv
Some error message will come i.e. testlv is not found
#lslv newlv

It will show newlv details, because testlv is renamed as newlv.


Changing the LV permissions: If we want to change LV permissions to read only then the command will be
#chlv –p r testlv

After executing the above command testlv permissions changed as read only , so we can only read the LV, we can not copy new files into this LV.

AIX - LVM - Change File System

Using chfs command we can rename and increase the size of the file system online
We want to increase file system size
#chfs –a size=+block size /filesystem name
#chfs –a size=+32m /filesystem name
#chfs-a size=+4g /filesystem name


+block size – We can mention the size using blocks (2048 blocks = 1MB)
+32m – We can mention the size using MB
+4g – We can mention the size using GB


After increasing the file system size, we can verify using commands

#df –k
#ls –q /newfs


#lsfs /newfs
It will display /newfs details


Now we want to rename /newfs to /testfs then your command will be
#chfs –m /testfs /newfs


After executing the above command /newfs renamed as /testfs
We can auto mount the file system while booting using chfs command
#chfs –A /testfs

AIX - List Volume Group

We can list VG information using following commands

#lsvg                   :  It will display the available vg’s
#lsvg datavg        :  It will display full details about datavg only
#lsvg –o              :  It will display the online vg’s
#lsvg – l datavg   :  It will display the all logical volume details across the datavg
#lsvg –p datavg   :  It will display the information about all PV’s in datavg

AIX - Create Voulme Group

We can create VG by using mkvg commands
#mkvg –s 32 –y datavg hdisk4

The above command is creating datavg using pv hdisk4 and pp size is 32MB

#mkvg datavg hdisk4