Sobes.tech
Junior — Middle

How can the size of a partition be increased in Linux?

sobes.tech AI

Answer from AI

To increase the size of a partition in Linux, the following steps are usually performed:

  1. Extend the physical volume or disk (if using LVM or a virtual disk).
  2. Change the size of the partition using utilities such as fdisk, parted, or gparted.
  3. Expand the filesystem within the partition, for example using resize2fs for ext4 or xfs_growfs for XFS.

Example for a partition with ext4 filesystem on LVM:

# Extend the physical volume (if needed)
# lvextend -L +10G /dev/mapper/vg0-lv0

# Extend the filesystem
resize2fs /dev/mapper/vg0-lv0

Important: Before modifying partitions, it is recommended to back up data and ensure that the partition is not in use (or mounted in read-only mode).