Sunday, February 12, 2012

AIX LVM Concepts and Configuration


Disk storage management – By Senthilkumar

6.1 Storage management concepts :

The fundamental concepts used by LVM are physical volumes, volume groups, physical  partitions, logical volumes, logical partitions, file systems, and raw devices. Some of their characteristics are presented as follows:


·         Each individual disk drive is a named physical volume (PV) and has a name such as hdisk0 or hdisk1.
·         One or more PVs can make up a volume group (VG). A physical volume can belong to a maximum of one VG.

·         You cannot assign a fraction of a PV to one VG. A physical volume is assigned entirely to a volume group.

·         Physical volumes can be assigned to the same volume group even though they are of different types, such as SCSI or SSA.

·         Storage space from physical volumes is divided into physical partitions (PPs). The size of the physical partitions is identical on all disks belonging to the same VG.

·         Within each volume group, one or more logical volumes (LVs) can be defined. Data stored on logical volumes appears to be contiguous from the user point of view, but can be spread on different physical volumes from the same volume group.


·         Logical volumes consist of one or more logical partitions (LPs). Each logical partition has at least one corresponding physical partition. A logical partition and a physical partition always have the same size. You can have up to three copies of the data located on different physical partitions. Usually, physical partitions storing identical data are located on different physical disks for redundancy purposes.

·         Data from a logical volume can be stored in an organized manner, having the form of files located in directories. This structured and hierarchical form of organization is named a file system.


·         Data from a logical volume can also be seen as a sequential string of bytes. This type of logical volumes are named raw logical volumes. It is the responsibility of the application that uses this data to access and interpret it correctly.

·         The volume group descriptor area (VGDA) is an area on the disk that contains information pertinent to the volume group that the physical volume belongs to. It also includes information about the 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 be identical. The VGDA internal architecture and Chapter 6. Disk storage management 213 location on the disk depends on the type of the volume group (original, big, or scalable).

·         The 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.

·         A 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 isk 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 formation 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.



Note: The layout of the hard disk drives is defined by the /usr/include/sys/hd_psn.h header file. The LVM records starts at sector 7 on the disk. All LVM record structures are defined in the /usr/include/lvmrec.h
header file



6.1.1 Limitations of logical volume storage :

The LVM layer for AIX 5L Version 5.3 provides an increased level of flexibility in disk management


