ot@localhost ~]# fdisk /dev/sdc
命令(输入 m 获取帮助):n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
分区号 (1-4,默认 1):1
起始 扇区 (2048-41943039,默认为 2048):
将使用默认值 2048
Last 扇区, +扇区 or +size{K,M,G} (2048-41943039,默认为 41943039):
将使用默认值 41943039
分区 1 已设置为 Linux 类型,大小设为 20 GiB
命令(输入 m 获取帮助):
命令(输入 m 获取帮助):p
磁盘 /dev/sdc:21.5 GB, 21474836480 字节,41943040 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x19f070cc
设备 Boot Start End Blocks Id System
/dev/sdc1 2048 41943039 20970496 83 Linux
命令(输入 m 获取帮助):w
The partition table has been altered!
Calling ioctl() to re-read partition table.
正在同步磁盘。
[root@localhost ~]# mkfs.ext4 /dev/sdc
mke2fs 1.42.9 (28-Dec-2013)
/dev/sdc is entire device, not just one partition!
无论如何也要继续? (y,n) y
文件系统标签=
OS type: Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
1310720 inodes, 5242880 blocks
262144 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=2153775104
160 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 ~]# mkdir /IT
修改/etc/fstab文件,设置开机后自动挂载/dev/sdc 分区到/IT目录,支持磁盘配额功能
Usrquota(用户配额)
Grpquota(组配额)
[root@localhost /]# cat /etc/fstab
# /etc/fstab
# Created by anaconda on Mon Oct 22 21:16:34 2018
#
# 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=681f3d0d-b5ee-47a1-80c3-754d6a1bdbbe /boot xfs defaults 0 0
/dev/mapper/centos-swap swap swap defaults 0 0
/dev/sdb1 swap swap defaults 0 0
/dev/sdc /IT ext4 defaults,usrquota,grpquota,usrquota 0 0
重启对分区进行挂载
[root@localhost /]# mount -o grpquota,usrquota /dev/sdc /IT/
进入挂载目录中去创建配额文件
[root@localhost IT]# quotacheck -ucvg /dev/sdc
[root@localhost IT]# ll
总用量 32
-rw------- 1 root root 6144 11月 3 19:42 aquota.group
-rw------- 1 root root 6144 11月 3 19:42 aquota.user
drwx------ 2 root root 16384 11月 3 19:19 lost+found
为用户admin创建一个为限制10M,超过7M就会报警的配额并查看
[root@localhost IT]# setquota -u admin 7000 10000 0 0 /dev/sdc
[root@localhost IT]# edquota -u admin
Disk quotas for user admin (uid 1000):
Filesystem blocks soft hard inodes soft hard
/dev/sdc 0 7000 10000 0 0 0
启用配额管理
quotaon /dev/sdc