255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
/dev/sda1 * 1 3916 31455238+ 83 Linux
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
[root@zhaoyun ~]# fdisk /dev/sdb
Command action
e extended
p primary partition (1-4)
e
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):
Using default value 2610
Command action
l logical (5 or over)
p primary partition (1-4)
l
First cylinder (1-2610, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-2610, default 2610): +100M
Command action
l logical (5 or over)
p primary partition (1-4)
l
First cylinder (14-2610, default 14):
Using default value 14
Last cylinder or +size or +sizeM or +sizeK (14-2610, default 2610): +100M
Command action
l logical (5 or over)
p primary partition (1-4)
l
First cylinder (27-2610, default 27):
Last cylinder or +size or +sizeM or +sizeK (27-2610, default 2610): +100M
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
/dev/sdb1 1 2610 20964793+ 5 Extended
/dev/sdb5 1 13 104359+ 83 Linux
/dev/sdb6 14 26 104391 83 Linux
/dev/sdb7 27 39 104391 83 Linux
The partition table has been altered!
[root@zhaoyun ~]#
[root@zhaoyun ~]# fdisk -l
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
/dev/sda1 * 1 3916 31455238+ 83 Linux
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
/dev/sdb1 1 2610 20964793+ 5 Extended
/dev/sdb5 1 13 104359+ 83 Linux
/dev/sdb6 14 26 104391 83 Linux
/dev/sdb7 27 39 104391 83 Linux
[root@zhaoyun ~]#
Physical volume "/dev/sdb5" successfully created
[root@zhaoyun ~]# pvs 还有一个pvdisplay命令也可以查看
PV VG Fmt Attr PSize PFree
/dev/sdb5 lvm2 -- 101.91M 101.91M
Volume group "vg0" successfully created
[root@zhaoyun ~]# vgs 还有一个vgdisplay命令也可以查看
VG #PV #LV #SN Attr VSize VFree
vg0 1 0 0 wz--n- 100.00M 100.00M
Logical volume "lv0" created
[root@zhaoyun ~]# lvs 还有一个lvdisplay命令也可以查看
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
lv0 vg0 -wi-a- 100.00M
[root@zhaoyun ~]# cd /mnt
[root@zhaoyun mnt]# ls
lost+found
[root@zhaoyun mnt]# touch file
[root@zhaoyun mnt]# ls
file lost+found
[root@zhaoyun mnt]# df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/sda1 30G 3.1G 25G 11% /
tmpfs 95M 0 95M 0% /dev/shm
/dev/mapper/vg0-lv0 97M 5.6M 87M 7% /mnt #看到挂载的卷。
Physical volume "/dev/sdb6" successfully created
[root@zhaoyun ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sdb5 vg0 lvm2 a- 100.00M 0
/dev/sdb6 lvm2 -- 101.94M 101.94M 现在可以看到物理卷有俩块磁盘了。
Volume group "vg0" successfully extended
[root@zhaoyun ~]# vgs
VG #PV #LV #SN Attr VSize VFree
vg0 2 1 0 wz--n- 200.00M 100.00M
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
lv0 vg0 -wi-ao 100.00M
[root@zhaoyun ~]# lvextend -L +100M /dev/vg0/lv0
Extending logical volume lv0 to 200.00 MB
Logical volume lv0 successfully resized
文件系统 容量 已用 可用 已用% 挂载点
/dev/sda1 30G 3.1G 25G 11% /
tmpfs 95M 0 95M 0% /dev/shm
/dev/mapper/vg0-lv0 97M 5.6M 87M 7% /mnt
[root@zhaoyun ~]# resize2fs /dev/vg0/lv0
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/vg0/lv0 is mounted on /mnt; on-line resizing required
Performing an on-line resize of /dev/vg0/lv0 to 204800 (1k) blocks.
The filesystem on /dev/vg0/lv0 is now 204800 blocks long.
文件系统 容量 已用 可用 已用% 挂载点
/dev/sda1 30G 3.1G 25G 11% /
tmpfs 95M 0 95M 0% /dev/shm
/dev/mapper/vg0-lv0 194M 5.6M 179M 4% /mnt
e2fsck 1.39 (29-May-2006)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/vg0/lv0: 12/49400 files (8.3% non-contiguous), 11903/204800 blocks
resize2fs 1.39 (29-May-2006)
Resizing the filesystem on /dev/vg0/lv0 to 153600 (1k) blocks.
The filesystem on /dev/vg0/lv0 is now 153600 blocks long.
Rounding up size to full physical extent 152.00 MB
WARNING: Reducing active logical volume to 152.00 MB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce lv0? [y/n]: y
Reducing logical volume lv0 to 152.00 MB
Logical volume lv0 successfully resized
[root@zhaoyun ~]# df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/sda1 30G 3.1G 25G 11% /
tmpfs 95M 0 95M 0% /dev/shm
/dev/mapper/vg0-lv0 146M 5.6M 134M 4% /mnt
[root@zhaoyun ~]#
Logical volume "lv0bak" created
[root@zhaoyun ~]# ll /dev/vg0/lv0
lv0 lv0bak
[root@zhaoyun ~]# ll /dev/vg0/lv0bak
lrwxrwxrwx 1 root root 22 11-29 08:29 /dev/vg0/lv0bak -> /dev/mapper/vg0-lv0bak
[root@zhaoyun ~]#
[root@zhaoyun ~]# mount /dev/vg0/lv0bak /media
[root@zhaoyun ~]# cd /media
[root@zhaoyun media]# ls
file lost+found
[root@zhaoyun media]# touch file2
[root@zhaoyun media]# ls
file file2 lost+found
[root@zhaoyun media]# cd /mnt
[root@zhaoyun mnt]# ls
file lost+found
[root@zhaoyun mnt]#
[root@zhaoyun ~]# umount /dev/vg0/lv0bak
[root@zhaoyun ~]# lvremove /dev/vg0/lv0
Do you really want to remove active logical volume lv0bak? [y/n]: y
Logical volume "lv0bak" successfully removed
Do you really want to remove active logical volume lv0? [y/n]: y
Logical volume "lv0" successfully removed
[root@zhaoyun ~]# lvremove /dev/
Display all 197 possibilities? (y or n)
[root@zhaoyun ~]# lvs
[root@zhaoyun ~]# vgs
VG #PV #LV #SN Attr VSize VFree
vg0 2 0 0 wz--n- 200.00M 200.00M
[root@zhaoyun ~]# vgremove vg0
Volume group "vg0" successfully removed
[root@zhaoyun ~]# vgs
[root@zhaoyun ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sdb5 lvm2 -- 101.91M 101.91M
/dev/sdb6 lvm2 -- 101.94M 101.94M
[root@zhaoyun ~]# pvremove /dev/sdb5 /dev/sdb6
Labels on physical volume "/dev/sdb6" successfully wiped
[root@zhaoyun ~]# pvs