Partition
Extend partition without LVM
Check the size of the disk:
$ fdisk -l
Disk /dev/sda: 25 GiB, 26843545600 bytes, 52428800 sectors
Disk model: Virtual Disk
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: F5F02D9D-060D-422F-BA27-1981A6CA23F4
Device Start End Sectors Size Type
/dev/sda1 2048 4095 2048 1M BIOS boot
/dev/sda2 4096 1054719 1050624 513M EFI System
/dev/sda3 1054720 52426751 51372032 24.5G Linux filesystem
Assume that the disk is increase in size to 30GB:
$ fdisk -l
Disk /dev/sda: 30 GiB, 32212254720 bytes, 62914560 sectors
Disk model: Virtual Disk
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: F5F02D9D-060D-422F-BA27-1981A6CA23F4
Device Start End Sectors Size Type
/dev/sda1 2048 4095 2048 1M BIOS boot
/dev/sda2 4096 1054719 1050624 513M EFI System
/dev/sda3 1054720 52426751 51372032 24.5G Linux filesystem
Next to increase the partition itself.
$ fdisk /dev/sda
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 p to list the partition:
Command (m for help): p
Disk /dev/sda: 30 GiB, 32212254720 bytes, 62914560 sectors
Disk model: Virtual Disk
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: F5F02D9D-060D-422F-BA27-1981A6CA23F4
Device Start End Sectors Size Type
/dev/sda1 2048 4095 2048 1M BIOS boot
/dev/sda2 4096 1054719 1050624 513M EFI System
/dev/sda3 1054720 52426751 51372032 24.5G Linux filesystem
## To expand a partition, first need to delete information about it.
## Only the information about partition deleted, the data itself remains on the disk
## To do this, enter d and specify the partition (3 for /dev/sda3):
Command (m for help): d
Partition number (1-3, default 3): 3
Partition 3 has been deleted.
## Enter n to create a new partition
Command (m for help): n
## Indicate the number of the partition:
Partition number (3-128, default 3):3
## Indicate the starting and ending sectors:
First sector (1054720-62914526, default 1054720): 1054720
Last sector, +/-sectors or +/-size{K,M,G,T,P} (1054720-62914526, default 62914526): 62914526
Created a new partition 3 of type 'Linux filesystem' and of size 29.5 GiB.
## A 29.5 GB partition was created with the Linux filesystem type.
## It will also ask if the current filesystem type want to delete. We refuse:
Partition #3 contains a ext4 signature.
Do you want to remove the signature? [Y]es/[N]o: N
## Save the partition table:
Command (m for help): w
Reboot the machine.
$ reboot
Next, use resize2fs utility (for ext4) to increase the size of the filesystem:
$ resize2fs /dev/sda3
resize2fs 1.45.6 (20-Mar-2020)
Filesystem at /dev/sda3 is mounted on /; on-line resizing required
old_desc_blocks = 4, new_desc_blocks = 4
The filesystem on /dev/sda3 is now 7732475 (4k) blocks long.
Checking the result:
$ df -h
Filesystem Size Used Avail Use% Mounted on
tmpfs 394M 1.4M 392M 1% /run
/dev/sda3 29G 7.4G 21G 27% /
tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 4.0M 0 4.0M 0% /sys/fs/cgroup
/dev/sda2 512M 7.8M 505M 2% /boot/efi
tmpfs 394M 84K 394M 1% /run/user/126
tmpfs 394M 72K 394M 1% /run/user/1000
Re-read The Partition Table Without Rebooting
partprobe
utility
partprobe
utility# Installation
# Debian / Ubuntu
apt install parted
# Redhat
dnf install parted
# Usage
partprobe <path_to_drive>
Replace <path_to_drive>
with actual device/drive name. Example: /dev/sda
kpartx
utility
kpartx
utility# Installation
# Debian / Ubuntu
apt install kpartx
# Redhat
dnf install kpartx
# Usage
kpartx -u <path_to_drive>
Replace <path_to_drive>
with actual device/drive name. Example: /dev/sda
Last updated
Was this helpful?