Low Orbit Flux Logo 2 D

Linux - How to Expand a Partition

The basic idea is that you will delete the old partition and create a new one that is larger. It will start at the same place on the disk but the last sector will be larger. Here are some key points:

You will want to run most or all of these commands as root. You can also use sudo if you like.

WARNING - Make sure you understand what you are doing. Things could still go wrong. Back up your data first. Don’t blindly rely on these instructions without understanding what you are doing.

Steps - How to Expand a Partition on Linux

WARNING - Make sure you get the first sector right or you could ( probably will ) lose data. Also pay attention to the last sector or the size that you want to expand to. Back your data up before doing this!

umount /dev/sdb2
fdisk /dev/sdb

p   print existing partitions ( note start and end sectors )
d   delete partition
2   enter partition number to delete
n   create new partition
p   create primary partition
[enter]  to accept default first sector or enter a value (enter the value if this is not correct)
+50G   Enter the new size or just specify the last sector if you want
p   show the partition table to make sure everything is as expected
w  write changes to disk
e2fsck /dev/sdb2
resize2fs /dev/sdb2
mount /dev/sdb2

Expand LVM Volumes On Linux

umount /dev/sdb2
fdisk /dev/sdb
pvresize /dev/sdb2
lvdisplay -v
lvextend -l +100%FREE /dev/vg/lv_root
resize2fs /dev/vg/lv_root
mount /dev/vg/lv_root

Helpful Info

If you want to see what disks are available on your system you can use any of the following commands:

df -h
fdisk -l