Score:0

I have a local Amazon Linux 2 (EC2) AMI Instance; How do I repartition the disk and expand the file system?

si flag

I have expanded the disk of my VM.
How do I now repartition the disk and expand the file system on the guest?
Which is Amazon Linux 2 Kernel 4.14.252-195.483.amzn2.x86_64 on an x86_64

$> sudo lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 52G 0 disk
├─sda1 8:1 0 25G 0 part /
└─sda128 259:0 0 1M 0 part
sr0 11:0 1 1024M 0 rom

$> sudo fdisk -l
GPT PMBR size mismatch (52428799 != 109051903) will be corrected by w(rite).
Disk /dev/sda: 52 GiB, 55834574848 bytes, 109051904 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: B5D4B016-37AF-4CFE-A37B-2B3B6F23154F

Device Start End Sectors Size Type
/dev/sda1 4096 52428766 52424671 25G Linux filesystem
/dev/sda128 2048 4095 2048 1M BIOS boot

Partition table entries are not in disk order.

sudo cfdisk (sorted) gives;

                            Disk: /dev/sda
                            Size: 52 GiB, 55834574848 bytes, 109051904 sectors
                            Label: gpt, identifier: B5D4B016-37AF-4CFE-A37B-2B3B6F23154F

Device Start End Sectors Size Type
/dev/sda1 2048 4095 2048 1M BIOS boot
/dev/sda2 4096 52428766 52424671 25G Linux filesystem
Free space 52428800 109051870 56623071 27G


Based on the cfdisk output I'm guessing that I need to

  1. create a new partition sda3 from the "Free Space"
  2. add sda1, sda2 and the new sda3 to the same LVM

Can someone confirm the steps and let me know how this can be done from the CLI it would be much appreciated?
Cheers Chris

Score:0
in flag

This shouldn't be a problem ... follow this procedure and you'll have it done!

https://repost.aws/knowledge-center/extend-linux-file-system

PLEASE!?! Do NOT skip the first step, where you take a snapshot of the volume BEFORE you start screwing around with data storage.

chris-j avatar
si flag
So based on this answer; `$ sudo growpart /dev/sda 1` to expand sda1 and I used `$ sudo xfs_growfs /dev/sda1` as a direct replacement for resize2fs.
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.