磁盘管理综合测试题
 
实验需求:
1、用户需把/dev/myvg/mylv逻辑卷以支持磁盘配额的方式挂载到网页目录下
2、在网页目录下创建测试文件index.html,内容为用户名称,通过浏览器访问测试
3、创建用户账户,对LVM配置磁盘配额限制用户磁盘容量为软限制80M;硬限制100M、文件数量软限制为80个;硬限制为100个。
 
实验拓扑:
 
实验步骤:

[root@localhost ~]# fdisk -l |grep "raid"        //查找磁盘
/dev/sdb1 2048 41943039 20970496 fd Linux raid autodetect
/dev/sdc1 2048 41943039 20970496 fd Linux raid autodetect
/dev/sdd1 2048 41943039 20970496 fd Linux raid autodetect

[root@localhost ~]# mdadm -Cv /dev/md5 -l5 -n3 /dev/sd[bcd]1    //创建MD5
mdadm: layout defaults to left-symmetric
mdadm: layout defaults to left-symmetric
mdadm: chunk size defaults to 512K
mdadm: size set to 20954112K
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md5 started.

[root@localhost ~]# pvcreate /dev/md5      //创建物理卷
Physical volume "/dev/md5" successfully created
[root@localhost ~]# vgremove /dev/myvg
Volume group "myvg" not found
Cannot process volume group myvg
[root@localhost ~]# lvre
lvreduce lvremove lvrename lvresize
[root@localhost ~]# vgcreate myvg /dev/md5       //创建卷组
Volume group "myvg" successfully created
[root@localhost ~]# lvcreate -L 30G -n mylv myvg    //创建逻辑卷
Logical volume "mylv" created. 

[root@localhost ~]# mkfs.ext4 /dev/myvg/mylv          //格式化ext4格式
mke2fs 1.42.9 (28-Dec-2013)
文件系统标签=
OS type: Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=128 blocks, Stripe width=256 blocks
1966080 inodes, 7864320 blocks
393216 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=2155872256
240 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000

Allocating group tables: 完成
正在写入inode表: 完成
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成

[root@localhost ~]#
[root@localhost ~]# mount /dev/myvg/mylv /usr/local/apache/htdocs   //把磁盘挂载到文件
[root@localhost ~]# df -hT
文件系统 类型 容量 已用 可用 已用% 挂载点
/dev/mapper/centos-root xfs 38G 5.0G 33G 14% /
devtmpfs devtmpfs 481M 0 481M 0% /dev
tmpfs tmpfs 490M 84K 490M 1% /dev/shm
tmpfs tmpfs 490M 7.0M 483M 2% /run
tmpfs tmpfs 490M 0 490M 0% /sys/fs/cgroup
/dev/sda1 xfs 497M 124M 373M 25% /boot
/dev/sr0 iso9660 4.1G 4.1G 0 100% /run/media/root/CentOS 7 x86_64
/dev/mapper/myvg-mylv ext4 30G 45M 28G 1% /usr/local/apache/htdocs

[root@localhost ~]# systemctl stop firewalld.service      //关闭防火墙
[root@localhost ~]# setenforce 0

[root@localhost ~]# /usr/local/apache/bin/apachectl start       //关闭防火墙  

[root@localhost htdocs]# vim index.html
[root@localhost htdocs]# lynx 192.168.24.10

 

[root@localhost ~]# mount -o remount,usrquota,grpquota /usr/local/apache/htdocs/
[root@localhost ~]# mount |grep "htdocs"
/dev/mapper/myvg-mylv on /usr/local/apache/htdocs type ext4 (rw,relatime,seclabel,quota,usrquota,grpquota,stripe=256,data=ordered)
[root@localhost ~]# grep /dev/myvg/mylv /etc/mtab
[root@localhost ~]# mount |tail -1
/dev/mapper/myvg-mylv on /usr/local/apache/htdocs type ext4 (rw,relatime,seclabel,quota,usrquota,grpquota,stripe=256,data=ordered)
[root@localhost ~]# quota
quota quotacheck quotaoff quotaon quotastats quotasync
[root@localhost ~]# quotacheck -avug
quotacheck: Your kernel probably supports journaled quota but you are not using it. Consider switching to journaled quota to avoid running quotacheck after an unclean shutdown.
quotacheck: Scanning /dev/mapper/myvg-mylv [/usr/local/apache/htdocs] done
quotacheck: Cannot stat old user quota file /usr/local/apache/htdocs/aquota.user: 没有那个文件或目录. Usage will not be subtracted.
quotacheck: Cannot stat old group quota file /usr/local/apache/htdocs/aquota.group: 没有那个文件或目录. Usage will not be subtracted.
quotacheck: Cannot stat old user quota file /usr/local/apache/htdocs/aquota.user: 没有那个文件或目录. Usage will not be subtracted.
quotacheck: Cannot stat old group quota file /usr/local/apache/htdocs/aquota.group: 没有那个文件或目录. Usage will not be subtracted.
quotacheck: Checked 2 directories and 1 files
quotacheck: Old file not found.
quotacheck: Old file not found.
[root@localhost ~]# quota
quota quotacheck quotaoff quotaon quotastats quotasync
[root@localhost ~]# quotao
quotaoff quotaon
[root@localhost ~]# quotao
quotaoff quotaon
[root@localhost ~]# quotaon -auvg
/dev/mapper/myvg-mylv [/usr/local/apache/htdocs]: group quotas turned on
/dev/mapper/myvg-mylv [/usr/local/apache/htdocs]: user quotas turned on

[root@localhost ~]# chmod 777 /usr/
[root@localhost ~]# ed
ed edid-decode editdiff edquota
[root@localhost ~]# ed
ed edid-decode editdiff edquota
[root@localhost ~]# ed
ed edid-decode editdiff edquota
[root@localhost ~]# edquota -u yun192
[root@localhost ~]# su - yun192

[yun192@localhost ~]$ dd if=/dev/zero of=/usr/local/apache/htdocs/ceshi bs=1M count=200
dm-2: warning, user block quota exceeded.
dm-2: write failed, user block limit reached.
dd: 写入"/usr/local/apache/htdocs/ceshi" 出错: 超出磁盘限额
记录了101+0 的读入
记录了100+0 的写出
104857600字节(105 MB)已复制,0.654819 秒,160 MB/秒