Linux 主分区_扩展分区_逻辑分区

摘要:
目录:1.MBR分区简介。2.创建主分区。3.创建扩展分区。4.创建逻辑分区。可以从扩展分区中再次划分多个逻辑分区。逻辑分区号直接从5开始。

目录:

  1、MBR分区介绍

  2、创建主分区

  3、创建扩展分区

  4、创建逻辑分区  

1、MBR分区介绍

  1.1 分区规定:

  每个磁盘设备最多4个主分区,或者3个主分区+1个扩展分区,是因为MBR(主引导记录)的分区表主分区表)只能存放4个分区 (GPT分区没有这个限制)。

  扩展分区只能有一个。

  逻辑分区可以有多个。

  可以从扩展分区中再次划分多个逻辑分区,逻辑分区编号直接从5开始。

  1.2 分区作用:

  主分区:主要是用来启动操作系统的,它主要放的是操作系统的启动或引导程序,/boot分区最好放在主分区上;

  扩展分区是不能使用的,它只是做为逻辑分区的容器存在的,先创建一个扩展分区,在扩展分区之上创建逻辑分区;

  我们真正存放数据的是主分区和逻辑分区,大量数据都放在逻辑分区中。

2、创建主分区

[root@servera ~]# fdisk /dev/vdb

Command (m for help): n  # 创建新分区 Partition type p primary (0 primary, 0 extended, 4 free) e extended (container for logical partitions) Select (default p): p  # 创建主分区 Partition number (1-4, default 1):   # 回车 First sector (2048-10485759, default 2048):   # 回车,设置起始扇区 Last sector, +sectors or +size{K,M,G,T,P} (2048-10485759, default 10485759): 409600  # 设置结尾扇区 Created a new partition 1 of type 'Linux' and of size 199 MiB. Command (m for help): n Partition type p primary (1 primary, 0 extended, 3 free) e extended (container for logical partitions) Select (default p): p  # 创建主分区 Partition number (2-4, default 2):   # 回车 First sector (409601-10485759, default 411648):   # 回车,设置起始扇区 Last sector, +sectors or +size{K,M,G,T,P} (411648-10485759, default 10485759): 819200  # 设置结尾扇区 Created a new partition 2 of type 'Linux' and of size 199 MiB.
Command (m for help): w  # 保存配置 The partition table has been altered. Calling ioctl() to re-read partition table. Syncing disks. [root@servera ~]# fdisk -l /dev/vdb Disk /dev/vdb: 5 GiB, 5368709120 bytes, 10485760 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 Disklabel type: dos Disk identifier: 0x03864530 Device Boot Start End Sectors Size Id Type /dev/vdb1 2048 409600 407553 199M 83 Linux /dev/vdb2 411648 819200 407553 199M 83 Linux

3、创建扩展分区

[root@servera ~]# fdisk /dev/vdb

Command (m for help): n  # 创建新分区 Partition type p primary (2 primary, 0 extended, 2 free) e extended (container for logical partitions) Select (default p): e  # 创建扩展分区 Partition number (3,4, default 3):   # 选择分区号 First sector (409601-10485759, default 821248):   # 起始扇区 Last sector, +sectors or +size{K,M,G,T,P} (821248-10485759, default 10485759):   # 结尾扇区 Created a new partition 3 of type 'Extended' and of size 4.6 GiB. Command (m for help): w  # 保存配置 The partition table has been altered. Calling ioctl() to re-read partition table. Syncing disks. [root@servera ~]# fdisk -l /dev/vdb Disk /dev/vdb: 5 GiB, 5368709120 bytes, 10485760 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 Disklabel type: dos Disk identifier: 0x03864530 Device Boot Start End Sectors Size Id Type /dev/vdb1 2048 409600 407553 199M 83 Linux  # 主分区 /dev/vdb2 411648 819200 407553 199M 83 Linux  # 主分区 /dev/vdb3 821248 10485759 9664512 4.6G 5 Extended  # 扩展分区

4、创建逻辑分区

[root@servera ~]# fdisk /dev/vdb

Command (m for help): n  # 创建新分区
All space for primary partitions is in use.  # 提示所有空间都已经分配给主分区使用
Adding logical partition 5  # 从扩展分区中,自动划分逻辑分区
First sector (823296-10485759, default 823296):   # 起始扇区
Last sector, +sectors or +size{K,M,G,T,P} (823296-10485759, default 10485759):   # 结尾扇区

Created a new partition 5 of type 'Linux' and of size 4.6 GiB.

