Linux磁盘分区管理
磁盘管理
Linux磁盘管理好坏管理直接关系到整个系统的性能问题。
Linux磁盘管理常用四个命令为df、du和fdisk,free,blkid。
• df:列出文件系统的整体磁盘使用量
• du:检查磁盘空间使用量
• fdisk:用于磁盘分区
•free:可以显示当前系统未使用的和已使用的内存数目,还可以显示被内核使用的内存缓冲区。
• blkid:查看磁盘uuid,type
命令介绍
df
df命令参数功能:检查文件系统的磁盘空间占用情况。可以利用该命令来获取硬盘被占用了多少空间,目前还剩下多少空间等信息。
语法:
df [-ahikHTm] [目录或文件名]
选项与参数:
• -a :列出所有的文件系统,包括系统特有的 /proc 等文件系统;
• -k :以 KBytes 的容量显示各文件系统;
• -m :以 MBytes 的容量显示各文件系统;
• -h :以人们较易阅读的 GBytes, MBytes, KBytes 等格式自行显示;
• -H :以 M=1000K 取代 M=1024K 的进位方式;
• -T :显示文件系统类型, 连同该 partition 的 filesystem 名称 (例如 ext3) 也列出;
• -i :不用硬盘容量,而以 inode 的数量来显示
1.用于显示磁盘分区上的可使用的磁盘空间
df -ah
2.统计目录(或文件)所占磁盘空间的大小。
du –sh file/directory
fdisk
磁盘分区命令
1.查看当前系统识别了几块硬盘:
fdisk -l
2.fdisk /dev/设备 新建分区
[root@localhost ~]# fdisk /dev/sdb 划分/dev/sdb
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): m 获取帮助
Command action
a toggle a bootable flag
b edit bsd disklabel 设定设备标签
c toggle the dos compatibility flag
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
p print the partition table 显示分区表
q quit without saving changes 退出分区工具
s create a new empty Sun disklabel
t change a partition's system 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
P