Linux has been operating the company's FTP server for LVM for several years. Now there is a shortage of space, and it is decided to use LVM for resizing. Idea: first copy the data, purchase a large-capacity hard disk and add it to the server, and then convert the existing common partition into a physical volume, finally, you can use physical volumes to create logical volume groups to expand the capacity. Implementation Process: A. Check whether the LVM tool is installed in the system. If not, download and install it. [Root @ linuxas ~] # Rpm-qa | grep lvmsystem-config-lvm-1.0.22-1.0.el5lvm2-2.02.16-3.el5B, create and manage LVM1, create or convert partitions [root @ linuxas ~] # Fdisk/dev/sdaThe number of cylinders for this disk is set to 1044. there is nothing wrong with that, but this is larger than 1024, and cocould in certain setups cause problems with: 1) software that runs at boot time (e.g ., old versions of LILO) 2) booting and partitioning software from other OSs (e.g ., dos fdisk, OS/2 FDISK) Command (m for help): p (view partition information) Disk/dev/sda: 8589 MB, 8589934592 bytes255 hea Ds, 63 sectors/track, 1044 cylindersUnits = cylinders of 16065*512 = 8225280 bytesDevice Boot Start End Blocks Id System/dev/sda1 * 1 25 200781 83 Linux/dev/sda2 26 535 4096575 83 Linux/dev/sda3 536 854 2562367 + 83 Linux/dev/sda4 855 1044 1526175 5 Extended/dev/sda5 855 905 409626 82 Linux swap/Solaris/dev/sda6 906 1044 1116486 83 LinuxCommand (m for help): t (Change Partition type) Partition number (1-6): 6 (Convert 6th partitions to LVM) Hex code (type L to list codes): 8e (specify the partition type as "8e" or LVM) changed system type of partition 6 to 8e (Linux LVM) Command (m for help): w (SAVE) The partition table has been altered! Calling ioctl () to re-read partition table. WARNING: Re-reading the partition table failed with error 16: Too scared when there are too many failed attempts. the kernel still uses the old table. the new table will be used at the next reboot. syncing disks.2. Create a physical volume [root @ linuxas/] # pvcreate/dev/sda6Can't open/dev/sda6 exclusively. mounted filesystem? The above error occurs because the partition file is in use and umount is required. [Root @ linuxas/] # pvcreate/dev/sda6Physical volume "/dev/sda6" successfully created after creating a physical volume, you can run the "pvdisplay" command to view the physical volume status. [root @ linuxas/] # pvdisplay --- NEW Physical volume --- PV Name/dev/sda6VG NamePV Size 1.06 GBAllocatable NOPE Size (KByte) 0 Total PE 0 Free PE 0 Allocated PE 0PV UUID N2LgeT-RB4Y-8YEP-lO2J-tDWu-UeCT-4Obl8p3, create logical volume group [root @ linuxas/] # vgcreate tgt/dev/sda6Volume group "tgt" successfully creat EdYou have new mail in/var/spool/mail/root View logical Volume group status [root @ linuxas/] # vgdisplay --- Volume group --- VG Name tgtSystem IDFormat lvm2Metadata Areas 1 Metadata Sequence No 1VG Access read/writeVG Status resizableMAX LV 0Cur LV 0 Open LV 0Max PV 0Cur PV 1Act PV 1VG Size 1.06 GB (VG is the Size of the logical volume group) PE Size 4.00 MB (PE is the smallest storage unit of the logical volume group) Total PE 272 Alloc PE/Size 0/0 Free PE/Size 272/1 .06 gbvg uuid g33wzW-yCvX-gc64- YQuD-LYeP-zgra-TGAa8G4, activate logical volume group [root @ linuxas/] # vgchange-a y tgt0 logical volume (s) in volume group "tgt" now active5, create a logical volume [root @ linuxas/] # lvcreate-L 1000 M-n lvm tgt (-L specifies the size, -n specifies the name of the logical volume) logical volume "lvm" created6. Create a file system [root @ linuxas/] # mkfs-j/dev/tgt/lvmmke2fs 1.39 (29-May-2006) Filesystem label = OS type: linuxBlock size = 4096 (log = 2) Fragment size = 4096 (log = 2) 128000 inodes, 256000 blocks12 800 blocks (5.00%) reserved for the super userFirst data block = 0 Maximum filesystem blocks = 2642411528 block groups32768 blocks per group, 32768 fragments per group16000 inodes per groupSuperblock backups stored on blocks: 32768,983 04, 163840,229 376 Writing inode tables: doneCreating journal (4096 blocks): doneWriting superblocks and filesystem accounting information: doneThis filesystem will be aut Omatically checked every 31 mounts or180 days, whichever comes first. use tune2fs-c or-I to override.7. mount the file system [root @ linuxas/] # mount-t ext3/dev/tgt/lvm/homeC, resize LVM 1. Add a new one disk and partition, it is also specified as LVM [root @ linuxas/] # fdisk-lDisk/dev/sda: 8589 MB, 8589934592 bytes255 heads, 63 sectors/track, 1044 cylindersUnits = cylinders of 16065*512 = 8225280 bytesDevice Boot Start End Blocks Id System/dev/sda1 * 1 25 200781 83 Linux/dev/sda2 26 535 4096575 83 Linux/dev/sda3 536 854 2562367 + 83 Linux/dev/sda4 855 1044 1526175 5 Extended/dev/sda5 855 905 409626 82 Linux swap/Solaris/dev/sda6 906 1044 1116486 8e Linux LVMDisk/dev/sdb: 5368 MB, 5368709120 bytes255 heads, 63 sectors/track, 652 cylindersUnits = cylinders of 16065*512 = 8225280 bytesDevice Boot Start End Blocks Id System/dev/sdb1 1 652 5237 158 + 8e Linux LVM2, create a physical volume [root @ linuxas/] # pvcreate/dev/sdb1Physical volume "/dev/sdb1" successfully created ======== ====================================== last, w save and exit. Use sfsik-l to view the new disk. In this case, if you use the lvm disk initialization tool or directly use the pvcreate/dev/sda3 command, an error will be prompted, prompting Device "/dev/sda3" not found (or ignored by filtering) the error occurs because the configuration is not modified in runlevel 1 when fdisk is used. This problem can be solved after the system is restarted. =======================================================3. to the existing logical volume group [root @ linuxas/] # vgextend tgt/dev/sdb1Volume group "tgt" successfully extended4, resize LVM [root @ linuxas/] # lvextend-L 5368 M/dev/tgt/lvm (the total capacity of this volume is set to 5368 M) extending logical volume lvm to 5.24 GBLogical volume lvm successfully resized or use [root @ linuxas/] # lvextend-L + 1000 M/dev/tgt/lvm (this command sets the total capacity of this volume increase by 1000 MB) [root @ linuxas/] # e2fsck-f/dev/tgt/lvm (check the relationship between inode and block of the LVM device) [root @ linuxas/] # resize2fs/dev/tgt/lvm (for effective capacity)