centos7之磁盘配额

centos
磁盘配额管理

针对普通用户,根用户除外

实验步骤:
1,添加一块新硬盘,分一个区,mkfs.ext4格式化
    /dev/sdb1        /mnt/disk        ext4    rw,usrquota,grpquota

2,安装配额的工具
yum -y install quota

3,创建配额文件quotacheck -ug /mnt/disk/(-u是用户配额,g是组配额)挂载点,会在挂载点生产两个文件:aquota.group和aquota.user(用户配额)

4,编辑用户配额或者组配额
     edquota -u 用户|edquota -g 组

    例如:创建mike用户,设置密码,编辑用户配额

    blocks:文件大小限制
    soft:数量软限制(警告位:只警告,不限制)。
    hard:数量硬限制(限制位:直接限制)
    inodes:针对文件数量
    /dev/sdb1        0    0    0    5    10    /数量软限制

6,启动配额:quotaon -ug /mnt/disk
     关闭配额:quotaoff -ug /mnt/disk

7,用mike用户去验证(注意文件夹要有写入的权限:ls -l查看)        //如果权限不够,需要添加权限
chmod o+w        //其他人权限+w写入

磁盘配额是ext4文件系统的一个功能

Last login: Sat Dec 19 06:57:29 2020 from 10.1.19.9
[root@localhost ~]# cd /
[root@localhost /]# ls /dev/sd*        //查看硬盘
/dev/sda  /dev/sda1  /dev/sda2  /dev/sdb
[root@localhost /]# cd /dev
[root@localhost dev]# fdisk sdb        //硬盘分区
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x72875d3a.

Command (m for help): n                //创建分区
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p                    //主分区
Partition number (1-4, default 1): 1       //区号
First sector (2048-2097151, default 2048):     //从哪里开始分区
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-2097151, default 2097151):  //回车代表全部分区
Using default value 2097151
Partition 1 of type Linux and of size 1023 MiB is set

Command (m for help): p                //查看分区

Disk sdb: 1073 MB, 1073741824 bytes, 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x72875d3a

Device Boot      Start         End      Blocks   Id  System
  sdb1            2048     2097151     1047552   83  Linux

Command (m for help): w                //保存并退出
The partition table has been altered!

# CentOS-Media.repo
#
#  This repo can be used with mounted DVD media, verify the mount point for
#  CentOS-7.  You can use this repo and yum to install items directly off the
#  DVD ISO that we release.
#
# To use this repo, put in your DVD and use it with the other repos too:
#  yum --enablerepo=c7-media [command]
#
# or for ONLY the media repo, do this:
#
#  yum --disablerepo=\* --enablerepo=c7-media [command]

[c7-media]
name=CentOS-$releasever - Media
baseurl=file:///media/CentOS/
        file:///media/cdrom/
        file:///media/cdrecorder/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

~                                                                                        
~                                                                                        
~                                                                                        
~                                                                                        
~                                                                                        
~                                                                                        
~                                                                                        
~                                                                                        
~                                                                                        
~                                                                                        
~                                                                                        
~                                                                                        
~                                                                                        
~                                                                                        
~                                                                                    
  • 0
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值