你好,游客 登录 注册 搜索
背景:
阅读新闻

Linux下分区详解之--Fdisk

[日期:2012-05-06] 来源:Linux社区  作者:吴伟龙 [字体:大 中 小]

3、            通过Fdisk对磁盘分区进行操作:

Fdisk 创建分区:

[root@ www.linuxidc.com ~]#fdisk /dev/sdb

Device contains neither a valid DOSpartition table, nor Sun, SGI or OSF disklabel

Building a new DOS disklabel. Changes willremain in memory only,

until you decide to write them. After that,of course, the previous

content won't be recoverable.

 

 

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)

Warning: invalid flag 0x0000 of partitiontable 4 will be corrected by w(rite)

 

Command (m for help): n          ---输入m会有帮助信息出来,输入n不打印帮助信息

Command action

  e   extended

  p   primary partition (1-4)      ---指定分区类型  e为扩展分区   p为主分区

p

Partition number (1-4): 1           ---定义分区数量   --主分区最多只能有四个

First cylinder (1-2610, default 1): 1   ---设定起始分区的位置

Last cylinder or +size or +sizeM or +sizeK(1-2610, default 2610):

Using default value 2610            ---设定结束分区的位置

 

Command (m for help): w           ---保存刚才的配置信息。

The partition table has been altered!

 

Calling ioctl() to re-read partition table.

Syncing disks.

[root@ www.linuxidc.com ~]#

 

 Fdisk 删除分区:

 

[root@ www.linuxidc.com ~]# fdisk /dev/sdb   

 

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): d      ---d 是代表删除,并且会列出当前磁盘的分区数。

Selected partition 1

 

Command (m for help): p      ----p 是代表删除后,显示磁盘还有几个剩余的分区。

 

Disk /dev/sdb: 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    ----已经没有分区了

 

Command (m for help): w                  ----保存刚才的操作并且生效

The partition table has been altered!

 

Calling ioctl() to re-read partition table.

 

WARNING: Re-reading the partition tablefailed with error 16: Device or resource busy.  

The kernel still uses the old table.

The new table will be used at the nextreboot.

这里报了一错误,分区表正在使用,删除再下次启动生效

Syncing disks.        ---同步新的磁盘信息

[root@ www.linuxidc.com ~]# fdisk -l /dev/sdb

 

Disk /dev/sdb: 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

 

通过fdisk 命令来创建一指定大小的分区并增加一个分区

Fdisk n

linux
相关资讯       Linux入门教程 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款