Operating Environment:
[Email protected] ~]# uname-a
Linux Linux 2.6.32-358.18.1.el6.x86_64#1 SMP Wed 17:19:38 UTC x86_64 x86_64 x86_64 gnu/linux
Current 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)
The procedure is as follows:
First step, view native existing partitions
[Email protected] ~]# df-h
File system capacity has been used with available percent mount points
/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-l
disk/dev/sda:107.4 GB, 107374182400 bytes
255 heads, Sectors/track, 13054cylinders
Units = Cylinders of 16065 * 8225280bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512bytes
Disk IDENTIFIER:0X000DC0AD
Device Boot Start End Blocks Id System
/DEV/SDA1 * 1 512000 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 2089 16264192 8e Linux LVM
/dev/sda3 2090 13054 88076362+-up Linux
disk/dev/mapper/volgroup-lv_root:8325 mb,8325693440 bytes
255 heads, Sectors/track, 1012 cylinders
Units = Cylinders of 16065 * 8225280bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512bytes
Disk identifier:0x00000000
disk/dev/mapper/volgroup-lv_swap:8325 mb,8325693440 bytes
255 heads, Sectors/track, 1012 cylinders
Units = Cylinders of 16065 * 8225280bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512bytes
Disk identifier:0x00000000
Note: No second hard drive has been added to EXSI5.0 at this time
[Email protected] ~]#
Step three, add a second hard drive
View system disk conditions at this time
[Email protected] ~]# fdisk-l
disk/dev/sda:107.4 GB, 107374182400 bytes
255 heads, Sectors/track, 13054cylinders
Units = Cylinders of 16065 * 8225280bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512bytes
Disk IDENTIFIER:0X000DC0AD
Device Boot Start End Blocks Id System
/DEV/SDA1 * 1 512000 Linux
Partition 1 does not end on cylinderboundary.
/dev/sda2 2089 16264192 8e Linux LVM
/dev/sda3 2090 13054 88076362+-up Linux
disk/dev/sdb:17.2 GB, 17179869184 bytes
255 heads, Sectors/track, 2088 cylinders
Units = Cylinders of 16065 * 8225280bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512bytes
Disk identifier:0x00000000
disk/dev/mapper/volgroup-lv_root:8325 mb,8325693440 bytes
255 heads, Sectors/track, 1012 cylinders
Units = Cylinders of 16065 * 8225280bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512bytes
Disk identifier:0x00000000
disk/dev/mapper/volgroup-lv_swap:8325 mb,8325693440 bytes
255 heads, Sectors/track, 1012 cylinders
Units = Cylinders of 16065 * 8225280bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512bytes
Disk identifier:0x00000000
Can see our newly added HDD SDB
[Email protected] ~]#
Fourth step, partition the second hard drive SDB
[Email protected] ~]# Fdisk/dev/sdb
Device contains neither a valid dospartition table, nor Sun, SGI or OSF Disklabel
Building a new DOS disklabel with Diskidentifier 0XFA4ABBDC.
Changes'll remain in memory only, Untilyou decide to write them.
After that, of course, the previous Contentwon ' t is recoverable.
Warning:invalid flag 0x0000 of partitiontable 4 would be corrected by W (rite)
Warning:dos-compatible mode is deprecated. It ' s strongly recommended to
Switch off the mode (command ' C ') and change display units to
Sectors (Command ' u ').
Command (M for help): M
Command Action
A toggle a bootable flag
b Edit BSD Disklabel
C Toggle the DOS Compatibilityflag
D Delete a partition
L list known partition types
M Print this menu
n Add a new partition
o Create a new empty dospartition table
P Print the partition table
Q Quit without saving changes
s create a new empty Sundisklabel
t change a partition ' s system ID
U Change display/entry units
V Verify the partition table
W Write table to disk and exit
X extra Functionality (EXPERTSONLY)
Command (M for help): N
Command Action
E Extended
P primary partition (1-4)
P
Partition number (1-4): 4
First cylinder (1-2088, default 1):
Using Default value 1
Last cylinder, +cylinders or +size{k,m,g} (1-2088, default 2088):
Using Default Value 2088
Command (M for help): W
The 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/SDB4
MKE2FS 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 blocks
1048576 inodes, 4192957 blocks
209647 blocks (5.00%) reserved for thesuper user
First block of data =0
Maximum filesystem blocks=4294967296
Block groups
32768 blocks per group, 32768 fragments Pergroup
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000
Writing Inode table: complete
Creating Journal (32768 blocks): complete
Writing Superblocks and filesystemaccounting Information:done completed
This filesystem'll be automaticallychecked every mounts or
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/SDB4
Physical volume "/DEV/SDB4" successfully created
Seventh step, view the current system physical volume (PV) situation
[Email protected] ~]# Pvdisplay
---physical volume---
Pvname/dev/sda2
Vgname VolGroup
Pvsize 15.51 Gib/not usable3.00 MiB
allocatable Yes (butfull)
Pesize 4.00 MiB
Total PE 3970
Free PE 0
Allocated PE 3970
Pvuuid UP77SG-SNKF-JA0K-CRBF-N0WZ-A5HY-T6SVFH
"/DEV/SDB4" is a new physical volume of "15.99 GiB"
---NEW physical volume---
Pvname/dev/sdb4
Vgname
Pvsize 15.99 GiB
Allocatable NO
Pesize 0
Total PE 0
Free PE 0
Allocated PE 0
Pvuuid 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 VolGroup
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
Vgaccess Read/write
Vgstatus resizable
MAXLV 0
CURLV 2
Open LV 2
MAXPV 0
CURPV 1
ACTPV 1
Vgsize 15.51 GiB
Pesize 4.00 MiB
Total PE 3970
Alloc pe/size 3970/15.51gib
Free 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/SDB4
Volume Group "VolGroup" successfully extended
Tenth step, view the current logical volume
[Email protected] ~]# Lvdisplay
---Logical volume---
Lvpath/dev/volgroup/lv_root
Lvname Lv_root
Vgname VolGroup
Lvuuid Dcisej-0nwx-bvfe-bt6l-c4ey-oy4g-9lnboc
Lvwrite Access Read/write
Lvcreation host, Time,
Lvstatus available
#open 1
Lvsize 7.75 GiB
Current LE 1985
Segments 1
Allocation inherit
Read ahead Sectors Auto
-currently set to 256
Block Device 253:0
---Logical volume---
Lvpath/dev/volgroup/lv_swap
Lvname Lv_swap
Vgname VolGroup
Lvuuid k5bxjo-2smm-6ncu-mbjp-qzp1-zodh-nblk0k
Lvwrite Access Read/write
Lvcreation host, Time,
Lvstatus available
#open 1
Lvsize 7.75 GiB
Current LE 1985
Segments 1
Allocation inherit
Read ahead Sectors Auto
-currently set to 256
Block 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 VolGroup
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 4
Vgaccess Read/write
Vgstatus resizable
MAXLV 0
CURLV 2
Open LV 2
MAXPV 0
CURPV 2
ACTPV 2
Vgsize 31.50 GiB
Pesize 4.00 MiB
Total PE 8064
Alloc pe/size 3970/15.51gib
Free Pe/size 4094/15.99 GiB
Vguuid 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 GiB
Extending logical Volume Lv_root to 23.75 GiB
Logical 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 required
Old desc_blocks = 1, new_desc_blocks = 2
Performing an on-line resize of/dev/volgroup/lv_root to 6224896 (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 has been used with available percent mount points
/dev/mapper/volgroup-lv_root
24G 7.1G 16G 32%/
Tmpfs 3.9G 144K 3.9G 1%/DEV/SHM
/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