df命令:
df
-l :仅显示本地文件系统的相关系统
[root@localhost local]# df -l /dev/sdb2
Filesystem 1K-blocks Used Available Use% Mounted on
- 494788 260 494528 1% /dev
[root@localhost local]# df -l
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda2 121418860 2719280 112525116 3% /
tmpfs 506144 72 506072 1% /dev/shm
/dev/sda1 289293 28485 245448 11% /boot
[root@localhost local]#
-h :单位换算
[root@localhost local]# df -h /dev/sdb2
Filesystem Size Used Avail Use% Mounted on
- 484M 260K 483M 1% /dev
[root@localhost local]#
-i :显示inode的使用情况而非磁盘块的
[root@localhost local]# df -i /dev/sdb2
Filesystem Inodes IUsed IFree IUse% Mounted on
- 123697 756 122941 1% /dev
[root@localhost local]#
du
用于评估文件大小
-s :统计整个目录及内部所有文件总体大小;
[root@localhost local]# du -s /etc/
39556 /etc/
[root@localhost local]#
-h:human-readable
[root@localhost local]# du -sh /etc/
39M /etc/
[root@localhost local]#
mkswap
free命令:查看内存的使用状况
free -m 兆显示
-g G显示
[root@localhost local]# free
total used free shared buffers cached
Mem: 1012292 623920 388372 1360 26996 395064
-/+ buffers/cache: 201860 810432
Swap: 2031612 0 2031612
[root@localhost local]# free -m
total used free shared buffers cached
Mem: 988 609 379 1 26 385
-/+ buffers/cache: 197 791
Swap: 1983 0 1983
[root@localhost local]# free -g
total(总体) used(已用) free(空闲) shared(共享) buffers(缓冲) cached(缓存)
Mem: 0 0 0 0 0 0
-/+ buffers/cache:() 0 0
Swap: 1 0 1
[root@localhost local]#
如何启用交换分区
swapon /dev/sda6(创建好的swap)
-a:启用/etc/fstab文件中定义的所有交换分区
禁用交换分区
swapoff device
文件系统相关的配置文件:/etc/fstab
[root@localhost local]# cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Sat Apr 4 08:45:23 2015
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=4fb479dc-0364-41ac-a12d-841210d879a4 / ext4 defaults 1 1
UUID=30d2724b-a9be-4e32-8b9a-cf731a92173a /boot ext4 defaults 1 2
UUID=7568de25-a229-43cb-952a-ca5fd83bbdcc swap swap defaults 0 0
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
[root@localhost local]#
定义开机可自动挂载的文件系统,每行一个:
/etc/fstab
6个列/字段
1,挂载的设备
设备文件
卷标
uuid
伪文件系统:如sysfs,proc,tmpfs等
2, 挂载点
swap的挂载点仍为swap
3,文件系统类型
4, 挂载选项
defaults表示使用默认挂载选项,多个挂载选项间使用逗号分隔:如defaults,alc,noatime
5,转储频率,多久备份一次
0:不备份
1:每天备份
2:每隔一天备份
6,自检次序,开机对文件自检
0:不自检
1:首先自检,通常根文件系统可首先自检
2:次级自检
....
一般来讲,除了根,其他文件开机不自检
示例:将/dev/sdb2 挂载到/tmp/1mark
vim /etc/fstab
/dev/sdb2 /tmp/1mark ext4 defaults,noatime 0 0
wq保存退出
mount -a 当前系统自动挂载
[root@localhost local]# mount
/dev/sda2 on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
/dev/sda1 on /boot type ext4 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
vmware-vmblock on /var/run/vmblock-fuse type fuse.vmware-vmblock (rw,nosuid,nodev,default_permissions,allow_other)
[root@localhost local]# mount -a
[root@localhost local]# mount
/dev/sda2 on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
/dev/sda1 on /boot type ext4 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
vmware-vmblock on /var/run/vmblock-fuse type fuse.vmware-vmblock (rw,nosuid,nodev,default_permissions,allow_other)
/dev/sdb2 on /tmp/1mark type ext4 (rw,noatime)
[root@localhost local]#