Command (m for help): t  # 分区类型
Partition number (1-3,5, default 5): 
Hex code (type L to list all codes): 8e   # LVM类型

Changed type of partition 'Linux' to 'Linux LVM'.

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


[root@servera ~]# fdisk -l /dev/vdb
Disk /dev/vdb: 5 GiB, 5368709120 bytes, 10485760 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
Disklabel type: dos
Disk identifier: 0x03864530

Device     Boot  Start      End Sectors  Size Id Type
/dev/vdb1         2048   409600  407553  199M 83 Linux
/dev/vdb2       411648   819200  407553  199M 83 Linux
/dev/vdb3       821248 10485759 9664512  4.6G  5 Extended
/dev/vdb5       823296 10485759 9662464  4.6G 8e Linux LVM

[root@servera ~]# mkfs.xfs /dev/vdb5  # 格式化逻辑分区
meta-data=/dev/vdb5              isize=512    agcount=4, agsize=301952 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=1, rmapbt=0
         =                       reflink=1
data     =                       bsize=4096   blocks=1207808, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
log      =internal log           bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
[root@servera ~]# mount /dev/vdb5 /var/tmp  # 挂载逻辑分区

5、Parted格式化2TB以上的磁盘

通常我们使用fdisk工具来进行磁盘分区,但是fdisk只能格式化小于2TB的磁盘。因此大于2TB的磁盘分区就需要parted工具。

5.1 设置DiskLable Type

  # parted /dev/sdb mklabel gpt

5.2 创建分区并格式化

  # parted /dev/sdb mkpart primary xfs 0 100%

  # mkfs.xfs /dev/sdb1

5.3 挂载分区

  # mount /dev/sdb1 /var/tmp

5.4 删除分区

  # parted /dev/sdb rm 1

免责声明:文章转载自《Linux 主分区_扩展分区_逻辑分区》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇prepend与append的区别【转】巧用CAT706做掉电检测下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

phpStudy for Linux (lnmp+lamp一键安装包)

phpStudy»PHP教程» phpStudy for Linux (lnmp+lamp一键安装包) phpStudy for Linux (lnmp+lamp一键安装包) phpStudy Linux版&Win版同步上线 支持Apache/Nginx/Tengine/Lighttpd/IIS7/8/6 phpStudy for Linux...

Linux学习 : 总线-设备-驱动模型

  platform总线是一种虚拟的总线,相应的设备则为platform_device,而驱动则为platform_driver。Linux 2.6的设备驱动模型中,把I2C、RTC、LCD等都归纳为platform_device。总线将设备和驱动绑定,在系统每注册一个设备的时候,会寻找与之匹配的驱动;相反的,在系统每注册一个驱动的时候,会寻找与之匹配的设...

linux ps命令详解

ps命令(全称:process status)是linux查看当前系统中进程状态的常用命令,比如我们可以通过以下命令查看当前系统所有进程信息: ps -aux 执行结果如下: 如果查看指定的进程,如java进程,可以通过管道符和grep命令进行过滤,命令如下: ps -aux|grep java 执行结果如下: ps命令详细介绍 ps命令的用法如下:...

Linux netstat命令详解和使用例子(显示各种网络相关信息)

netstat命令用于显示与IP、TCP、UDP和ICMP协议相关的统计数据,一般用于检验本机各端口的网络连接情况。netstat是在内核中访问网络及相关信息的程序,它能提供TCP连接,TCP和UDP监听,进程内存管理的相关报告 原文链接:https://www.jb51.net/LINUXjishu/152405.html 如果你的计算机有时候接收...

大数据--Spark原理

Apache Spark是一个围绕速度、易用性和复杂分析构建的大数据处理框架,最初在2009年由加州大学伯克利分校的AMPLab开发,并于2010年成为Apache的开源项目之一,与Hadoop和Storm等其他大数据和MapReduce技术相比,Spark有如下优势: 1.运行速度快,Spark拥有DAG执行引擎,支持在内存中对数据进行迭代计算。官方提供...

Redhat7.4安装oracle11.2.0.4版本数据库遇见的问题_oracle

一、描述 需要在redhat7.4版本上面安装11g版本oracle数据库 遇见问题: 1、裸盘处理 ASM能识别的裸盘的容量不能大于2048G,对于一个LUN大于2048G的,需要使用LVM进行切割。   ①计算需要划分的数量以及大小   fdisk -l  查看一个磁盘的大小,例如我这边是11520.6GB   每个LVM的大小:     11520....