linux中fdisk管理分区

1、fdisk是什么?

fdisk进行硬盘分区从实质上说就是对硬盘的一种格式化。当我们创建分区时,就已经设置好了硬盘的各项物理参数,指定了硬盘主引导记录(即MasterBootRecord,MBR)和引导记录备份的存放位置。而对于文件系统以及其他操作系统管理硬盘所需要的信息则是通过之后的高级格式化,即Format命令来实现。用一个形象的比喻,分区就好比在一张白纸上画一个大方框。而格式化好比在方框里打上格子。安装各种软件就好比在格子里写上字。分区和格式化就相当于为安装软件打基础,实际上它们为电脑在硬盘上存储数据起到标记定位的作用。

2、关于硬盘分区的介绍

硬盘的分区由主分区、扩展分区和逻辑分区组成;
主分区(包括扩展分区)的最大个数是四个;其中扩展分区也算一个主分区;
扩展分区可以继续划分为更多的逻辑分区;
所以主分区(包括扩展分区)范围是从1-4,逻辑分区是从5开始的;

3、 通过fdisk -l查看机器挂载的硬盘个数,及分区情况

[root@ localhost ~]# fdisk -l

Disk /dev/sda: 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: 0x00042d23

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          26      204800   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              26         124      786432   82  Linux swap / Solaris
Partition 2 does not end on cylinder boundary.
/dev/sda3             124        2611    19979264   83  Linux

4、 使用fdisk对硬盘进行分区操作

命令格式:fdisk 设备

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

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            # 列出分区类型
   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/system值
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit          # 保存分区表,退出
   x   extra functionality (experts only)    # 扩展功能,专家模式

1)列出当前操作磁盘分区情况,p

Command (m for help): p

Disk /dev/sda: 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: 0x00042d23

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          26      204800   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              26         124      786432   82  Linux swap / Solaris
Partition 2 does not end on cylinder boundary.
/dev/sda3             124        2611    19979264   83  Linux

2) 删除一个分区,d

Command (m for help): d               # 删除分区
Partition number (1-4): 4             
  • 5
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值