格式化完毕后,要将新的分区加入到LVM(Logical Volume Manager)以便以后管理。
我们先用pvdisplay命令查看LVM的物理卷信息
[root@localhost ~]# pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name VolGroup00
PV Size 29.81 GB / not usable 25.93 MB
Allocatable yes
PE Size (KByte) 32768
Total PE 953
Free PE 1
Allocated PE 952
PV UUID gjFDfY-J0vK-7YKm-uo32-eiQZ-YO3D-PFbp1A
可以看到,只有/dev/sda2加入了LVM的VolGroup00卷组。
使用我们新的/dev/sda5创建LVM物理卷,命令是pvcreate
[root@localhost ~]# pvcreate /dev/sda5
Physical volume "/dev/sda5" successfully created
创建成功,再键入pvdisplay查看
[root@localhost ~]# pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name VolGroup00
PV Size 29.81 GB / not usable 25.93 MB
Allocatable yes
PE Size (KByte) 32768
Total PE 953
Free PE 1
Allocated PE 952
PV UUID gjFDfY-J0vK-7YKm-uo32-eiQZ-YO3D-PFbp1A
"/dev/sda5" is a new physical volume of "10.00 GB"
--- NEW Physical volume ---
PV Name /dev/sda5
VG Name
PV Size 10.00 GB
Allocatable NO
PE Size (KByte) 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID WiG7f0-jGuq-HCUR-3MCZ-d8V0-rwV9-rEF2wg
新的物理卷已经创建,但是没有加入任何卷组。现在我们把它加入VolGroup00卷组
[root@localhost ~]# vgextend VolGroup00 /dev/sda5
Volume group "VolGroup00" successfully extended
加入成功。键入lvdisplay查看我们当前的逻辑卷信息
[root@localhost ~]# lvdisplay
--- Logical volume ---
LV Name /dev/VolGroup00/LogVol00
VG Name VolGroup00
LV UUID nvo0P1-8kmf-f9jJ-X4ii-RHUD-VvwK-AvIm36
LV Write Access read/write
LV Status available
# open 1
LV Size 29.25 GB
Current LE 936
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
--- Logical volume ---
LV Name /dev/VolGroup00/LogVol01
VG Name VolGroup00
LV UUID 2hi7f1-SPdo-FQdX-s4gE-Y74F-rgzQ-KAO55X
LV Write Access read/write
LV Status available
# open 1
LV Size 512.00 MB
Current LE 16
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
我们要扩展的是名为/dev/VolGroup00/LogVol00的逻辑卷,使用lvextend命令
[root@localhost ~]# lvextend /dev/VolGroup00/LogVol00 /dev/sda5
Extending logical volume LogVol01 to 10.47 GB
Logical volume LogVol01 successfully resized
扩展成功,此时再键��lvdisplay查看信息,显示如下
[root@localhost ~]# lvdisplay
--- Logical volume ---
LV Name /dev/VolGroup00/LogVol00
VG Name VolGroup00
LV UUID nvo0P1-8kmf-f9jJ-X4ii-RHUD-VvwK-AvIm36
LV Write Access read/write
LV Status available
# open 1
LV Size 39.22 GB
Current LE 1255
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
--- Logical volume ---
LV Name /dev/VolGroup00/LogVol01
VG Name VolGroup00
LV UUID 2hi7f1-SPdo-FQdX-s4gE-Y74F-rgzQ-KAO55X
LV Write Access read/write
LV Status available
# open 1
LV Size 32.00 MB
Current LE 1
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
LogVol00扩大了10G。但此时键入df -h,会发现我们的空间还是不能用
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
29G 26G 2.3G 92% /
/dev/sda1 190M 13M 168M 7% /boot
tmpfs 506M 48K 506M 1% /dev/shm
gvfs-fuse-daemon 29G 26G 2.3G 92% /root/.gvfs
需要用resize2fs工具调整Linux文件系统大小。如果你的Linux内核是2.6及以上版本,可以直接调整,否则需要先umount相关的设备后进行调整。Fedora 9的内核版本是2.6.25。OK,我们直接调整df命令中列出的/dev/mapper/VolGroup00-LogVol00文件系统
[root@localhost ~]# resize2fs /dev/mapper/VolGroup00-LogVol00
resize2fs 1.40.8 (13-Mar-2008)
Filesystem at /dev/mapper/VolGroup00-LogVol00 is mounted on /; on-line resizing required
old desc_blocks = 2, new_desc_blocks = 3
Performing an on-line resize of /dev/mapper/VolGroup00-LogVol00 to 10280960 (4k) blocks.
The filesystem on /dev/mapper/VolGroup00-LogVol00 is now 10280960 blocks long.
此时再键入df -h命令查看
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
39G 26G 12G 69% /
/dev/sda1 190M 13M 168M 7% /boot
tmpfs 506M 48K 506M 1% /dev/shm
gvfs-fuse-daemon 39G 26G 12G 69% /root/.gvfs
至此,我们的文件系统扩充完毕。