Debian Jessie - extend root partition

0

I have Debian Jessie 64bit and Windows 10 alongside and i want to increase root partition (in my configuration called sda5) size. I installed gparted in version 0.19, but he doesn't allow me to change size of any partition. I was trying to shrink home partition first and extend root it automatically sets previous value. When i try to reduce size of single partition it automatically sets previous value. He shows that minimal value is equal to maximal. gparted Why gparted doesn't work?

I also tried to do this by command line: fdisk -l returns:

Disk /dev/sda: 238.5 GiB, 256060514304 bytes, 500118192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 0AE14023-D392-11E6-8283-B4774F0AF981

Device         Start       End   Sectors   Size Type
/dev/sda1       2048   1845248   1843201   900M Windows recovery environment
/dev/sda2    1845249   2050049    204801   100M EFI System
/dev/sda3    2050050   2312194    262145   128M Microsoft reserved
/dev/sda4    2312195 332339202 330027008 157.4G Microsoft basic data
/dev/sda5  332341248 346011647  13670400   6.5G Linux filesystem
/dev/sda6  346011648 351870975   5859328   2.8G Linux filesystem
/dev/sda7  351870976 368355327  16484352   7.9G Linux swap
/dev/sda8  368355328 369135615    780288   381M Linux filesystem
/dev/sda9  369135616 500117503 130981888  62.5G Linux filesystem

I previously read that partitions must be continous. I want to increase root partition by 5GB from home partition. Do i need to change size of each partition beetween root (sda5) and home (sda9)?

I was also trying to remove swap partition basing on this post: https://askubuntu.com/questions/492054/how-to-extend-my-root-partition

but sudo resize2fs /dev/sda doesn't increase size of root partion becase there is var partition beetween them. I created swap partition once again to restore previous state. What should i do? Please help.

domandinho

Posted 2017-11-21T20:16:19.250

Reputation: 101

You can't grow a partition unless you have contiguous unallocated space after said partition. – None – 2017-11-21T21:34:46.503

So what you suggest? Should i remove /var and /swap partitions? But removal of /var partition by gparted ends with failure because disk was busy. What should i do? – domandinho – 2017-11-21T21:57:32.623

I don't. Honestly, your partitioning is absurd from the start and anything you need to do is risky. You'd need to swapoff, remove the swap partition (which is huge, BTW), resize (shrink) sda9, then move it all the way to the right, then also move sda6 and sda8 all the way to the right, then resize (grow) sda5 provisioning for a new swap, create the new swap in the remaining free space and finally boot (if it boots with all this done) and update fstab to reflect the new UUID for the new swap... – None – 2017-11-21T22:07:10.137

It was created by choosing one of options in GUI during Debian installation. I didn't perform any partition changes during installation – domandinho – 2017-11-22T12:18:03.123

The defaults aren't always the best option, just the more convenient. That explains the huge swap and the separated /var and /tmp (both can be under /. I don't know what criteria Debian installer has for making such small / and give the rest to /home (as above, having it in a separated partition isn't a requirement; useful if reinstalling while keeping the user files and settings but not mandatory) though but I guess it must have its reasons. Users can always use manual partitioning. – None – 2017-11-22T12:25:54.817

can i remove /var first than remove swap than extend root partition and create smaller /var and smaller swap? when i tried to remove /var gparted says that this partition is busy – domandinho – 2017-11-22T12:28:48.143

That will break your system and managing partitions CAN'T be done from within the running system (partitions are in use). You must boot a live session and run GParted (or other) from there. If doable, deleting all those partitions and reinstall with your own partition schema is much easier. – None – 2017-11-22T12:41:32.983

Answers

0

Why gparted doesn't work?

Because you're trying to affect partitions that are in use. Key icons on the left of your screenshot indicate such partitions.

I haven't tried to confirm this. I chickened out in case I'm wrong and gparted does mangle partitions in use. However this comment and answers to this question support my claim. In particular Rod Smith's answer is exactly what you need to know (BTW, Rod is the creator of gdisk, AFAIK):

GParted won't adjust any partition that's currently in use, but it should be able to alter partitions that are not currently mounted and create new partitions in unpartitioned areas of the disk. In some cases you can unmount a mounted partition (GParted can do this, in fact), but you will never be able to unmount your root (/) partition, and possibly not some others. If you need to adjust them, you'll need to boot from a live CD to edit the partitions.

Some other tools, such as the text-mode fdisk and gdisk, do enable you to edit partitions that are in use; however, these tools don't support filesystem resizing, and if you edit in-use partitions the kernel won't use the changes until after you reboot.

My comment to the last sentence though: if you edit in-use partitions without altering their filesystems accordingly, then after you reboot these filesystems may get corrupted or/and not mount at all. This is because fdisk modifies just a partition table – a map telling us where particular partitions start and end. Changing the map only makes kernel "think" the filesystems (and swap, if altered) are now in different places. Without actually moving them you create discrepancy that can easily lead to data loss.

Kamil Maciorowski

Posted 2017-11-21T20:16:19.250

Reputation: 38 429