|
» |
|
|
|
The section addresses the following topics: Initializing a Disk for LVM Use | |
| | | | | CAUTION: Initializing a disk using pvcreate results in the loss of any existing data currently on the disk. | | | | |
| | | | | NOTE: If your disk is already connected to the system,
skip the first four steps of this procedure. | | | | |
To initialize a disk for use as a physical volume,
follow these steps: Shut
down and power off the system. Connect
the disk to the system and power supply. For detailed information
and instructions on adding a particular type of disk, see your device
documentation. Power
on the disk. Boot
the system. Determine
the disk's associated device file. To show the disks attached
to the system and their device file names, enter the ioscan command with the -f, -N, and -n options. For example: # ioscan -f -n -N -C disk |
For more information, see ioscan(1M). Initialize
the disk as a physical volume using the pvcreate command. For example: # pvcreate /dev/rdisk/disk3 |
Use the
character device file for the disk. If you
are initializing a disk for use as a boot device, add the -B option to pvcreate to reserve an area
on the disk for a LIF volume and boot utilities. If you are creating
a boot disk on an HP Integrity server, make sure the device file specifies
the HP-UX partition number (2). For example: # pvcreate -B /dev/rdisk/disk3_p2 |
| | | | | NOTE: Version 2.x volume groups do not support bootable
physical volumes. Do not use the -B option if the
disk will be used in a Version 2.x volume group. | | | | |
After a disk is initialized, it is called a physical
volume. Creating a Volume Group | |
To create a volume group, use the vgcreate command. The options differ depending on whether you are creating
a Version 1.0 volume group or a Version 2.x volume group. Creating the Volume Group Device FileAs of the March 2008 release of HP-UX 11i Version
3, the vgcreate command automatically creates the
device file /dev/vgname/group to manage the volume group, regardless of the volume group version.
If you are using an HP-UX release before March 2008, or if you want
to specify the minor number of the group file, you must create /dev/vgname/group before running
the vgcreate command. If the group file does not exist and vgcreate can not create it, vgcreate displays the following message: vgcreate: "/dev/vgname/group": not a character device. |
To create the volume group device file, follow
these steps: Create a directory for the
volume group. For example: By convention, vgname is vgnn, where nn is a unique number across all volume groups. However,
you can choose any unique name up to 255 characters. Create a device file named group in the volume group directory with the mknod command. For example: # mknod /dev/vgname/group c major 0xminor |
The c following the device file
name specifies that group is a character device
file. major is the major number for the group device file.
For a Version 1.0 volume group, it is 64. For a Version 2.x volume
group, it is 128. minor is
the minor number for the group file in hexadecimal.
For a Version 1.0 volume group, minor has
the form 0xnn0000, where nn is a unique number across all Version 1.0 volume
groups. For a Version 2.x volume group, minor has the form 0xnnn000, where nnn is a unique number across
all Version 2.x volume groups. For more information on mknod, see mknod(1M); for more information on major numbers
and minor numbers, see “Device Number Format”.
Creating a Version 1.0 Volume GroupTo create a Version 1.0 volume group, use the vgcreate command, specifying each physical volume to be
included. For example: # vgcreate /dev/vgname /dev/disk/disk3 |
Use the block device file to include each disk
in your volume group. You can assign all the physical volumes to the
volume group with one command, or create the volume group with a single
physical volume. No physical volume can already be part of an existing
volume group. You can set volume group attributes using the
following options: - -V 1.0
Version 1.0 volume group
(default) - -s pe_size
Size of a physical extent
in MB (default 4) - -e max_pe
Maximum number of physical
extents per physical volume (default 1016) - -l max_lv
Maximum number of logical
volumes (default 255) - -p max_pv
Maximum number of physical
volumes (default 255)
The size of a physical volume is limited by pe_size times max_pe. If
you plan to assign a disk larger than approximately 4 GB (1016 * 4
MB) to this volume group, use a larger value of pe_size or max_pe. The size of the LVM metadata on each disk depends
on max_lv, max_pv, and max_pe. If the vgcreate options would cause the metadata to exceed its available space, vgcreate does not create the volume group. You must select
new values of max_lv, max_pv, and max_pe. For example, if you plan
to use disks larger than 100 GB, consider reducing max_pv. For recommendations on choosing an optimal extent size, see Appendix C. Creating a Version 2.x Volume GroupFor Version 2.x volume groups, the vgcreate command does not require maximum values for the number of physical
volumes (-p), number of logical volumes (-l), or extents per physical volume (-e). Instead you must specify only the extent size (-s) and the maximum size to which the volume group can grow (-S). For example: # vgcreate -V 2.0 -s pe_size -S vg_size /dev/vgname /dev/disk/disk3 |
Use the block device file to include each disk
in your volume group. You can assign all the physical volumes to the
volume group with one command, or create the volume group with a single
physical volume. No physical volume can already be part of an existing
volume group. You must use the following options: - -V 2.0 or -V 2.1
Version 2.0 or Version
2.1 volume group - -s pe_size
Size of a physical extent
in MB - -S vg_size
Maximum future size of
the volume group The size of a volume group
is the sum of the user data space on all physical volumes assigned
to the volume group. vg_size is not the
size of the volume group at creation; it is the size to which the
volume group can grow in the future. This value can be specified in
megabytes, gigabytes, terabytes, or petabytes, by adding the character m, g, t, or p, respectively. For example, to specify a maximum size
of two terabytes, use -S 2t.
In a Version 2.x volume group, the number of physical
extents in a volume group has an architectural limit, so your choice
of physical extent size affects the maximum size of the volume group.
To display the maximum volume group size for a given physical extent
size, use the -E option to vgcreate with the -s option. For example: # vgcreate -V 2.0 -E -s 256
Max_VG_size=2p:extent_size=256m |
Conversely,
to display the minimum physical extent size for a given volume group
size, use the -E option to vgcreate with -S. For example: # vgcreate -V 2.0 -E -S 2t
Max_VG_size=2t:extent_size=1m |
Adding a Disk to a Volume Group | |
Often, as new disks are added to a system, they
must be added to an existing volume group rather than creating a whole
new volume group. If new disks are being added for user data, such
as file systems or databases, do not to add them to the root volume
group. Instead, leave the root volume group as only the disks containing
the root file system and system file systems such as /usr, /tmp, and so on. To add a disk to a volume group, follow these
steps: Initialize the disk as a physical
volume by using the pvcreate command, as described
in “Initializing a Disk for LVM Use”. Add the physical volume to
the volume group using the vgextend command and
the block device file for the disk. For example: # vgextend /dev/vgname /dev/disk/disk3 |
Removing a Disk from a Volume Group | |
To remove a disk from a volume group, follow these
steps: Make
sure the disk has no assigned physical extents, using the pvdisplay command. For example: # pvdisplay /dev/disk/disk3
-- Physical volumes --
PV Name /dev/disk/disk3
VG Name /dev/vg00
PV Status available
Allocatable yes
VGDA 2
Cur LV 9
PE Size (Mbytes) 4
Total PE 1023
Free PE 494
Allocated PE 529
Stale PE 0
IO Timeout (Seconds) default
Autoswitch On
Proactive Polling On
-- Distribution of physical volume --
LV Name LE of LV PE for LV
/dev/vg00/lvol1 25 25
/dev/vg00/lvol2 25 25
/dev/vg00/lvol3 50 50
--- Physical extents ---
PE Status LV LE
0000 current /dev/vg00/lvol1 0000
0001 current /dev/vg00/lvol1 0001
0002 current /dev/vg00/lvol1 0002
1021 free 0000
1022 free 0000
|
Check that the number of free physical extents
(Free PE) matches the total number
of physical extents (Total PE). If
they are not the same, do one of the following tasks:
Remove the logical volumes from the disk, as described
in “Removing a Logical Volume”. The
logical volumes with physical extents on the disk are shown at the
end of the pvdisplay listing.
After
the disk no longer holds any physical extents, use the vgreduce command to remove it from the volume group. For example: # vgreduce /dev/vgnn /dev/disk/disk3 |
Creating a Logical Volume | |
To create a logical volume, follow these steps: Decide
how much disk space the logical volume needs. For example, you can add 200 MB of device swap space, or you might
have a new project that you expect to grow to 10 GB. Find
a volume group that has adequate free space. To determine if there is sufficient disk space available for the
logical volume within a volume group, use the vgdisplay command to calculate this information. vgdisplay outputs data on one or more volume groups, including the physical
extent size (under PE Size (MBytes)) and the number of available physical extents (under Free PE). By multiplying these two figures, you
get the number of megabytes available within the volume group. For
more information, see vgdisplay(1M). Create
the logical volume using lvcreate. For example: # lvcreate -L size_in_MB /dev/vgnn |
This command creates the logical volume /dev/vgnn/lvoln with
LVM automatically assigning the n in lvoln.
When LVM creates the logical volume, it creates
block and character device files for that logical volume and places
them in the /dev/vgnn directory. Creating a Mirrored Logical VolumeTo create a mirrored logical volume, use lvcreate with the -m option to select
the number of mirror copies. To control how the mirror copies are
managed, choose from the following options: -
Strict, Nonstrict, or PVG-strict Extent Allocation - -s y
Strict allocation (default) - -s n
Nonstrict allocation - -s g
PVG-strict allocation -
Contiguous or Noncontiguous Extent Allocation - -C y
Contiguous allocation - -C n
Noncontiguous allocation
(default) -
Mirror Scheduling Policy - -d p
Parallel scheduling (default) - -d s
Sequential scheduling -
Mirror Consistency Policy - -M y
MWC enable (default, optimal
mirror resynchronization during crash recovery) - -M n -c y
MCR enable (full mirror
resynchronization during crash recovery) - -M n -c n
MCR disable (no mirror
resynchronization during crash recovery)
For example, to create a 240 MB mirrored logical
volume with one mirror copy, nonstrict allocation, parallel scheduling,
and no mirror resynchronization, enter the following command: # lvcreate -m 1 -s n -d p -M n -c n -L 240 -n lvol1 /dev/vg01 |
| | | | | TIP: To change the characteristics of an existing mirrored
logical volume, use the lvchange command. It supports
the -C, -c, -d, -M, and -s options. For more information,
see lvchange(1M). | | | | |
Extending a Logical Volume | |
Decide
how much more disk space the logical volume needs. For example, you can add 200 MB of swap space, or an
existing project might need an additional 1 GB. Find out if any space is available
using the vgdisplay command. For example: # vgdisplay vg00
--- Volume groups ---
VG Name /dev/vg00
VG Write Access read/write
VG Status available
Max LV 255
Cur LV 8
Open LV 8
Max PV 16
Cur PV 1
Act PV 1
Max PE per PV 2000
VGDA 2
PE Size (Mbytes) 4
Total PE 249
Alloc PE 170
Free PE 79
Total PVG 0
Total Spare PVs 0
Total Spare PVs in use 0
VG Version 1.0
VG Max Size 1082g
VG Max Extents 69248 |
The Free PE entry
indicates the number of 4 MB extents available, in this case, 79 (316
MB). Extend the logical volume.
For example: # lvextend -L 332 /dev/vg00/lvol7 |
This increases the size of this volume to 332
MB.
Extending a Logical Volume to a Specific DiskFor performance reasons, you can force a logical
volume to span disks. For example, if you want to create a 30 GB logical
volume and put 10 GB on the first disk, another 10 GB on the second
disk, and 10 GB on the third disk, then assuming that the extent size
is 4 MB, the logical volume requires a total of 7680 extents. To extend
the logical volume, follow these steps: After
making the disks physical volumes and creating your volume group,
create a logical volume named lvol1 of size 0.
For example: # lvcreate -n lvol1 /dev/vg01 |
Allocate
a third of the extents to the logical volume on the first physical
volume. For example: # lvextend -l 2560 /dev/vg01/lvol1 /dev/disk/disk7 |
Increase
the total number of physical extents allocated to the logical volume
for the remaining physical volumes by 2560. In each case, the additional
2560 extents are allocated to the disk specified. For example: # lvextend -l 5120 /dev/vg01/lvol1 /dev/disk/disk8
# lvextend -l 7680 /dev/vg01/lvol1 /dev/disk/disk9 |
When you use the -l option with lvextend, you specify space in logical extents.
For another example, you have two disks in a volume
group, both identical models. You currently have a 24 GB logical volume
that resides on only one of the disks. You want to extend the logical
volume size to 40 GB and ensure that the 16 GB increase is allocated
to the other disk. Extend the logical volume to a specific disk as
follows: # lvextend -L 40960 /dev/vg01/lvol2 /dev/disk/disk3 |
Here, when you use the -L option (uppercase), you
specify space in megabytes, not logical extents. For complete information on command options, see lvextend(1M). Reducing a Logical Volume | |
To reduce a logical volume, follow these steps: To find
out what applications are using the logical volume, use the fuser command. For example: # fuser -cu /dev/vg01/lvol5 |
If the logical volume is in use, ensure the underlying applications
can handle the size reduction. You might have to stop the applications. Decide
on the new size of the logical volume. For
example, if the logical volume is mounted to a file system, the new
size must be greater than the space the data in the file system currently
occupies. The bdf command shows the size of all
mounted volumes. The first column shows the space allocated to the
volume; the second shows how much is actually being used. The new
size of the logical volume must be larger than the size shown in the
second column of the bdf output. Reduce the size of the logical
volume as follows: # lvreduce -L 500 /dev/vg01/lvol5 |
This command reduces the logical volume/dev/vg01/lvol5 to 500 MB.
Removing a Mirror from a Logical Volume | |
To remove a mirror copy, use the lvreduce command, specifying the number of mirror copies you want to leave.
For example, to remove all mirrors of a logical volume, enter the
following command: # lvreduce -m 0 /dev/vg00/lvol1 |
This reduces the number of mirror copies to 0,
so only the original copy is left. To remove the mirror copy from a specific disk,
use lvreduce and specify the disk from which to
remove the mirror copy. For example: # lvreduce -m 0 /dev/vg00/lvol1 /dev/disk/disk4 |
Renaming a Logical Volume | |
To change the name of a logical volume, follow
these steps: Make sure that the logical
volume has two existing device files, a block device file and a character
or raw device file. They must have the same name, except that the
character device file name has a leading r. For
example, to rename a logical volume in volume group vg00 from lvol1 to database, list the contents of the /dev/vg00 directory.
For example: # cd /dev/vg00
# ls -l
total 0
crw-r----- 1 root sys 64 0x000000 Nov 16 02:49 group
brw-r----- 1 root sys 64 0x000001 Nov 16 02:49 lvol1
brw-r----- 1 root sys 64 0x000002 Nov 16 02:49 lvol2
brw-r----- 1 root sys 64 0x000003 Nov 16 02:49 lvol3
brw-r----- 1 root sys 64 0x000004 Nov 16 02:49 lvol4
crw-r----- 1 root sys 64 0x000001 Nov 16 02:49 rlvol1
crw-r----- 1 root sys 64 0x000002 Nov 16 02:49 rlvol2
crw-r----- 1 root sys 64 0x000003 Nov 16 02:49 rlvol3
crw-r----- 1 root sys 64 0x000004 Nov 16 02:49 rlvol4 |
Use the mv command to rename both files. For example: # mv /dev/vg00/lvol1 /dev/vg00/database
# mv /dev/vg00/rlvol1 /dev/vg00/rdatabase |
Update all references to the
old name in any other files on the system. These include /etc/fstab for mounted file systems or swap devices and
existing mapfiles from a vgexport command.
Exporting a Volume Group | |
Exporting a volume group removes all data concerning
the volume group from the system, while leaving the data on the disks
intact. The disks of an exported volume can be physically moved or
connected to another system, and the volume group can be imported
there. Exporting a volume group removes information
about the volume group and its associated physical volumes from /etc/lvmtab and /etc/lvmtab_p, and removes
the volume group's directory with device files in the /dev directory. Make
sure that none of the logical volumes in the volume group are in use.
You might need to stop applications using any logical volumes in the
volume group, and unmount file systems contained in the volume group. Use the fuser command on each
logical volume. For example: # fuser -cu /dev/vgnn/lvoln |
Deactivate the volume group.
For example: Use the vgexport command to export the volume group. For example: # vgexport -v -m /tmp/vgnn.map vgnn |
If you are planning to move the volume group to
another system, use the -m option to vgexport to create a mapfile. This ASCII file contains
the logical volume names because they are not stored on the disks.
You must create a mapfile if you do not use the default names /dev/vgnn/lvoln for the logical volumes in the volume group. If there are several disks in the volume group,
use the -s option with vgexport; this option adds the volume group identifier (VGID) to the mapfile.
When the volume group is imported, you can avoid specifying all the
disks by name. See “Importing a Volume Group”.
When vgexport completes, all
information about the volume group has been removed from the system.
The disks can now be moved to a different system, and the volume group
can be imported there. Importing a Volume Group | |
To import a volume group, follow these steps: Connect the disks to the system. If you are using an HP-UX
release before March 2008, or if you want to specify the minor number
of the volume group device file, create it using the procedure in “Creating the Volume Group Device File”. Use the vgimport command to import the volume group: # vgimport -v -N -m /tmp/vgnn.map /dev/vgnn list_of_disks |
If there are several disks in the volume group
and the VGID was saved in the mapfile (that is, the vgexport command was run with the –s and –m options), you can avoid specifying all of them
in the vgimport command line by using the -s option. This causes vgimport to scan
all the disks on the system. Any physical volumes with a VGID matching
the one in the mapfile are included automatically into the volume
group. Activate the volume group
as follows:
Modifying Volume Group Parameters | |
| | | | | NOTE: The vgmodify command does not
support Version 2.x volume groups. | | | | |
When you create a volume group, you set certain
characteristics of the volume group, such as the maximum number of
physical extents per physical volume, the maximum number of physical
volumes, and the maximum number of logical volumes. Using the vgmodify command, you can adjust these parameters without
removing and re-creating the volume group or having to move your data. Use the following procedure to adjust these volume
group parameters: Run vgmodify to collect information about the volume group. Save the output from these three commands: # vgmodify -o -r vgnn
# vgmodify -v -t vgnn
# vgmodify -v -n -t vgnn |
The -o option attempts to optimize
the values by making full use of the existing LVM metadata space.
The -t option reports the optimized range of settings
without renumbering physical extents; the -n option
enables renumbering of physical extents. Based on the information collected
in the previous step, choose new values for the volume group parameters. The new values may increase
the size of the volume group reserved area (VGRA) on each physical
volume. The VGRA resides in the LVM header, so increasing its size
may require moving the first physical extent of any user data on physical
volume. Use the pvmove command to move the first
physical extent to another location. Review the values by running vgmodify with the new settings and the -r option. Deactivate the volume group. Commit the new values by running vgmodify without the -r option. Activate the volume group.
Run the vgdisplay command to verify the settings
have been applied.
As an example, you expect to add larger disks
to the volume group vg32. You want to increase
the maximum number of physical extents per physical volume (max_pe) and the maximum number of physical volumes (max_pv). Here are the steps involved: Run vgmodify to collect information about the volume group. Save the output from these three commands: |
# vgmodify -o -r vg32
Current Volume Group settings:
Max LV 255
Max PV 16
Max PE per PV 1016
PE Size (Mbytes) 32
VGRA Size (Kbytes) 176
New configuration requires "max_pes" are increased from 1016 to 6652
The current and new Volume Group parameters differ.
An update to the Volume Group IS required
New Volume Group settings:
Max LV 255
Max PV 16
Max PE per PV 6652
PE Size (Mbytes) 32
VGRA Size (Kbytes) 896
Review complete. Volume group not modified
# vgmodify -v -t vg32
Current Volume Group settings:
Max LV 255
Max PV 16
Max PE per PV 1016
PE Size (Mbytes) 32
VGRA Size (Kbytes) 176
VGRA space (Kbytes) on Physical Volumes with extents in use:
PV current -n
/dev/rdisk/disk6 896 32768
/dev/rdisk/disk5 896 32768
Summary 896 32768
Volume Group optimized settings (no PEs renumbered):
max_pv(-p) max_pe(-e) Disk size (Mb)
2 53756 1720193
3 35836 1146753
...
213 296 9473
255 252 8065
# vgmodify -v -n -t vg32
Volume Group configuration for /dev/vg32 has been saved in
/etc/lvmconf/vg32.conf
Current Volume Group settings:
Max LV 255
Max PV 16
Max PE per PV 1016
PE Size (Mbytes) 32
VGRA Size (Kbytes) 176
VGRA space (Kbytes) on Physical Volumes with extents in use:
PV current -n
/dev/rdisk/disk6 896 32768
/dev/rdisk/disk5 896 32768
Summary 896 32768
Physical Extent zero is not free on all PVs. You will not achieve these
values until the first extent is made free (see pvmove(1M)) on all the
following disks:
/dev/rdisk/disk6
/dev/rdisk/disk5
Volume Group optimized settings (PEs renumbered lower):
max_pv(-p) max_pe(-e) Disk size (Mb)
61 65535 2097152
62 65532 2097056
...
252 16048 513568
255 15868 507808 |
|
Based on the output of vgmodify -n -t, choose 255 for max_pv and 15868 for max_pe. Since the new values require
physical extent 0 to be free, use pvmove to move
it to another location: # pvmove /dev/disk/disk5:0 /dev/disk/disk5
Transferring logical extents of logical volume "/dev/vg32/lvol2"...
Physical volume "/dev/disk/disk5" has been successfully moved.
Volume Group configuration for /dev/vg32 has been saved in
/etc/lvmconf/vg32.conf
# pvmove /dev/disk/disk6:0 /dev/disk/disk6
Transferring logical extents of logical volume "/dev/vg32/lvol1"...
Physical volume "/dev/disk/disk6" has been successfully moved.
Volume Group configuration for /dev/vg32 has been saved in
/etc/lvmconf/vg32.conf |
Preview the
changes by using the -r option to vgmodify: # vgmodify -p 255 -e 15868 -r -n vg32
Current Volume Group settings:
Max LV 255
Max PV 16
Max PE per PV 1016
PE Size (Mbytes) 32
VGRA Size (Kbytes) 176
The current and new Volume Group parameters differ.
An update to the Volume Group IS required
New Volume Group settings:
Max LV 255
Max PV 255
Max PE per PV 15868
PE Size (Mbytes) 32
VGRA Size (Kbytes) 32640
Review complete. Volume group not modified |
Deactivate the volume group: # vgchange -a n vg32
Volume group "vg32" has been successfully changed. |
Commit the new values: # vgmodify -p 255 -e 15868 -n vg32
Current Volume Group settings:
Max LV 255
Max PV 16
Max PE per PV 1016
PE Size (Mbytes) 32
VGRA Size (Kbytes) 176
The current and new Volume Group parameters differ.
An update to the Volume Group IS required
New Volume Group settings:
Max LV 255
Max PV 255
Max PE per PV 15868
PE Size (Mbytes) 32
VGRA Size (Kbytes) 32640
New Volume Group configuration for "vg32" has been saved in
"/etc/lvmconf/vg32.conf"
Old Volume Group configuration for "vg32" has been saved in
"/etc/lvmconf/vg32.conf.old"
Starting the modification by writing to all Physical Volumes
Applying the configuration to all Physical Volumes from
"/etc/lvmconf/vg32.conf"
Completed the modification process.
New Volume Group configuration for "vg32" has been saved in
"/etc/lvmconf/vg32.conf.old"
Volume group "vg32" has been successfully changed. |
Activate the volume group
and verify the changes: # vgchange -a y vg32
Activated volume group
Volume group "vg32" has been successfully changed.
# vgdisplay vg32
--- Volume groups ---
VG Name /dev/vg32
VG Write Access read/write
VG Status available
Max LV 255
Cur LV 0
Open LV 0
Max PV 255
Cur PV 2
Act PV 2
Max PE per PV 15868
VGDA 4
PE Size (Mbytes) 32
Total PE 1084
Alloc PE 0
Free PE 1084
Total PVG 0
Total Spare PVs 0
Total Spare PVs in use 0
VG Version 1.0 |
Quiescing and Resuming a Volume Group | |
If you plan to use a disk management utility to
create a backup image or “snapshot” of all the disks
in a volume group, you must make sure that LVM is not writing to any
of the disks when the snapshot is being taken; otherwise, some disks
can contain partially written or inconsistent LVM metadata. To keep
the volume group disk image in a consistent state, you must either
deactivate the volume group or quiesce it. Deactivating the volume group requires you to
close all the logical volumes in the volume group, which can be disruptive.
For example, you must unmount any file system using a logical volume
in the volume group. However, temporarily quiescing the volume group
enables you to keep the volume group activated and the logical volumes
open during the snapshot operation, minimizing the impact to your
system. You can quiesce both read and write operations
to the volume group, or just write operations. While a volume group
is quiesced, the vgdisplay command reports the
volume group access mode as quiesced. The indicated I/O operations queue until the volume group is resumed,
and commands that modify the volume group configuration fail immediately. To quiesce a volume group, use the vgchange command with the -Q option as follows: The mode parameter
can be either rw, which blocks both read and write
operations, or w, which permits read operations
but blocks write operations. By default, the volume group remains quiesced
until it is explicitly resumed. You can specify a maximum quiesce
time in seconds using the -t option. If the quiesce
time expires, the volume group is resumed automatically. For example,
to quiesce volume group vg08 for a maximum of
ten minutes (600 seconds) but permitting read operations, enter the
following command: # vgchange -Q w -t 600 vg08 |
To resume a quiesced volume group, use the vgchange command with the -R option as
follows: Renaming a Volume Group | |
To change the name of a volume group, export it,
then import it using the new name. For more detailed information on
how to export and import a volume group, see “Exporting a Volume Group” and “Importing a Volume Group”. To rename the volume group vg01 to vgdb, follow these steps: Deactivate the volume group
as follows: If you want to retain the
same minor number for the volume group, examine the volume group's group file as follows: # ls -l /dev/vg01/group
crw-r--r-- 1 root sys 64 0x010000 Mar 28 2004 /dev/vg01/group |
For this example, the volume group major number is 64, and
the minor number is 0x010000. Export the volume group as
follows: # vgexport -m vg01.map vg01 |
If you are using an HP-UX
release before March 2008, or if you want to specify the minor number
of the volume group device file, create it for the volume group's
new name, using the procedure in “Creating the Volume Group Device File”. Since
the group file in this example has a major number
of 64 and a minor number of 0x010000, enter the following commands: # mkdir /dev/vgdb
# mknod /dev/vgdb/group c 64 0x010000 |
Import the volume group under
its new name as follows: # vgimport -m vg01.map /dev/vgdb |
Back up the volume group configuration
information as follows: Activate the volume group
as follows: # vgchange -a y /dev/vgdb |
Remove saved configuration
information based on the old volume group name as follows: # rm /etc/lvmconf/vg01.conf |
Update all references to the
old name in any other files on the system. These include /etc/fstab for mounted file systems or swap devices, and
existing mapfiles from a vgexport command.
Splitting a Volume Group | |
You can use the vgchgid to split
an existing volume group into two or more volume groups, provided
that the physical volumes to be split are self-contained; that is,
any logical volumes on the physical volumes must be wholly contained
on those physical volumes. For example, a splittable volume group
can have logical volumes 1, 2, and 3 on physical volumes 0 and 1,
and logical volumes 4, 5, and 6 on physical volumes 2, 3, 4, and 5. In this example, volume group vgold contains physical volumes /dev/disk/disk0 through /dev/disk/disk5. Logical volumes lvol1, lvol2, and lvol3 are
on physical volumes /dev/disk/disk0 and /dev/disk/disk1, and logical volumes lvol4, lvol5, and lvol6 are
on the remaining physical volumes. To keep /dev/disk/disk0 and /dev/disk/disk1 in vgold and split
the remaining physical volumes into a new volume group named vgnew, follow these steps: Deactivate the volume group
as follows: Export the volume group as
follows: Change the VGID on the physical
volumes to be assigned to the new volume group as follows: # vgchgid -f /dev/rdisk/disk2 /dev/rdisk/disk3 \
/dev/rdisk/disk4 /dev/rdisk/disk5 |
If you are using an HP-UX
release before March 2008, or if you want to specify the minor number
of the vgold group file, create it using the
procedure in “Creating the Volume Group Device File”. If you are using an HP-UX
release before March 2008, or if you want to specify the minor number
of the vgnew group file, create it using the
procedure in “Creating the Volume Group Device File”. Import the physical volumes
in the old volume group as follows: # vgimport /dev/vgold /dev/rdisk/disk0 /dev/rdisk/disk1 |
Import the physical volumes
in the new volume group as follows: # vgimport /dev/vgnew /dev/rdisk/disk2 /dev/rdisk/disk3 \
/dev/rdisk/disk4 /dev/rdisk/disk5 |
Activate the volume groups.
Disable quorum checks for the old volume group (it is missing over
half its disks) as follows: # vgchange -a y -q n /dev/vgold
# vgchange -a y /dev/vgnew |
The logical volumes are currently
defined in both volume groups. Remove the duplicate logical volumes
from the volume group that no longer contains them as follows: # lvremove -f vgold/lvol4 vgold/lvol5 vgold/lvol6
# lvremove -f vgnew/lvol1 vgnew/lvol2 vgnew/lvol3 |
The physical volumes are currently
defined in both volume groups. Remove the missing physical volumes
from both volume groups as follows: # vgreduce -f vgold
# vgreduce -f vgnew |
Enable quorum checks for the
old volume group as follows: # vgchange -a y -q y /dev/vgold |
On completion, the original volume group contains
three logical volumes (lvol1, lvol2, and lvol3) with physical volumes /dev/disk/disk0 and /dev/disk/disk1. The new volume group vgnew contains three
logical volumes (lvol4, lvol5, and lvol6) across physical volumes /dev/disk/disk2, /dev/disk/disk3, /dev/disk/disk4, and /dev/disk/disk5. Removing a Volume Group | |
| | | | | TIP: It is easier to export a volume group than to
remove it, because removing the volume group requires that you remove
all the logical volumes and physical volumes from the volume group
before running vgremove. In addition, exporting
the volume group leaves the LVM information on the disks untouched,
which is an advantage if you want to reimport the volume group later.
For the procedure to export a volume group, see “Exporting a Volume Group”. | | | | |
To remove a volume group, follow these steps: Back
up all user data. Find the names of all logical
volumes and physical volumes in the volume group. Enter the following
command: Make
sure that none of those logical volumes are in use. This may require
stopping applications using any logical volumes in the volume group,
and unmounting file systems contained in the volume group. Use the fuser command on each logical
volume: # fuser -cu /dev/vgnn/lvoln |
Remove each of the logical
volumes as follows: # lvremove /dev/vgnn/lvoln |
For more information, see “Removing a Logical Volume”. Remove all but one of the
physical volumes as follows: # vgreduce /dev/vgnn /dev/disk/diskn |
For
more information, see “Removing a Disk from a Volume Group”. Use the vgremove command to remove the volume group as follows:
Backing Up a Mirrored Logical Volume | |
| | | | | NOTE: Mirroring requires the optional product HP MirrorDisk/UX. | | | | |
You can split a mirrored logical volume into two
logical volumes to perform a backup on an offline copy while the other
copy stays online. When you complete the backup of the offline copy,
you can merge the two logical volumes back into one. To bring the
two copies back in synchronization, LVM updates the physical extents
in the offline copy based on changes made to the copy that remained
in use. You can use HP SMH to split and merge logical
volumes, or use the lvsplit and lvmerge commands. To back up a mirrored logical volume containing
a file system, using lvsplit and lvmerge, follow these steps: Split the logical volume /dev/vg00/lvol1 into two separate logical volumes as follows: # lvsplit /dev/vg00/lvol1 |
This creates the new logical volume /dev/vg00/lvol1b. The original logical volume /dev/vg00/lvol1 remains online. Perform a file system consistency
check on the logical volume to be backed up as follows: Mount the file system as follows: # mkdir /backup_dir
# mount /dev/vg00/lvol1b /backup_dir |
Perform the backup using the
utility of your choice. Unmount the file system as
follows: Merge the split logical volume
back with the original logical volume as follows: # lvmerge /dev/vg00/lvol1b /dev/vg00/lvol1 |
Backing Up and Restoring Volume Group Configuration | |
It is important that volume group configuration
information be saved whenever you make any change
to the configuration such as: Adding or removing disks
to a volume group Changing the disks in a
root volume group Creating or removing logical
volumes Extending or reducing logical
volumes
Unlike fixed disk partitions or nonpartitioned
disks that begin and end at known locations on a given disk, each
volume group configuration is unique, changes, and uses space on several
disks. If you back up your volume group configuration,
you can restore a corrupted or lost LVM configuration in the event
of a disk failure or corruption of your LVM configuration information. The vgcfgbackup command creates
or updates a backup file containing the volume group configuration;
it does not back up the data within your logical volumes. To simplify the backup process, vgcfgbackup is
invoked automatically whenever you make a configuration change as
a result of using any of the following commands: lvchange | lvcreate | lvextend | lvlnboot | lvmerge | lvreduce | lvremove | lvrmboot | lvsplit | vgcreate | pvchange | pvmove | vgextend | vgmodify | vgreduce |
You can display LVM configuration information previously
backed up with vgcfgbackup or restore it using vgcfgrestore. By default, vgcfgbackup saves
the configuration of a volume group to the file /etc/lvmconf/volume_group_name.conf. You can also run vgcfgbackup at the command line, saving the backup file in any directory you
indicate. If you do, first run vgdisplay with the -v option to ensure that the all logical volumes in the
volume group are shown as available/syncd. If so, then run the following command: # vgcfgbackup -f pathname/filename volume_group_name |
If you use a nondefault volume group configuration
file, take note of and retain its location. For information on command
options, see vgcfgbackup(1M). Make sure backups of the
root volume group are on the root file system, in case these are required
during recovery. To run vgcfgrestore, the physical
volume must be detached. If all the data on the physical volume is
mirrored and the mirror copies are current and available, you can
temporarily detach the physical volume using pvchange, perform the vgcfgrestore, and reattach the physical
volume. For example, to restore volume group configuration data for /dev/disk/disk5, a disk in the volume group /dev/vgsales, enter the following commands: # pvchange -a n /dev/disk/disk5
# vgcfgrestore -n /dev/vgsales /dev/rdisk/disk5
# pvchange -a y /dev/disk/disk5 |
If the physical volume is not mirrored or the
mirror copies are not current and available, you must deactivate the
volume group with vgchange, perform the vgcfgrestore, and activate the volume group as follows: # vgchange -a n /dev/vgsales
# vgcfgrestore -n /dev/vgsales /dev/rdisk/disk5
# vgchange -a y /dev/vgsales |
These examples restore the LVM configuration to
the disk from the default backup location in /etc/lvmconf/vgsales.conf. For information on command options, see vgcfgrestore(1M).
|