制作LVM卷的步骤:
裸设备---分区---PV---VG---LV---格式化---挂载使用
[root@localhost ~]# pvcreate /dev/sdb1 /dev/sdc1 建立pv物理卷
Physical volume "/dev/sdb1" successfully created
Physical volume "/dev/sdc1" successfully created
[root@localhost ~]# vgcreate hehe /dev/sdb1 /dev/sdc1 建立vg卷组
Volume group "hehe" successfully created
[root@localhost ~]# lvcreate -L 30G -n xixi hehe 建立lv逻辑卷
Logical volume "xixi" created
[root@localhost ~]# mkfs.ext3 /dev/hehe/xixi 格式化为ext3的文件系统mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
[root@localhost ~]# mkdir /lvm 创建lvm文件夹
[root@localhost ~]# mount /dev/hehe/xixi /lvm 挂载lvm逻辑卷到lvm文件夹下使用[root@localhost ~]# cd /lvm 切换
[root@localhost lvm]# ls 查看
lost+found
[root@localhost lvm]# df -hT 查看磁盘使用情况
文件系统类型容量已用可用已用% 挂载点
/dev/mapper/VolGroup00-LogVol00
ext3 38G 3.1G 33G 9% /
/dev/sda1 ext3 99M 11M 83M 12% /boot
tmpfs tmpfs 177M 0 177M 0% /dev/shm
/dev/mapper/hehe-xixi
ext3 30G 173M 28G 1% /lvm
[root@localhost lvm]# lvextend -L +3G /dev/hehe/xixi 扩展lvm卷的空间Extending logical volume xixi to 33.00 GB
Logical volume xixi successfully resized
[root@localhost lvm]# resize2fs /dev/hehe/xixi 重新识别文件系统的大小
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/hehe/xixi is mounted on /lvm; on-line resizing required
Performing an on-line resize of /dev/hehe/xixi to 8650752 (4k) blocks.
The filesystem on /dev/hehe/xixi is now 8650752 blocks long.
制作磁盘配额的步骤:
分区(LVM逻辑卷)---添加配额功能----生成配额文件---编辑配额设置---启动配额功能---验证配额功能---查看使用情况
[root@localhost lvm]# mount -o remount,usrquota,grpquota /dev/hehe/xixi /lvm 重新挂载以增加支持配额功能
[root@localhost lvm]# mount
/dev/mapper/VolGroup00-LogVol00 on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/sda1 on /boot type ext3 (rw)
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
none on /proc/fs/vmblock/mountPoint type vmblock (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
/dev/mapper/hehe-xixi on /lvm type ext3 (rw,usrquota,grpquota)
[root@localhost lvm]# vi /etc/fstab 编辑该文件开机自挂载
/dev/hehe/xixi /lvm etx3 defaults,ursquota,grpquota 0 0
[root@localhost lvm]# quotacheck -augcv 生成配额文件
quotacheck: Scanning /dev/mapper/hehe-xixi [/lvm] quotacheck: Cannot stat old user quota file: 没有那个文件或目录
quotacheck: Cannot stat old group quota file: 没有那个文件或目录
quotacheck: Cannot s
[root@localhost lvm]# cd /lvm 切换
[root@localhost lvm]# ls 查看
aquota.group er lost+found
[root@localhost lvm]# edquota -u gege 为用户gege设置配额
/dev/mapper/hehe-xixi 0 80000 10000 0 0 0
[root@localhost lvm]# quotaon -ugv /lvm 启用lvm文件系统的磁盘配额功能,并显示命令的执行过程信息
/dev/mapper/hehe-xixi [/lvm]: group quotas turned on
/dev/mapper/hehe-xixi [/lvm]: user quotas turned on
[root@localhost ~]# chmod 777 /lvm 修改lvm文件夹权限
[root@localhost ~]# su gege 切换为用户gege
[gege@localhost root]$ dd if=/dev/zero of=/lvm/2.txt bs=1M count=8 创建大小为8M的2.txt文件验证是否提示警告
dm-2: write failed, user block limit reached.
dd: 写入“/lvm/2.txt”: 超出磁盘限额
2+0 records in
1+0 records out
1835008 bytes (1.8 MB) copied, 0.0390995
[gege@localhost root]$ quota -u gege 查看用户gege的配额使用情况
Disk quotas for user gege (uid 500):
Filesystem blocks quota limit grace files quota limit grace
/dev/mapper/hehe-xixi
10000* 80000 10000 2 0 0。