实例(环境为: CentOS Linux release 7.2.1511 (Core), 3.10.0-327.el7.x86_64)


选择要具体操作的第二块磁盘(linux下一切是文件形式对应):

[root@vathe ~]#fdisk /dev/sdb
[root@fp-web-130 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 100G 0 disk
├─sda1 8:1 0 500M 0 part /boot
└─sda2 8:2 0 99.5G 0 part
├─centos-root 253:0 0 95.5G 0 lvm /
└─centos-swap 253:1 0 4G 0 lvm
sdb 8:16 0 200G 0 disk
sr0 11:0 1 1024M 0 rom
loop0 7:0 0 100G 0 loop
└─docker-253:0-268708167-pool 253:2 0 100G 0 dm
├─docker-253:0-268708167-edbba54df531d54ce62f43155c402a262fb51abfd1984c1ce3a765677fdd6256 253:3 0 10G 0 dm /var/lib/docker/devicemapper/mnt/edbba54df531d54ce62f43155c402a262fb51abfd
loop1 7:1 0 2G 0 loop
└─docker-253:0-268708167-pool 253:2 0 100G 0 dm
├─docker-253:0-268708167-edbba54df531d54ce62f43155c402a262fb51abfd1984c1ce3a765677fdd6256 253:3 0 10G 0 dm /var/lib/docker/devicemapper/mnt/edbba54df531d54ce62f43155c402a262fb51abfd

输入m可列出可以执行的命令:

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
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: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 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: 0x48283ee0 Device Boot Start End Blocks Id System

新建一个主分区:

Command action                      #选择新增分区类型
e extended #扩展分区
p primary partition (1-4) #主分区
Select (default p): p // 键入p
Partition number (1-4): 1 // 键入1
First cylinder (1-1305, default 1): # 选择分区起点柱面
Using default value 1 //选择默认1
Last cylinder, +cylinders or +size{K,M,G} (1-1305, default 1305): +1G #设置分区大小1G,+表示往起点后添加,-表示往起点前添加分区

查看主分区创建:

Command (m for help): p

Disk /dev/sdb: 10.7 GB, 10737418240 bytes    # 磁盘总大小 10.7GB
255 heads, 63 sectors/track, 1305 cylinders # 255个磁头,每个磁道63个扇区,1305个圆柱面
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: 0x48283ee0 Device Boot Start End Blocks Id System
/dev/sdb1 1 132 1060258+ 83 Linux 建立一个扩展分区

Command (m for help):n //输入n回车
  Partition type:
    p primary (0 primary, 0 extended, 4 free)
    e extended
  Select (default p): p #输入p表示创建主分区,回车
  Partition number (1-4): 1 #分区号为1,分区号是1到4,我们这里输入1,回车
  First sector (2048-419430399, default 2048): #直接回车默认从第一个柱面开始划分,默认分区起始位置是从2048开始
  Using default value 2048

  First sector (2048-419430399, default 2048): 2048
  Last sector, +sectors or +size{K,M,G} (2048-419430399, default 419430399): 69905066 //这里直接默认回车将
  全部都分配给当前创建的主分区,这里肯定不想,所以需要这里设置一个值,我用计算器419430399/6=69905066

  Partition 1 of type Linux and of size 33GiB is set

  

  Command (m for help): p //这时再次出现提示: 这里输入p,查看创建情况

  Disk /dev/sdb: 214.7 GB, 214748364800 bytes, 419430400 sectors //硬盘整个的信息
  Units = sectors of 1 * 512 = 512 bytes
  Sector size (logical/physical): 512 bytes / 512 bytes
  I/O size (minimum/optimal): 512 bytes / 512 bytes
  Disk label type: dos
  Disk identifier: 0xbd1a05e2

  Device Boot Start End Blocks Id System
  /dev/sdb1 2048 69905066 34951509+ 83 Linux

  注: 每次操作完毕,就会回到 Command (m for help): 提示让你继续操作。

在扩展分区中创建一个逻辑分区

  Command (m for help):n
  Partition type:
         p primary (1 primary, 0 extended, 3 free)
    e extended
  Select (default p):e //输入e,表示要创建扩展分区

  Partition number (2-4, default 2):2 //输入2回车,开始创建继续扩展分区

  First sector (69905067-419430399, default 69906432): //这里我直接回车

  Using default value 69906432: Last sector, +sectors or +size{K,M,G} (69906432-419430399, default 419430399): //这里也直接回车,表示把剩下的部分都划给扩展分区
  Using default value 419430399
  Partition 2 of type Extended and of size 166.7 GiB is set(这里翻译为分区2为扩展分区,大小为166.7G被设置)

查看分区列表

  Command (m for help): p   //出现提示,输入p查看当前创建情况

  Disk /dev/sdb: 214.7 GB, 214748364800 bytes, 419430400 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes 
    Disk label type: dos
    Disk identifier: 0xbd1a05e2

  Device    Boot Start    End       Blocks     Id System
    /dev/sdb1      2048     69905066  34951509+  83 Linux
    /dev/sdb2      69906432 419430399 174761984  5  Extended

保存退出

Command (m for help): w             # 保存退出
The partition table has been altered! Calling ioctl() to re-read partition table.
Syncing disks.

分区成功,当然,要使用磁盘,还需要进行两部操作,才能使用磁盘——将磁盘挂载在具体目录(或文件),和对个分区进行格式化,最后结果如下。

请参考我的另一篇文章 linux磁盘分区fdisk命令操作(实践)详细版:

https://www.cnblogs.com/aozhejin/p/15863016.html  

Linux磁盘分区fdisk命令操作(简洁版)的更多相关文章

  1. linux磁盘分区fdisk命令操作(实践)

    写这篇的目的,还是要把整个过程完整的记录下来,特别是小细节的地方,通常很多情况是一知半解,平时不实践操作只凭看是没有用的,所以做这个行业就是要多动手,多学习,多思考慢慢你的思路也会打开.练就自己的学习 ...

  2. linux磁盘分区fdisk命令详解

    1.什么是分区?    分区是将一个硬盘驱动器分成若干个逻辑驱动器,分区是把硬盘连续的区块当做一个独立的磁硬使用.分区表是一个硬盘分区的索引,分区的信息都会写进分区表.2.为什么要有多个分区? 防止数 ...

  3. (转)linux磁盘分区fdisk分区和parted分区

    linux磁盘分区fdisk分区和parted分区 原文:http://www.cnblogs.com/jiu0821/p/5503660.html ~~~~~~~~~~~~~~~~~~~~~~~~~ ...

  4. Linux fdisk命令参数及用法详解---Linux磁盘分区管理命令fdisk

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

  5. linux磁盘分区fdisk分区和parted分区

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 磁盘分区 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ...

  6. Linux磁盘分区(一)之fdisk命令

    Linux磁盘分区(一)之fdisk命令转自:https://www.cnblogs.com/machangwei-8/p/10353683.html 一.fdisk 的介绍fdsik 能划分磁盘成为 ...

  7. linux磁盘 分区 物理卷 卷组 逻辑卷 文件系统加载点操作案例

    转自:truemylife.linux磁盘 分区 物理卷 卷组 逻辑卷 文件系统加载点操作案例 基本概念: 磁盘.分区.物理卷[物理部分] 卷组[中间部分] 逻辑卷.文件系统[虚拟化后可控制部分] 磁 ...

  8. Linux磁盘分区(三)之查看磁盘分区常用命令

    Linux磁盘分区(三)之查看磁盘分区常用命令转自https://blog.csdn.net/x356982611/article/details/77893264 1.df     df -T 总的 ...

  9. Linux磁盘分区(二)之挂载卸载常用命令

    Linux磁盘分区(二)之挂载卸载常用命令 转自:https://blog.csdn.net/qq_36183935/article/details/81053383           https: ...

随机推荐

  1. LGP3307题解

    题意有点儿神秘,而且出题人可能有点大病( 项链由 \(n\) 颗珠子构成,相邻的珠子不能相同. 每颗珠子上有 \(3\) 个数字,这 \(3\) 个数之间没有顺序,且 \(\gcd\) 为 \(1\) ...

  2. Anaconda 安装 国内镜像问题解决方案

    镜像下载.域名解析.时间同步请点击阿里云开源镜像站 遇到问题:安装2021版本后无法打开Anaconda Navigator 解决方案:使用管理员身份打开Avaconda Prompt,输入conda ...

  3. kubernetes修改ingress默认端口

    kubectl edit daemonset nginx-ingress-controller -n ingress-nginx containers: - args: - /nginx-ingres ...

  4. mybatis学习一:基于xml与注解配置入门实例与问题

    注:本case参考自:http://www.cnblogs.com/ysocean/p/7277545.html 一:Mybatis的介绍: MyBatis 本是apache的一个开源项目iBatis ...

  5. 在 java 中 wait 和 sleep 方法的不同?

    最大的不同是在等待时 wait 会释放锁,而 sleep 一直持有锁.Wait 通常被用于线 程间交互,sleep 通常被用于暂停执行. 直接了解的深入一点吧: 在 Java 中线程的状态一共被分成  ...

  6. Kafka 高效文件存储设计特点?

    Kafka把topic中一个parition大文件分成多个小文件段,通过多个小文件段,就容易定期清除或删除已经消费完文件,减少磁盘占用. 通过索引信息可以快速定位message和确定response的 ...

  7. java的jsr303校验

    因为是菜鸡,所以就还没有具体了解jsr303具体是什么 JSR是Java Specification Requests的缩写,意思是Java 规范提案.是指向JCP(Java Community Pr ...

  8. Maria DB数据库基础知识

    Maria DB连接 与MariaDB建立连接的一种方法是在命令提示符下使用mysql二进制文件. Maria DB命令行登录数据库服务: mysql -u root -p -- 换行输入密码 上面给 ...

  9. 面试问题之数据库:SQL优化的具体操作

    转载于:https://www.cnblogs.com/wangzhengyu/p/10412499.html SQL优化的具体操作: 1.尽量避免使用select *,返回无用的字段会降低查询效率. ...

  10. mybatis-数据库类型的对应关系