[SOLVED] Expanding the root directory

Nourr

New Member
Joined
Jun 17, 2022
Messages
6
Reaction score
3
Credits
42
Hello,
I'm new to the community and I got a question, When I installed Ubuntu, I specified 30gb for it.
Now I want to expand it, but of course it's not possible to umount the root directory and expand it with Gparted,
so is it possible to expand the root directory if I booted ubuntu from a USB ?
 


Fanboi

Well-Known Member
Joined
Apr 16, 2021
Messages
499
Reaction score
406
Credits
6,114
Simple answer: Yes.

Complex answer: it may lead to data loss as you may be hit by lightning. However, the UUID for the partition will change. If you do not know what you are doing, don't unless you're prepared to ask questions. I'll answer your first, though:
After resizing the root partition, you can run blkid to get that partition's UUID (Gparted tells you, but there's more).
Now mount your newly-sized partition at /mnt.
Edit the fstab file using your preferred plaintext editor. But just before doing so, use blkid /dev/your-partion >> /mnt/etc/fstab which will make copy-pasting easier. Now open /mnt/etc/fstab and go to the bottom. Copy the UUID (can be done with the mouse) and delete blkid's output. Go to the top of fstab and replace the UUID for the partition mounted at / to what you copied (paste it).
Save, exit, reboot and hope there were no complications.
 

wizardfromoz

Administrator
Staff member
Gold Supporter
Joined
Apr 30, 2017
Messages
7,498
Reaction score
6,343
Credits
26,486
I may need more coffee (and I do), but I see a simpler solution, if the OP has not already performed the above.

And welcome to linux.org @Nourr :)

....so is it possible to expand the root directory if I booted ubuntu from a USB ?

Yes, if you have your installation stick, or a GParted Live stick.

If installation, boot from it, and choose Try Ubuntu before installing. I would switch off power saving features so the process is not interrupted.

Go to your applications launcher, search for and open GParted.

Check for available unallocated space immediately following or preceding your root partition. If your root partition has an icon of a padlock or key or similar beside it to say it is mounted, unmount it.

Use GParted to adjust the size of the root partition to expand to incorporate the additional space you require, and OK that.

If the preview appears to be satisfactory, click the check mark at top whose quick tip shows something like apply changes and the operation will proceed.

Once completed, leave a few seconds and then close out of GParted, power down your system and remove the stick.

Reboot and you should enter your new expanded environment.

No change of the partition's UUID and no need for editing /etc/fstab.

If the system was working (albeit cramped) prior to performing this, I would install Timeshift and take a full snapshot stored preferably externally, and once the operation is successfully completed I would replace that with a new full snapshot.

Cheers

Chris Turner
wizardfromoz
 
OP
N

Nourr

New Member
Joined
Jun 17, 2022
Messages
6
Reaction score
3
Credits
42
I may need more coffee (and I do), but I see a simpler solution, if the OP has not already performed the above.

And welcome to linux.org @Nourr :)



Yes, if you have your installation stick, or a GParted Live stick.

If installation, boot from it, and choose Try Ubuntu before installing. I would switch off power saving features so the process is not interrupted.

Go to your applications launcher, search for and open GParted.

Check for available unallocated space immediately following or preceding your root partition. If your root partition has an icon of a padlock or key or similar beside it to say it is mounted, unmount it.

Use GParted to adjust the size of the root partition to expand to incorporate the additional space you require, and OK that.

If the preview appears to be satisfactory, click the check mark at top whose quick tip shows something like apply changes and the operation will proceed.

Once completed, leave a few seconds and then close out of GParted, power down your system and remove the stick.

Reboot and you should enter your new expanded environment.

No change of the partition's UUID and no need for editing /etc/fstab.

If the system was working (albeit cramped) prior to performing this, I would install Timeshift and take a full snapshot stored preferably externally, and once the operation is successfully completed I would replace that with a new full snapshot.

Cheers

Chris Turner
wizardfromoz
Thank you so much for welcoming me and for the detailed explanation :), I will try the solution you provided.
 

Fanboi

Well-Known Member
Joined
Apr 16, 2021
Messages
499
Reaction score
406
Credits
6,114
I may need more coffee (and I do), but I see a simpler solution, if the OP has not already performed the above.

And welcome to linux.org @Nourr :)



Yes, if you have your installation stick, or a GParted Live stick.

If installation, boot from it, and choose Try Ubuntu before installing. I would switch off power saving features so the process is not interrupted.

Go to your applications launcher, search for and open GParted.

Check for available unallocated space immediately following or preceding your root partition. If your root partition has an icon of a padlock or key or similar beside it to say it is mounted, unmount it.

Use GParted to adjust the size of the root partition to expand to incorporate the additional space you require, and OK that.

If the preview appears to be satisfactory, click the check mark at top whose quick tip shows something like apply changes and the operation will proceed.

Once completed, leave a few seconds and then close out of GParted, power down your system and remove the stick.

Reboot and you should enter your new expanded environment.

No change of the partition's UUID and no need for editing /etc/fstab.

If the system was working (albeit cramped) prior to performing this, I would install Timeshift and take a full snapshot stored preferably externally, and once the operation is successfully completed I would replace that with a new full snapshot.

Cheers

