你是否正在寻找关于fdisk的内容?让我把最全的东西奉献给你:

linux fdisk命令使用

2010-05-31 17:16:50

分类: LINUX

fdisk 对硬盘及分区的操作,进入fdisk 对硬盘操作阶段

我们可以对硬盘进行分区操作,前提是您把fdisk -l 弄明白了;通过fdisk -l ,我们能找出机器中所有硬盘个数及设备名称;比如上面的例子,我们会看到两个设备一个是/dev/hda ,另一个是/dev/sda ;

fdisk 操作硬盘的命令格式如下:

[root@localhost beinan]# fdisk 设备

比如我们通过 fdisk -l 得知 /dev/hda 或者 /dev/sda设备;我们如果想再添加或者删除一些分区,可以用

[root@localhost beinan]# fdisk /dev/hda

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

注 在以后的例子中,我们要以 /dev/sda设备为例,来讲解如何用fdisk 来操作添加、删除分区等动作;

fdisk 的说明

当我们通过 fdisk 设备,进入相应设备的操作时,会发现有如下的提示;以 fdisk /dev/sda 设备为例,以下同;

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

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 注:l是列出分区类型,以供我们设置相应分区的类型;

m print this menu 注:m 是列出帮助信息;

n add a new partition 注:添加一个分区;

o create a new empty DOS partition table

p print the partition table 注:p列出分区表;

q quit without saving changes 注:不保存退出;

s create a new empty Sun disklabel

t change a partition's system id 注:t 改变分区类型;

u change display/entry units

v verify the partition table

w write table to disk and exit 注:把分区表写入硬盘并退出;

x extra functionality (experts only) 注:扩展应用,专家功能;

其实我们常用的只有注有中文的,其它的功能我们不常用(呵,主要是我不会用,否则早会卖弄一下了);x扩展功能,也不是常用的;一般的情况下只要懂得 d l m p q t w 就行了;

下面以实例操作来详述,没有例子没有办法就,新手也看不懂;

列出当前操作硬盘的分区情况,用p

Command (m for help): p

Disk /dev/sda: 1035 MB, 1035730944 bytes

256 heads, 63 sectors/track, 125 cylinders

Units = cylinders of 16128 * 512 = 8257536 bytes

Device Boot Start End Blocks Id System

/dev/sda1 1 25 201568+ c W95 FAT32 (LBA)

/dev/sda2 26 125 806400 5 Extended

/dev/sda5 26 50 201568+ 83 Linux

/dev/sda6 51 76 200781 83 Linux

通过fdisk的d指令来删除一个分区

Command (m for help): p 注:列出分区情况;

Disk /dev/sda: 1035 MB, 1035730944 bytes

256 heads, 63 sectors/track, 125 cylinders

Units = cylinders of 16128 * 512 = 8257536 bytes

Device Boot Start End Blocks Id System

/dev/sda1 1 25 201568+ c W95 FAT32 (LBA)

/dev/sda2 26 125 806400 5 Extended

/dev/sda5 26 50 201568+ 83 Linux

/dev/sda6 51 76 200781 83 Linux

Command (m for help): d 注:执行删除分区指定;

Partition number (1-6): 6 注:我想删除 sda6 ,就在这里输入 6 ;

Command (m for help): p 注:再查看一下硬盘分区情况,看是否删除了?

Disk /dev/sda: 1035 MB, 1035730944 bytes

256 heads, 63 sectors/track, 125 cylinders

Units = cylinders of 16128 * 512 = 8257536 bytes

Device Boot Start End Blocks Id System

/dev/sda1 1 25 201568+ c W95 FAT32 (LBA)

/dev/sda2 26 125 806400 5 Extended

/dev/sda5 26 50 201568+ 83 Linux

Command (m for help):

