您的位置:首页 > 运维架构 > Linux

Linux系统学习第三章:磁盘与文件系统管理(三)硬盘分区、格式化、检验与挂载

2012-12-04 10:42 861 查看
新增一块硬盘时,我们应该有的操作

  (1)对硬盘进行分区,以新建可用的分区

  (2)对硬盘进行格式化,以创建可用的文件系统

  (3)对新建的文件系统进行检验

  (4)创建挂载点,将它挂载上来

一、磁盘分区命令fdisk

  1、查看系统所有能够找到的设备的分区:fdisk -l

  

[root@localhost ~]# fdisk -l

Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 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        1288    10241437+  83  Linux
/dev/sda3            1289        1925     5116702+  83  Linux
/dev/sda4            1926        3916    15992707+   5  Extended
/dev/sda5            1926        2052     1020096   82  Linux swap / Solaris


看第一行:Disk /dev/sda:32.2GB,没有其他的disk,说明,这个系统只有一块硬盘,大小为32.2GB

每个设备对应着七列内容:

Device:代表设备对应的文件名

Boot:是否为开机引导模块

Start:该设备(分区)所在的柱面的开始号码

End:该设备所在的柱面的结束号码

Blocks:该分区的容量

System:所用的文件系统(只是参考)

  2、分区操作

    fdisk 设备名称

   输入以上命令后,会让你输入一些其他的参数,这些参数代表着不同的含义:

    (1)p 打印当前系统分区表

    

[root@localhost ~]# fdisk /dev/sda

The number of cylinders for this disk is set to 3916.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): p

Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 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        1288    10241437+  83  Linux
/dev/sda3            1289        1925     5116702+  83  Linux
/dev/sda4            1926        3916    15992707+   5  Extended
/dev/sda5            1926        2052     1020096   82  Linux swap / Solaris


  (2)m 调出参数命令菜单(相当于 --help)

    

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
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)


  (3)n 新建一个分区

  

Command (m for help): n
First cylinder (2053-3916, default 2053): 3500
Last cylinder or +size or +sizeM or +sizeK (3500-3916, default 3916): +100M

Command (m for help): p

Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 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        1288    10241437+  83  Linux
/dev/sda3            1289        1925     5116702+  83  Linux
/dev/sda4            1926        3916    15992707+   5  Extended
/dev/sda5            1926        2052     1020096   82  Linux swap / Solaris
/dev/sda6            3500        3512      104422+  83  Linux


  (4)d 删除一个分区

  

Command (m for help): d
Partition number (1-6): 6

Command (m for help): p

Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 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        1288    10241437+  83  Linux
/dev/sda3            1289        1925     5116702+  83  Linux
/dev/sda4            1926        3916    15992707+   5  Extended
/dev/sda5            1926        2052     1020096   82  Linux swap / Solaris


  (5)q 离开fdisk命令,不保存

  (6)w 把操作后的结果写入分区表并离开

二、磁盘格式化

  mkfs -t 文件系统类型 设备名

  如:mkfs -t ext3 /dev/sda6

三、磁盘检验

  fsck [-atCfD] 设备名称

  -a 自动修复检查到的有问题的扇区

  -t 指定文件系统(一般能自动识别)

  -C 显示检验过程的进度

  -f 强制检验

  -D 针对 文件系统下的目录进行优化配置

四、磁盘挂载与卸载 :mount、umount

  (1)mount 设备名 挂载目录

    如:mount /dev/sda6 /home/web

  (2)umount 设备名
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