0

I would like to increase the size of my root partition. I was thinking that I could run fdisk /dev/sdb delete the sdb2 partition and create a new one that is bigger. However, I have read that I need to umount the partition ( not sure that's true ). I also saw things about resize2fs, but that is for resizing the filesystem ( I think ). What is the easiest way to increase the size to the rest of the sdb ? It'd be nice if I didn't have to boot into another partition ( as I don't have one set up ).

Current partitions and mounts:

- sdb      |  119.2G  |
  - sdb1   |   512M   |   /efi
  - sdb2   |   30G    |   /
MrDrago9
  • 3
  • 1
  • 5
  • "I also saw things about `resize2fs`, but that is for resizing the filesystem ( I think )" -- **IFF** the filesystem is from the ext family. AFAIK the tool can expand a filesystem to the right even when it's mounted, but you need to be sure it's the right tool (what is the type of the filesystem?). See [this question](https://superuser.com/q/1446907/432690) and my answer there. – Kamil Maciorowski Apr 27 '22 at 05:10
  • You are right about the partition != filesystem part. And after resizing the `/` partition, you'll need to forcefully update the "in-memory" partition table with `blockdev` / `partprobe` / ..., or the simplest and safest way `reboot`. After that you should be able to resize the filesystem on it with the corresponding filesystem-specfic tool (the tool should let you know whether the filesystem can be extended while it is mounted). – Tom Yan Apr 27 '22 at 05:53

1 Answers1

2

First off, you should consider this to be a high risk operation. You definitely want a backup in case something goes wrong.

You can increase the size of an active mounted partition (provided there is empty space at the end of the disk). You simply go into fdisk, list the partition details, then delete /dev/sdb2 and recreate it with the same starting point, same file descriptor and also ensure the boot flag is correctly toggled. Save the changes.

Once you have done this you need to reboot the system, which will hopefully reboot fine. (You need to go through this step so the OS sees the larger disk space)

All thats left is to resize the filesystem (which can be done online if its ext) To do this, just do resize2fs /dev/sdb2 (or resize4fs /dev/sdb2 depending on your distro - both commands are the same)

davidgo
  • 68,623
  • 13
  • 106
  • 163
  • Did exactly this while booted into /dev/sdb2. Seems to have worked just fine :) Thank you for confirming. – MrDrago9 Apr 27 '22 at 23:46