You are not logged in.

#1 2020-11-26 23:02:48

OrakMoya
Member
Registered: 2019-09-22
Posts: 75

Extend root partition into unallocated space before it

Recently I set up zswap, and decided to shrink my swap partition and enlarge my root partition by that little bit.
However, the swap partition is before the root partition, and I can't figure out how to extend my root partition into it.

https://i.imgur.com/PKYGRla.png

How would I go about extending my root partition into that space?

Offline

#2 2020-11-27 06:12:35

fire100265
Member
Registered: 2020-10-05
Posts: 95

Re: Extend root partition into unallocated space before it

get a gparted usb drive and extend it.

Offline

#3 2020-11-27 07:51:37

respiranto
Member
Registered: 2015-05-15
Posts: 479
Website

Re: Extend root partition into unallocated space before it

Note that when you want to extend a filesystem to the left, you effectively need to shift/move it the required amount left (1) and then extend it to the right (2).  This takes a long time and is also what gparted does.  One can manually do this using `dd' in a for-loop (3).  Always, make a backup first.

Alternatively one could copy the data elsewhere, recreate the filesystem further left and copy the data back.  Since you would anyways want to have a backup, this is possibly the best way.

You might also be interested in LVM, which would have avoided this issue.  I assume it should even be somehow possible to convert your mbr/gpt partition to an lvm one, without the need for moving (much) data.

(1) I assume it is theoretically possible for filesystems to be extended directly to the left, but I am unaware of any tools supporting this.
(2) Not all filesystems support extending (to the right).  ext4 does (and likely most).
(3) Copy in chunks sized the recently freed space.  Also, update the mbr/gpt.  You would want to do this with your root partition unmounted / mounted read-only.

Offline

#4 2020-11-27 07:52:48

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,689

Re: Extend root partition into unallocated space before it

For some context:
- you must perform this offline (ie. from a "gparted usb drive", ie. not while the system on that partition is running)
- this is probably going to take a while (since the data on the partition must be copied in-place; you cannot "just" grow the partition this direction - it's effectively re-created)
- the process is far more fragile than growing the partition the other direction.

=> figure whether that's actually worth the hassle and BACKUP IMPORTANT DATA FROM THAT PARTITION

Edit: fuck.

Last edited by seth (2020-11-27 07:53:24)

Offline

Board footer

Powered by FluxBB