chapter06
Posted wzy01
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了chapter06相关的知识,希望对你有一定的参考价值。
1.为主机增加80G SCSI 接口硬盘
2.划分三个各20G的主分区
[root@localhost ~]# fdisk /dev/sdb
欢迎使用 fdisk (util-linux 2.23.2)。
[root@localhost ~]# fdisk /dev/sdb
欢迎使用 fdisk (util-linux 2.23.2)。
更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。
使用写入命令前请三思。
Device does not contain a recognized partition table
使用磁盘标识符 0xac26b8ab 创建新的 DOS 磁盘标签。
使用磁盘标识符 0xac26b8ab 创建新的 DOS 磁盘标签。
命令(输入 m 获取帮助):p
磁盘 /dev/sdb:85.9 GB, 85899345920 字节,167772160 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0xac26b8ab
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0xac26b8ab
设备 Boot Start End Blocks Id System
命令(输入 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-167772159,默认为 2048):
将使用默认值 2048
Last 扇区, +扇区 or +sizeK,M,G (2048-167772159,默认为 167772159):+20G
分区 1 已设置为 Linux 类型,大小设为 20 GiB
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p):
Using default response p
分区号 (1-4,默认 1):
起始 扇区 (2048-167772159,默认为 2048):
将使用默认值 2048
Last 扇区, +扇区 or +sizeK,M,G (2048-167772159,默认为 167772159):+20G
分区 1 已设置为 Linux 类型,大小设为 20 GiB
命令(输入 m 获取帮助):n
Partition type:
p primary (1 primary, 0 extended, 3 free)
e extended
Select (default p):
Using default response p
分区号 (2-4,默认 2):
起始 扇区 (41945088-167772159,默认为 41945088):
将使用默认值 41945088
Last 扇区, +扇区 or +sizeK,M,G (41945088-167772159,默认为 167772159):+20G
分区 2 已设置为 Linux 类型,大小设为 20 GiB
Partition type:
p primary (1 primary, 0 extended, 3 free)
e extended
Select (default p):
Using default response p
分区号 (2-4,默认 2):
起始 扇区 (41945088-167772159,默认为 41945088):
将使用默认值 41945088
Last 扇区, +扇区 or +sizeK,M,G (41945088-167772159,默认为 167772159):+20G
分区 2 已设置为 Linux 类型,大小设为 20 GiB
命令(输入 m 获取帮助):n
Partition type:
p primary (2 primary, 0 extended, 2 free)
e extended
Select (default p):
Using default response p
分区号 (3,4,默认 3):
起始 扇区 (83888128-167772159,默认为 83888128):
将使用默认值 83888128
Last 扇区, +扇区 or +sizeK,M,G (83888128-167772159,默认为 167772159):+20G
分区 3 已设置为 Linux 类型,大小设为 20 GiB
Partition type:
p primary (2 primary, 0 extended, 2 free)
e extended
Select (default p):
Using default response p
分区号 (3,4,默认 3):
起始 扇区 (83888128-167772159,默认为 83888128):
将使用默认值 83888128
Last 扇区, +扇区 or +sizeK,M,G (83888128-167772159,默认为 167772159):+20G
分区 3 已设置为 Linux 类型,大小设为 20 GiB
命令(输入 m 获取帮助):p
磁盘 /dev/sdb:85.9 GB, 85899345920 字节,167772160 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0xac26b8ab
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0xac26b8ab
设备 Boot Start End Blocks Id System
/dev/sdb1 2048 41945087 20971520 83 Linux
/dev/sdb2 41945088 83888127 20971520 83 Linux
/dev/sdb3 83888128 125831167 20971520 83 Linux
/dev/sdb1 2048 41945087 20971520 83 Linux
/dev/sdb2 41945088 83888127 20971520 83 Linux
/dev/sdb3 83888128 125831167 20971520 83 Linux
命令(输入 m 获取帮助):w
The partition table has been altered!
The partition table has been altered!
Calling ioctl() to re-read partition table.
正在同步磁盘。
3.将三个主分区转换为物理卷(pvcreate),扫描系统中的物理卷
[root@localhost ~]# pvcreate /dev/sdb[123]
Physical volume "/dev/sdb1" successfully created
Physical volume "/dev/sdb2" successfully created
Physical volume "/dev/sdb3" successfully created
[root@localhost ~]# pvscan
PV /dev/sda2 VG centos lvm2 [29.51 GiB / 44.00 MiB free]
PV /dev/sdb3 lvm2 [20.00 GiB]
PV /dev/sdb2 lvm2 [20.00 GiB]
PV /dev/sdb1 lvm2 [20.00 GiB]
Total: 4 [89.51 GiB] / in use: 1 [29.51 GiB] / in no VG: 3 [60.00 GiB]
4.使用两个物理卷创建卷组,名字为myvg,查看卷组大小
[root@localhost ~]# vgcreate myvg /dev/sdb[12]
Volume group "myvg" successfully created
[root@localhost ~]# vgdisplay /dev/myvg
--- Volume group ---
VG Name myvg
System ID
Format lvm2
Metadata Areas 2
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 2
Act PV 2
VG Size 39.99 GiB
PE Size 4.00 MiB
Total PE 10238
Alloc PE / Size 0 / 0
Free PE / Size 10238 / 39.99 GiB
VG UUID fY3K7H-FKfW-XZ9g-PaDW-Dwwi-dshM-Kvi8ii
正在同步磁盘。
3.将三个主分区转换为物理卷(pvcreate),扫描系统中的物理卷
[root@localhost ~]# pvcreate /dev/sdb[123]
Physical volume "/dev/sdb1" successfully created
Physical volume "/dev/sdb2" successfully created
Physical volume "/dev/sdb3" successfully created
[root@localhost ~]# pvscan
PV /dev/sda2 VG centos lvm2 [29.51 GiB / 44.00 MiB free]
PV /dev/sdb3 lvm2 [20.00 GiB]
PV /dev/sdb2 lvm2 [20.00 GiB]
PV /dev/sdb1 lvm2 [20.00 GiB]
Total: 4 [89.51 GiB] / in use: 1 [29.51 GiB] / in no VG: 3 [60.00 GiB]
4.使用两个物理卷创建卷组,名字为myvg,查看卷组大小
[root@localhost ~]# vgcreate myvg /dev/sdb[12]
Volume group "myvg" successfully created
[root@localhost ~]# vgdisplay /dev/myvg
--- Volume group ---
VG Name myvg
System ID
Format lvm2
Metadata Areas 2
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 2
Act PV 2
VG Size 39.99 GiB
PE Size 4.00 MiB
Total PE 10238
Alloc PE / Size 0 / 0
Free PE / Size 10238 / 39.99 GiB
VG UUID fY3K7H-FKfW-XZ9g-PaDW-Dwwi-dshM-Kvi8ii
5.创建逻辑卷mylv,大小为30G
[root@localhost ~]# lvcreate -L 30G -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 uPpkx8-cr4D-YoZB-LanG-BZMW-ThTH-lK62bK
LV Write Access read/write
LV Creation host, time localhost.localdomain, 2019-08-01 20:44:12 +0800
LV Status available
# open 0
LV Size 30.00 GiB
Current LE 7680
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:2
[root@localhost ~]# lvcreate -L 30G -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 uPpkx8-cr4D-YoZB-LanG-BZMW-ThTH-lK62bK
LV Write Access read/write
LV Creation host, time localhost.localdomain, 2019-08-01 20:44:12 +0800
LV Status available
# open 0
LV Size 30.00 GiB
Current LE 7680
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:2
6.将逻辑卷格式化成xfs文件系统,并挂载到/data目录上,创建文件测试
[root@localhost ~]# mkfs.xfs /dev/myvg/mylv
meta-data=/dev/myvg/mylv isize=256 agcount=4, agsize=1966080 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0 finobt=0
data = bsize=4096 blocks=7864320, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal log bsize=4096 blocks=3840, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
[root@localhost ~]# mkdir /data
[root@localhost ~]# mount /dev/myvg/mylv /data/
[root@localhost ~]# mkfs.xfs /dev/myvg/mylv
meta-data=/dev/myvg/mylv isize=256 agcount=4, agsize=1966080 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0 finobt=0
data = bsize=4096 blocks=7864320, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal log bsize=4096 blocks=3840, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
[root@localhost ~]# mkdir /data
[root@localhost ~]# mount /dev/myvg/mylv /data/
7.增大逻辑卷到35G
[root@localhost ~]# lvextend -L 35G /dev/myvg/mylv
Size of logical volume myvg/mylv changed from 30.00 GiB (7680 extents) to 35.00 GiB (8960 extents).
Logical volume mylv successfully resized
[root@localhost ~]# lvdisplay /dev/myvg/mylv
--- Logical volume ---
LV Path /dev/myvg/mylv
LV Name mylv
VG Name myvg
LV UUID uPpkx8-cr4D-YoZB-LanG-BZMW-ThTH-lK62bK
LV Write Access read/write
LV Creation host, time localhost.localdomain, 2019-08-01 20:44:12 +0800
LV Status available
# open 1
LV Size 35.00 GiB
Current LE 8960
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:2
[root@localhost ~]# lvextend -L 35G /dev/myvg/mylv
Size of logical volume myvg/mylv changed from 30.00 GiB (7680 extents) to 35.00 GiB (8960 extents).
Logical volume mylv successfully resized
[root@localhost ~]# lvdisplay /dev/myvg/mylv
--- Logical volume ---
LV Path /dev/myvg/mylv
LV Name mylv
VG Name myvg
LV UUID uPpkx8-cr4D-YoZB-LanG-BZMW-ThTH-lK62bK
LV Write Access read/write
LV Creation host, time localhost.localdomain, 2019-08-01 20:44:12 +0800
LV Status available
# open 1
LV Size 35.00 GiB
Current LE 8960
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:2
8.编辑/etc/fstab文件挂载逻辑卷,并支持磁盘配额选项
[root@localhost ~]# vim /etc/fstab
[root@localhost ~]# vim /etc/fstab
/dev/myvg/mylv xfs defaults,usrquota,grpquota 0 0
9.创建磁盘配额,crushlinux用户在/data目录下文件大小软限制为80M,硬限制为100M,
crushlinux用户在/data目录下文件数量软限制为80个,硬限制为100个。
crushlinux用户在/data目录下文件数量软限制为80个,硬限制为100个。
[root@localhost ~]# edquota -u crushlinux
Disk quotas for user crushlinux (uid 1001):
Filesystem blocks soft hard inodes soft hard
/dev/mapper/myvg-mylv 12 81920 102400 7 80 100
Filesystem blocks soft hard inodes soft hard
/dev/mapper/myvg-mylv 12 81920 102400 7 80 100
10.使用touch dd 命令在/data目录下测试
11.查看配额的使用情况:用户角度
12.查看配额的使用情况:文件系统角度
以上是关于chapter06的主要内容,如果未能解决你的问题,请参考以下文章