命令行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

相关文章

csu 1446 Problem J Modified LCS (扩展欧几里得算法的简单应用)

这是一道扩展欧几里得算法的简单应用题,这题是在湖南多校训练赛中队友ac的一道题,在比赛之后请教了队友,然后自己把它a掉 这也是自己独自做扩展欧几里得算法的题目 题意:把题意转变下就变成了:求d1*x - d2*y = f2 - f1的解,很明显用exgcd来解 下面介绍一下exgcd的一些知识点:求ax + by = c的解 一、首先求ax + by = gcd(a,b)的解 这个

hdu2544(单源最短路径)

模板题: //题意:求1到n的最短路径,模板题#include<iostream>#include<algorithm>#include<cstring>#include<stack>#include<queue>#include<set>#include<map>#include<stdio.h>#include<stdlib.h>#include<ctype.h>#i

科研绘图系列:R语言扩展物种堆积图(Extended Stacked Barplot)

介绍 R语言的扩展物种堆积图是一种数据可视化工具,它不仅展示了物种的堆积结果,还整合了不同样本分组之间的差异性分析结果。这种图形表示方法能够直观地比较不同物种在各个分组中的显著性差异,为研究者提供了一种有效的数据解读方式。 加载R包 knitr::opts_chunk$set(warning = F, message = F)library(tidyverse)library(phyl

poj 1734 (floyd求最小环并打印路径)

题意: 求图中的一个最小环,并打印路径。 解析: ans 保存最小环长度。 一直wa,最后终于找到原因,inf开太大爆掉了。。。 虽然0x3f3f3f3f用memset好用,但是还是有局限性。 代码: #include <iostream>#include <cstdio>#include <cstdlib>#include <algorithm>#incl

用命令行的方式启动.netcore webapi

用命令行的方式启动.netcore web项目 进入指定的项目文件夹,比如我发布后的代码放在下面文件夹中 在此地址栏中输入“cmd”,打开命令提示符,进入到发布代码目录 命令行启动.netcore项目的命令为:  dotnet 项目启动文件.dll --urls="http://*:对外端口" --ip="本机ip" --port=项目内部端口 例: dotnet Imagine.M

pico2 开发环境搭建-基于ubuntu

pico2 开发环境搭建-基于ubuntu 安装编译工具链下载sdk 和example编译example 安装编译工具链 sudo apt install cmake gcc-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib 注意cmake的版本,需要在3.17 以上 下载sdk 和ex

Spring框架5 - 容器的扩展功能 (ApplicationContext)

private static ApplicationContext applicationContext;static {applicationContext = new ClassPathXmlApplicationContext("bean.xml");} BeanFactory的功能扩展类ApplicationContext进行深度的分析。ApplicationConext与 BeanF

【408DS算法题】039进阶-判断图中路径是否存在

Index 题目分析实现总结 题目 对于给定的图G,设计函数实现判断G中是否含有从start结点到stop结点的路径。 分析实现 对于图的路径的存在性判断,有两种做法:(本文的实现均基于邻接矩阵存储方式的图) 1.图的BFS BFS的思路相对比较直观——从起始结点出发进行层次遍历,遍历过程中遇到结点i就表示存在路径start->i,故只需判断每个结点i是否就是stop

Android Environment 获取的路径问题

1. 以获取 /System 路径为例 /*** Return root of the "system" partition holding the core Android OS.* Always present and mounted read-only.*/public static @NonNull File getRootDirectory() {return DIR_ANDR

图的最短路径算法——《啊哈!算法》

图的实现方式 邻接矩阵法 int[][] map;// 图的邻接矩阵存储法map = new int[5][5];map[0] = new int[] {0, 1, 2, 3, 4};map[1] = new int[] {1, 0, 2, 6, 4};map[2] = new int[] {2, 999, 0, 3, 999};map[3] = new int[] {3, 7