实例(环境为: 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. 『现学现忘』Docker基础 — 25、Docker镜像讲解

    目录 1.镜像是什么 2.Docker镜像获取的方式 3.Docker镜像加载原理 (1)UnionFS(联合文件系统) (2)Docker镜像加载原理 1.镜像是什么 镜像是一种轻量级.可执行的独立 ...

  2. Net Framework 中托管代码与非托管代码的区别

    托管代码与非托管代码的区别 1 简单的说,就是代码被编译成MSIL后在.net的Framework下运行,同操作系统底层的交互都交给framework去做. 所谓非托管代码就是脱离了Framework ...

  3. Caffeine缓存详解

    概要 Caffeine是一个高性能,高命中率,低内存占用,near optimal 的本地缓存,简单来说它是 Guava Cache 的优化加强版,有些文章把 Caffeine 称为"新一代 ...

  4. 基于Kali的一次DDos攻击实践

    镜像下载.域名解析.时间同步请点击 阿里云开源镜像站 一.什么是DDos攻击 DDOS(Distributed Denial of Service),即分布式拒绝服务,是一种针对于网络服务的攻击行为. ...

  5. python Apache和php错误日志邮件报警

    # qianxiao996精心制作 #博客地址:https://blog.csdn.net/qq_36374896 #!/usr/bin/python #-*- coding: utf-8 -* im ...

  6. MVC 生成安全验证码(例:用于登陆验证) 方法2

    MVC前台页面中,重新获取图片验证码的第二种方式:(前端页面代码如下,后台页面请参考上一篇文章) ---------html <td> <img id="imgValida ...

  7. KCP协议:从TCP到UDP家族QUIC/KCP/ENET

    行文前先安利下<再深谈TCP/IP三步握手&四步挥手原理及衍生问题-长文解剖IP >.<再谈UDP协议-浅入理解深度记忆> KCP协议科普 KCP是一个快速可靠协议,能 ...

  8. Ubuntu16.04 oh_my_zsh 安装与配置

    参考文章 Ubuntu上使终端显示Git分支(oh-my-zsh) oh-my-zsh的安装与基本配置 Ubuntu 下安装oh-my-zsh 前言 之前学习Laravel的时候,经常要切换git分支 ...

  9. Kafka学习(一)

    作者:普适极客链接:https://www.zhihu.com/question/53331259/answer/1321992772来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载 ...

  10. We're sorry but demo3 doesn't work properly without JavaScript enabled. Please enable it to continue.

    今天遇到一个问题为 vue请求得到的响应为 We're sorry but demo3 doesn't work properly without JavaScript enabled. Please ...