警告:删除分区时要小心,请看好分区的序号,如果您删除了扩展分区,扩展分区之下的逻辑分区都会删除;所以操作时一定要小心;如果知道自己操作错了,请不要惊慌,用q不保存退出;切记切记!!!!在分区操作错了之时,千万不要输入w保存退出!!!

通过fdisk的n指令增加一个分区

Command (m for help): p

Disk /dev/sda: 1035 MB, 1035730944 bytes

256 heads, 63 sectors/track, 125 cylinders

Units = cylinders of 16128 * 512 = 8257536 bytes

Device Boot Start End Blocks Id System

/dev/sda1 1 25 201568+ c W95 FAT32 (LBA)

/dev/sda2 26 125 806400 5 Extended

/dev/sda5 26 50 201568+ 83 Linux

Command (m for help): n 注:增加一个分区;

Command action

l logical (5 or over) 注:增加逻辑分区,分区编号要大于5;为什么要大于5,因为已经有sda5了;

p primary partition (1-4) 注:增加一个主分区;编号从 1-4 ;但sda1 和sda2都被占用,所以只能从3开始;

p

Partition number (1-4): 3

No free sectors available 注:失败中,为什么失败?

注:我试图增加一个主分区,看来是失败了,为什么失败?因为我们看到主分区+扩展分区把整个磁盘都用光了,看扩展分区的End的值,再看一下 p输出信息中有125 cylinders;最好还是看前面部份;那里有提到;

所以我们只能增加逻辑分区了

Command (m for help): n

Command action

l logical (5 or over)

p primary partition (1-4)

l 注:在这里输入l,就进入划分逻辑分区阶段了;

First cylinder (51-125, default 51): 注:这个就是分区的Start 值;这里最好直接按回车,如果您输入了一个非默认的数字,会造成空间浪费;

Using default value 51

Last cylinder or +size or +sizeM or +sizeK (51-125, default 125): +200M 注:这个是定义分区大小的,+200M 就是大小为200M ;当然您也可以根据p提示的单位cylinder的大小来算,然后来指定 End的数值。回头看看是怎么算的;还是用+200M这个办法来添加,这样能直观一点。如果您想添加一个10G左右大小的分区,请输入 +10000M ;

Command (m for help):

通过fdisk的t指令指定分区类型

Command (m for help): t 注:通过t来指定分区类型;

Partition number (1-6): 6 注:要改变哪个分区类型呢?我指定了6,其实也就是sda6

Hex code (type L to list codes):L 注:在这里输入L,就可以查看分区类型的id了;

Hex code (type L to list codes): b 注:如果我想让这个分区是 W95 FAT32 类型的,通过L查看得知 b是表示的是,所以输入了b;

Changed system type of partition 6 to b (W95 FAT32) 注:系统信息,改变成功;是否是改变了,请用p查看;

Command (m for help): p

Disk /dev/sda: 1035 MB, 1035730944 bytes

256 heads, 63 sectors/track, 125 cylinders

Units = cylinders of 16128 * 512 = 8257536 bytes

Device Boot Start End Blocks Id System

/dev/sda1 1 25 201568+ c W95 FAT32 (LBA)

/dev/sda2 26 125 806400 5 Extended

/dev/sda5 26 50 201568+ 83 Linux

/dev/sda6 51 75 201568+ b W95 FAT32

6、fdisk 的退出,用q或者 w

其中 q是 不保存退出,w是保存退出

Command (m for help): w

Command (m for help): q

四,一个添加分区的例子

本例中我们会添加两个200M的主分区,其它为扩展分区,在扩展分区中我们添加两个200M大小的逻辑分区

Command (m for help): p 注:列出分区表;

Disk /dev/sda: 1035 MB, 1035730944 bytes

256 heads, 63 sectors/track, 125 cylinders

Units = cylinders of 16128 * 512 = 8257536 bytes

Device Boot Start End Blocks Id System

Command (m for help): n 注:添加分区;

Command action

e extended

p primary partition (1-4)

p 注:添加主分区;

