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

新增一块硬盘时,我们应该有的操作

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

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

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

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

一、磁盘分区命令fdisk

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

  

 1 [root@localhost ~]# fdisk -l
 2 
 3 Disk /dev/sda: 32.2 GB, 32212254720 bytes
 4 255 heads, 63 sectors/track, 3916 cylinders
 5 Units = cylinders of 16065 * 512 = 8225280 bytes
 6 
 7    Device Boot      Start         End      Blocks   Id  System
 8 /dev/sda1   *           1          13      104391   83  Linux
 9 /dev/sda2              14        1288    10241437+  83  Linux
10 /dev/sda3            1289        1925     5116702+  83  Linux
11 /dev/sda4            1926        3916    15992707+   5  Extended
12 /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 打印当前系统分区表

    

 1 [root@localhost ~]# fdisk /dev/sda
 2 
 3 The number of cylinders for this disk is set to 3916.
 4 There is nothing wrong with that, but this is larger than 1024,
 5 and could in certain setups cause problems with:
 6 1) software that runs at boot time (e.g., old versions of LILO)
 7 2) booting and partitioning software from other OSs
 8    (e.g., DOS FDISK, OS/2 FDISK)
 9 
10 Command (m for help): p
11 
12 Disk /dev/sda: 32.2 GB, 32212254720 bytes
13 255 heads, 63 sectors/track, 3916 cylinders
14 Units = cylinders of 16065 * 512 = 8225280 bytes
15 
16    Device Boot      Start         End      Blocks   Id  System
17 /dev/sda1   *           1          13      104391   83  Linux
18 /dev/sda2              14        1288    10241437+  83  Linux
19 /dev/sda3            1289        1925     5116702+  83  Linux
20 /dev/sda4            1926        3916    15992707+   5  Extended
21 /dev/sda5            1926        2052     1020096   82  Linux swap / Solaris

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

    

 1 Command (m for help): m
 2 Command action
 3    a   toggle a bootable flag
 4    b   edit bsd disklabel
 5    c   toggle the dos compatibility flag
 6    d   delete a partition
 7    l   list known partition types
 8    m   print this menu
 9    n   add a new partition
10    o   create a new empty DOS partition table
11    p   print the partition table
12    q   quit without saving changes
13    s   create a new empty Sun disklabel
14    t   change a partition's system id
15    u   change display/entry units
16    v   verify the partition table
17    w   write table to disk and exit
18    x   extra functionality (experts only)

  (3)n 新建一个分区

  

 1 Command (m for help): n 
 2 First cylinder (2053-3916, default 2053): 3500     
 3 Last cylinder or +size or +sizeM or +sizeK (3500-3916, default 3916): +100M
 4 
 5 Command (m for help): p
 6 
 7 Disk /dev/sda: 32.2 GB, 32212254720 bytes
 8 255 heads, 63 sectors/track, 3916 cylinders
 9 Units = cylinders of 16065 * 512 = 8225280 bytes
10 
11    Device Boot      Start         End      Blocks   Id  System
12 /dev/sda1   *           1          13      104391   83  Linux
13 /dev/sda2              14        1288    10241437+  83  Linux
14 /dev/sda3            1289        1925     5116702+  83  Linux
15 /dev/sda4            1926        3916    15992707+   5  Extended
16 /dev/sda5            1926        2052     1020096   82  Linux swap / Solaris
17 /dev/sda6            3500        3512      104422+  83  Linux

  (4)d 删除一个分区

  

 1 Command (m for help): d
 2 Partition number (1-6): 6
 3 
 4 Command (m for help): p
 5 
 6 Disk /dev/sda: 32.2 GB, 32212254720 bytes
 7 255 heads, 63 sectors/track, 3916 cylinders
 8 Units = cylinders of 16065 * 512 = 8225280 bytes
 9 
10    Device Boot      Start         End      Blocks   Id  System
11 /dev/sda1   *           1          13      104391   83  Linux
12 /dev/sda2              14        1288    10241437+  83  Linux
13 /dev/sda3            1289        1925     5116702+  83  Linux
14 /dev/sda4            1926        3916    15992707+   5  Extended
15 /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 设备名

posted @ 2012-12-04 10:42  遗梦诗心  阅读(254)  评论(0编辑  收藏  举报