Score:0

Resize a persistent disk for Linux (MBR partition) on Google Cloud Compute Engine

ls flag

I want to expand my disk capacity for my Google Cloud machine and have been following the tutorial that's located here.

However, I'm fairly certain that the tutorial assumes the user has a GPT partition table but I have MBR. I only need 20GB so this shouldn't be a problem.

Anyway, I followed the tutorial up to step 4a and everything seemed to execute just fine including everything involved with the command sudo parted /dev/sda.

But, when I reached step 4b which tells you to run sudo sgdisk --move-second-header /dev/sda, I got the following message:

Warning: Partition table header claims that the size of partition table

entries is 1119092736 bytes, but this program supports only 128-byte entries.

Adjusting accordingly, but partition table may be garbage.

Warning: Partition table header claims that the size of partition table

entries is 0 bytes, but this program supports only 128-byte entries.

Adjusting accordingly, but partition table may be garbage.


***************************************************************

Found invalid GPT and valid MBR; converting MBR to GPT format

in memory.

***************************************************************



Warning! Secondary partition table overlaps the last partition by

33 blocks!

You will need to delete this partition or resize it in another utility.

Non-GPT disk; not saving changes. Use -g to override.

I'm lost as to what to do next. Right now, I have the 20GB available yet my sda1 says that it's only 10GB.

In case it helps, here is the output of sudo df -Th:

Filesystem     Type      Size  Used Avail Use% Mounted on
udev           devtmpfs  976M     0  976M   0% /dev
tmpfs          tmpfs     199M  716K  198M   1% /run
/dev/sda1      ext4      9.8G  8.6G  720M  93% /
tmpfs          tmpfs     992M     0  992M   0% /dev/shm
tmpfs          tmpfs     5.0M     0  5.0M   0% /run/lock
/dev/loop5     squashfs   62M   62M     0 100% /snap/core20/1611
/dev/loop2     squashfs   45M   45M     0 100% /snap/certbot/2344
/dev/loop6     squashfs   64M   64M     0 100% /snap/core20/1623
/dev/loop4     squashfs  115M  115M     0 100% /snap/core/13741
/dev/loop1     squashfs  115M  115M     0 100% /snap/core/13886
/dev/loop0     squashfs   45M   45M     0 100% /snap/certbot/2414
tmpfs          tmpfs     199M  4.0K  199M   1% /run/user/1000

And here is the output of sudo lsblk:

NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
loop0    7:0    0  44.7M  1 loop /snap/certbot/2414
loop1    7:1    0   115M  1 loop /snap/core/13886
loop2    7:2    0  44.5M  1 loop /snap/certbot/2344
loop4    7:4    0 114.9M  1 loop /snap/core/13741
loop5    7:5    0    62M  1 loop /snap/core20/1611
loop6    7:6    0  63.2M  1 loop /snap/core20/1623
sda      8:0    0    20G  0 disk 
└─sda1   8:1    0    20G  0 part /
Siegfred V. avatar
md
Are you resizing the disk online and are you using a custom image? It is a best practice to resize the persistent disk offline or attached as an additional disk on a separate VM Instance and run the command sudo resize2fs /dev/sda. Be sure to take a snapshot first as backup
JimmyTheCuck avatar
ls flag
I'm not using a public image if that's what you're asking. All I need to know is what to do next. The linked tutorial says nothing about online/offline and of course I took a snapshot. To reiterate, I've done everything up to and including step 4a.
Siegfred V. avatar
md
Run the command `sudo resize2fs /dev/sda` and skip `sudo sgdisk --move-second-header /dev/sda` since the free remaining space is recognized by the lsblk
Score:1
US flag

Run the command sudo resize2fs /dev/sda1 and skip sudo sgdisk --move-second-header /dev/sda since the free remaining space is recognized by the lsblk

JimmyTheCuck avatar
ls flag
What about step 5?
Siegfred V. avatar
md
I have updated my answer, you should run `sudo resize2fs /dev/sda1` as you are using the persistent disk as boot disk. step 5 is only run for additional disk attached on your VM
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.