Partition number (1-4): 1 注:添加主分区1;

First cylinder (1-125, default 1): 注:直接回车,主分区1的起始位置;默认为1,默认就好;

Using default value 1

Last cylinder or +size or +sizeM or +sizeK (1-125, default 125): +200M 注:指定分区大小,用+200M来指定大小为200M

Command (m for help): n 注:添加新分区;

Command action

e extended

p primary partition (1-4)

p 注:添加主分区

Partition number (1-4): 2 注:添加主分区2;

First cylinder (26-125, default 26):

Using default value 26

Last cylinder or +size or +sizeM or +sizeK (26-125, default 125): +200M 注:指定分区大小,用+200M来指定大小为200M

Command (m for help): n

Command action

e extended

p primary partition (1-4)

e 注:添加扩展分区;

Partition number (1-4): 3 注:指定为3 ,因为主分区已经分了两个了,这个也算主分区,从3开始;

First cylinder (51-125, default 51): 注:直接回车;

Using default value 51

Last cylinder or +size or +sizeM or +sizeK (51-125, default 125): 注:直接回车,把其余的所有空间都给扩展分区;

Using default value 125

Command (m for help): p

Disk /dev/sda: 1035 MB, 1035730944 bytes

256 heads, 63 sectors/track, 125 cylinders

Units = cylinders of 16128 * 512 = 8257536 bytes

Device Boot Start End Blocks Id System

/dev/sda1 1 25 201568+ 83 Linux

/dev/sda2 26 50 201600 83 Linux

/dev/sda3 51 125 604800 5 Extended

Command (m for help): n

Command action

l logical (5 or over)

p primary partition (1-4)

l 注:添加逻辑分区;

First cylinder (51-125, default 51):

Using default value 51

Last cylinder or +size or +sizeM or +sizeK (51-125, default 125): +200M 注:添加一个大小为200M大小的分区;

Command (m for help): n

Command action

l logical (5 or over)

p primary partition (1-4)

l 注:添加一个逻辑分区;

First cylinder (76-125, default 76):

Using default value 76

Last cylinder or +size or +sizeM or +sizeK (76-125, default 125): +200M 注:添加一个大小为200M大小的分区;

Command (m for help): p 列出分区表;

Disk /dev/sda: 1035 MB, 1035730944 bytes

256 heads, 63 sectors/track, 125 cylinders

Units = cylinders of 16128 * 512 = 8257536 bytes

Device Boot Start End Blocks Id System

/dev/sda1 1 25 201568+ 83 Linux

/dev/sda2 26 50 201600 83 Linux

/dev/sda3 51 125 604800 5 Extended

/dev/sda5 51 75 201568+ 83 Linux

/dev/sda6 76 100 201568+ 83 Linux

然后我们根据前面所说通过t指令来改变分区类型;

最后不要忘记w保存退出

本文来自电脑杂谈,转载请注明本文网址:

http://www.pc-fly.com/a/jisuanjixue/article-11405-1.html