VG Type
Maximum PVs
Maximum
LVs
Maximum PPs
per VG
Maximum PP
size
Normal VG
32
256
256 32512
(1016*32)
1 GB
Big VG
128
512
130048
(1016*128
1 GB
Scalable VG
1024
4096
2097152
128 GB


6.2 Physical volumes :

When a disk drive is initially added to the system, it is seen a simple device. The disk is not yet accessible for LVM operations. To be made accessible, it has to be assigned to a volume group, which means changing from a disk to a physical volume. For each disk, two device drivers will be created under the /dev directory: one block device driver and one character device driver. The disk drive is assigned an 32-bit unique identifier that is  called a physical volume identifier (PVID).

The lspv command, used without any parameters, displays all physical volumes, their PVIDs, the volume groups whom the PVs belong to, and the status of volume groups, as shown in Example 6-1.



# lspv
hdisk0                      00c478de09a40b16         rootvg          active
hdisk1                      00c478de09caf163          rootvg          active
hdisk2                      00c478de09caf37f           None
hdisk3                      00c478de49630c6a          None
hdisk4                      00c478de00655246          None
hdisk5                      00c478de008a399b         None
hdisk6                     00c478de008a3ba1           None




6.2.1 PVID :

When the PVID is generated, the system uses its own serial number and a time stamp to ensure that two disks would never have the same PVID.

  • The PVIDs are stored also in ODM. They are used by LVM commands and possibly referenced by external applications such as HACMP.

  • The following command changes an available disk device to a physical volume by assigning a PVID, if it does not already have one:
# chdev -l hdisk7 -a pv=yes

  • This command has no effect if the disk is already a physical volume.

  • The following commands clears the PVID from the physical volume:

 # chdev -l hdisk7 -a pv=clear

Note: You can list the PVID of a disk using intermediate level commands, such as lquerypv, as follows:

# lquerypv -h /dev/hdisk2 80 10

00000080 00C478DE 09CAF37F 00000000 00000000 |..x.............|


6.2.2 Listing information about physical volumes :

You can use the lspv command and pass the name of the physical volume as a parameter in order to find more details about a physical volume.


# lspv hdisk2

PHYSICAL VOLUME:       hdisk2                                     VOLUME GROUP: testvg
PV IDENTIFIER:             00c478de09caf37f VG IDENTIFIER
00c478de00004c00000001078fc3497d
PV STATE:                    active
STALE PARTITIONS: 0 ALLOCATABLE:                                 yes
PP SIZE:                     128 megabyte(s)                             LOGICAL VOLUMES: 1
TOTAL PPs:               546 (69888 megabytes)                    VG DESCRIPTORS: 2
FREE PPs:                  542 (69376 megabytes)                   HOT SPARE: no
USED PPs:                  4 (512 megabytes)                         MAX REQUEST: 256 kilobytes
FREE DISTRIBUTION: 110..105..109..109..109
USED DISTRIBUTION: 00..04..00..00..00



The lspv command can be used with the -l flag to display the names of all the logical volumes that have at least one partition located on the physical volume, the total number of partitions located on that physical volume, the total number of PPs that correspond to the LPs, the distribution of PPs corresponding to each
intra-physical disk area, the mounting point of the logical volume, if it exists. An example of the output  obtained when running this command is presented in


# lspv -l hdisk0
hdisk0:
LV NAME        LPs     PPs     DISTRIBUTION                   MOUNT POINT
hd3               1         1        00..00..01..00..00           /tmp
hd10opt         1        1        00..00..01..00..00           /opt
hd5                 1        1        01..00..00..00..00          N/A
hd8                  1       1         00..00..01..00..00         N/A


If you want to display the number, location of partitions, and the logical volumes they correspond to, use the lspv -p command.


# lspv -p hdisk0

hdisk0:
PP               RANGE    STATE   REGION   LV NAME  TYPE  MOUNT POINT
1-1              used        outer   edge           hd5         boot       N/A
2-110          free          outer   edge



You can make a detailed map of the disk layout and display the relationship between each physical and logical partition by using the lspv -M command,

# lspv -M hdisk0|more
hdisk0:1    hd5:1
hdisk0:2-110

hdisk0:111 lv1:1:1
hdisk0:112 lv1:2:1
hdisk0:113 lv1:3:1
hdisk0:114 lv1:4:1



6.2.3 Changing the allocation permission for a physical volume :

The allocation permission for a physical volume determines if physical partitions located on that physical volume, which have not been allocated to a logical volume yet, can be allocated to logical volumes. The operation of logical volumes that reside on that physical volume is not affected.

In Example 6-6, we disabled the ability to allocate new free physical partitions from hdisk2 to any logical volume. We tried to create a logical volume that would use PPs from hdisk2 and received an error message stating that partitions from that physical volume were not allocatable.

# chpv -an hdisk2
# lspv hdisk2
PHYSICAL VOLUME: hdisk2 VOLUME GROUP: testvg
PV IDENTIFIER: 00c478de09caf37f VG IDENTIFIER
00c478de00004c00000001078fc3497d
PV STATE: active
STALE PARTITIONS: 0 ALLOCATABLE: no
PP SIZE: 128 megabyte(s) LOGICAL VOLUMES: 1
TOTAL PPs: 546 (69888 megabytes) VG DESCRIPTORS: 2
FREE PPs: 542 (69376 megabytes) HOT SPARE: no
USED PPs: 4 (512 megabytes) MAX REQUEST: 256 kilobytes
FREE DISTRIBUTION: 110..105..109..109..109
USED DISTRIBUTION: 00..04..00..00..00
# mklv -y test -t jfs2 testvg 10 hdisk2
0516-823 lquerypv: Physical Volume hdisk2 is not allocatable.
0516-848 lquerypv: Failure on physical volume hdisk2, it may be missing
or removed.
0516-822 mklv: Unable to create logical volume


To turn on the allocation permission, use the following command:

# chpv -ay hdisk2


6.2.4 Changing the availability of a physical volume :

The availability of a physical volume defines whether any logical input/output operations can be performed to the specified physical volume. VGDA and VGSA copies on the physical volume will not be taken into account for any subsequent LVM operations. Also, information regarding the physical volume will be removed from the VGDAs of the other physical volumes within the volume group. The physical volume will be marked as removed.
  • The lsvg testvg command shows that the VG is active, contains two PVs, both PVs are active, and the VG has three VGDAs.
  • The lsvg -p testvg command shows that testvg contains disks hdisk2 and hdisk3, and both are active.
  • lspv hdisk3 shows that hdisk3 is active and has two VGDAs.
  • lspv hdisk2 shows that hdisk2 is active and has one VGDA.
  • chpv -vr hdisk3 makes hdisk3 unavailable.
  • lspv hdisk3 confirms that hdisk3 is removed and does not have any VGDAs on it.
  • lspv hdisk2 confirms that hdisk2 is active and now contains two VGDAs, because any volume group must contain at least one VGDA.
  • lsvg -p testvg shows that hdisk3 has been removed.
  • lsvg testvg shows that the volume group is still active, one PV of two is active, and the total number of VGDAs has been changed to two.
  • chpv -va hdisk3 makes hdisk3 available again.
  • lspv hdisk3 shows that hdisk3 is active and contains only one VGDA.
  • lsvg -p testvg confirms that both disks are now active.


6.2.5 Cleaning the boot record from a physical volume :

To clear the boot record located on physical volume hdisk1, use the command:

# chpv -c hdisk1

6.2.6 Declaring a physical volume hot spare :

You can use the chpv command to define a physical volume as a hot spare. This command also disables the allocation permission for the physical volume. The disk size has to be at least equal with the size of the smallest disk already existing in the volume group.

To define hdisk3 as a hot spare, use the command:
# chpv -hy hdisk3

To remove hdisk3 from the hot spare pool of its volume group, use the command:
# chpv -hn hdisk3


6.2.7 Migrating data from physical volumes :

Physical partitions located on a physical volume can be moved to one or more physical volumes contained in the same volume. In Example 6-8, we offer an example of migrating data from a physical volume as follows:

  • lsvg -p rootvg displays all PVs that are contained in rootvg.
  • lsvg -M hdisk1 displays the map of all physical partitions located on hdisk1.
  • lspv -M hdisk5 shows that all partitions of hdisk5 are not allocated.
  • migratepv hdisk1 hdisk5 migrates the data from hdisk1 to hdisk5.
  • lspv -M hdisk1 confirms that hdisk1 has all partitions free.
  • chpv -c hdisk1 clears the boot record from hdisk1.
  • lspv -M hdisk5 confirms that all physical partitions have been migrated to hdisk5.


If you migrate data from a physical volume that contains a boot image, you should also update the boot list.

It is possible to migrate only data from partitions that belong to a specific logical volume. To migrate only  physical partitions that belong to logical volume testlv from hdisk1 to hdisk5, use the command:

# migratepv -l testlv hdisk1 hdisk5





6.2.8 Migrating partitions :

You can move data from one partition located on a physical disk to another physical partition on a different disk.

In Example 6-9 on page 225, we offer an example of migrating data from a physical partition to another as follows:

·         lspv -M hdisk1 displays the map of all physical partitions located on hdisk1. Note that the second copy of the logical partition number 1 of logical volume testlv resides on physical partition 115.

·         lspv -M hdisk5 shows that all partitions of hdisk5 are not allocated.
·         migratelp testlv/1/2 hdisk5/123 migrates the data from the second copy of the logical partition  number 1 of logical volume to hdisk5 on physical partition 123.
·         lsvg -M hdisk1 displays the map of all physical partitions located on hdisk1.Note that physical partition 115 is free.
·         lspv -M hdisk5 confirms that the second copy of the logical partition number 1 of logical volume testlv now resides on physical partition 123 of hdisk5.

6.2.9 Finding the LTG size :


Logical track group (LTG) size is the maximum allowed transfer size for an I/O disk operation.

You can use the lquerypv command to find the LTG size for a physical disk, as shown in Example 6-10. A disk can support multiple LTG sizes, which are discovered using an ioctl call.

# lquerypv -M hdisk0
256


6.3 Volume groups :

When the operating system is installed, one volume group named rootvg is created by default. Additional volume groups can be created on the system using one or more physical volumes that have not been allocated to other volume groups yet and are in an available state. All physical volumes will be divided in physical partitions having the same size. The size of the physical partitions cannot be changed after the volume group is created.

This section discusses the operations that can be performed on volume groups.


6.3.1 Creating a volume group :

You can use the mkvg command to create volume groups. Each volume group is assigned an volume group identifier (VGID) that will be used internally by LVM commands. For each volume group, two device driver files are created under directory /dev, as shown in Example 6-11. Both files will have the major device
number equal to the major number of the volume group.


# lsvg
rootvg
testvg
vg1
vg2
# cd /dev
# ls -l|grep vg
crw-rw---- 1 root system 10, 0 Nov 10 11:35 IPL_rootvg
crw------- 1 root system 10, 0 Nov 15 19:08 __vg10
crw------- 1 root system 100, 0 Nov 16 10:24 __vg100
crw------- 1 root system 46, 0 Nov 15 18:48 __

For each volume group varied on, there is a file under /etc/vg having the name identical to the VGID, as shown in Example 6-12.

# lsvg -o
vg1
testvg
rootvg
# cd /etc/vg
# ls -l
total 0
-rw-r--r-- 1 root system 0 Nov 15 16:15
vg00C478DE00004C00000001077B1E974A
-rw-rw---- 1 root system 0 Nov 15 15:49
vg00C478DE00004C00000001078FC3497D
-rw-rw---- 1 root system 0 Nov 16 10:37
vg00C478DE00004C000000010799E10D8E
# lsvg rootvg |grep -i identifier
VOLUME GROUP: rootvg VG IDENTIFIER:
00c478de00004c00000001077b1e974a
# lsvg testvg |grep -i identifier
VOLUME GROUP: testvg VG IDENTIFIER:
00c478de00004c00000001078fc3497d
# lsvg vg1 |grep -i identifier
VOLUME GROUP: vg1 VG IDENTIFIER:
00c478de00004c000000010799e10d8e


we use the mkvg command to create an original volume group named vg1, with a physical partition size of 64 MB, having major number 99 and using the physical volumes hdisk4.

# mkvg -y vg1 -s64 -V99 hdisk4
vg1


6.3.2 Listing information about volume groups :

The lsvg command displays information about the volume groups currently known to the system.

# lsvg
rootvg
dumpvg
test2vg
test1vg

we use the lsvg -o command to display all volume groups that are varied on
# lsvg -o
test1vg
dumpvg
rootvg


6.3.3 Changing volume group characteristics :

Auto varyon flag
The following command changes the volume group testvg to be activated automatically the next time the system is restarted:
# chvg -ay newvg
The following command changes the volume group testvg to not be activated automatically next time the system is restarted:
# chvg -an newvg

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 testv

6.3.2 Listing information about volume groups :

The lsvg command displays information about the volume groups currently known to the system.

In Example 6-18, we use the lsvg command to display all volume groups that are known to the system, either varied on or not.

# lsvg
rootvg
dumpvg
test2vg
test1vg


6.3.3 Changing volume group characteristics :

The following section discusses the tasks required to modify a volume group’s characteristics. Auto varyon flag

The following command changes the volume group testvg to be activated  automatically the next time the system is restarted:
# chvg -ay newvg

The following command changes the volume group testvg to not be activated automatically next time the system is restarted:
# chvg -an newvg

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 testv















***********************For Technical Review*******************


LVM (Logical Volume Manager)


In AIX first Physical volumes (PV) are added into volume group(VG), After that only we can create logical volumes, and file systems.

Minimum one PV is belongs to VG, While creating the VG we should mention physical partition (pp) size, this pp’s pointed to logical portions (LP),

Suppose we have 40GB HDD, we have added in one VG named DataVG , While creating the VG we should mention the pp size, i.e.

PP size will be 4MB to 128MB, suppose we are mentioned pp size is 32MB, then that 40GB HDD divided into


1024MB *40 = 40960MB

Each pp size is 32MB, then 40GB HDD spited into i.e.

40960 / 32 = 1280 PP’s

So DATAVG has 1280 PP’s

While creating the Logical volumes we should mention the lv size by giving the no of pp

Suppose you want to create one file system /userdata, that file system size will be 1GB, this file system is belongs to one particular LV, So while creating the LV we should mention the lv size is 1GB, but directly we cannot mention the GB size.

Each pp has 32MB, So you create LV with 315 PP’s, then that lv size will be 1GB.

After creating the LV using 1GB space we can increase LV size online, reboot is not required.

This LVM we can do following things,

  1. List PV
  2. Change PV
  3. Create VG
  4. List VG
  5. Extend VG
  6. Reduce VG
  7. Varryon VG
  8. Varryoff VG
  9. Create LV
  10. List LV
  11. Extend LV
  12. Change LV
  13. Create LV copy
  14. Remove LV copy
  15. Remove LV
  16. Create FS
  17. Change FS
  18. List Fs
  19. Mount FS
  20. Unmount FS
  21. Remove FS
  22. Repair FS
  23. Mirror VG
  24. Syncvg
  25. Unmirror VG
  26. Migrate PV
  27. Migrate LV
  28. Export VG
  29. Import VG
  30. Change VG

NOTE:
After AIX installation by default root volume group (rootvg) will be available


1. List Physical Volumes :

Suppose we want to know how many PV’s available in server, The following command is list the Pv’s

#lspv

Hdisk0
Hdisk1
Hdisk2.


Suppose you want to see particular PV information then your command will be

#lspv hdisk1

After executing lspv command it will display the hdisk2 PV information. All the information, like pp size, used pp’s, free pp, allocatable, hotspare etc.

Suppose we want to see logical volumes details in single hdisk2 PV Then your command will be

#lspv –l hdisk2

The above command is used to display all the LV details across the PV hdisk2

Suppose we want to see pp storage information in hdisk2, then your command will be

#lspv –p hdisk2

The above command is display the pp usage information across the PV hdisk2


2. Change PV :

Suppose 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)

