欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 科技 > IT业 > linux 操作系统下的用户磁盘配额场景介绍

linux 操作系统下的用户磁盘配额场景介绍

2026/3/13 13:28:27 来源:https://blog.csdn.net/lisanmengmeng/article/details/141951135  浏览:    关键词:linux 操作系统下的用户磁盘配额场景介绍

linux 操作系统下的用户磁盘配额场景介绍

安装部署qutoa

root@meng:~# apt install quota

Reading package lists... Done

Building dependency tree... Done

Reading state information... Done

Suggested packages:

libnet-ldap-perl rpcbind default-mta | mail-transport-agent

The following NEW packages will be installed:

quota

0 upgraded, 1 newly installed, 0 to remove and 224 not upgraded.

Need to get 213 kB of archives.

After this operation, 1249 kB of additional disk space will be used.

Get:1 http://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy/main amd64 quota amd64 4.06-1build2 [213 kB]

Fetched 213 kB in 2s (123 kB/s)

Preconfiguring packages ...

Selecting previously unselected package quota.

(Reading database ... 75135 files and directories currently installed.)

Preparing to unpack .../quota_4.06-1build2_amd64.deb ...

Unpacking quota (4.06-1build2) ...

Setting up quota (4.06-1build2) ...

Processing triggers for man-db (2.10.2-1) ...

Scanning processes...

Scanning linux images...

Running kernel seems to be up-to-date.

No services need to be restarted.

No containers need to be restarted.

No user sessions are running outdated binaries.

No VM guests are running outdated hypervisor (qemu) binaries on this host.

给系统账号 meng 配置配额

root@meng:~# id meng

uid=1000(meng) gid=1000(meng) groups=1000(meng),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),110(lxd)

root@meng:~# quota

root@meng:~# which quota

/usr/bin/quota

修改/etc/fstab文件支持配额

root@meng:~# cat /etc/fstab

# /etc/fstab: static file system information.

#

# Use 'blkid' to print the universally unique identifier for a

# device; this may be used with UUID= as a more robust way to name devices

# that works even if disks are added and removed. See fstab(5).

#

# <file system> <mount point> <type> <options> <dump> <pass>

# / was on /dev/ubuntu-vg/ubuntu-lv during curtin installation

/dev/disk/by-id/dm-uuid-LVM-YoRsmY1YOgfCYYiq7hmRVFR12j0fXJtVxxT6h8Tp7Gv0wPdyXnwGoX67m4e2hGQi / ext4 defaults 0 1

# /boot was on /dev/sda2 during curtin installation

/dev/disk/by-uuid/9f85f04d-eef5-4538-b062-caf325262174 /boot ext4 defaults 0 1

改成:

/dev/disk/by-id/dm-uuid-LVM-YoRsmY1YOgfCYYiq7hmRVFR12j0fXJtVxxT6h8Tp7Gv0wPdyXnwGoX67m4e2hGQi / ext4 defaults,usrquota 0 2

重新挂载文件系统

sudo mount -o remount /

使用quotacheck命令创建配额数据库文件

sudo quotacheck -cug / # -c表示创建,-u表示用户配额,-g表示组配额

使用setquota命令为用户meng设置配额,例如限制其使用100MB的软限制和120MB的硬限制:

sudo setquota -u meng 100M 120M 0 0 /

这里,0 0表示不设置inode限制。

使用quota命令检查用户meng的配额:

sudo quota -u meng

使用repquota命令可以生成所有用户的配额使用情况报告

sudo repquota -s /

sudo repquota -a

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词