(1)disk free (查看磁盘的使用情况以及文件系统被挂载的位置)
df
显示如下:
文件系统 1K-块 已用 可用 已用% 挂载点
/dev/sda2 2672264 2473244 63272 98% /
/dev/sda1 101089 9233 86637 10% /boot
none 79012 0 79012 0% /dev/shm
(2)disk usage (显示空间的使用,包括文件和目录文件)
du -h 目录名 (h--human readable)
显示如下:
8.0K ./.kde/Autostart
12K ./.kde
4.0K ./.gnome2/accels
8.0K ./.gnome2/share/fonts
8.0K ./.gnome2/share/cursor-fonts
20K ./.gnome2/share
4.0K ./.gnome2/nautilus-scripts
28K ./.gnome2/panel2.d/default/launchers
32K ./.gnome2/panel2.d/default
36K ./.gnome2/panel2.d
76K ./.gnome2
48K ./.pyinput
du -sh 目录名 (s--summary)
显示一个目录的总大小
(3)分区
fdisk -l 查看所有磁盘情况
显示如下:
Disk /dev/sda: 3221 MB, 3221225472 bytes
255 heads, 63 sectors/track, 391 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 351 2714985 83 Linux
/dev/sda3 352 391 321300 82 Linux swap
Disk /dev/sdb: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdb doesn't contain a valid partition table
fdisk -l /dev/sda 查看sda磁盘情况
分区操作:
fdisk /dev/sdb
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
* d delete a partition
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)
(4)格式化
mkfs.bfs mkfs.ext2 mkfs.jfs mkfs.msdos mkfs.vfatmkfs.cramfs mkfs.ext3 mkfs.minix mkfs.reiserfs mkfs.xfs 等命令来格式化分区
比如我想格式化 sdb1为ext3文件系统,则输入;
mkfs.ext3 /dev/sdb1
(5)挂载文件系统
mount /dev/sdb1 /mnt/sdb1
umount /mnt/sdb1
但是这样重启之后不会自动挂载
编辑文件/etc/fstab加入/dev/sdb1 /opt ext3 defaults 0 0