LVM创建及分区调整、更换LVM硬盘

1.新建2个分区(略)
2.修改分区id为8e
3.partprobe
4.初始化物理卷
[root@ ~]# pvcreate /dev/sda7 /dev/sda8

Physical volume "/dev/sda7" successfully created

Physical volume "/dev/sda8" successfully created

5.创建卷组

[root@ ~]# vgcreate testvg /dev/sda7 /dev/sda8

Volume group "testvg" successfully created

6创建逻辑卷,不要占用所有空间

[root@ ~]# lvcreate -L 40M -n testlv testvg

Logical volume "testlv" created

[root@ data-lv]# df

Filesystem           1K-blocks      Used Available Use% Mounted on

/dev/sda2              6940516   2217116   4365152  34% /

/dev/sda1               101086     11009     84858  12% /boot

tmpfs                   972276         0    972276   0% /dev/shm

/dev/md2                972280     17632    905256   2% /mnt

/dev/mapper/testvg-testlv

39663     39640         0 100% /data-lv

7在逻辑卷上创建ext3文件系统:

mke2fs –j  /dev/testvg/testlv

8创建data-lv目录并挂载

9在testlv目录下创建文件

[root@ data-lv]# dd if=/dev/zero of=/data-lv/bigfile bs=1M count=50

dd: writing `/data-lv/bigfile': No space left on device

35+0 records in

34+0 records out

35733504 bytes (36 MB) copied, 1.30968 seconds, 27.3 MB/s

提示空间不足

10 扩展逻辑卷,再增加50M,须先调整分区大小 再调整文件系统大小

[root@ ~]# lvextend -L +50M /dev/testvg/testlv

Rounding up size to full physical extent 52.00 MB

Extending logical volume testlv to 92.00 MB

Logical volume testlv successfully resized

[root@ ~]# resize2fs /dev/testvg/testlv

[root@ ~]# df

Filesystem           1K-blocks      Used Available Use% Mounted on

/dev/sda2              6940516   2217120   4365148  34% /

/dev/sda1               101086     11009     84858  12% /boot

tmpfs                   972276         0    972276   0% /dev/shm

/dev/md2                972280     17632    905256   2% /mnt

/dev/mapper/testvg-testlv

91099     40117     46276  47% /data-lv

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/70ba2a6af0c9165f3c616f1891ed339c.html