磁盘管理综合测试题

实验需求:
1、用户需把/dev/myvg/mylv逻辑卷以支持磁盘配额的方式挂载到网页目录下
[root@localhost ~]# mount /dev/myvg/mylv /usr/local/httpd/htdocs/

2、在网页目录下创建测试文件index.html,内容为用户名称,通过浏览器访问测试
[root@localhost ~]# touch /usr/local/httpd/htdocs/index.html
[root@localhost ~]# vim /usr/local/httpd/htdocs/index.html


3、创建用户账户,对LVM配置磁盘配额限制用户磁盘容量为软限制80M;硬限制100M、文件数量软限制为80个;硬限制为100个。

[root@localhost ~]# useradd xiao
[root@localhost ~]# mount -o remount,usrquota /usr/local/httpd/htdocs/
[root@localhost ~]# vi /etc/fstab

#
# /etc/fstab
# Created by anaconda on Sat Jul 27 13:57:15 2019
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/centos-root / xfs defaults 0 0
UUID=5b23a4cd-a55b-48cb-8ba6-564a284d1543 /boot xfs defaults
/dev/mapper/centos-swap swap swap defaults 0 0
/dev/myvg/mylv /usr/local/httpd/htdocs ext4 defaults,usrquota
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
"/etc/fstab" 12L, 558C written
[root@localhost ~]# vi /etc/fstab

#
# /etc/fstab
# Created by anaconda on Sat Jul 27 13:57:15 2019
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/centos-root / xfs defaults 0 0
UUID=5b23a4cd-a55b-48cb-8ba6-564a284d1543 /boot xfs defaults
/dev/mapper/centos-swap swap swap defaults 0 0
/dev/myvg/mylv /usr/local/httpd/htdocs ext4 defaults,usrquota
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
"/etc/fstab" 12L, 558C written
[root@localhost ~]# quotacheck -avu
[root@localhost ~]# quotaon -a
[root@localhost ~]# setquota -u xiao 80M 100M 80 100 /usr/local/httpd/htdocs/
[root@localhost ~]# repquota -usv /usr/local/httpd/htdocs/
*** Report for user quotas on device /dev/mapper/myvg-mylv
Block grace time: 7days; Inode grace time: 7days
Space limits File limits
User used soft hard grace used soft hard grace
----------------------------------------------------------------------
root -- 24K 0K 0K 3 0 0
xiao -- 0K 81920K 100M 0 80 100

Statistics:
Total blocks: 7
Data blocks: 1
Entries: 2
Used average: 2.000000



从下往上

安装Apache WEB 服务
网页目录位置:/usr/local/httpd/htdocs
[root@localhost ~]# ls
anaconda-ks.cfg initial-setup-ks.cfg 模板 图片 下载 桌面
httpd-2.2.17.tar.gz 公共 视频 文档 音乐
[root@localhost ~]# tar xf httpd-2.2.17.tar.gz -C /usr/src
[root@localhost ~]# cd /usr/src/httpd-2.2.17/
[root@localhost httpd-2.2.17]# ./configure --prefix=/usr/local/httpd && make && make install
[root@localhost httpd-2.2.17]# vi /usr/local/httpd/conf/httpd.conf
[root@localhost httpd-2.2.17]# /usr/local/httpd/bin/apachectl start


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

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


转化成LV : mylv
[root@localhost ~]# lvcreate -L 39.9G -n mylv myvg
Rounding up size to full physical extent 39.90 GiB
Logical volume "mylv" created.


转换成vg : myvg
[root@localhost ~]# vgcreate myvg /dev/md5
Volume group "myvg" successfully created


转换成pv : /dev/md5
[root@localhost ~]# pvcreate /dev/md5
Physical volume "/dev/md5" successfully created.


RAID : /dev/md5
/dev/sdb1 /dev/sdc1 /dev/sdd1
20G 2G 20G
[root@localhost ~]# fdisk /dev/sdb
欢迎使用 fdisk (util-linux 2.23.2)。

更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。

Device does not contain a recognized partition table
使用磁盘标识符 0x2d0018bc 创建新的 DOS 磁盘标签。

命令(输入 m 获取帮助):n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p):
Using default response p
分区号 (1-4,默认 1):
起始 扇区 (2048-41943039,默认为 2048):
将使用默认值 2048
Last 扇区, +扇区 or +size{K,M,G} (2048-41943039,默认为 41943039):
将使用默认值 41943039
分区 1 已设置为 Linux 类型,大小设为 20 GiB

命令(输入 m 获取帮助):w
The partition table has been altered!

Calling ioctl() to re-read partition table.
正在同步磁盘。

[root@localhost ~]# fdisk /dev/sdc
欢迎使用 fdisk (util-linux 2.23.2)。

更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。

Device does not contain a recognized partition table
使用磁盘标识符 0x3e944df9 创建新的 DOS 磁盘标签。

命令(输入 m 获取帮助):n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p):
Using default response p
分区号 (1-4,默认 1):
起始 扇区 (2048-41943039,默认为 2048):
将使用默认值 2048
Last 扇区, +扇区 or +size{K,M,G} (2048-41943039,默认为 41943039):
将使用默认值 41943039
分区 1 已设置为 Linux 类型,大小设为 20 GiB

命令(输入 m 获取帮助):w
The partition table has been altered!

Calling ioctl() to re-read partition table.
正在同步磁盘。
[root@localhost ~]# fdisk /dev/sdd
欢迎使用 fdisk (util-linux 2.23.2)。

更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。

Device does not contain a recognized partition table
使用磁盘标识符 0x735b6617 创建新的 DOS 磁盘标签。

命令(输入 m 获取帮助):n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p):
Using default response p
分区号 (1-4,默认 1):
起始 扇区 (2048-41943039,默认为 2048):
将使用默认值 2048
Last 扇区, +扇区 or +size{K,M,G} (2048-41943039,默认为 41943039):
将使用默认值 41943039
分区 1 已设置为 Linux 类型,大小设为 20 GiB

命令(输入 m 获取帮助):w
The partition table has been altered!

Calling ioctl() to re-read partition table.
正在同步磁盘。

[root@localhost ~]# mdadm -C /dev/md5 -l5 -n3 /dev/sd[bcd]1
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md5 started.

原文地址:https://www.cnblogs.com/ITXJW/p/11305010.html