码迷,mamicode.com
首页 > 系统相关 > 详细

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

时间:2020-03-07 13:06:52      阅读:111      评论:0      收藏:0      [点我收藏+]

标签:cto   ber   系统   sync   meta   minimum   add   version   bsp   

目录:

  1、Linux分区介绍

  2、创建主分区

  3、创建扩展分区

  4、创建逻辑分区  

 

1、Linux分区介绍

  1.1 分区规定:

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

  扩展分区只能有一个。

  逻辑分区可以有多个。

  可以从扩展分区中再次划分多个逻辑分区,逻辑分区编号直接从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  # 挂载逻辑分区

 

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

标签:cto   ber   系统   sync   meta   minimum   add   version   bsp   

原文地址:https://www.cnblogs.com/vincenshen/p/12433469.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!