06 磁盘划分

06 磁盘划分

ls /dev/sdb

fdisk /dev/sdb

n p 1 回车键 +5G p w

ls -l /dev/sdb

格式化 mkfs.ext4/dev/sdb1

mkdir /xiaoniu

mount /dev/sdb1 /xiaoniu

df -h

vim /etc/fstab

dev/sdb1 /xiaoniu ext4 defaults 0 0

reboot

du命令

df -h

du -sh /* 查看文件目录每个文件占用的大小

free -m

fdisk /dev/sdb

p n e 2 回车 回车 n l +3G p w partprobe

mkswap /dev/sdb5

swapon /dev/sdb5

free -m

vim /dev/fstab

/dev/sdb5 swap swap defaults 0 0

reboot

磁盘配额

vim /etc/fstab

UUID=3140f7bc-7ad1-49f9-ba78-de519564edee /boot xfs defaults ,uquota 0 0

reboot

mount | grep boot

id linuxprobe

1. xfs_quota命令

个数 isoft 软限制 ihard 硬限制

大小 bsoft 软限制 bhard 硬限制

[root@linuxprobe ~]# xfs_quota -x -c 'limit bsoft=3m bhard=6m isoft=3 ihard=6 tom' /boot [root@linuxprobe ~]# xfs_quota -x -c report /boot User quota on /boot (/dev/sda1) Blocks User ID Used Soft Hard Warn/Grace

[root@linuxprobe ~]# su - tom [tom@linuxprobe ~]$ dd if=/dev/zero of=/boot/tom bs=5M count=1 1+0 records in 1+0 records out 5242880 bytes (5.2 MB) copied, 0.123966 s, 42.3 MB/s [tom@linuxprobe ~]$ dd if=/dev/zero of=/boot/tom bs=8M count=1 dd: error writing ‘/boot/tom’: Disk quota exceeded 1+0 records in 0+0 records out 6291456 bytes (6.3 MB) copied, 0.0201593 s, 312 MB/s

2、edquota命令

[root@linuxprobe ~]# edquota -u tom
Disk quotas for user tom (uid 1001):
Filesystem blocks soft hard inodes soft hard
/dev/sda1 6144 3072 8192 1 3 6
[root@linuxprobe ~]# su - tom
Last login: Mon Sep 7 16:43:12 CST 2017 on pts/0
[tom@linuxprobe ~]$ dd if=/dev/zero of=/boot/tom bs=8M count=1
1+0 records in
1+0 records out
8388608 bytes (8.4 MB) copied, 0.0268044 s, 313 MB/s
[tom@linuxprobe ~]$ dd if=/dev/zero of=/boot/tom bs=10M count=1
dd: error writing ‘/boot/tom’: Disk quota exceeded
1+0 records in
0+0 records out
8388608 bytes (8.4 MB) copied, 0.167529 s, 50.1 MB/s
软硬方式链接

ln命令

参数作用
-s 创建“符号链接”(如果不带-s参数,则默认创建硬链接)
-f 强制创建文件或目录的链接
-i 覆盖前先询问
-v 显示创建链接的过程
[root@linuxprobe ~]# echo "Welcome to linuxprobe.com" > readme.txt
[root@linuxprobe ~]# ln -s readme.txt readit.txt
[root@linuxprobe ~]# cat readme.txt
Welcome to linuxprobe.com
[root@linuxprobe ~]# cat readit.txt
Welcome to linuxprobe.com
[root@linuxprobe ~]# ls -l readme.txt
-rw-r--r-- 1 root root 26 Jan 11 00:08 readme.txt
[root@linuxprobe ~]# rm -f readme.txt
[root@linuxprobe ~]# cat readit.txt
cat: readit.txt: No such file or directory

接下来针对一个原始文件创建一个硬链接,即相当于针对原始文件的硬盘存储位置创建了一个指针,这样一来,新创建的这个硬链接就不再依赖于原始文件的名称等信息,也不会因为原始文件的删除而导致无法读取。同时可以看到创建硬链接后,原始文件的硬盘链接数量增加到了2。

[root@linuxprobe ~]# echo "Welcome to linuxprobe.com" > readme.txt
[root@linuxprobe ~]# ln readme.txt readit.txt
[root@linuxprobe ~]# cat readme.txt
Welcome to linuxprobe.com
[root@linuxprobe ~]# cat readit.txt
Welcome to linuxprobe.com
[root@linuxprobe ~]# ls -l readme.txt
-rw-r--r-- 2 root root 26 Jan 11 00:13 readme.txt
[root@linuxprobe ~]# rm -f readme.txt
[root@linuxprobe ~]# cat readit.txt
Welcome to linuxprobe.com
posted @ 2020-03-30 12:28  一只小白呀  阅读(161)  评论(0编辑  收藏  举报