日期:2014-05-16  浏览次数:20714 次

Linux学习记录--磁盘分区,格式化与检验

磁盘分区,格式化与检验

?

磁盘分区:fdisk

磁盘格式化:mkfs,mke2fs

磁盘检测:fsck

?

磁盘分区

?

语法:fdisk[-l] 设备名称

-l:输出系统内所有分区

?

举例:

[root@localhost ~]# fdisk -l
 
Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280bytes
 
  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        2610    5502262+   5  Extended
/dev/sda5            1926        2052    1020096   82 Linux swap / Solaris
/dev/sda6            2053        2302    2008093+  83  Linux


1.?????? 查看磁盘文件名

[root@localhost ~]# df /

文件系统?????????????? 1K-块??????? 已用???? 可用 已用% 挂载点

/dev/sda2????????????? 9920624?? 4329108??5079448? 47% /

?

2.?????? 查看磁盘分区功能

[root@localhost ~]# fdisk /dev/sda  //这里不带数字
 
The number of cylinders for this disk isset to 2610.
There is nothing wrong with that, but thisis larger than 1024,
and could in certain setups cause problemswith:
1) software that runs at boot time (e.g.,old versions of LILO)
2) booting and partitioning software fromother OSs
  (e.g., DOS FDISK, OS/2 FDISK)
 
Command (m for help): m
Command action
  a   toggle a bootable flag
  b   edit bsd disklabel
  c   toggle the dos compatibilityflag
  d   delete a partition //删除磁盘分区
  l   list known partition types
  m   print this menu  //查看磁盘分区功能
  n   add a new partition //增加一个磁盘分区
  o   create a new empty DOSpartition table
  p   print the partition table //查看磁盘分区
  q   quit without saving changes
  s   create a new empty Sundisklabel
  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 (expertsonly)

?

删除磁盘分区

[root@localhost ~]# fdisk /dev/sda
 
The number of cylinders for this disk isset to 2610.
There is nothing wrong with that, but thisis larger than 1024,
and could in certain setups cause problemswith:
1) software that runs at boot time (e.g.,old versions of LILO)
2) booting and partitioning software fromother OSs
  (e.g., DOS FDISK, OS/2 FDISK)
 
Command (m for help): p
 
Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280bytes
 
  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        2610    5502262+   5  Extended
/dev/sda5            1926        2052    1020096   82  Linux swap / Solaris
/dev/sda6            2053        2302    2008093+  83  Linux

由上可知我的磁盘主要分为6个分区,1,2,3为主分区,4为扩展分区,5为swap分区,6是逻辑分区

?

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