命令行fdisk扩展ubuntu 扩展分区sda2下的sda5 挂载根路径下的主分区

2023-12-28 12:28

本文主要是介绍命令行fdisk扩展ubuntu 扩展分区sda2下的sda5 挂载根路径下的主分区,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

具体如下

root@ubuntu:~# fdisk /dev/sdaWelcome to fdisk (util-linux 2.34).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.#查询现有分区情况,40G需要扩展到50G
Command (m for help): p
Disk /dev/sda: 50 GiB, 53687091200 bytes, 104857600 sectors
Disk model: VMware Virtual S
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: 0xa52b58b2Device     Boot   Start      End  Sectors  Size Id Type
/dev/sda1  *       2048  1050623  1048576  512M  b W95 FAT32
/dev/sda2       1052670 83886079 82833410 39.5G  5 Extended
/dev/sda5       1052672 83886079 82833408 39.5G 83 Linux
#删除sda5分区
Command (m for help): d
Partition number (1,2,5, default 5): 5Partition 5 has been deleted.
#删除sda2分区
Command (m for help): d
Partition number (1,2, default 2): 2Partition 2 has been deleted.
# 创建新扩展分区sda2(不断的按默认回车)
Command (m for help): n
Partition typep   primary (1 primary, 0 extended, 3 free)e   extended (container for logical partitions)
Select (default p): e (选择扩展分区)
Partition number (2-4, default 2): 
First sector (1050624-104857599, default 1050624): 
Last sector, +/-sectors or +/-size{K,M,G,T,P} (1050624-104857599, default 104857599): +49.5G             
Value out of range.
Last sector, +/-sectors or +/-size{K,M,G,T,P} (1050624-104857599, default 104857599): Created a new partition 2 of type 'Extended' and of size 49.5 GiB.
#查询创建好的扩展分区
Command (m for help): p
Disk /dev/sda: 50 GiB, 53687091200 bytes, 104857600 sectors
Disk model: VMware Virtual S
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: 0xa52b58b2Device     Boot   Start       End   Sectors  Size Id Type
/dev/sda1  *       2048   1050623   1048576  512M  b W95 FAT32
/dev/sda2       1050624 104857599 103806976 49.5G  5 Extended
# 继续创建分区,默认主分区这个时候就是在扩展分区下面
Command (m for help): n
All space for primary partitions is in use.
Adding logical partition 5
First sector (1052672-104857599, default 1052672): 
Last sector, +/-sectors or +/-size{K,M,G,T,P} (1052672-104857599, default 104857599): Created a new partition 5 of type 'Linux' and of size 49.5 GiB.
Partition #5 contains a ext4 signature.Do you want to remove the signature? [Y]es/[N]o: YThe signature will be removed by a write command.
# 查询创建好的分区,这个时候所有的空间都已经用了
Command (m for help): p
Disk /dev/sda: 50 GiB, 53687091200 bytes, 104857600 sectors
Disk model: VMware Virtual S
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: 0xa52b58b2Device     Boot   Start       End   Sectors  Size Id Type
/dev/sda1  *       2048   1050623   1048576  512M  b W95 FAT32
/dev/sda2       1050624 104857599 103806976 49.5G  5 Extended
/dev/sda5       1052672 104857599 103804928 49.5G 83 LinuxFilesystem/RAID signature on partition 5 will be wiped.
# 保存退出,因为我们是根分区,所以会提示分区忙碌
Command (m for help): w
The partition table has been altered.
Failed to add partition 2 to system: Device or resource busyThe kernel still uses the old partitions. The new table will be used at the next reboot. 
Syncing disks.

重启服务器

init 6

重启后查看分区情况
发现还是没有生效,但是分区却已经扩展了

root@ubuntu:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda5        39G  7.4G   30G  20% /
/dev/sda1       511M  4.0K  511M   1% /boot/efi
root@ubuntu:~# lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0    50G  0 disk 
├─sda1   8:1    0   512M  0 part /boot/efi
├─sda2   8:2    0     1K  0 part 
└─sda5   8:5    0  49.5G  0 part /

刷新盘符

root@ubuntu:~# resize2fs /dev/sda5
resize2fs 1.45.5 (07-Jan-2020)
Filesystem at /dev/sda5 is mounted on /; on-line resizing required
old_desc_blocks = 5, new_desc_blocks = 7
The filesystem on /dev/sda5 is now 12975616 (4k) blocks long.root@ubuntu:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            1.9G     0  1.9G   0% /dev
/dev/sda5        49G  7.4G   40G  16% /
/dev/sda1       511M  4.0K  511M   1% /boot/efi