Linux低级格式化硬盘,低级格式化?ghost?linux fdisk命令使用相关推荐

  1. linux用ghost 未格式化,低级格式化?ghost?linux fdisk命令使用(2)

    五.对分区进行格式化,以及加载 先提示一下:用 mkfs.bfs mkfs.ext2 mkfs.jfs mkfs.msdos mkfs.vfatmkfs.cramfs mkfs.ext3 mkfs.m ...

  2. linux学习笔记(10)fdisk命令

    一.fdisk 的介绍: 显示磁盘分区或磁盘信息命令. fdsik 也能划分磁盘成为若干个区,同时也能为每个分区指定文件系统. 二.fdisk -l 查看硬盘及分区信息: 主分区(包括扩展分区)的总个 ...

  3. Linux下fdisk命令操作磁盘详解--添加、删除、转换分区

    linux下fdisk命令操作磁盘详解--添加.删除.转换分区等 fdisk 操作硬盘的命令格式如下: [root@localhost beinan]# fdisk 设备 比如我们通过 fdisk - ...

  4. oracle linux查看磁盘,fdisk命令_Linux fdisk命令使用详解:查看磁盘使用情况与磁盘分区...

    fdisk命令用于观察硬盘实体使用情况,也可对硬盘分区.它采用传统的问答式界面,而非类似DOS fdisk的cfdisk互动式操作界面,因此在使用上较为不便,但功能却丝毫不打折扣. 语法 fdisk( ...

  5. linux中fdisk的参数,Linux fdisk命令参数及用法详解--Linux磁盘分区管理命令fdisk

    fdisk 命令 linux磁盘分区管理 用途:观察硬盘之实体使用情形与分割硬盘用. 使用方法: 一.在 console 上输入 fdisk -l /dev/sda ,观察硬盘之实体使用情形. 二.在 ...

  6. Linux中fdisk对应的c函数,linux下fdisk命令实战案例之详解

    一.fdisk命令中参数介绍: 1.查看硬盘使用情形#fdisk -l 观察硬盘之实体使用情形 2.fdisk /dev/sda,进入硬盘分割模式1. 输入 m 显示所有命令列示. 2. 输入 p 显 ...

  7. linux下使用fdisk命令进行硬盘分区

    添加一块硬盘 # fdisk -l Disk /dev/vdb: 53.7 GB, 53687091200 bytes 16 heads, 63 sectors/track, 104025 cylin ...

  8. Linux 命令(38)—— fdisk 命令

    文章目录 1.命令简介 2.命令格式 3.选项说明 4.常用示例 参考文献 1.命令简介 fdisk 命令用于创建和维护磁盘分区表. 它采用传统的问答式界面,而不是类似于 fdisk 的 cfdisk ...

  9. Linux U盘分区格式化 fdisk命令

    转载:http://blog.chinaunix.net/uid-23859284-id-57796.html Linux U盘分区格式化 fdisk命令 今天为方便修复系统,做了个U盘WINPE的启 ...

最新文章

  1. html如何打包压缩,所有css打包压缩到一个js里面
  2. c语言未命名exe,用dev-c++编译出现问题,求大神解答啊
  3. linux ccenteros 部署 redis
  4. VMware Pro 14 安装 Ubuntu 18.04 详细教程
  5. nginx配置url重写
  6. 关于nginx rtmp的一点配置
  7. php极速链,php PHP极速链 战群源码系列(全自动采集更新+引流神器无数据库版) WEB(ASP,PHP,...) 261万源代码下载- www.pudn.com...
  8. 分享一下免费的ppt网站(好看,免费)
  9. 2021-07-14 西门子PLC编程软件--博途V14软件的安装
  10. hibernate 各历史版本下载
  11. 米的换算单位和公式_米的换算单位
  12. 17AHU排位赛2 A题(最小生成树、LCA维护树上路径)
  13. 个人java学习路线-Spring
  14. 传统的6d位姿估计fangfa1_6D目标姿态估计,李飞飞夫妇等提出DenseFusion
  15. 我的2018:微信朋友圈的24个瞬间
  16. 电路仿真软件详谈(28),如何在印刷电路板中应用proteus电路仿真软件
  17. Linux与Fedora
  18. python-九九乘法表(矩形)
  19. Bellman-Ford Spfa
  20. 恒指市场新手的困惑,最新战法来解决。

热门文章

  1. 1.LoRaWAN介绍
  2. CAD垂直标注出现拐角的问题
  3. shell编程入门(二)
  4. elementUI——表格单元格合并——技能提升
  5. AccessController.doPrivileged
  6. python中的键盘事件
  7. markdown 各种符号
  8. Pubwin4版网吧系统破解一
  9. 关于诚信的名人名言推荐
  10. c语言汉字属于什么类型_设计源于传承|为什么字体设计太难?独属于我们的汉字—甲骨文...