Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Increase the size of a persistent disk - Fails with unmount error

Hi, I'm trying to increase my disk partition so I can use the extra space I already set in the VM Disk settings (600gb).

Brent_0-1668461226328.png

However, while following the instructions in this tutorial, "Increase the size of a persistent disk", I received an unexpected error, "Partition /dev/sda2 is being used. You must unmount it before you modify it with Parted." (full console output below)

I expected to be able to continue the tutorial but I'm not sure how to unmount the disk or if I should unmount the disk. It seems like it could corrupt my data. If I take down the server I'm not sure I can bring it back up.

Does anyone know how to get past this part of the tutorial?

--
Last login: Mon Nov 14 02:03:03 2022 from 35.235.242.209
[brentfm@whm ~]$ sudo df -Th
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 5.8G 0 5.8G 0% /dev
tmpfs tmpfs 5.8G 8.0K 5.8G 1% /dev/shm
tmpfs tmpfs 5.8G 449M 5.4G 8% /run
tmpfs tmpfs 5.8G 0 5.8G 0% /sys/fs/cgroup
/dev/sda2 xfs 300G 221G 80G 74% /
/dev/sda1 vfat 200M 12M 189M 6% /boot/efi
/dev/loop0 ext4 3.9G 8.4M 3.7G 1% /tmp
tmpfs tmpfs 1.2G 0 1.2G 0% /run/user/1002
[brentfm@whm ~]$ sudo lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 600G 0 disk
├─sda1 8:1 0 200M 0 part /boot/efi
└─sda2 8:2 0 299.8G 0 part /
loop0 7:0 0 4G 0 loop /home/virtfs/bigislandfun/var/tmp
[brentfm@whm ~]$ sudo parted /dev/sda
GNU Parted 3.1
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) resizepart
Partition number? 2
Error: Partition /dev/sda2 is being used. You must unmount it before you modify it with Parted.
(parted)

0 5 4,234
5 REPLIES 5

Growpart is the command that will enable us to accomplish that. A partition's size can be increased via Growpart to any desired value. Using this command will also help to avoid the error message you are currently getting.

Example:

$ sudo growpart /dev/sda 1

CHANGED: partition=1 start=2048 old: size=419428319 end=419430367 new: size=2097149919

,end=2097151967

You can actually adhere to the instructions in the Xiambo QIAN written guide titled Resize your persistent drive on Google Cloud.

Here is additional documentation that might also help you with the process.

Thank you for weighing in on this, @JGerman23 ! I've created an internal bug requesting the owner of the doc https://cloud.google.com/compute/docs/disks/resize-persistent-disk to look into the potential need for updating the instructions.

Thank you @kumards @JGerman23

I hit a snag while following Xianbo's tutorial.
While trying to use growpart, I received, "[brentfm@whm ~]$ sudo growpart /dev/sda 2
sudo: growpart: command not found"

The slashroot article recommends the "xfs_growfs command instead of resize2fs" but I'm not sure if that command is supported or recommended.

Observations for possible inclusion tutorial edit;

1. Clarification of terms "boot" and "root". They seem to be used interchangeably but I know they are not synonyms.

2. The term "Boot" disk in many of the examples I've read refer to "/dev/sda 1". This would seem accurate since the disk boots the OS. But in my case I have two partitions. A clarifying statement like, "Be sure to reference the partition you want to increase. If you are increasing sda 1 then use sda 1. If you are increasing sda 2 then use sda 2."  My lack of understanding might be the use of "root" which would seem only to describe /dev/sda. Is that true?

3. The tutorials I've found all seem to be missing just a few clarifying statements that might help noobs like me.

4. Overall, I don't have a clear understanding of the danger level of the commands I'm trying to use. The stakes are high for me. It would seem like one mistake and my entire business is relegated to the success of restoring a snapshot.

Here's the output from my attempt to increase disk partition 2:

[brentfm@whm ~]$ df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 5.8G 0 5.8G 0% /dev
tmpfs 5.8G 8.0K 5.8G 1% /dev/shm
tmpfs 5.8G 561M 5.3G 10% /run
tmpfs 5.8G 0 5.8G 0% /sys/fs/cgroup
/dev/sda2 300G 226G 75G 76% /
/dev/sda1 200M 12M 189M 6% /boot/efi
/dev/loop0 3.9G 8.4M 3.7G 1% /tmp
tmpfs 1.2G 0 1.2G 0% /run/user/1002
tmpfs 1.2G 0 1.2G 0% /run/user/0
[brentfm@whm ~]$ sudo lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 600G 0 disk
├─sda1 8:1 0 200M 0 part /boot/efi
└─sda2 8:2 0 299.8G 0 part /
loop0 7:0 0 4G 0 loop /home/virtfs/bigislandfun/var/tmp
[brentfm@whm ~]$ sudo growpart /dev/sda 2
sudo: growpart: command not found
[brentfm@whm ~]$

Thank you for your help. I will never ask again once I get some better understanding. 😉

I appreciate your help. I think I'm being charged for the upgrade while I learn how to partition the drive. I'll repost to try to learn another way. Thank you for trying to help!

 

Thanks again for the suggestions. It turns out that a stop/start service automatically resizes the partition. Only took a couple weeks and a paid support plan for someone in support to tell me. Looks like the doc has been updated: https://cloud.google.com/compute/docs/disks/resize-persistent-disk