最后重启一次服务器验证是否有问题

这篇关于命令行fdisk扩展ubuntu 扩展分区sda2下的sda5 挂载根路径下的主分区的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/545931

相关文章

PostgreSQL的扩展dict_int应用案例解析

《PostgreSQL的扩展dict_int应用案例解析》dict_int扩展为PostgreSQL提供了专业的整数文本处理能力,特别适合需要精确处理数字内容的搜索场景,本文给大家介绍PostgreS... 目录PostgreSQL的扩展dict_int一、扩展概述二、核心功能三、安装与启用四、字典配置方法

MySQL 定时新增分区的实现示例

《MySQL定时新增分区的实现示例》本文主要介绍了通过存储过程和定时任务实现MySQL分区的自动创建,解决大数据量下手动维护的繁琐问题,具有一定的参考价值,感兴趣的可以了解一下... mysql创建好分区之后,有时候会需要自动创建分区。比如,一些表数据量非常大,有些数据是热点数据,按照日期分区MululbU

sqlite3 命令行工具使用指南

《sqlite3命令行工具使用指南》本文系统介绍sqlite3CLI的启动、数据库操作、元数据查询、数据导入导出及输出格式化命令,涵盖文件管理、备份恢复、性能统计等实用功能,并说明命令分类、SQL语... 目录一、启动与退出二、数据库与文件操作三、元数据查询四、数据操作与导入导出五、查询输出格式化六、实用功

SQLite3命令行工具最佳实践指南

《SQLite3命令行工具最佳实践指南》SQLite3是轻量级嵌入式数据库,无需服务器支持,具备ACID事务与跨平台特性,适用于小型项目和学习,sqlite3.exe作为命令行工具,支持SQL执行、数... 目录1. SQLite3简介和特点2. sqlite3.exe使用概述2.1 sqlite3.exe

SpringBoot项目配置logback-spring.xml屏蔽特定路径的日志

《SpringBoot项目配置logback-spring.xml屏蔽特定路径的日志》在SpringBoot项目中,使用logback-spring.xml配置屏蔽特定路径的日志有两种常用方式,文中的... 目录方案一:基础配置(直接关闭目标路径日志)方案二:结合 Spring Profile 按环境屏蔽关

Ubuntu设置程序开机自启动的操作步骤

《Ubuntu设置程序开机自启动的操作步骤》在部署程序到边缘端时,我们总希望可以通电即启动我们写好的程序,本篇博客用以记录如何在ubuntu开机执行某条命令或者某个可执行程序,需要的朋友可以参考下... 目录1、概述2、图形界面设置3、设置为Systemd服务1、概述测试环境:Ubuntu22.04 带图

Spring组件实例化扩展点之InstantiationAwareBeanPostProcessor使用场景解析

《Spring组件实例化扩展点之InstantiationAwareBeanPostProcessor使用场景解析》InstantiationAwareBeanPostProcessor是Spring... 目录一、什么是InstantiationAwareBeanPostProcessor?二、核心方法解

VSCode设置python SDK路径的实现步骤

《VSCode设置pythonSDK路径的实现步骤》本文主要介绍了VSCode设置pythonSDK路径的实现步骤,包括命令面板切换、settings.json配置、环境变量及虚拟环境处理,具有一定... 目录一、通过命令面板快速切换(推荐方法)二、通过 settings.json 配置(项目级/全局)三、

使用Python和Matplotlib实现可视化字体轮廓(从路径数据到矢量图形)

《使用Python和Matplotlib实现可视化字体轮廓(从路径数据到矢量图形)》字体设计和矢量图形处理是编程中一个有趣且实用的领域,通过Python的matplotlib库,我们可以轻松将字体轮廓... 目录背景知识字体轮廓的表示实现步骤1. 安装依赖库2. 准备数据3. 解析路径指令4. 绘制图形关键

Linux查看系统盘和SSD盘的容量、型号及挂载信息的方法

《Linux查看系统盘和SSD盘的容量、型号及挂载信息的方法》在Linux系统中,管理磁盘设备和分区是日常运维工作的重要部分,而lsblk命令是一个强大的工具,它用于列出系统中的块设备(blockde... 目录1. 查看所有磁盘的物理信息方法 1:使用 lsblk(推荐)方法 2:使用 fdisk -l(