# 文件系统管理 #
## 常用的磁盘管理命令 ##
1、df 命令
常用选项:
-a 显示特殊文件系统,
-h 人性化单位显示
-T显示文件系统类型
2、du [选项] [目录或者文件名]
-a 显示每一个子文件磁盘占用量
-h 人性化单位显示
-s 统计总量占用比例
3、stat 文件名 可以查看文件详细时间
4、判断文件类型的有file命令 判断文件类型,tpye 判断命令类型。
## fdisk 给磁盘分区 ##
1、查看当前系统所有硬件分区情况 fidisk -l 或者lsblk也可以简单的磁盘分区情况,如果新加磁盘没有显示,可以通过:
echo "- - -" > /sys/class/scsi_host/host{1、2、3}/scan来重新扫描SCSI总线添加设备
2、fdisk /dev/sdb 来给sdb就行分区
Command action
a toggle a bootable flag 设置可引导标记
b edit bsd disklabel 编辑bsd磁盘标签
c toggle the dos compatibility flag 设置一个dos操作系统兼容标记
d delete a partition 删除一个分区
g create a new empty GPT partition table
G create an IRIX (SGI) partition table
l list known partition types显示一致的文件类型
m print this menu 显示帮助
n add a new partition 增加分区
o create a new empty DOS partition table 建立一个空的dos 分区表
p print the partition table 显示分区信息
q quit without saving changes 退出不保存
s create a new empty Sun disklabel新建一个空白的sun磁盘标签
t change a partition's system id 改变一个分区的系统ID
u change display/entry units 改变显示记录单位
v verify the partition table 验证分区表
w write table to disk and exit保存退出
x extra functionality (experts only) 附加功能
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-20971519, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-20971519, default 20971519): +2G
Partition 1 of type Linux and of size 2 GiB is set
Command (m for help): w 一定要w 保存退出
The partition table has been altered!
#创建一个主分区,大小2G
Command (m for help): n
Partition type:
p primary (1 primary, 0 extended, 3 free)
e extended
Select (default p): e
Partition number (2-4, default 2):
First sector (4196352-20971519, default 4196352):
Using default value 4196352
Last sector, +sectors or +size{K,M,G} (4196352-20971519, default 20971519):
Using default value 20971519
Partition 2 of type Extended and of size 8 GiB is set
#创建一个扩展分区,把8G空间给到这个扩展分区。
Command (m for help): n
Partition type:
p primary (1 primary, 1 extended, 2 free)
l logical (numbered from 5)
Select (default p): l
Adding logical partition 5
First sector (4198400-20971519, default 4198400):
Using default value 4198400
Last sector, +sectors or +size{K,M,G} (4198400-20971519