Skip to content

I've run out of space on my root directory, and I'm unable to resize root partition (sdb3). How would I fix this?

Not downloaded yet
134 points65 comments
Open on Reddit
About this post
Posted
Archived
Score
134 · 100% up
Kind
Image
ID
ecsdp3

Author

8
posts
34
comments
2
media
View profile

67 comments

clean your pacman cache of old/stale packages: https://wiki.archlinux.org/index.php/Pacman#Cleaning_the_package_cache ; maybe that helps as a first step

45 points

clean old logfiles too that wouldn't be of use to you

16 points

I just checked my cache directory and that wouldn't free up enough space. Also my terminal told me "Error: target not found: paccache"

Edit: nevermind I just installed pacman-contrib

When I used paccache it said "no canditate packagees found for purging."

5 points

sudo ncdu -x / to check where the space gets occupied the most.

2 points

flash a gparted live disk or any other distro which comes with it into a flash drive and boot from it.

open gparted, right click the disk sda4 and choose resize.

then free up some space by entering the desired numbers to the "free space preceding" option.

it should create unallocated space in between the sda3 (your root) and sda4 which you can then use to expand your sda3 partition

24 points

I've always stuck with the most recent live version directly from GParted's site over some random old/pached-up version from various distros. This primarily stems from paranoia as most file systems have stable on-disk structures at this point. These operations can take a long time but often are still preferable to restoring from backups (i.e. over a network link). I really don't want to spend hours on something that doesn't work, leaving me with another multi-hour recovery process.

I'd like to say there's a valid reason for insisting on the newest vanilla version but, if I'm being honest, it's mostly paranoia. Something, something, Ley lines.

I honestly don't know why I'm sharing this ha ha.

11 points

The partition you want to grow must immediately precede the free space, if you want to grow sda3, you have to either make space on the left of it (by removing your swap) and then move the partition to the left + grow it to 16G, or make space on the right by moving sdb4 further to the right and then growing sdb3.

The time it takes to move partitions around scales linearly with their size, but depending on the filesystem used, gparted might be able to do some smart shuffling around to avoid copying gigabytes of empty space. Worst case scenario, without more info, you will have to read & write back 900G of data, which is gonna keep your system busy for a few hours.

17 points

Do you know why this is? Non sequential storage shouldn't be that hard to implement.

In my mind it would only be pointers saying: this block of storage ends at position x, continues at position y and finally ends at position z.

Forgive my ignorance if this is a really stupid question.

4 points

Not a stupid question, this is possible using LVM, you can add multiple physical volumes to a pool, and assign logical volumes from the total available space of the pool. Then you can later add more physical volumes and extend the logical volumes at will. You just have to plan for this from the start.

8 points

Like the other reply said, this is the use case for LVM. You can make logical volumes that can span multiple disks/partitions and are seen by the OS as a single volume. It also supports dynamic resizing (dependent on the filesystem).

The issue here is that when you create a partition, it segments the disk from block x to y on the physical disk. A file system is then created that labels those sectors. The file system needs sequential sectors in order to work properly. It has no concept of other partitions or disks and doesn't really need to.

LVM provides an abstraction layer between the physical drive and the file system so you can provide a logical (virtual) sequential disk to the file system regardless of the source of the space.

The solution to this problem exists and is well-documented. It is just not employed in this example.

3 points

I think if you are using an HDD, if a file starts before position x but ends after position y, and if it is a frequently accessed file, it might shorten the life of the HDD because the head contantly needs to move more than it should be. I don't think this is the exact reason but it would also be a side effect.

1 points

You ever had to defrag your disks? It's because your OS does this, 'x ends at y, continues at z' and over time takes up a significant amount of space keeping track of x, y, and z.

Someone already hit LVMs, so I'll leave it at that.

1 points

Do you know why this is?

LBA. There are ways around it but they all have limitations.

1 points

Generally, you can only resize/enlarge/extend a partition into free space that is adjacent to it, which is why you are unable to despite having free space.

There are a few options you have, but without being able to simply expand your root partition, they'll probably all involve a bit of trickery. What I'd probably do is create a new partition with the free space, then shutdown, boot to a LiveUSB, rsync one of the larger directories to it, (i.e. /var ) preserving ownership and permissions, remove that dir from the full partition (sdb3), and then adjust my /etc/fstab file to mount that dir from the new partition.

6 points

I am a noob too, but have a similar issue, I was reading that the swap partition is not necessary in Arch and can be emulated from a file.

Could it be possible to remove the swap partition SDB2, resize the root partition (SDB3) adding the now free swap space and then set the swap on a file?

thank you

5 points

If you want to expand the filesystem, you could move sdb4 down to make space, then expand the partition from a liveusb.

But frankly, I'd just switch to btrfs, which lets you use noncontiguous partitions for a single volume, and also compresses data (which has performance benefits as well since mass storage is generally much slower than CPU). You can even convert ext3/4 partitions to btrfs without affecting the data on them.

3 points

