将其他磁盘分区加入逻辑卷并更改逻辑卷大小
9.将/dev/sde分区
[root@lyt ~]# fdisk /dev/sde
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.
The number of cylinders for this disk is set to 2610.
There is nothing wrong with that, but this is larger than 1024,
and could 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)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-2610, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-2610, default 2610): +512M
Command (m for help): p
Disk /dev/sde: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sde1 1 63 506016 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
10.更改磁盘分区类型:
[root@lyt ~]# fdisk /dev/sde
The number of cylinders for this disk is set to 2610.
There is nothing wrong with that, but this is larger than 1024,
and could 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): t
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): p
Disk /dev/sde: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sde1 1 63 506016 8e Linux LVM
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
11.将/dev/sde1加入到物理卷中
[root@lyt ~]# pvcreate /dev/sde1
Physical volume "/dev/sde1" successfully created
12.将扩展卷组
[root@lyt ~]# vgextend vgtest /dev/sde1
/dev/cdrom: open failed: Read-only file system
Attempt to close device '/dev/cdrom' which is not open.
Volume group "vgtest" successfully extended
13.扩展逻辑卷lvtest的大小(有2中方法)
(1)将逻辑卷/dev/vgtest/lvtest的大小扩展为1500M
[root@lyt ~]# lvextend -L 1500M /dev/vgtest/lvtest
Extending logical volume lvtest to 1.46 GB
Logical volume lvtest successfully resized
(2)将逻辑卷/dev/vgtest/lvtest的大小增加12M
[root@lyt ~]# lvextend -L+12M /dev/vgtest/lvtest
Extending logical volume lvtest to 1.48 GB
Logical volume lvtest successfully resized
14.重新读取逻辑卷大小
[root@lyt ~]# resize2fs /dev/vgtest/lvtest
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/vgtest/lvtest is mounted on /lvdate; on-line resizing required
Performing an on-line resize of /dev/vgtest/lvtest to 387072 (4k) blocks.
The filesystem on /dev/vgtest/lvtest is now 387072 blocks long.
15.减小逻辑卷大小(有2种方法)
[root@lyt ~]# umount /dev/vgtest/lvtest #首先卸载逻辑卷
(1)将逻辑卷的大小减小到1500M
[root@lyt ~]# lvreduce -L 1500M /dev/vgtest/lvtest #将逻辑卷减小到1500M
WARNING: Reducing active logical volume to 1.46 GB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce lvtest? [y/n]: y
Reducing logical volume lvtest to 1.46 GB
Logical volume lvtest successfully resized
(2)将逻辑卷的大小减小100M
[root@lyt ~]# lvreduce -L-100M /dev/vgtest/lvtest
WARNING: Reducing active logical volume to 1.37 GB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce lvtest? [y/n]: y
Reducing logical volume lvtest to 1.37 GB
Logical volume lvtest successfully resized
16.清除逻辑卷(逻辑卷必须卸载后才能清除)
[root@lyt ~]# lvremove /dev/vgtest/lvtest
Do you really want to remove active logical volume lvtest? [y/n]: y
Logical volume "lvtest" successfully removed
17.清除卷组
[root@lyt ~]# vgremove /dev/vgtest
/dev/cdrom: open failed: Read-only file system
Attempt to close device '/dev/cdrom' which is not open.
Volume group "vgtest" successfully removed
18.清除物理卷
[root@lyt ~]# pvremove /dev/sd* #将物理卷全部清除
Physical Volume /dev/sda not found
No physical volume label read from /dev/sda1
Physical Volume /dev/sda1 not found
/dev/cdrom: open failed: Read-only file system
Attempt to close device '/dev/cdrom' which is not open.
Can't pvremove physical volume "/dev/sda2" of volume group "VolGroup00" without -ff
Physical Volume /dev/sdb not found
/dev/cdrom: open failed: Read-only file system
Attempt to close device '/dev/cdrom' which is not open.
Labels on physical volume "/dev/sdb1" successfully wiped
/dev/cdrom: open failed: Read-only file system
Attempt to close device '/dev/cdrom' which is not open.
Labels on physical volume "/dev/sdb2" successfully wiped
Physical Volume /dev/sdc not found
/dev/cdrom: open failed: Read-only file system
Attempt to close device '/dev/cdrom' which is not open.
Labels on physical volume "/dev/sdc1" successfully wiped
/dev/cdrom: open failed: Read-only file system
Attempt to close device '/dev/cdrom' which is not open.
Labels on physical volume "/dev/sdc2" successfully wiped
Physical Volume /dev/sdd not found
/dev/cdrom: open failed: Read-only file system
Attempt to close device '/dev/cdrom' which is not open.
Labels on physical volume "/dev/sdd1" successfully wiped
/dev/cdrom: open failed: Read-only file system
Attempt to close device '/dev/cdrom' which is not open.
Labels on physical volume "/dev/sdd2" successfully wiped
Physical Volume /dev/sde not found
/dev/cdrom: open failed: Read-only file system
Attempt to close device '/dev/cdrom' which is not open.
Labels on physical volume "/dev/sde1" successfully wiped
19.浏览物理卷、卷组和逻辑卷的命令分别有:
pvscan和pvdisplay、vgscan和vgdisplay、lvscan和lvdisplay