[root@ninglianjie_app_1 ~]# vgscan
Reading all physical volumes. This may take a while...
/dev/cdrom: open failed:
只读文件系统
Attempt to close device '/dev/cdrom' which is not open.
No volume groups found
|
[root@ninglianjie_app_1 ~]# pvcreate /dev/sdb1
Wiping software RAID md superblock on /dev/sdb1
Physical volume "/dev/sdb1" successfully created
|
[root@ninglianjie_app_1 ~]# vgcreate VG1 /dev/sdb1
Volume group "VG1" successfully created
|
[root@ninglianjie_app_1 ~]# vgextend VG1 /dev/sdc1
/dev/cdrom: open failed:
只读文件系统
/dev/cdrom: open failed:
只读文件系统
Attempt to close device '/dev/cdrom' which is not open.
Volume group "VG1" successfully extended
|
[root@ninglianjie_app_1 ~]# vgdisplay
--- Volume group ---
VG Name VG1
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 0
Max PV 0
Cur PV 2
Act PV 2
VG Size 9.86 GB
PE Size 4.00 MB
Total PE 2525
Alloc PE / Size 125 / 500.00 MB
Free PE / Size 2400 / 9.38 GB
VG UUID RMT3aA-XRau-coeV-H40J-72TX-h0eM-bvu0g5
|
[root@ninglianjie_app_1 ~]# vgreduce VG1 /dev/sdc1
Removed "/dev/sdc1" from volume group "VG1"
|
[root@ninglianjie_app_1 ~]# lvcreate -n LV1 -L 500M VG1
/dev/cdrom: open failed:
只读文件系统
Logical volume "LV1" already exists in volume group "VG1"
[root@ninglianjie_app_1 ~]# mkfs.ext3 /dev/VG1/LV1
|
[root@ninglianjie_app_1 ~]# lvextend -L +200M /dev/VG1/LV1
Extending logical volume LV1 to 700.00 MB
Logical volume LV1 successfully resized
[root@ninglianjie_app_1 ~]# e2fsck -f /dev/VG1/LV1
[root@ninglianjie_app_1 ~]# resize2fs /dev/VG1/LV1
|
[root@ninglianjie_app_1 ~]# e2fsck -f /dev/VG1/LV1
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/VG1/LV1: 11/89664 files (9.1% non-contiguous), 7102/179200 blocks
[root@ninglianjie_app_1 ~]# resize2fs /dev/VG1/LV1 400M
*
调整后为
400M
resize2fs 1.39 (29-May-2006)
Resizing the filesystem on /dev/VG1/LV1 to 102400 (4k) blocks.
The filesystem on /dev/VG1/LV1 is now 102400 blocks long.
[root@ninglianjie_app_1 ~]# e2fsck -f /dev/VG1/LV1
[root@ninglianjie_app_1 ~]# lvreduce -L -100M /dev/VG1/LV1
*
以减的大小为主
WARNING: Reducing active logical volume to 600.00 MB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce LV1? [y/n]: y
Reducing logical volume LV1 to 600.00 MB
Logical volume LV1 successfully resized
|
[root@ninglianjie_app_1 ~]# lvcreate -L 4M -s -n kuaizhao1 /dev/VG1/LV1
Logical volume "kuaizhao1" created
|
[root@ninglianjie_app_1 data1]# find / -name kuaizhao1
/dev/VG1/kuaizhao1
[root@ninglianjie_app_1 data1]#
[root@ninglianjie_app_1 data1]#
[root@ninglianjie_app_1 data1]# cd /dev/VG1/
[root@ninglianjie_app_1 VG1]# ls
kuaizhao1 LV1
[root@ninglianjie_app_1 VG1]# ll
总计
0
lrwxrwxrwx 1 root root 25 11-09 19:19 kuaizhao1 -> /dev/mapper/VG1-kuaizhao1
|
[root@ninglianjie_app_1 VG1]# mount /dev/mapper/VG1-kuaizhao1 /data2
|
[root@ninglianjie_app_1 data2]# cd
[root@ninglianjie_app_1 ~]# umount /dev/mapper/VG1-kuaizhao1 /data2
umount: /dev/mapper/VG1-kuaizhao1: not mounted
umount: /dev/mapper/VG1-kuaizhao1: not mounted
[root@ninglianjie_app_1 ~]# lvremove /dev/mapper/VG1-kuaizhao1
Do you really want to remove active logical volume "kuaizhao1"? [y/n]: y
Logical volume "kuaizhao1" successfully removed
|
[root@ninglianjie_app_1 ~]# pvcreate /dev/sdc1
*
指定物理卷
/dev/cdrom: open failed:
只读文件系统
Attempt to close device '/dev/cdrom' which is not open.
Physical volume "/dev/sdc1" successfully created
[root@ninglianjie_app_1 ~]# vgextend VG1 /dev/sdc1
*
加入卷组
/dev/cdrom: open failed:
只读文件系统
Attempt to close device '/dev/cdrom' which is not open.
Volume group "VG1" successfully extended
[root@ninglianjie_app_1 ~]# pvmove /dev/sdb1 /dev/sdc1
*
移动卷内数据
/dev/sdb1: Moved: 100.0%
|
[root@ninglianjie_app_1 ~]# umount /data1
*
卸载卷
[root@ninglianjie_app_1 ~]# vgchange -a n VG1
* -a
改变状态、
n
不生效
0 logical volume(s) in volume group "VG1" now active
[root@ninglianjie_app_1 ~]# vgexport VG1
/dev/cdrom: open failed:
只读文件系统
Volume group "VG1" successfully exported
|
[root@ninglianjie_app_1 ~]# pvscan
*
扫描物理卷
/dev/cdrom: open failed:
只读文件系统
Attempt to close device '/dev/cdrom' which is not open.
PV /dev/sdb1 is in exported VG VG1 [1.87 GB / 1.87 GB free]
PV /dev/sdc1 is in exported VG VG1 [8.00 GB / 7.41 GB free]
Total: 2 [9.86 GB] / in use: 2 [9.86 GB] / in no VG: 0 [0 ]
[root@ninglianjie_app_1 ~]# vgimport VG1
*
导入卷组
Volume group "VG1" successfully imported
[root@ninglianjie_app_1 ~]# vgchange -a y VG1
*
设置为生效
1 logical volume(s) in volume group "VG1" now active
[root@ninglianjie_app_1 ~]# mount /dev/VG1/LV1 /data1
|