Linux 扩展磁盘分区(命令行操作)

news/发布时间2024/5/4 19:48:04

之前安装 Ubuntu 虚拟机时使用的都是默认配置,虚拟机硬盘分配了 60 GB。后来想要扩容,特此记录一下扩容过程。

首先在 VMware 中修改虚拟机硬盘大小。

image

然后使用 gdisk -l 来查看硬盘分区情况。

$ sudo gdisk -l /dev/sda
GPT fdisk (gdisk) version 1.0.8Partition table scan:MBR: protectiveBSD: not presentAPM: not presentGPT: presentFound valid GPT with protective MBR; using GPT.
Disk /dev/sda: 134217728 sectors, 64.0 GiB
Model: Ubuntu Linux 22.
Sector size (logical/physical): 512/4096 bytes
Disk identifier (GUID): 11AE34C9-947E-405F-A204-1BDAB7A8C48A
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 134217694
Partitions will be aligned on 2048-sector boundaries
Total free space is 4029 sectors (2.0 MiB)Number  Start (sector)    End (sector)  Size       Code  Name1            2048         2203647   1.0 GiB     EF00  2         2203648       134215679   62.9 GiB    8300

这里可以看到挂载在根目录 / 的是 /dev/sda3sda 是磁盘名,3 是分区号)。

接下来使用 gdisk 命令设置磁盘 sda 的分区。

$ sudo gdisk /dev/sda
GPT fdisk (gdisk) version 1.0.8Partition table scan:MBR: protectiveBSD: not presentAPM: not presentGPT: presentFound valid GPT with protective MBR; using GPT.Command (? for help):

首先使用 d 选项删除分区。这里我们要删除 3 号分区,因此接下来的分区号填 3

Command (? for help): d
Partition number (1-3): 3

删除分区后,使用 n 选项新建分区。接下来要填写分区号,我们再次填写 3 以重建一个 3 号分区。之后会让你填写分区起始扇区号,默认就是

Command (? for help): n
Partition number (3-128, default 3): 3
First sector (34-1258291166, default = 1054720) or {+-}size{KMGTP}: 
Last sector (1054720-1258291166, default = 1258291166) or {+-}size{KMGTP}: 
Current type is 8300 (Linux filesystem)
Hex code or GUID (L to show codes, Enter = 8300): 
Changed type of partition to 'Linux filesystem'Command (? for help):
Command (? for help): wFinal checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!Do you want to proceed? (Y/N): Y
OK; writing new GUID partition table (GPT) to /dev/sda.
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot or after you
run partprobe(8) or kpartx(8)
The operation has completed successfully.

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.ulsteruni.cn/article/26181776.html

如若内容造成侵权/违法违规/事实不符,请联系编程大学网进行投诉反馈email:xxxxxxxx@qq.com,一经查实,立即删除!

相关文章

【安全事件分类】

根据网络安全事件的起因、表现、结果等,网络安全事件分为恶意程序事件、网络攻击事件、数据安全事件、信息内网安全事件、设备设施故障事件、违规操作事件、其他网络安全事件等的基本分类,每个基本分类包括若干个子类。 下文主要对这些事件下的分类、攻击级别和描述进行整理。…

Unity的Forward+ FPTL光照剔除解析(四)

看完上一节基本上HDRP的光照剔除数据的流程就写完了,这一节主要是解析适用于透明队列的Cluster光照剔除。 为了让Cluster的均匀分布,Cluster的光照剔除也同样是借助了PreDepth的深度图。序言 看完上一节基本上HDRP的光照剔除数据的流程就写完了,这一节主要是解析适用于透明队…

虚拟机+FunASR的安装与使用

写在前面:我是偶然了解到这个语音识别这个AI方向的,由于当时没有接触过其他的AI模型(ps:当时常见的AI大都是使用过的,但只是止于直接地使用,画个图,让AI帮我解决一些不知道的问题而已),所以FunASR算是我接触过的首个开源且我现有的设备能跑的动的AI项目。所以我对AI的了…

Swoole 源码分析之 Timer 定时器模块

原文首发链接:Swoole 源码分析之 Timer 定时器模块 大家好,我是码农先森。 引言 Swoole 中的毫秒精度的定时器。底层基于 epoll_wait 和 setitimer 实现,数据结构使用最小堆,可支持添加大量定时器。 在同步 IO 进程中使用 setitimer 和信号实现,如 Manager 和 TaskWorker …