Partition type:
p primary (1 primary, 0 extended, 3 free)
e extended
Last 扇区, +扇区 or +size{K,M,G} (20973568-46088191,默认为 46088191):+6G
分区 2 已设置为 Linux 类型,大小设为 6 GiB
-选择d删除之前的设置,选择w保存分区设置,设置成功。
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: 设备或资源忙.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
正在同步磁盘。
mkfs.文件系统名 /dev/新建分区名
如果在设置的时候出现找不到分区的情况,终端输入partprobe即可。
进行挂载:mount -o uquota,gquota /dev/新建分区名 /mnt/新建分区名
当使用的是xfs文件系统时,挂载必须加上-o uquota,gquota,并且载fstab文件中defaults后也必须加上
uquota,gquota;但是如果使用的是ext4文件系统,这两处都不要添加这些内容。
保存配置即可
注意:dev/新建分区名可以使用UUID来代替,使用blkid来查询所有分区UUID,把UUID复制到第一个位置
/dev/sdb2 /mnt/sdb2 xfs defaults,uquota,gquota 0 0
15 /dev/sdb3 /mnt/sdb3 ext4 defaults 0 0
挂载完成
User quota on /mnt/sdb2 (/dev/sdb2)
Blocks Inodes
User ID Used Soft Hard Warn/Grace Used Soft Hard Warn/Grace
---------- --------------------------------- ---------------------------------
root 0 0 0 00 [------] 3 0 0 00 [------]
Group quota on /mnt/sdb2 (/dev/sdb2)
Blocks Inodes
Group ID Used Soft Hard Warn/Grace Used Soft Hard Warn/Grace
---------- --------------------------------- ---------------------------------
root 0 0 0 00 [------] 3 0 0 00 [------]
xfs_quota -x -c 'limit -u isoft=5 ihard=10 liuyang' /mnt/sdb2
xfs_quota -x -c 'limit -g isoft=6 ihard=15 group1' /mnt/sdb2
i是对节点进行限制,也可以使用b对块进行限制
mkswap: /dev/sdb3: warning: wiping old ext4 signature.
正在设置交换空间版本 1,大小 = 6265852 KiB
无标签,UUID=d98c05eb-ce84-4d90-a735-216f673bffa4
total used free shared buff/cache available
Mem: 5291 658 3969 21 663 4387
Swap: 11622 0 11622
total used free shared buff/cache available
Mem: 5291 655 3968 21 667 4389
Swap: 5503 0 5503
可以发现,当交换分区打开的时候,swap大小被扩展,当关闭的时候,swap大小还原为原来的大小。
正在设置交换空间版本 1,大小 = 4194300 KiB
无标签,UUID=916cd6c1-637b-40e4-bd4b-6af584cd4e85
设置swapfile权限:chmod 600 /swapfile
注意:这一步必须进行设定,不能不设
total used free shared buff/cache available
Mem: 5291 679 1145 21 3466 4323
Swap: 9599 0 9599
total used free shared buff/cache available
Mem: 5291 676 1148 21 3466 4326
Swap: 5503 0 5503
文件挂载:/swapfile swap swap defaults 0 0
交换分区的挂载点和文件系统都是swap,这个需要注意
原文:https://www.cnblogs.com/ddzc/p/12539471.html