Disk expansion when booting CentOS 8.2 of aarch64 on EC2

When I built Zabbix server with r6g instance the other day, there should be 32GB storage, but there is only 8GB area, so it took time to expand, so this article is also a memorandum.

State at startup

I should have booted with a 32GB SSD, but there is only 8GB under / By the way, even if you hit xfs_growfs -d / in this state, you could not expand it.

[centos@ip-10-0-2-177 ~]$ df -Th
Filesystem     Type      Size  Used Avail Use% Mounted on
devtmpfs       devtmpfs  3.7G     0  3.7G   0% /dev
tmpfs          tmpfs     3.7G     0  3.7G   0% /dev/shm
tmpfs          tmpfs     3.7G   22M  3.7G   1% /run
tmpfs          tmpfs     3.7G     0  3.7G   0% /sys/fs/cgroup
/dev/nvme0n1p2 xfs       7.8G  1.4G  6.5G  18% /
/dev/nvme0n1p1 vfat      599M  6.4M  593M   2% /boot/efi
tmpfs          tmpfs     754M     0  754M   0% /run/user/1000

Hitting fdisk -l seems to find some problems

[root@ip-10-0-2-177 ~]# fdisk -l
GPT PMBR size mismatch (20971519 != 67108863) will be corrected by write.
The backup GPT table is not on the end of the device. This problem will be corrected by write.

Partition modification

First of all, there was a problem with fdisk, so I will fix it with parted -l

[root@ip-10-0-2-177 ~]# parted -l
Warning: Not all of the space available to /dev/nvme0n1 appears to be used, you
can fix the GPT to use all of the space (an extra 46137344 blocks) or continue
with the current setting?
Fix/Ignore?

You will be asked Fix / Ignore, so enter Fix

Fix/Ignore? Fix
Model: NVMe Device (nvme)
Disk /dev/nvme0n1: 34.4GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system  Name                  Flags
 1      1049kB  630MB   629MB   fat32        EFI System Partition  boot, esp
 2      630MB   8966MB  8336MB  xfs
 3      8966MB  8967MB  1049kB                                     bios_grub

Check with fdisk again

[root@ip-10-0-2-177 ~]# fdisk -l
Disk /dev/nvme0n1: 32 GiB, 34359738368 bytes, 67108864 sectors
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: gpt
Disk identifier: E97B9FFA-2C13-474E-A0E4-ABF1572CD20C

Device            Start      End  Sectors  Size Type
/dev/nvme0n1p1     2048  1230847  1228800  600M EFI System
/dev/nvme0n1p2  1230848 17512447 16281600  7.8G Linux filesystem
/dev/nvme0n1p3 17512448 17514495     2048    1M BIOS boot

The error disappeared and only the partition information is displayed I feel like I can't extend it because / dev / nvme0n1p3 is at the end.

Delete unnecessary partition

Next, we will expand the / area of the main subject.

As I wrote earlier, / dev / nvme0n1p3 seems to be in the way, so delete it Execute fdisk and delete it with the d command.

[root@ip-10-0-2-177 ~]# fdisk /dev/nvme0n1

Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help):

Enter d here

Command (m for help): d
Partition number (1-3, default 3):

For Partition number, enter the number of the partition you want to delete Enter 3 this time

Partition number (1-3, default 3): 3

Partition 3 has been deleted.

Finally enter the w command to exit fdisk

Command (m for help): w
The partition table has been altered.
Syncing disks.

Since the obstructive partition has disappeared, I will expand it

/ Expansion of area

First, use the growpart command to extend the partition

[root@ip-10-0-2-177 ~]# growpart /dev/nvme0n1 2

It is okay if CHANGED ..... is displayed as shown below.

CHANGED: partition=2 start=1230848 old: size=16281600 end=17512448 new: size=65877983,end=67108831

Expand / area with xfs_growfs command

[root@ip-10-0-2-177 ~]# xfs_growfs -d /
meta-data=/dev/nvme0n1p2         isize=512    agcount=4, agsize=508800 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=1, rmapbt=0
         =                       reflink=1
data     =                       bsize=4096   blocks=2035200, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
log      =internal log           bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 2035200 to 8234747

Check with the df command, and if it is extended, it's done.

[root@ip-10-0-2-177 ~]# df -Th
Filesystem     Type      Size  Used Avail Use% Mounted on
devtmpfs       devtmpfs  3.7G     0  3.7G   0% /dev
tmpfs          tmpfs     3.7G     0  3.7G   0% /dev/shm
tmpfs          tmpfs     3.7G   22M  3.7G   1% /run
tmpfs          tmpfs     3.7G     0  3.7G   0% /sys/fs/cgroup
/dev/nvme0n1p2 xfs        32G  1.5G   30G   5% /
/dev/nvme0n1p1 vfat      599M  6.4M  593M   2% /boot/efi
tmpfs          tmpfs     754M     0  754M   0% /run/user/1000

Summary

I don't know if it's the right way to do it, but I was able to successfully expand the disk. When I was in this state for the first time, I thought I made a mistake in creating the instance ...

Recommended Posts

Disk expansion when booting CentOS 8.2 of aarch64 on EC2
Error when deploying EC2 on CircleCI
Disk expansion on Ubuntu 20.04.1 LTS on GCP Compute Engine