System Environment:
1)
HP-UX 11.00
2) model: 9000/715/d
This note contains the following content: Creating LVM, expanding the file system, narrowing down the file system, moving LVM, and deleting VG.
1. Establish LVM
Suppose we have twoHard Disk: C0t3d0 and c0t4d0. To create vg02, which contains the two hard disks, you can perform the following operations:
1. Generate PV Information
# Pvcreate-F/dev/rdsk/c0t3d0
# Pvcreate-F/dev/rdsk/c0t4d0
Note: If the hard disk contains other LVM information, this operation may report an error. In this case, you can remove the information related to the hard disk Disk Head. The command is as follows:
# Dd If =/dev/Zero of =/dev/rdsk/c0t3d0 BS = 1024 COUNT = 1024
Then, use the preceding command to create the PV information.
2. # mkdir/dev/vg02
3. # mknod/dev/vg02/group C 64 0x020000
Note: This command is used to create a device file. C indicates that a character device is created, and 64 indicates a device.Driver. The format of 0x020000 is always starting with 0x. 02 corresponds to vg02, which does not actually correspond to each other. It is only for future convenience. Most of the time, we make the corresponding format and connect it to 0000.
4. # vgcreate/dev/vg02/dev/DSK/c0t3d0/dev/DSK/c0t4d0
Note: This command is used to create vg02 and include c0t3d0 and c0t4d0. Of course, you can also include a hard disk and then expand the second hard disk as needed, the procedure is as follows:
# Vgcreate/dev/vg02/dev/DSK/c0t3d0
# Vgextend/dev/vg02/dev/DSK/c0t4d0 (this command is to expand the second hard disk to vg02)
5. lvcreate-L 100 vg02
Note: after creating the VG information (that is, the volume group information), you can use the lvcreate command to create a logical volume. This command is used to create a logical volume that is 100 MB in size and contained in the volume group vg02. In addition, the default name is lvol1. The second time you use this command, the default generated name is lvol2, and so on.
Of course, sometimes we can name the created logical volume for the convenience of our work. The example is as follows:
# Lvcreate-L 100 N my_lvol1 vg02
In this way, we use the N parameter to define the name of the logical volume. If we do not use the-l parameter to specify the size of the logical volume, the default size is 0 m, which sometimes facilitates our work, such as when performing mirror, specify the size of the logical volume to 0, so that the synchronization speed will be very fast, and then expand the logical volume after synchronization. As for how to expand, we will discuss it later.
6. newfs-F vxfs-O largefiles/dev/vg02/rlvol1
Note: The-F parameter specifies the file system type. Here, the vxfs file system is actually a common JFS file system.-O is used to specify that the file system supports large-format files, that is, a file system with a single file larger than 2 GB is supported. Otherwise, problems may occur as files, especially database files, increase. In addition, if the database files use bare files, do not perform this operation!
7. mkdir/vg02_lvol1
8. Mount/dev/vg02/lvol1/vg02_lvol1
9. vgcfgbackup vg02
Note: The backup files generated by this command are stored in the/etc/lvmconf/v1_2.conf file. Similarly, vgcfgbackup
The backup file generated by VG ** is stored in the/etc/lvmconf/VG **. conf file. (It seems that the strings command is used instead of the more command to view the file)
Ii. Extend the File System
The purpose of extending a file system is to expand the available space of a file system. Generally, when the usage of a file system exceeds 90%, we should pay special attention to it because the usage will continue to decrease, which may greatly reduce the system performance. At this point, we will delete some temporary files to increase the available space. Of course, we can also use the method to expand the file system as described below.
We still follow the example above. For example, we created a 200 m lvol1 File System in vg02, and now we want to extend it to M:
1. # lvextend-L 200/dev/vg02/lvol1
2. # umount/dev/vg02/lvol1
3. # extendfs-F vxfs/dev/vg01/lvol2
Note: After the logical volume in step 1 is expanded, you must remember to use this file system expansion operation. Otherwise, the system will use Sam to view the file system size in the future, the size is different from the size shown by the BDF command. In fact, the expanded space cannot be used!
4. # Mount-
Note: umount has been created before extendfs. After the file system is expanded, remember to mount it again.
5. # vgcfgbackup vg02
Note: because we have modified the file system, do not forget to back up relevant information files.
Iii. Zoom out the file system (use with caution !)
It is generally not recommended to reduce the file system, because this may cause loss of some files and data. If you have to perform this operation, consider the following solution:
A. Purchase onlie-JFS from HPSoftware
B. Back up data before the operation
We still use the expanded lvol1 as an example. Follow these steps:
1. # fbackup-F/dev/RMT/0 m-0vhi/vg02_lvol1
Note: This file system is backed up first.
2. # umount/dev/vg02/lvol1
3. # lvreduce-L 100/dev/vg02/lvol1
4. # newfs-F vxfs-O largefiles/dev/vg02/rlvol1
Note: This operation causes all files on the file system to be lost. Therefore, you must back up the files!
5. # Mount-
6. # frecover-F/dev/RMT/0 m
Note: the recovery operation may fail because if the file system is too small, the size of the previously backed up file may be greater than that. Therefore, before narrowing down the file system, use the BDF Command carefully.
7. # vgcfgbackup vg02
Iv. Mobile logical volume (LV)
This type of operation is rarely used, and the operation will succeed only when the LV is set up and the block space needs to be contiguous. Here we have added a new hard disk c0t5d0 as an example to move lvol1 up from c0t3d0. The procedure is as follows:
1. # pvcreate-F/dev/rdsk/c0t5d0
2. # vgextend/dev/vg02/dev/DSK/c0t5d0
3. # pvmove-N/dev/vg02/lvol1/dev/DSK/c0t3d0/dev/DSK/c0t5d0
4. # vgcfgbackup vg02
5. Remove VG
Sometimes we don't need a volume group, so we can remove it. The following example shows how to remove vg02:
1. Of course, it is necessary to back up the information and files, so you can use the fbackup, cpio, or tar command to check your choice.
2. determine the number of LV contained in the VG.
# Lvdisplay/dev/vg02/lvol *
Note: similarly, we can see the number of LV contained in VG **. You can also use lvdisplay.
/Dev/VG **/lvol. More reliable. To prevent users from defining their own names, you can use lvdisplay/dev/VG **/* to view them.
3. lv under the VG to be removed by umount
# Cd/
# Umount/dev/vg02/lvol1
Note: In the above example, we only created lvol1. Otherwise, umount should be created one by one. Sometimes, this command does not work. We can use Fuser
-Kill the existing process in kU/dev/VG **/lvol * and re-umount.
4. Remove LV
# Lvremove/dev/vg02/lvol1
Note: Similarly, if there are multiple LV, remove them one by one.
5. Check the/etc/lvmtab file. Make sure that the VG to be removed contains only one PV.
# Strings/etc/lvmtab
Note: Use the strings command to view this file. If there are multiple PVS, remove them one by one. The last one is used as the carrier of VG.
6. Remove excess PVS.
# Vgreduce/dev/vg02/dev/DSK/c0t5d0
# Vgreduce/dev/vg02/dev/DSK/c0t4d0
Note: In the above example, we added c0t3d0, c0t4d0 and c0t5d0 hard disks to vg02. Therefore, we need to remove the redundant ones and use the last one as the carrier of VG.
7. Remove VG
# Vgremove/dev/vg02