Linux磁盘和⽂件系统管理⽂件实验1、添加 10G 硬盘,为硬盘分三个分区:
分区1:1G ext4 挂载⾄ /part-ext4
分区2:2G xfs 挂载⾄ /part-xfs
分区3:2G swap (代码82)
下列字符中ascii码值最小的分别设置分区1,分区2 可以开机⾃动挂载,启⽤swap分区3
[root@localhost ~]# fdisk -l
Disk /dev/sdb: 10.7 GB, 10737418240 bytes, 20971520 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
[root@localhost ~]# mkdir /part-ext4
[root@localhost ~]# mkdir /part-xfs
[root@localhost ~]# 4 /dev/sdb1
[root@localhost ~]# mkfs.xfs /dev/sdb2
[root@localhost ~]# vim /etc/fstab
[root@localhost ~]# mkswap /dev/sdb3
2、创建⼀个逻辑分区 /dev/sdb5 分区5:2G
配置 autofs ⾃动挂载⾄⽬录 /autodir/test 并设置⽬录20秒不被使⽤时⾃动卸载
[root@localhost ~]# mkfs.xfs /dev/sdb5
[root@localhost ~]# vim /etc/auto.master
linux建立文件系统的命令/autodir /etc/auto.misc --timeout=20
[root@localhost ~]# vim /etc/auto.misc
it培训创新与技术test -fstype=xfs :/dev/sdb5
[root@localhost ~]# systemctl start autofs
[root@localhost ~]# systemctl enable autofs
3、将 Centos 7 光盘制作成 iso 镜像⽂件,并将镜像⽂件挂载⾄ /dvd ⽬录
[root@localhost ~]# useradd li
[root@localhost ~]# dd if=/dev/cdrom of=/root/centos7.iso
[root@localhost ~]# mkdir /dvd
[root@localhost ~]# mount -o loop centos7.iso /dvd
4、为 /part-ext4 ⽬录配置磁盘配额,设置⽤户 li 的磁盘软配额为 8M 硬配额为 10M
i节点软配额 2 硬配额 3 ,并经过验证
[root@localhost ~]# cd /part-ext4
[root@localhost part-ext4]# quotacheck -avug
[root@localhost part-ext4]# ls
[root@localhost part-xfs]# cd /part-ext4
[root@localhost part-ext4]# edquota -u li
[root@localhost part-ext4]# chmod 1777 /part-ext4/
[root@localhost part-ext4]# quotaon /part-ext4/
5、为 /part-xfs ⽬录配置磁盘配额,设置⽤户 li 的磁盘软配额为 20M 硬配额为 30M
i节点软配额 2 硬配额 3,并经过验证
[root@localhost ~]# xfs_quota -x -c 'limit bsoft=20M bhard=30M isoft=2 ihard=3 li' /part-xfs/手机播放器下载安卓版
[root@localhost ~]# xfs_quota -x -c report /part-xfs/
[root@localhost ~]# chmod 1777 /part-xfs/
测试
[root@localhost ~]# su - li
[li@localhost part-ext4]$ dd if=/dev/zero of=/part-ext4/kk bs=1M count=9
sdb1: warning, user block quota exceeded.
9+0 records in
9+0 records out
9437184 bytes (9.4 MB) copied, 0.13922 s, 67.8 MB/s
[li@localhost part-ext4]$ dd if=/dev/zero of=/part-ext4/kk2 bs=1M count=2 sdb1: write failed, user block limit reached.
dd: error writing ‘/part-ext4/kk2’: Disk quota exceeded
2+0 records in
1+0 records out
1048576 bytes (1.0 MB) copied, 0.0142495 s, 73.6 MB/s
[li@localhost part-ext4]$ ll
total 10272
-rw-------. 1 root root 7168 Oct 29 15:up
-rw-------. 1 root root 7168 Oct 29 15:14 aquota.user
-rw-rw-r--. 1 li li 9437184 Oct 29 15:25 kk
-rw-rw-r--. 1 li li 1048576 Oct 29 15:26 kk2
drwx------. 2 root root 16384 Oct 29 14:19 lost+found
[li@localhost ~]$ cd /part-xfs
form a[li@localhost part-xfs]$ dd if=/dev/zero of=/part-xfs/aa bs=1M count=29 29+0 records in
php开发工具排行榜
29+0 records out
30408704 bytes (30 MB) copied, 0.313577 s, 97.0 MB/s
[li@localhost part-xfs]$ dd if=/dev/zero of=/part-xfs/aa1 bs=1M count=2 dd: error writing ‘/part-xfs/aa1’: Disk quota exceeded
2+0 records in
1+0 records out
1048576 bytes (1.0 MB) copied, 0.0120921 s, 86.7 MB/s
[li@localhost part-xfs]$ dd if=/dev/zero of=/part-xfs/aa2 bs=1M count=2 dd: failed to open ‘/part-xfs/aa2’: Disk quota exceeded
[li@localhost part-xfs]$ ll
total 30720
-rw-rw-r--. 1 li li 30408704 Oct 29 15:27 aa
-rw-rw-r--. 1 li li 1048576 Oct 29 15:27 aa1
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论