delfinnium: (Default)
Drel ([personal profile] delfinnium) wrote in [community profile] linux4all2012-02-10 11:07 am

root directory being filled?

Hi all

I've had a clean reinstall of my linux mint and everything is good... until just today a thing popped up to say that my root is full.

D: I had given it 4GB when I reinstalled linux mint, leaving everything to my home drive. Now what I read is that root IS required in larger volumes.

So what can I do? I have plenty of space in /home, and I don't particularly want to reinstall everything. Where is the files where I can delete/clear my cache? How do I go about doing it?

(In nice easy steps because I can't actually find this .tmp or .var folders that other websites say I must look in.)
blnchflr: Remus/Ghost!Sirius (Ubuntu)

[personal profile] blnchflr 2012-02-10 05:26 am (UTC)(link)
Without knowing a whole lot, deleting .tmp files sounds … temporary - I don't think you'll get much day-to-day use out of the system without a re-install. But if you don't want to move your home partition, create a large enough partition at the end of it, and reinstall / there?
kerravonsen: 9th Doctor wearing his headlamp: Technical wizard (technical-wiz)

[personal profile] kerravonsen 2012-02-10 08:17 am (UTC)(link)
Okay, if your root is full, then you certainly have problems, and they aren't trivial. No, I don't want to scare you, but you do need to be very careful, or you will have to reinstall everything from scratch.

In nice easy steps because I can't actually find this .tmp or .var folders that other websites say I must look in.

Possibly because you should be looking for "/tmp" and "/var"?

Deleting files from those directories is only a temporary short-term solution. For a long-term solution, you really really need to have a larger root partition.

If you've managed to find files to delete in /tmp and /var, fine. (And, no, I'm not going to give you detailed, step-by-step instructions for that, because I don't know what desktop environment you're using, I don't know if you even know how to use the command line, and it would be much quicker and more useful for you to Read The Fine Manual).

The second short-term thing you can do is remove packages which are taking up a lot of space. To find out that, you need the "dpigs" command.

apt-get install debian-goodies

A common one that takes up a lot of space is OpenOffice.org/LibreOffice.
Note that removing this is only temporary, you can re-install it after you've fixed the main problem. It's just that getting rid of large packages will give you a bit of breathing room.

But the only long-term solution to your problem apart from reinstalling from scratch, is to re-partition your drive. Whichever one you choose to do, you must do one thing first:

BACK UP YOUR DATA! RIGHT NOW! I MEAN IT!

Doesn't matter how you do it, whether you burn it to a DVD or copy it to a flash drive or email it to yourself, back up all your personal data NOW.

Ahem.

To re-partition your disks without wiping them, you will need
1. a Linux system on a live-CD that you can boot from
2. that Linux system must have the "gparted" program on it.

I don't know if the Linux Mint install disks have gparted on them, so you will have to look. Shut down your system, put the CD in the drive, and boot. Hopefully the Linux Mint install disks give you an option of trying out Linux Mint from the CD rather than just installing it. If it doesn't, don't worry, I just thought it would save you time since presumably you already have a Linux Mint install disk. If it does allow you to run Mint from the CD, then do so, and look around in the menu for "gparted" - it will probably be in the "System" menu.

Start up gparted.
It will show you your disks, and the partitions on them. Presumably you want to re-partition the first hard drive, which is likely to be called "/dev/sda".
Now, be very, very careful.
The first thing that you want to do is shrink the size of your /home partition.
This can be done with the "Resize/Move" command.
Click on the /home partition. Click on the "Resize/Move" button. A window will pop up. Adjust the slider to reduce the size of the partition. Make sure that you do it in the direction that will free up space NEXT TO the root partition. That is, if the root partition comes first on the disk, and then the /home partition, then you need to remove space from the FRONT of the /home partition. If it's the other way around, you need to remove space from the BACK.
Click on "Apply". Hold your breath and pray there isn't a power failure.
Wait. If it succeeds, you haven't lost your data. Yay! If it fails, you'll have to reinstall from scratch.
Now there should be free space next to the root partition.
Click on the root partition.
Click on the Resize/Move button. A window will pop up. Adjust the size of the root partition so that it takes up all the space that you've freed up.
Click on "Apply". This should resize the root partition so that it is bigger!
Wait. If it comes back with no errors, hooray, you have succeeded! Now you have a bigger root partion!

Now, if Linux Mint doesn't have a run-from-CD option and/or it doesn't have gparted on the install CD, never fear. There are other live-CDs that do. The one I highly recommend is "System Rescue CD".
http://www.sysresccd.org/

I suggest you go and get a copy of it anyway; it will come in handy on other occasions.
kerravonsen: Eighth Doctor's legs sticking out from underneath TARDIS console: "tea, tools, Tinkering" (tinkering)

[personal profile] kerravonsen 2012-02-10 09:55 am (UTC)(link)
I think I had found a disk partitioning tool somewhere but that it only affected my non-linux OS partitions, not the linux partitions itself.

That's because you can't change a partition that you're actually using at the time! I assume that you were running linux, yes? That means that the operating system and the programs that were running, including the disk partitioning tool itself, were using the disk!

That's why one needs to run from the live-CD in order to re-partition the disk(s) on which your original Linux system is installed, because if one is running from CD, one isn't running from disk.

Are all my programs installed on root, is that why it is filled up?

Yep. If you have two partitions, root and /home, then everything that isn't on /home is on root. And the only things that are put in /home are your personal files and configurations. Which isn't a lot, unless you've got a massive music collection or something.

My rule of thumb for partitions:
* swap partition: somewhere between the same size as memory, or twice the size of the memory.
* boot partition: sometimes I have a separate partition for /boot, sometimes I don't. If I do, it's small, but not too small. About 1G is plenty.
* divide the remaining space in half, and give half to the root partition and half to the /home (or in my case, /files) partition. That way, I don't have to think a lot about how big to make them. Disks are so big nowadays it doesn't really matter if one doesn't have a /home partition that's taking up most of the disk. And it's much worse to run out of room on the root partition than it is to run out of space on /home, since it's much easier to move your personal files elsewhere.

I'd encourage you to give the re-partitioning a go, because if you're resigned to re-installing, then it won't matter if the re-partitioning doesn't work, but if it does work, then (a) you won't have to re-install (b) you won't have lost your settings and (c) you will have gotten some Valuable Experience!
kerravonsen: Buffy and the Tenth Doctor in front of the TARDIS: "World Savers" (world-savers)

[personal profile] kerravonsen 2012-02-11 06:34 am (UTC)(link)
Glad I could help.
doldonius: (Default)

[personal profile] doldonius 2012-02-11 06:06 pm (UTC)(link)
Another partitioning strategy.

Swap: you don't really need a separate partition for swap since, IIRC, Linux 2.2. A swap partition used to be faster than a swap file, but it isn't any more. And if it's desktop we're talking about, you'd want to keep your swap as empty as at all possible. If your system keeps using more than, say, 20Kb of swap (as shown by free), add more RAM if at all possible. Normally, a 512Mb swap file is an overkill. (Just in case, creating a swap file is as simple as dd if=/dev/zero of=/.swapfile bs=1M count=512 && mkswap /.swapfile && swapon /.swapfile && echo '/.swapfile none swap sw 0 0' >> /etc/fstab.) If your system can't handle more RAM, and this swap file turns out to be insufficient, just add another swap file. Preferably, on a different drive. Of course, you can still create a giant swap partition, just to be on the safe side. But you don't have to.

Boot: a 128Mb partition with an ext2 filesystem should be enough. Actually, mine's 124Mb and only 20% used.

Root: 10 to 20Gb if you keep your /var elsewhere. Unless, of course, you want to install each and every Debian package. If it's not the case, some 30Gb should be enough even with /var on the same partition.

The rest of the disk: /home.

Also, remember that in Unix-like systems, links work. If, e. g., you're using MySQL and your /var/lib/mysql grows too large, you can always move it to a less used partition and replace it with a soft link to the new location. Just shut MySQL down while you're at that. It'll never ever know you've fooled it. (Again just in case, it's done like that: /etc/init.d/mysql stop && cd /var/lib && mv mysql /home/ && ln -s /home/mysql && /etc/init.d/mysql start.) That said, a separate /var is usually a good idea if you have more than one HDD.
kerravonsen: (fractal)

[personal profile] kerravonsen 2012-02-11 11:42 pm (UTC)(link)
Swap: you don't really need a separate partition for swap since, IIRC, Linux 2.2.

Just shows how old I am.

Boot: a 128Mb partition with an ext2 filesystem should be enough. Actually, mine's 124Mb and only 20% used.

It depends on which distro you're using... some distro policies are to have multiple kernels available, and ever since the time I ran out of space on /boot when I was trying to do a dist-upgrade from one version of Ubuntu to another, I've been a bit more generous than that.

Also, remember that in Unix-like systems, links work.

One notable exception: if you're running an Apache server and using suexec, it does check if you're doing soft links for /var/www and suexec spits the dummy. As it should, since that's a security vulnerability.

That said, a separate /var is usually a good idea if you have more than one HDD.

Though having more than one HDD, with disks the size they are nowadays, isn't something that common unless one built one's system oneself.
doldonius: (Default)

[personal profile] doldonius 2012-02-12 05:50 am (UTC)(link)
Swap file improvements never created big flame wars. Guess that's why the fact remains generally unknown. Also, everything said may be wrong if using hibernation.

It depends on which distro you're using...

Indeed. The strategy above is aimed at a Debian desktop. Should've mentioned it.

running an Apache server and using suexec

Now, that's a bit tricky. But generally, you only need to keep the cgi-bin subdirectory in the right place and with the right rights. So on my server users' document roots are in their ~/public_html, and their cgi-bin subdirs are created in /var/www and symlinked from ~/public_html.

Nobody uses cgi-bin these days, though. It's all PHP and 'Help, my site's got pwned again.'

Some FTP servers won't let remote users to follow symlinks and even mounts, either. Well, it's security vs usability, as always.

having more than one HDD, with disks the size they are nowadays, isn't something that common

Most hardware sellers here in Siberia let you customise your system right at the counter. Some even don't void the warranty on preinstalled components if you modify it later. Never imagined this could be a problem elsewhere.

Still, having multiple disks is generally a good idea. At least until the blessed times to come when home users will have an affordable backup solution once again.