root@localhost ~]# fdisk /dev/sdb
欢迎使用 fdisk (util-linux 2.23.2)。
更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。
Device does not contain a recognized partition table
使用磁盘标识符 0x6d4c9ce7 创建新的 DOS 磁盘标签。
命令(输入 m 获取帮助):n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
分区号 (1-4,默认 1):
起始 扇区 (2048-167772159,默认为 2048):
将使用默认值 2048
Last 扇区, +扇区 or +size{K,M,G} (2048-167772159,默认为 167772159):+10G
分区 1 已设置为 Linux 类型,大小设为 10 GiB
命令(输入 m 获取帮助):n
Partition type:
p primary (1 primary, 0 extended, 3 free)
e extended
Select (default p): p
分区号 (2-4,默认 2):
起始 扇区 (20973568-167772159,默认为 20973568):
将使用默认值 20973568
Last 扇区, +扇区 or +size{K,M,G} (20973568-167772159,默认为 167772159):+10G
分区 2 已设置为 Linux 类型,大小设为 10 GiB
命令(输入 m 获取帮助):n
Partition type:
p primary (2 primary, 0 extended, 2 free)
e extended
Select (default p): p
分区号 (3,4,默认 3):
起始 扇区 (41945088-167772159,默认为 41945088):
将使用默认值 41945088
Last 扇区, +扇区 or +size{K,M,G} (41945088-167772159,默认为 167772159):+10G
分区 3 已设置为 Linux 类型,大小设为 10 GiB
命令(输入 m 获取帮助):n
Partition type:
p primary (3 primary, 0 extended, 1 free)
e extended
Select (default e): p
已选择分区 4
起始 扇区 (62916608-167772159,默认为 62916608):
将使用默认值 62916608
Last 扇区, +扇区 or +size{K,M,G} (62916608-167772159,默认为 167772159):+10G
分区 4 已设置为 Linux 类型,大小设为 10 GiB
命令(输入 m 获取帮助):p
磁盘 /dev/sdb:85.9 GB, 85899345920 字节,167772160 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x6d4c9ce7
设备 Boot Start End Blocks Id System
/dev/sdb1 2048 20973567 10485760 83 Linux
/dev/sdb2 20973568 41945087 10485760 83 Linux
/dev/sdb3 41945088 62916607 10485760 83 Linux
/dev/sdb4 62916608 83888127 10485760 83 Linux
命令(输入 m 获取帮助):w
The partition table has been altered!
Calling ioctl() to re-read partition table.
正在同步磁盘。
[root@localhost ~]# partprobe /dev/sdb
[root@localhost ~]# mdadm -C /dev/md5 -l 5 -n 3 /dev/sdb[123]
mdadm: /dev/sdb1 appears to be part of a raid array:
level=raid5 devices=3 ctime=Sat Aug 3 11:59:40 2019
mdadm: /dev/sdb2 appears to be part of a raid array:
level=raid5 devices=3 ctime=Sat Aug 3 11:59:40 2019
mdadm: /dev/sdb3 appears to be part of a raid array:
level=raid5 devices=3 ctime=Sat Aug 3 11:59:40 2019
Continue creating array? y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md5 started.
[root@localhost ~]# pvcreate /dev/md5
WARNING: xfs signature detected on /dev/md5 at offset 0. Wipe it? [y/n]: y
Wiping xfs signature on /dev/md5.
Physical volume "/dev/md5" successfully created
[root@localhost ~]# vgcreate myvg /dev/md5
Volume group "myvg" successfully created
[root@localhost ~]# vgdisplay myvg
--- Volume group ---
VG Name myvg
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 19.98 GiB
PE Size 4.00 MiB
Total PE 5115
Alloc PE / Size 0 / 0
Free PE / Size 5115 / 19.98 GiB
VG UUID anPbvx-7gdl-yq5g-ZqNs-JhGr-jbhD-n7n10E
[root@localhost ~]# lvcreate -L 15G -n mylv myvg
Logical volume "mylv" created.
[root@localhost ~]# lvdisplay /dev/myvg/mylv
--- Logical volume ---
LV Path /dev/myvg/mylv
LV Name mylv
VG Name myvg
LV UUID rixKvz-v4FL-hxX0-h7Be-kEJE-TOfi-PYEUpT
LV Write Access read/write
LV Creation host, time localhost.localdomain, 2019-08-03 15:01:19 +0800
LV Status available
# open 0
LV Size 15.00 GiB
Current LE 3840
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 4096
Block device 253:2
sh yum.sh #安装yum
#!/bin/bash
umount /dev/sr0 #取消挂载
mount /dev/sr0 /media #挂载光盘
cd /etc/yum.repos.d
if [ ! -d "a/" ];then
mkdir a
mv C* a/
else
echo "存在a目录,复制C*文件"
fi
if [ ! -f "local.repo" ];then
echo "[cd]
name=cd
baseurl=file:///media
enabled=1
gpgcheck=0" > local.repo #创建yum仓库文件
else
echo "已存在文件"
fi
yum -y clean all #清空yum缓存
yum makecache #重建yum缓存
vim httpd.sh #安装httpd
#!/bin/bash
yum -y install gcc gcc-c++ make lynx #安装软件
tar -xf /root/httpd-2.2.17.tar.gz -C /usr/src #解压httpd安装包到/usr/src/
cd /usr/src/httpd-2.2.17
./configure --prefix=/usr/local/httpd #配置安装目录
make #编译
make install #安装
cd /usr/local/httpd/conf
sed -i "s/^#ServerName www/ServerName www/g" /usr/local/httpd/conf/httpd.conf #修改配置文件
cd
/usr/local/httpd/bin/apachectl start #启动服务
echo "/dev/myvg/mylv /usr/local/httpd/htdocs xfs defaults,usrquota,grpquota 0 0 " >> /etc/fstab #修改fstab加入配额
mkfs.xfs /dev/myvg/mylv #格式化逻辑卷
mount -a #挂载全部fstab下硬盘
echo "wangbaoxin
lfjdlsfjlsdjfls
sjaflskdjflsdf" >> /usr/local/httpd/htdocs/index.html #创建index文件
systemctl stop firewalld #停止防火墙
lynx 127.0.0.1 #查看
浏览器查看
[root@localhost ~]# df -hT
文件系统 类型 容量 已用 可用 已用% 挂载点
/dev/mapper/centos-root xfs 38G 8.9G 29G 24% /
devtmpfs devtmpfs 481M 0 481M 0% /dev
tmpfs tmpfs 490M 80K 490M 1% /dev/shm
tmpfs tmpfs 490M 7.1M 483M 2% /run
tmpfs tmpfs 490M 0 490M 0% /sys/fs/cgroup
/dev/sda1 xfs 497M 107M 391M 22% /boot
/dev/sr0 iso9660 4.1G 4.1G 0 100% /media
/dev/mapper/myvg-mylv xfs 15G 33M 15G 1% /usr/local/httpd/htdocs
[root@localhost ~]# mount | tail -1
/dev/mapper/myvg-mylv on /usr/local/httpd/htdocs type xfs (rw,relatime,seclabel,attr2,inode64,sunit=1024,swidth=2048,usrquota,grpquota)
[root@localhost ~]# useradd wangbaoxin
[root@localhost ~]# quotacheck -avug
quotacheck: Skipping /dev/mapper/myvg-mylv [/usr/local/httpd/htdocs]
quotacheck: Cannot find filesystem to check or filesystem not mounted with quota option.
[root@localhost ~]# quotaon -avug
[root@localhost ~]# edquota -u wangbaoxin
Disk quotas for user wangbaoxin (uid 1003):
Filesystem blocks soft hard inodes soft hard
/dev/mapper/myvg-mylv 0 80000 100000 0 80 100
[wangbaoxin@localhost htdocs]$ touch {1..101}.txt
touch: 无法创建"101.txt": 超出磁盘限额
[wangbaoxin@localhost apache]$ dd if=/dev/zero of=/usr/local/apache/htdocs/1.txt bs=1M count=100
dd: 写入"/usr/local/apache/htdocs/1.txt" 出错: 超出磁盘限额
记录了98+0 的读入
记录了97+0 的写出