First, the operating environment
[Email protected] ~]# uname-alinux linuxidc 2.6.32-358.18.1.el6.x86_64#1 SMP Wed 17:19:38 UTC-x86_64 x86_64 x86_64 Gnu/linux
Second, the present situation analysis
The system has two hard disks, the first hard disk 107G, "/" Partition space at that time only gave 7.7G too small, space immediately occupied. Now the system has a second hard disk SDB size of 16GB, want to add all the space of SDB to "/" partition, is its space capacity from 7.7GB to 7.7GB+16GB (about 2.4GB). (Of course, if there is only one HDD SDA, there is a lot of space is not used can do the same operation)
Third, the Operation procedureFirst step, view native existing partitions
[[email protected] ~]# df-h file system capacity used with available percent mount point/dev/mapper/volgroup-lv_root 7.7G 7.1G 155M 98%/TMPFS 3.9G 296K 3.9G 1%/dev/shm/dev/sda1 485M 64M 396M 14%/boot/dev/sda3 83G 350M 79G 1 %/media
Second step, view the disk condition of the machine
[[email protected] ~]# fdisk -ldisk /dev/sda: 107.4 gb, 107374182400 bytes255 heads, 63 sectors/track, 13054cylindersunits = cylinders of 16065 * 512 = 8225280bytesSector size (logical/physical): 512 bytes /512 bytesi/o size (minimum/optimal): 512 bytes / 512bytesdisk identifier: 0x000dc0adDevice Boot Start end blocks id system/ dev/sda1 * 1 64 512000 83 linuxpartition 1 does not end on cylinder boundary./dev/sda2 64 2089 16264192 8e linux lvm/dev/sda3 2090 13054 88076362+ 83 linuxdisk /dev/mapper/volgroup-lv_root: 8325 mb,8325693440 bytes255 heads, 63 sectors/track, 1012 cylindersunits = cylinders of 16065 * 512 = 8225280bytesSector size (logical/physical): 512 bytes /512 bytesI/O size (Minimum/optimal): 512 bytes / 512bytesdisk identifier: 0x00000000disk /dev/mapper/volgroup-lv_swap: 8325 mb,8325693440 bytes255 heads, 63 sectors/track, 1012 cylindersunits = cylinders of 16065 * 512 = 8225280bytessector size (logical/physical): 512 bytes /512 bytesi/o size (minimum/ Optimal): 512 bytes / 512bytesdisk identifier: 0x00000000
Note: No second hard drive has been added to EXSI5.0 at this time
Step three, add a second hard drive
View system disk conditions at this time
[email protected] ~]# fdisk -ldisk /dev/sda: 107.4 gb, 107374182400 bytes255 heads, 63 sectors/track, 13054cylindersunits = cylinders of 16065 * 512 = 8225280bytesSector size (logical/physical): 512 bytes /512 bytesi/o size (minimum/optimal): 512 bytes / 512bytesdisk identifier: 0x000dc0ad Device Boot Start End Blocks Id system/dev/sda1 * 1 64 512000 83 LinuxPartition 1 does not end on cylinderboundary./dev/sda2 64 2089 16264192 8e linux lvm/dev/sda3 2090 13054 88076362+ 83 LinuxDisk /dev/sdb: 17.2 GB, 17179869184 bytes255 heads, 63 sectors/track, 2088 cylindersunits = cylinders of 16065 * 512 = 8225280bytesSector size (logical/physical): 512 bytes /512 bytesi/o size (minimum/optimal): 512 bytes / 512bytesdisk identifier: 0x00000000disk /dev/mapper/VolGroup-lv_root: 8325 MB,8325693440 bytes255 heads, 63 sectors/track, 1012 cylindersunits = cylinders of 16065 * 512 = 8225280bytessector size (logical/physical): 512 bytes /512 bytesi/o size (minimum/optimal): 512 bytes / 512bytesdisk identifier: 0x00000000disk /dev/mapper/volgroup-lv_swap : 8325 mb,8325693440 bytes255 heads, 63 sectors/track, 1012 cylindersunits = cylinders of 16065 * 512 = 8225280bytessector size (logical/physical): 512 bytes /512 bytesi/o size (minimum/optimal): 512 bytes / 512bytesdisk identifier: 0x00000000
Can see our newly added HDD SDB
Fourth step, partition the second hard drive SDB
[[Email protected] ~]# fdisk /dev/sdbdevice contains neither a valid dospartition table, nor sun, sgi or osf disklabelbuilding a  NEW DOS DISKLABEL WITH DISKIDENTIFIER 0XFA4ABBDC. Changes will remain in memory only, untilyou decide to write them. After that, of course, the previous contentwon ' t be recoverable. warning: invalid flag 0x0000 of partitiontable 4 will be Corrected by w (rite) warning: dos-compatible mode is deprecated. It ' s strongly recommended toswitch off the mode (command ' C ') and change display units to sectors (command ' u '). command (m for help): mcommand actiona toggle a bootable flagb edit bsd disklabelc toggle the dos compatibilityflagd delete a partitionl list known partition Typesm print this menun add a new partitiono create a new empty dospartition tablep print the partition tableq quit without saving changess create a new empty Sundisklabelt change a partition ' s system idu change display/ Entry unitsv verify the partition tablew write table to disk and exitx extra functionality (expertsonly) command (m for  HELP): ncommand actione extendedp primary partition (1-4) p Partition number (1-4): 4first cylinder (1-2088, default 1): using default value 1last cylinder, +cylinders or +size{k,m,g} (1-2088, default 2088): Using default value 2088Command (m for help): wthe partition table has been altered! Calling ioctl () to re-read partition table. Syncing disks.
Note: The above operation on the SDB hard disk partition operation, set to SDB4 partition (of course, the above established primary partition can be any one of 1-4, I choose here 4).
Fifth step, format the newly created SDB4 partition
[[email protected] ~]# mkfs.ext4 /dev/sdb4mke2fs 1.41.12 (17-May-2010) file System label = Operating system: Linux block Size =4096 (log=2) chunked size =4096 (log=2) stride=0 blocks, stripe width=0 blocks1048576 inodes, 4192957 blocks209647 blocks (5.00%) reserved for thesuper user first block of data =0maximum filesystem blocks=4294967296128 block groups32768 blocks per group, 32768 fragments pergroup8192 inodes per groupsuperblock backups stored on blocks: 32768, 98304, 163840, 229376 , 294912, 819200, 884736, 1605632, 2654208, 4096000 is writing to the Inode table: complete creating journal (32768 blocks): complete writing superblocks and filesystemaccounting information: done Complete This filesystem will be automaticallychecked every 20 mounts or180 days, whichever comes first. use tune2fs -c or -i to Override.
Description: Format the SDB4 partition as the EXT4 format, because the CentOS installation is the system's format EXT4, so pay attention here.
Sixth step, the SDB4 partition after the format is added as a physical volume
[Email protected] ~]# pvcreate/dev/sdb4physical Volume "/DEV/SDB4" successfully created
Seventh step, view the current system physical volume (PV) situation
[Email protected] ~]# pvdisplay---physical volume---pvname/dev/sda2vgname volgrouppvsize 15.51 gib/not usable3.00 MiB allocatable Yes (butfull) pesize 4.00 mibtotal pe 3970Free PE 0Allocated PE 3970PVUUID up77sg-snkf-ja0k-crbf-n0wz-a5hy-t6s VFH "/DEV/SDB4" is a new physical volume of "15.99 GiB"---new physical volume---pvname/dev/sdb4vgname pvsize 15.99 giball Ocatable nopesize 0 Total pe 0Free PE 0Allocated PE 0PVUUID GQNW7N-HOOX-S2NZ-1NIZ-YPOE-G0JO-GRG1RQ
Description: You can see the new physical volume added SDB4, the size of which matches the setting we added
Eighth step, view current volume group situation
[[email protected] ~]# vgdisplay---Volume group---vgname volgroupsystem ID Format lvm2metadata areas 1Metadata Sequence N o 3VGAccess read/writevgstatus resizablemaxlv 0CurLV 2Open LV 2MaxPV 0CurPV 1ActPV 1VGSize 15.51 gibpesize 4.00 mibtotal P E 3970Alloc pe/size 3970/15.51gibfree pe/size 0/0 vguuid PPRIFH-GLZL-NNXX-YKBM-XJ1S-RGNW-D1WSJD
Nineth step, convert partition SDB4 to extended partition
[Email protected] ~]# vgextend volgroup/dev/sdb4volume Group "VolGroup" successfully extended
Tenth step, view the current logical volume
[Email protected] ~]# lvdisplay---Logical volume---lvpath/dev/volgroup/lv_rootlvname lv_rootvgname volgrouplvuuid Dcisej-0nwx-bvfe-bt6l-c4ey-oy4g-9lnboclvwrite Access read/writelvcreation Host, time, Lvstatus Available#open 1LVSize 7.75 gibcurrent LE 1985Segments 1Allocation inheritread ahead sectors auto-currently set to 256Block device 253:0---Logica L Volume---lvpath/dev/volgroup/lv_swaplvname lv_swapvgname volgrouplvuuid K5bxjo-2smm-6ncu-mbjp-qzp1-zodh-nblk0klvwrite Access read/writelvcreation Host, time, Lvstatus Available#open 1LVSize 7.75 gibcurrent LE 1985Segments 1Allocation inheritread ahead sectors auto-currently set to 256Block device 253:1
Note: Here you can see the path name of the "/" root partition:/dev/volgroup/lv_root
11th step, view the expanded volume group situation
[[email protected] ~]# vgdisplay---Volume group---vgname volgroupsystem ID Format lvm2metadata areas 2Metadata Sequence N o 4VGAccess read/writevgstatus resizablemaxlv 0CurLV 2Open LV 2MaxPV 0CurPV 2ActPV 2VGSize 31.50 gibpesize 4.00 mibtotal P E 8064Alloc pe/size 3970/15.51gibfree pe/size 4094/15.99 gibvguuid PPRIFH-GLZL-NNXX-YKBM-XJ1S-RGNW-D1WSJD
Description: After the expansion of the paper situation, you can see the size increased by 16GB (compared with the eighth step)
12th Step, expand all new logical volumes to the "/" Partition
[Email protected] ~]# lvextend-l +15.99g/dev/volgroup/lv_root rounding size to boundary between physical extents:15.99 Gibextending Logical Volume Lv_root to 23.75 giblogical volume Lv_root successfully resized
Note: Here sdb4 a total of 16G, so add 16BG all to the root partition.
13th step, view "/" root partition format, and re-refresh the size of the root partition
[Email protected] ~]# e2fsck-f/dev/volgroup/lv_root e2fsck 1.41.12 (17-may-2010)/dev/volgroup/lv_root is Mounted.e2fsck: Cannot continue, abort. [Email protected] ~]# resize2fs/dev/volgroup/lv_root resize2fs 1.41.12 (17-may-2010) Filesystem at/dev/volgroup/lv_ Root ismounted on/; On-line resizing Requiredold desc_blocks = 1, new_desc_blocks = 2Performing an on-line resize of/dev/volgroup/lv_root to 6 224896 (4k) blocks. The filesystem on/dev/volgroup/lv_root Isnow 6224896 blocks long.
Description: The command RESIZE2FS refreshes the capacity of the root partition "/dev/volgroup/lv_root".
13th step, view the size of the root partition after the refresh
[[email protected] ~]# df-h file system capacity used with available percent mount point/dev/mapper/volgroup-lv_root24g 7.1G 16G 32%/tmpfs 3.9G 144K 3.9G 1%/dev/s Hm/dev/sda3 83G 350M 79G 1%/media/lucene
Note: You can see the size of the root partition 7.7G into 24G, restart the system to see the situation. At this point you can continue to install the software, will not be prompted for insufficient space.
CentOS Root Partition Expansion method