linux怎样 设定磁盘配额,Linux用户磁盘配额设置方法

本文详细介绍了如何在Linux系统下检查内核是否支持QUOTA,通过修改/etc/fstab文件添加QUOTA支持,以及使用quotacheck初始化QUOTA数据库的过程。这些步骤对于管理和限制用户或组在特定文件系统的磁盘使用非常关键。
摘要由CSDN通过智能技术生成

一:内核中支持QUOTA:

[root@localhost /]# grep CONFIG_QUOTA /boot/config-3.10.0-123.el7.x86_64

CONFIG_QUOTA=y

CONFIG_QUOTA_NETLINK_INTERFACE=y

# CONFIG_QUOTA_DEBUG is not set

CONFIG_QUOTA_TREE=y

CONFIG_QUOTACTL=y

CONFIG_QUOTACTL_COMPAT=y

如果有上列输出,则表示当前内核已经支持quota。

二:修改/etc/fstab加入QUOTA支持:

[root@localhost /]# vim /etc/fstab

/dev/sdb1       /dvd    xfs     defaults,usrquota,grpquota    1      2

三:使用quotacheck初始化QUOTA数据库:

因为quotacheck依据/etc/mtab搜索文件系统,所以要将刚刚修改的/dev/sdb1重新挂载

[root@localhost /]# mount /dvd -o remount

[root@localhost /]# mount

proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)

sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime,seclabel)

devtmpfs on /dev type devtmpfs (rw,nosuid,seclabel,size=926912k,nr_inodes=231728,mode=755)

securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)

tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev,seclabel)

devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,seclabel,gid=5,mode=620,ptmxmode=000)

tmpfs on /run type tmpfs (rw,nosuid,nodev,seclabel,mode=755)

tmpfs on /sys/fs/cgroup type tmpfs (rw,nosuid,nodev,noexec,seclabel,mode=755)

cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd)

pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime)

cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset)

cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpuacct,cpu)

cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory)

cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)

cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)

cgroup on /sys/fs/cgroup/net_cls type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls)

cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)

cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event)

cgroup on /sys/fs/cgroup/hugetlb type cgroup (rw,nosuid,nodev,noexec,relatime,hugetlb)

configfs on /sys/kernel/config type configfs (rw,relatime)

/dev/sda3 on / type xfs (rw,relatime,seclabel,attr2,inode64,noquota)

selinuxfs on /sys/fs/selinux type selinuxfs (rw,relatime)

systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=32,pgrp=1,timeout=300,minproto=5,maxproto=5,direct)

hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime,seclabel)

debugfs on /sys/kernel/debug type debugfs (rw,relatime)

mqueue on /dev/mqueue type mqueue (rw,relatime,seclabel)

sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw,relatime)

sunrpc on /proc/fs/nfsd type nfsd (rw,relatime)

/dev/sda1 on /boot type xfs (rw,relatime,seclabel,attr2,inode64,noquota)

/dev/sdb1 on /dvd type ext2 (rw,relatime,seclabel,quota,usrquota,grpquota)

[root@localhost /]# quotacheck -avug

quotacheck: Quota for users is enabled on mountpoint /dvd so quotacheck might damage the file.

Please turn quotas off or use -f to force checking.

-a : 扫描所有在/etc/mtab中开启quota的文件系统

-v : 显示扫描过程

-u : 扫描所有user quotas (usrquota)

-g : 扫描所有group quotas (grpquota)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值