This is the modus operandi I used :
---%<-----------------------------------------------
# df -hT | grep /dev/xvda
/dev/xvda1 ext4
8,9G 6,3G 2,1G 76% /
# parted /dev/xvda 'unit s print' free
Model: Xen Virtual Block Device (xvd)
Disk /dev/xvda: 29360128s
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
63s 2047s 1985s Free Space
1 2048s 18946047s 18944000s primary ext4
2 18946048s 20969471s 2023424s primary linux-swap(v1)
20969472s 29360127s 8390656s Free Space# free -h
total used free shared buff/cache available
Mem: 1,9Gi 209Mi 1,2Gi 6,0Mi 532Mi 1,6Gi
Swap: 987Mi 0B 987Mi
swap is unused here so I can turn it off
# swapoff /dev/xvda2
Now I change the partition table :
# fdisk /dev/xvda -c
Welcome to fdisk (util-linux 2.34).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help):
pDisk /dev/xvda: 14 GiB,
15032385536 bytes, 29360128 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: dos
Disk identifier: 0xb607ef98
Device Boot Start End Sectors Size Id Type
/dev/xvda1 2048 18946047 18944000 9G 83 Linux
/dev/xvda2 18946048 20969471 2023424 988M 82 Linux swap / Solaris
Command (m for help):
dPartition number (1,2, default 2):
1Partition 1 has been deleted.
Command (m for help):
nPartition type
p primary (1 primary, 0 extended, 3 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (1,3,4, default 1):
1First sector (2048-29360127, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-29360127, default 29360127):
Created a new partition 1 of type 'Linux' and of size 14 GiB.
Partition #1 contains a ext4 signature.
Do you want to remove the signature? [Y]es/[N]o:
NCommand (m for help):
aPartition number (1,2, default 2):
1The bootable flag on partition 1 is enabled now.
Command (m for help):
wThe partition table has been altered.
Failed to update system information about partition 1: Périphérique ou ressource occupé
The kernel still uses the old partitions. The new table will be used at the next reboot.
Syncing disks.
# swapon /dev/xvda2
# fdisk -l /dev/xvda
Disk /dev/xvda: 14 GiB,
15032385536 bytes, 29360128 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: dos
Disk identifier: 0xb607ef98
Device Boot Start End Sectors Size Id Type
/dev/xvda1 * 2048 29360127 29358080 14G 83 Linux
/dev/xvda2 18946048 20969471 2023424 988M 82 Linux swap / Solaris
# reboot
# resize2fs /dev/xvda1
resize2fs 1.44.4 (18-Aug-2018)
Filesystem at /dev/xvda1 is mounted on /; on-line resizing required
old_desc_blocks = 2, new_desc_blocks = 2
The filesystem on /dev/xvda1 is now 3669760 (4k) blocks long.
# df -hT | grep /dev/xvda
/dev/xvda1 ext4 14G 6,3G 6,8G 49% /
---%<-----------------------------------------------