Chris Turner
wizardfromoz
Last I resized a partition, it did change the UUID, but doing a quick web search says otherwise. Odd coz I remember the nightmare it took trying to figure out why it wasn't mounting and is the reason I label partitions now, so I can use LABEL= instead of UUID=. I guess there was something elss ar play. Anyway, interesting info. I also learned something now.
 
OP
N

Nourr

New Member
Joined
Jun 17, 2022
Messages
6
Reaction score
3
Credits
42
Last I resized a partition, it did change the UUID, but doing a quick web search says otherwise. Odd coz I remember the nightmare it took trying to figure out why it wasn't mounting and is the reason I label partitions now, so I can use LABEL= instead of UUID=. I guess there was something elss ar play. Anyway, interesting info. I also learned something now.
Glad that you knew something new, and surely Thank you for your help :) .
 

bob466

Well-Known Member
Joined
Oct 22, 2020
Messages
500
Reaction score
354
Credits
3,678
It's much easier to install the Distro to the whole Drive. Years ago partitioning was necessary to increase performance and efficiency...but times have changed and modern computers make this no longer necessary especially with SSDs.
happy0035.gif


Not long ago we had a Swap partition (virtual memory) but that too is a thing of the past...everyone has an opinion on this...so It's your choice. ;)
This might be helpful as most people now have SSDs....https://www.thetechwire.com/should-i-partition-my-ssd/
 

wizardfromoz

Administrator
Staff member
Gold Supporter
Joined
Apr 30, 2017
Messages
7,498
Reaction score
6,343
Credits
26,486
It's much easier to install the Distro to the whole Drive.

Quite so, but not everyone has the configuration and capacity to support that.

The choice by the OP to choose 30 GB in the first place suggests perhaps a reference to an internet article in the first instance, accompanied by a possibility of sharing a drive with Windows, and/or having sizable data partitions already committed to other purposes.

Is that so, @Nourr ?

Wiz
 

f33dm3bits

Gold Member
Gold Supporter
Joined
Dec 11, 2019
Messages
4,900
Reaction score
3,526
Credits
35,667
It's much easier to install the Distro to the whole Drive.
And not everyone want to use the default partition setup of the distribution, that's why most distribution also allow you to have a custom partition setup.
 

SlowCoder

Gold Member
Gold Supporter
Joined
May 2, 2022
Messages
456
Reaction score
314
Credits
3,611
Hi @Nourr, welcome to the forums!

Adding to what people here have said so far, most distros recommend a MINIMUM 20-25GB storage. That really isn't much, unless really all you do is browse the web and write some documents. If you plan to keep personal data, you'll want to plan more disk space, as appropriate.

Another thing to keep in mind is whether you use swap. Many modern mainline distros allow swap files, which are stored in your root partition, and can vary in size depending on your settings. You can also set up a separate swap partition (the more traditional approach) so it doesn't take space in your root partition.

Many of us split our /home partitions from our root (/) partitions. My root partition is 50GB, and my home is given the rest of the space. With all the software I have installed, my root partition has about 14GB of used space, and it'll be a long, comfortable time before I fill that space.
 
OP
N

Nourr

New Member
Joined
Jun 17, 2022
Messages
6
Reaction score
3
Credits
42
Quite so, but not everyone has the configuration and capacity to support that.

The choice by the OP to choose 30 GB in the first place suggests perhaps a reference to an internet article in the first instance, accompanied by a possibility of sharing a drive with Windows, and/or having sizable data partitions already committed to other purposes.

Is that so, @Nourr ?

Wiz
Yah, that's correct.
I was sharing the drive between windows and ubuntu, after a while I decided to delete windows and that's why I want to allocate window's space to ubuntu.
 
OP
N

Nourr

New Member
Joined
Jun 17, 2022
Messages
6
Reaction score
3
Credits
42
Hi @Nourr, welcome to the forums!

Adding to what people here have said so far, most distros recommend a MINIMUM 20-25GB storage. That really isn't much, unless really all you do is browse the web and write some documents. If you plan to keep personal data, you'll want to plan more disk space, as appropriate.

Another thing to keep in mind is whether you use swap. Many modern mainline distros allow swap files, which are stored in your root partition, and can vary in size depending on your settings. You can also set up a separate swap partition (the more traditional approach) so it doesn't take space in your root partition.

Many of us split our /home partitions from our root (/) partitions. My root partition is 50GB, and my home is given the rest of the space. With all the software I have installed, my root partition has about 14GB of used space, and it'll be a long, comfortable time before I fill that space.
I did that exactly and I did split my root and home partitions, but the root directory is running out of space so I want to expand it.
 

SlowCoder

Gold Member
Gold Supporter
Joined
May 2, 2022
Messages
456
Reaction score
314
Credits
3,611
I did that exactly and I did split my root and home partitions, but the root directory is running out of space so I want to expand it.
It might be good to try to identify what filled your partition, if you desire. To do this, you could use the du command, but if you're able to download it, I recommend ncdu.
 

KGIII

Super Moderator
Staff member
Gold Supporter
Joined
Jul 23, 2020
Messages
6,697
Reaction score
5,853
Credits
53,911
To do this, you could use the du command, but if you're able to download it, I recommend ncdu.

This can also be done graphically, in a nice fancy GUI - which will likely be easier for a fairly new user to digest (is my thinking). There's this:

 
$100 Digital Ocean Credit
Get a free VM to test out Linux!

Linux.org Hosting Donations
Consider making a donation

Members online


Top