大网数据广告活动
服务器运维问答

Resize partition at VPS without losing data

· 52CE 我爱测

I have small VPS server with 40 GB disk space. I bought extra 40 GB and now I would like to extend / partition size. My partitions looks like this: /dev/vda1 is /boot and /dev/vda5 is my / . My VPS provider added /dev/vda2 . I'm …

问题原文

原帖链接 · Odin · CC BY-SA 4.0

I have small VPS server with 40 GB disk space. I bought extra 40 GB and now I would like to extend / partition size.

My partitions looks like this:

/dev/vda1 is /boot and /dev/vda5 is my /. My VPS provider added /dev/vda2. I'm not sure if this is correct but I've tried to remove /dev/vda5 and /dev/vda2 and create /dev/vda5 but I don't have that option, I only can re-create devices with ID 2-4 and not 5 where my / is.

已采纳解答

原帖链接 · Michael Hampton · CC BY-SA 4.0

There is a utility named growpart that will safely grow partitions once your provider has expanded your virtual disk. The only trick in your case is that they have unnecessarily created an extended/logical DOS partition when it was not needed. Thus you will have to resize the extended partition, then the logical one it contains.

sudo apt install cloud-guest-utils

The growpart utility accepts the disk and partition number as separate arguments, so to resize /dev/vda2 you will write:

sudo growpart /dev/vda 2

Resize the extended partition /dev/vda2 first, then resize /dev/vda5 the same way.

sudo growpart /dev/vda 2
sudo growpart /dev/vda 5

Now you should be able to resize your filesystem. If it is ext4 then resize2fs /dev/vda5 will work. For XFS, use xfs_growfs /.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2021-01-14)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。