1. 磁盘检验

fsck,badblocks

[root@xuhui ~]# fsck -f /dev/sda7
fsck from util-linux-ng 2.17.2
e2fsck 1.41.12 (17-May-2010)
/dev/sda7 is mounted.
e2fsck: Cannot continue, aborting.
[root@xuhui ~]# badblocks -sv /dev/sda5
Checking blocks 0 to 2097151
Checking for bad blocks (read-only test): done                                
Pass completed, 0 bad blocks found.

2.fdisk创建磁盘分区

主分区,扩展分区,逻辑分区的概念

fdisk /dev/sda

常用参数:

d   delete a partition

l   list known partition types

m   print this menu

n   add a new partition

p   print the partition table

q   quit without saving changes

t   change a partition's system id

w   write table to disk and exit

使用n新增分区,p打印分区,w保存分区,d删除分区,保存后使用partprobe完成,虚拟机环境还是需要重新启动系统来使分区生效。

格式化分区,mkfs -t ext4 /dev/sda6

挂载mount /dev/sda6 /mnt

为了保证每次开机都可以自动重新挂载,须将相关信息写入/etc/fstab中。

[root@xuhui ~]# vim /etc/fstab

#
# /etc/fstab
# Created by anaconda on Tue Apr  5 10:56:45 2016
#
# 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=bbfe4e63-7042-43eb-ac33-cd09b896a1b0 /                       ext4    defaults        1 1
UUID=aa7b074a-5dfc-4667-bbcd-547f334d7fee /boot                   ext4    defaults        1 2
UUID=ff5706bd-e2bc-4f0a-a56b-671c7a7a5790 /home                   ext4    defaults,usrquota,grpquota
1 2
UUID=951faf97-4225-4a4c-9fe3-aa34d52d2c97 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
/dev/sda7               /mnt                    ext4    defaults        0 0


mount相关命令

mount -o remount,rw /mnt

mount -o remount,ro /mnt

mount -o remount,noexec /mnt

mount -o remount,exec /mnt

umount取消挂载


增加swap分区

(1)增加分区,并将分区mkswap格式化为swap,swapon激活swap分区

(2)dd if=/dev/zero of=file bs=1M count=100

mkswap file

swapon file

swapoff file

cat /proc/swaps查看所有swap

[root@xuhui ~]# cat /proc/swaps
Filename                                Type            Size    Used    Priority
/dev/sda5                               partition       2097144 0       -1