Above operations we can do by using chpv command






3. Create VG, :

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

The above command is creating datavg using pv hdisk4 and pp size is by default 128MB

4. List VG :

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

Above operations we can do by using lsvg commands


5. Extend VG :

We can increase VG size by adding Pv into existing VG using 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
#


6. Reduce VG :

We can remove the VG using reducevg command, Suppose 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


7. 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.

8. 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.

9. 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


10. 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


11. Extend LV :

Suppose 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)



12. Change LV :

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: suppose 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.


13. 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, suppose 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 run the following command

#lslv –m testlv (it will show lvcopy details for testlv)

Hdiks1   hdisk2               hdisk0

Testlv (copy1)    testlv (copy2)     testlv (copy3)

14. Remove LV copy :

Using rmlvcopy we can remove the lvcopy from the PV’s

Suppose 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


15. Remove LV :

Suppose 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. 








16. 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)


17. Change FS :

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

Rename the file system using chfs command

#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


18. List Fs :

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)


19. Mount FS :

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 put lsfs command it will show the /newfs details

#lsfs –a




20. 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


21. 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)


22. Repair FS :

Using fsck command we can repair the problematic FS or corrupted FS

Suppose 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)



23. Mirror VG :

We can do mirroring in AIX, using mirrorvg command and we can create max. Three copy of mirror.

