Monday, April 10, 2017

resize EBS

~$ lsblk
NAME    MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
xvda    202:0    0  120G  0 disk
`-xvda1 202:1    0    8G  0 part /

~$ sudo parted /dev/xvda resizepart 1
Warning: Partition /dev/xvda1 is being used. Are you sure you want to continue?
Yes/No? yes
End?  [8590MB]? 120G
Information: You may need to update /etc/fstab.

~$ sudo /sbin/resize2fs /dev/xvda1
resize2fs 1.42.12 (29-Aug-2014)
Filesystem at /dev/xvda1 is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 7
The filesystem on /dev/xvda1 is now 29296875 (4k) blocks long.


Grow filesystem to match disk size

Compare against and try to let a single page.

First check the partition layout. In the following example we have a 30GB disk with a 15GB partition for /. We have to extend this partition.

$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 30G 0 disk ├─sda1 8:1 0 15G 0 part / ├─sda2 8:2 0 1K 0 part └─sda5 8:5 0 975M 0 part [SWAP] sr0 11:0 1 46K 0 rom

Then we disable the SWAP partition:

$ sudo swapoff /dev/sda5 $ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 30G 0 disk ├─sda1 8:1 0 15G 0 part / ├─sda2 8:2 0 1K 0 part └─sda5 8:5 0 975M 0 part sr0 11:0 1 46K 0 rom

Now we remove all three partitions:

$ sudo fdisk /dev/sda Welcome to fdisk (util-linux 2.36.1). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Command (m for help): d Partition number (1,2,5, default 5): Partition 5 has been deleted. Command (m for help): d Partition number (1,2, default 2): Partition 2 has been deleted. Command (m for help): d Selected partition 1 Partition 1 has been deleted.
Confirm if it is really important to maintain the ext4 signature.
Confirm if it is really needed to perform the following steps in the same fdisk session.

And while still in the same fdisk session, re-create the partitions maintaining the ext4 signature. Determine the size of the first partition (28GB) as the total disk space (30GB) minus ~20% to ~25% of the assigned RAM memory (20% of 10GB is 2GB):

Command (m for help): n Partition type p primary (0 primary, 0 extended, 4 free) e extended (container for logical partitions) Select (default p): p Partition number (1-4, default 1): 1 First sector (2048-62914559, default 2048): Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-62914559, default 62914559): +28G Created a new partition 1 of type 'Linux' and of size 28 GiB. Partition #1 contains a ext4 signature. Do you want to remove the signature? [Y]es/[N]o: N Command (m for help): n Partition type p primary (1 primary, 0 extended, 3 free) e extended (container for logical partitions) Select (default p): e Partition number (2-4, default 2): 2 First sector (58722304-62914559, default 58722304): Last sector, +/-sectors or +/-size{K,M,G,T,P} (58722304-62914559, default 62914559): Created a new partition 2 of type 'Extended' and of size 2 GiB. Command (m for help): n Adding logical partition 5 First sector (58724352-62914559, default 58724352): Last sector, +/-sectors or +/-size{K,M,G,T,P} (58724352-62914559, default 62914559): Created a new partition 5 of type 'Linux' and of size 2 GiB. Command (m for help): w The partition table has been altered. Syncing disks. $ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 30G 0 disk ├─sda1 8:1 0 28G 0 part / ├─sda2 8:2 0 1K 0 part └─sda5 8:5 0 2G 0 part sr0 11:0 1 46K 0 rom

Then re-configure the SWAP:

$ sudo mkswap /dev/sda5 Setting up swapspace version 1, size = 2 GiB (2145382400 bytes) no label, UUID=204fbbfb-79bf-4a72-870d-2a94288da6ba

And update /etc/fstab with the new UUID for the SWAP partition.

Confirm that the following is really needed. https://www.claudiokuenzler.com/blog/1138/update-initramfs-warning-tools-configuration-sets-resume-no-matching-swap-device. It seems it doesn’t happen for the development instances under the “temp_jhablutzel” location. Maybe Veeam related?

Then edit /etc/initramfs-tools/conf.d/resume with the new UUID as well.

Then:

sudo update-initramfs -k all -u sudo update-grub

Then:

sudo resize2fs /dev/sda1

Then reboot.

And finally check the disk layout once again:

$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 30G 0 disk ├─sda1 8:1 0 28G 0 part / ├─sda2 8:2 0 1K 0 part └─sda5 8:5 0 2G 0 part [SWAP] sr0 11:0 1 46K 0 rom
Provide instructions on how to set up Veeam backups depending on the specific requirements of this VM.

No comments: