Linux基础教程:关于fdisk分区

fdisk 挺好学的,因为基本上按个m它就能告诉你该怎么做了。我这里有一个20g的虚拟磁盘。实际操作下。

开始对磁盘/dev/sdb分区
[root@rhel6 sjb]# fdisk /dev/sdb

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
        switch off the mode (command 'c') and change display units to
        sectors (command 'u').

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  显示已知的分区类型以及对应的id号
  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          改变分区id,即分区类型
  u  change display/entry units             
  v  verify the partition table           
  w  write table to disk and exit            写入分区表并退出
  x  extra functionality (experts only)       
 

显示磁盘分区
Command (m for help): p

Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xce4aaddb

  Device Boot      Start        End      Blocks  Id  System
/dev/sdb1  *          1        131    1048576  83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sdb2            131        784    5242880  83  Linux
Partition 2 does not end on cylinder boundary.
/dev/sdb3            784        1045    2097152  82  Linux swap / Solaris
Partition 3 does not end on cylinder boundary.
/dev/sdb4            1045        2611    12580864    f  W95 Ext'd (LBA)
Partition 4 does not end on cylinder boundary.
/dev/sdb5            1045        2611    12579840  83  Linux
删除磁盘分区
Command (m for help): d
Partition number (1-5): 1
Command (m for help): d
Partition number (1-5): 2
Command (m for help): d
Partition number (1-5): 3
Command (m for help): d
Partition number (1-5): 4
Command (m for help): d
Partition number (1-5): 5
查看删除情况
Command (m for help): p

Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xce4aaddb

  Device Boot      Start        End      Blocks  Id  System
 

新建主分区1,起始磁柱为1,分区大小我们用+100M来指定分区大小为100M.
Command (m for help): n
Command action
  e  extended
  p  primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-2610, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610): +100M

指定其为活动分区
Command (m for help): a
Partition number (1-6): 1

建立主分区2,大小为1G
Command (m for help): n
Command action
  e  extended
  p  primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (15-2610, default 15):
Using default value 15
Last cylinder, +cylinders or +size{K,M,G} (15-2610, default 2610): +1G

相关推荐