I'd boot from a live boot USB stick (preferably one with a gui) and do the following:

  • run gparted (if you have a graphical interface, or something like fdisk otherwise, but gparted is definitely easiest)
  • find the end of the data segment in your /home partition and shrink your /home partition to only include up to the end of said data segment
  • create a new partition from the new free space (to the right of the /home partition)
  • carefully migrate the data from the shrunk segment to the new partition (make sure all permissions are intact, /etc/fstab is updated, etc.)
  • resize root partition by incorporating previous /home partition

I'd only recommend doing this if you're comfortable with these procedures. Otherwise, you risk losing precious data, or even worse, IMMINENT DEATH (of your lost data). Hope this helps!

Edit: whenever modifying partitions, always backup EVERYTHING!

3 points

Next time set up LVM then you can just add another disk to the volume group and then extend the volume.

3 points

You don't need a swap partition, you can use a swap file (which can exist somewhere else of your choosing) instead. Kill your swap partition and give the 4gb to sdb3

3 points

I assume that /dev/sdb3 is your /home fs?

A "simple" fix without having to move a gajillion bytes around would be to move everything on the currnet /home into a /home directory and copy your old / to the current /home.

2 points

Ran into this last night as well, I don’t use the system much but try to keep up-to-date. I gave my root 32GB of storage in 2012. I really don’t know what I have installed that would take up so much space so I’m going back and removing programs I installed to test out and never removed.

I also think a nice chunk of this might be docker images too.

2 points

Need to keep track of root usage and run paccache periodically.

# paccache -rk1 keeps one past copy of installed packages

# paccache -ruk0 gets rid of all uninstalled packages

You will free up lots of space

5 points

Oh yeah, I do that regularly... via a systemd package.

I think for me the best course of action would be a reinstall. I learned a lot between the original install and today. I would do many things different in how I would design the system...

1 points

I am fearing similar thing might happen to me, I have like 5gb root space left, can I redirect all pacman and packer install to home folder?

2 points

Yes, with a bind mount. I used to do it since my root was a 24G drive so pacman cache and Docker overlays were wasting too much of it.

3 points

Just a tip for the future: next time you install use LVM instead of creating phisical partitions. That way resizing a partition is trivial!

In that situation the only thing that you can do is shrink sdb4 and grow sdb3, you of course need to do that from a live CD and depending on how much data there is on sdb4 will take a lot of time since the whole partition needs to be shifted to the right.

2 points

If you wan't to see what is taking up a lot of space, you can use something like

du -xhd 4 / | sort -h

The options mean

  • -x: Only show contents of the current filesystem.
  • -h: Size as human readable output (GB etc.)
  • -d n: Show output upto a depth of n subdirectories.

The sort part then sorts this (-h treats the numbers as human readable size). If you want you can also reverse the order with -r or pipe it into less to make the output scrollable.

2 points

I literallyJUST did this a couple days ago:

  1. Boot into liveUSB
  2. Make a new partition (on a new drive if you have to)
  3. Copy contents of sdb3 to the new partition (check for errors!)
  4. Mount the partition to FS & chroot into it
  5. Update /etc/fstab & grub

You can find detailed instructions for each step online. Good luck!

2 points

That's incredibly disproportionate. Only 16G (4, 12) for those first two partitions, but a whopping 900 for the last one? Hnng.

An "Instant" solution I can think of would be moving everything of the 900G one (Assuming it's /home) into a new /home on itself, then rsyncing everything from the others into the 900G one pretending it's your new root (/).

Then update your fstab and any other mount related stuff and use that, cull the other two, and one day with free time.. grow it out.

2 points

If that 900G partition is your home partition, I'd merge it with your root partitions. There isn't much point in keeping /home/ on a separate partition unless you specifically need it and know how to deal with the limitations that puts on you; one of which you just experienced first hand.

In your case I'd boot the ArchISO, mount the home partition somewhere (e.g. /mnt/home/), create a home directory in it, move everything from that partition's filesystem's root into that directory, mount the root fs in another place (e.g. /mnt/root/), copy its content to the second partition (so that /mnt/root/usr/ is copied to /mnt/home/usr/ etc.), arch-chroot in, remove the root partition from fstab, change the home partition to be the root partition in fstab, remake initcpio, reconfigure the bootloader, reboot and now your system should be just as before but with root (and home) on the 900G partition.

Next time you reinstall or restore from backup, use a merged root+home from the beginning and/or use a volume manager (LVM, BTRFS' and/or ZFS').

2 points

If you have the Arch bootable medium or a Gparted live iso you should be able to fix this

1 points

You could convert the ext FS to btrfs and then combine it with a new partition in raid0. It's a bit hacky, but it's faster than moving the partition and works well.

From a live CD:

https://btrfs.wiki.kernel.org/index.php/Conversion_from_Ext3

https://btrfs.wiki.kernel.org/index.php/Using_Btrfs_with_Multiple_Devices

(which is basically just 'btrfs add /dev/sda5 /mnt' and 'btrfs balance start -dconvert=raid0 /mnt')

You could even do the balance afterwards when it is already mounted and you're using your PC.

On my new install, I created a big btrfs with subvolumes for / and /home so I can make snapshots of only / .

1 points

I know this doesn't help right now but in the future, put everything except boot/efi in an LVM and create logical volumes for all the partitions you want. Then you can resize and move them any time you want without any hassle.

1 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.