Last night, fed up with seeing the root partition of my laptop (OpenSUSE on HP Pavillion dv4150us) nearly full at 93%, I decided to take some drastic action. I had ~18 GB on a couple left over partitions I'd created for installing secondary and test operating systems. I never got around to installing said systems (was gonna have another OpenSUSE install for testing upgrades, and an OpenSolaris install just for laughs), so killing those partitions (/secos and /testos respectively) was no big deal. Now the question was: what could I move off of the root partition, and more importantly, how could I do it safely.
Who Gets the Axe?
Well, technically, no one was getting the axe. But I did want to move the directory that was the biggest memory hog on the root partition OFF the root partition. Here's my partition setup after freeing the 18 GB mentioned above:
Device Mount Point FS Type /dev/hda2 / ext3 /dev/hda3 /data reiserfs devpts /dev/pts devpts /dev/cdrecorder /media/cdrw subfs /dev/dvdrecorder /media/dvdrecorder subfs proc /proc proc usbfs /proc/bus/usb usbfs /dev/hda5 /rescue ext3 (unused) /dev/hda1 swap swap /dev/hda6 /tmp reiserfs /dev/hda7 /var reiserfs
Now I needed to create a new partition, /dev/hda8, but before doing that, I needed the target directory so that I could determine the size. So being lazy, I went to the GNOME File Browser and simply displayed the properties of the main directories residing on the root partition. I also did a df from the bash command line, but this only gave me info for the partitions and not the directories themselves. Anyhow, here were the directories I had to choose from:
/etc /bin /opt /sbin /srv /usr
It was no contest. /usr blew the others away by a mile at ~5 GB in size. Knowing this, I decided to create a new reiser partition at 8 GB and mount it to a new directory called /usr2.
The Old Bait and Switch
So now that I had the new partition mounted:
/dev/hda8 /usr2 reiserfs
I needed to transfer the data from executing the following as root from the bash prompt:
/usr to /usr2. cp -ax /usr/* /usr2
took care of that. Needless to say, 5.0G took a bit to copy, so I watched the progress in another terminal using:
Just a nifty way to refresh the view of the partitions about every 2 seconds to track the change in the new partition's size. Probably slowed the progress of the copy itself, but I'm an impatient masochist who insists upon watching pots boil. When the copy from /usr to /usr2 finished I did a diff -qr between the two:
diff -qr /usr /usr2
Any vet will tell you (as I quickly found out) a diff on two huge directories takes a buttload of time. In hindsight, I would instead select a few key subdirectories to compare unless I've really got a buncha time to waste.
A few minor differences between the directories (a handful of missing files and differing attributes), but otherwise, a-okay. Okay enough for me to risk the next step.
DDRR: Delete, Dismount, Remount, Reboot
Here's where I really got scared. Could I now unmount the new partition, copy /usr to yet another backup (like the now empty /usr2 directory), delete the contents of /usr, and mount the new partition to /usr? I wasn't sure, but I gritted my teeth and went for it, and...
...well? Here's the deal. All of the above worked fine. It was the rebooting that was the catch. I restarted my system and almost immediately got a fatal error. X couldn't start. Files missing. However, fear not! A login prompt requesting my root password was provided so that I could try to fix the problem and reboot. Beat that, Windo$e!!! Anywho, I logged in, checked out my /etc/fstab file and immediately saw the prob:
/dev/hda8 /usr2 reiserfs ...
So the new partition was still mounting to /usr2, hence empty useless /usr directory hosing up the works. Simple fix in vi changed /usr2 to /usr. Reboot, and what the hell!?!? It actually worked!!!
Archimedes couldn't have been happier than I am. I'm now sittin' pretty with an extra 5 fat Gigs on my root partition, and /usr sitting in it's own 8 Gig partition. If I feel like it, I can even expand /usr to 10 Gig or more should the mood grab me. Yea!! I can start installing all kinds of Beta-ware again!!! The villagers rejoice, the kingdom is happy, and all is right with the world once more :-)
Upon Further Reflection...
Was this in fact the best way to go about this change? I really dunno. As you can tell from the story, I more or less winged it, and ultimately got lucky. If you are in a similar bind and see this as your only way out, I accept no responsibility for what may or may not happen. This would truly be an instance of the blind leading the blind. If there was a better way to have gone about the changes above, or at least some refinements you could recommend for the process I described, please leave them in the comments section. I thank you, and the hapless souls stumbling upon this site seeking guidence from my fumbling-stumbling-SysAdministrations thank you! Thanks and best of luck to all.