df命令查看自己的/目录属于哪个逻辑卷(我们要做的是对逻辑卷扩展)
[root@redhat6-3 ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/vg_redhat63-lv_root
18102140 1298416 15884172 8% /
tmpfs 124592 0 124592 0% /dev/shm
/dev/sda1 495844 29859 440385 7% /boot
新加一块硬盘,我的是sdb 先创建物理卷
[root@redhat6-3 ~]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xce359e4e.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will 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): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-261, default 1): (回车,默认将所有空间分配给第一个主分区)
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-261, default 261):
Using default value 261
Command (m for help): t(修改磁盘格式为LVM)
Selected partition 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
再次查看磁盘情况
[root@redhat6-3 ~]# fdisk -l
Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00085274
Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 2611 20458496 8e Linux LVM
Disk /dev/sdb: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xce359e4e
Device Boot Start End Blocks Id System
/dev/sdb1 1 261 2096451 8e Linux LVM
将新创建的主分区创建为物理卷
[root@redhat6-3 ~]# pvcreate /dev/sdb1
Writing physical volume data to disk "/dev/sdb1"
Physical volume "/dev/sdb1" successfully created
查看根目录所属的卷组和逻辑卷
[root@redhat6-3 ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/vg_redhat63-lv_root
(此处说明卷组是vg_redhat63逻辑卷是/dev/mapper/vg_redhat63-lv_root)
18102140 1298416 15884172 8% /
tmpfs 124592 0 124592 0% /dev/shm
/dev/sda1 495844 29859 440385 7% /boot
将刚创建的物理卷/dev/sdb1添加到卷组中
[root@redhat6-3 ~]# vgextend vg_redhat63 /dev/sdb1
Volume group "vg_redhat63" successfully extended
将卷组的1GB扩展给根所在的逻辑卷
[root@redhat6-3 ~]# lvextend -L +1G /dev/mapper/vg_redhat63-lv_root
Extending logical volume lv_root to 18.54 GiB
Logical volume lv_root successfully resized
激活修改的配置
[root@redhat6-3 ~]# resize2fs /dev/mapper/vg_redhat63-lv_root
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/vg_redhat63-lv_root is mounted on /; on-line resizing required
old desc_blocks = 2, new_desc_blocks = 2
Performing an on-line resize of /dev/mapper/vg_redhat63-lv_root to 4859904 (4k) blocks.
The filesystem on /dev/mapper/vg_redhat63-lv_root is now 4859904 blocks long.
查看系统情况
[root@redhat6-3 ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/vg_redhat63-lv_root
19134332 1298424 16868444 8% /
tmpfs 124592 0 124592 0% /dev/shm
/dev/sda1 495844 29859 440385 7% /boot
之前的系统
[root@redhat6-3 ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/vg_redhat63-lv_root
18102140 1298416 15884172 8% /
tmpfs 124592 0 124592 0% /dev/shm
/dev/sda1 495844 29859 440385 7% /boot
根目录成功扩展1G空间