Suppose 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.


24. Synchronize VG :

Using Syncvg command we can sync the mirrored Vg and LV copy information’s

Suppose we want to sync lvcopy

#syncvg –l lvname

#syncvg –l testlv

After executing the above command, testlv copy get sync with lv copied PV

Suppose we want to sync mirrored PV’s

#syncvg –v rootvg

The above sync the mirrored PV’s in rootvg


25. Unmirror VG :

Using Unmirror command we can Unmirror the VG

#unmirrorvg rootvg hdisk1

PV hdisk1 is removed from rootvg mirror


26. Migrate PV :

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

Suppose we want to migrate data from PV to PV

#migratepv hdisk1 hdisk2

After executing above command hdisk1 data is moved to hdisk2


27. Migrate LV :

Using migratepv command we can migrate lv from PV to PV

Suppose we want to migrate single LV

#migratepv –l testlv hdisk1 hdisk2

After executing above command testlv LV is moved hdisk2.


28. Export VG :

Using exportvg command we can export VG (including all the PV’s) from one server to another server.

Suppose 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


29. Import VG :

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:

Suppose 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.




30. Change VG :

Using chvg command we can change the VG options

#chvg –a y datavg (datavg is automatically activated at startup)
#chvg -a n datavg (To deactivate the automatic activation at startup)
#chvg –t 2 datavg (To change max. no of PP to 2032 on vg datavg)
#chvg –Qn datavg (To disable quorum on VG datavg)
#chvg –Qy datavg (To activate quorum on VG datavg)
#chvg –u datavg (To unlock the VG)

NOTE:

Quorum, VGDA, VGSA, LVCB

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.

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.

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.

No comments:

Post a Comment