|
操作流程如下:
[root@pc ~]# fdisk -l 一共有三个硬盘,我做lvm时只使用了sdb硬盘
- Disk /dev/sda: 8589 MB, 8589934592 bytes
- 255 heads, 63 sectors/track, 1044 cylinders
- Units = cylinders of 16065 * 512 = 8225280 bytes
- Device Boot Start End Blocks Id System
- /dev/sda1 * 1 978 7855753+ 83 Linux
- /dev/sda2 979 1043 522112+ 82 Linux swap / Solaris
- Disk /dev/sdb: 4294 MB, 4294967296 bytes
- 255 heads, 63 sectors/track, 522 cylinders
- Units = cylinders of 16065 * 512 = 8225280 bytes
- Disk /dev/sdb doesn't contain a valid partition table
- Disk /dev/sdc: 4294 MB, 4294967296 bytes
- 255 heads, 63 sectors/track, 522 cylinders
- Units = cylinders of 16065 * 512 = 8225280 bytes
- Disk /dev/sdc doesn't contain a valid partition table
复制代码
[root@pc ~]# pvcreate /dev/sdb 使用sdb建立了pv
- Physical volume "/dev/sdb" successfully created
复制代码
[root@pc ~]# vgcreate -s 64MB vg0 /dev/sdb 使用sdb建立了vg0卷组
- Volume group "vg0" successfully created
复制代码
[root@pc ~]# vgchange -a y vg0 激活vg0,不过好像没有什么做用
- 0 logical volume(s) in volume group "vg0" now active
复制代码
[root@pc ~]# vgdisplay 显示vg的情况
- --- Volume group ---
- VG Name vg0
- System ID
- Format lvm2
- Metadata Areas 1
- Metadata Sequence No 1
- VG Access read/write
- VG Status resizable
- MAX LV 0
- Cur LV 0
- Open LV 0
- Max PV 0
- Cur PV 1
- Act PV 1
- VG Size 3.94 GB
- PE Size 64.00 MB
- Total PE 63
- Alloc PE / Size 0 / 0
- Free PE / Size 63 / 3.94 GB
- VG UUID V1mX31-gXNc-xTEF-Cnsp-bD54-GVDS-XyCCcR
复制代码
[root@pc ~]# lvcreate -l63 -n lv vg0 建立了lv,LV使用了sdb的全部空间3.94G
- Logical volume "lv" created
复制代码
[root@pc ~]# lvdisplay 显示lv的情况
- --- Logical volume ---
- LV Name /dev/vg0/lv
- VG Name vg0
- LV UUID 6HiZwR-ZxZX-yudE-F1fS-Iyiy-W5ns-DMuZ8p
- LV Write Access read/write
- LV Status available
- # open 0
- LV Size 3.94 GB
- Current LE 63
- Segments 1
- Allocation inherit
- Read ahead sectors 0
- Block device 253:0
复制代码
[root@pc ~]# mkfs.ext3 /dev/vg0/lv 使用ext3格式成功格式化lv
- mke2fs 1.39 (29-May-2006)
- Filesystem label=
- OS type: Linux
- Block size=4096 (log=2)
- Fragment size=4096 (log=2)
- 516096 inodes, 1032192 blocks
- 51609 blocks (5.00%) reserved for the super user
- First data block=0
- Maximum filesystem blocks=1056964608
- 32 block groups
- 32768 blocks per group, 32768 fragments per group
- 16128 inodes per group
- Superblock backups stored on blocks:
- 32768, 98304, 163840, 229376, 294912, 819200, 884736
- Writing inode tables: done
- Creating journal (16384 blocks): done
- Writing superblocks and filesystem accounting information: done
- This filesystem will be automatically checked every 28 mounts or
- 180 days, whichever comes first. Use tune2fs -c or -i to override.
复制代码
[root@pc ~]# mount /dev/vg0/lv /mnt/ 加载lv到mnt
[root@pc ~]# df -h 查看加载的分区大小
- Filesystem Size Used Avail Use% Mounted on
- /dev/sda1 7.3G 2.4G 4.5G 35% /
- tmpfs 233M 0 233M 0% /dev/shm
- /dev/mapper/vg0-lv 3.9G 72M 3.7G 2% /mnt
复制代码
[root@pc ~]# umount /mnt/ 卸载了mnt分区
[root@pc ~]# lvreduce -L-1G /dev/vg0/lv 开始裁减,将lv分区减小1G,显示已经顺利的减小了
- WARNING: Reducing active logical volume to 2.94 GB
- THIS MAY DESTROY YOUR DATA (filesystem etc.)
- Do you really want to reduce lv? [y/n]: y
- Reducing logical volume lv to 2.94 GB
- Logical volume lv successfully resized
复制代码
[root@pc ~]# lvdisplay 再次查看lv的情况,发现lv的大小已经由原来的3.94G减小到了2.94G
- --- Logical volume ---
- LV Name /dev/vg0/lv
- VG Name vg0
- LV UUID 6HiZwR-ZxZX-yudE-F1fS-Iyiy-W5ns-DMuZ8p
- LV Write Access read/write
- LV Status available
- # open 0
- LV Size 2.94 GB
- Current LE 47
- Segments 1
- Allocation inherit
- Read ahead sectors 0
- Block device 253:0
复制代码
[root@pc ~]# mount /dev/vg0/lv /mnt/ 重新挂了分区
[root@pc ~]# df -h lv的分区还有3.9G,这是怎么回事?
- Filesystem Size Used Avail Use% Mounted on
- /dev/sda1 7.3G 2.4G 4.5G 35% /
- tmpfs 233M 0 233M 0% /dev/shm
- /dev/mapper/vg0-lv 3.9G 72M 3.7G 2% /mnt
复制代码
如果格式化LV后再加载的话就是2.9G了,这是怎么回事?我是不是少了一些步骤? |
|