linux 扩展分区作用,Linux 主分区_扩展分区_逻辑分区

本文详细介绍了Linux系统中磁盘分区的概念,包括主分区、扩展分区和逻辑分区的区别。通过实例演示了如何使用fdisk命令创建主分区、扩展分区,并在扩展分区上创建逻辑分区。最后展示了如何格式化和挂载逻辑分区。
摘要由CSDN通过智能技术生成

目录:

1、Linux分区介绍

2、创建主分区

3、创建扩展分区

4、创建逻辑分区

1、Linux分区介绍

1.1 分区规定:

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

扩展分区只能有一个。

逻辑分区可以有多个。

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

1.2 分区作用:

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

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

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

2、创建主分区

[[email protected] ~]# fdisk /dev/vdb

Command (m forhelp): n  # 创建新分区

Partition type

p primary (0 primary, 0 extended, 4 free)

e extended (containerforlogical 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 partition1 of type ‘Linux‘ and of size 199MiB.

Command (mforhelp): n

Partition type

p primary (1 primary, 0 extended, 3 free)

e extended (containerforlogical 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 partition2 of type ‘Linux‘ and of size 199MiB.Command (mfor help): w  # 保存配置The partition table has been altered.

Calling ioctl() to re-read partition table.

Syncing disks.~]# fdisk -l /dev/vdbDisk/dev/vdb: 5 GiB, 5368709120 bytes, 10485760sectors

Units: sectors of1 * 512 = 512bytes

Sector size (logical/physical): 512 bytes / 512bytes

I/O size (minimum/optimal): 512 bytes / 512bytes

Disklabel type: dos

Disk identifier:0x03864530Device Boot Start End Sectors Size Id Type/dev/vdb1 2048 409600 407553 199M 83Linux/dev/vdb2 411648 819200 407553 199M 83Linux

3、创建扩展分区

[[email protected] ~]# fdisk /dev/vdb

Command (m forhelp): n  # 创建新分区

Partition type

p primary (2 primary, 0 extended, 2 free)

e extended (containerforlogical 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 partition3 of type ‘Extended‘ and of size 4.6GiB.

Command (mfor help):w  # 保存配置The partition table has been altered.

Calling ioctl() to re-read partition table.

Syncing disks.~]# fdisk -l /dev/vdb

Disk/dev/vdb: 5 GiB, 5368709120 bytes, 10485760sectors

Units: sectors of1 * 512 = 512bytes

Sector size (logical/physical): 512 bytes / 512bytes

I/O size (minimum/optimal): 512 bytes / 512bytes

Disklabel type: dos

Disk identifier:0x03864530Device Boot Start End Sectors Size Id Type/dev/vdb1 2048 409600 407553 199M 83Linux  # 主分区/dev/vdb2 411648 819200 407553 199M 83Linux  # 主分区/dev/vdb3 821248 10485759 9664512 4.6G 5 Extended  # 扩展分区

4、创建逻辑分区

vdbCommand (mforhelp): n  # 创建新分区

All spacefor primary partitions is inuse.  # 提示所有空间都已经分配给主分区使用

Adding logical partition5  # 从扩展分区中,自动划分逻辑分区First sector (823296-10485759, default 823296):   # 起始扇区

Last sector,+sectors or +size{K,M,G,T,P} (823296-10485759, default 10485759):   # 结尾扇区

Created a new partition5 of type ‘Linux‘ and of size 4.6GiB.

Command (mforhelp): 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 (mfor help): w  # 保存配置The partition table has been altered.

Calling ioctl() to re-read partition table.

Syncing disks.l /dev/vdbDisk/dev/vdb: 5 GiB, 5368709120 bytes, 10485760sectors

Units: sectors of1 * 512 = 512bytes

Sector size (logical/physical): 512 bytes / 512bytes

I/O size (minimum/optimal): 512 bytes / 512bytes

Disklabel type: dos

Disk identifier:0x03864530Device Boot Start End Sectors Size Id Type/dev/vdb1 2048 409600 407553 199M 83Linux/dev/vdb2 411648 819200 407553 199M 83Linux/dev/vdb3 821248 10485759 9664512 4.6G 5Extended/dev/vdb5 823296 10485759 9662464 4.6G 8e Linux LVMvdb5  # 格式化逻辑分区

meta-data=/dev/vdb5 isize=512 agcount=4, agsize=301952blks= sectsz=512 attr=2, projid32bit=1

= crc=1 finobt=1, sparse=1, rmapbt=0

= reflink=1data= bsize=4096 blocks=1207808, imaxpct=25

= sunit=0 swidth=0blks

naming=version 2 bsize=4096 ascii-ci=0, ftype=1log=internal log bsize=4096 blocks=2560, version=2

= sectsz=512 sunit=0 blks, lazy-count=1realtime=none extsz=4096 blocks=0, rtextents=0mount /dev/vdb5 /var/tmp  # 挂载逻辑分区

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

  • 3
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值