On CentOS, moving space from large free directory to another

Hi. My "/usr" folder is running out of space. My "/home" folder is quite large and has a lot of free space. As follows:

Filesystem    Type    Size  Used Avail Use% Mounted on
...
/dev/sda5     ext3    9.7G  2.6G  6.7G  28% /
/dev/sda7     ext3    152G   16G  128G  11% /home
/dev/sda3     ext3    9.7G  9.3G     0 100% /usr
...
/usr/tmpDSK   ext3    2.0G  473M  1.5G  25% /tmp

I want to move some space from that /dev/sda7 ("/home") into the /usr folder.

What's a good way to do this? How do I ensure that the "free" part of the /home folder is given away to the /usr folder?

Thanks!

The best and easiest approach in my opinion, is to resize the partitions offline using a utility such as Gnome Partition Editor (GParted has a live CD/USB for download)

/usr should never have user files on it. I am guessing you have a process writing some big logfiles that has filled /usr. CentOS distros do not usually have 10G worth of software, although it is completely possible.

Regardless of adding space you need to see what is going on with /usr

find /usr -mtime -10 -size +10000 -ls

What you want is a really bad idea. You should fix /usr.

However:

  1. lets assume /usr/local has tons of extra software. Reboot into single user mode.
  2. As root, use mkdir to create a directory on the /home/ /home/usr/local
  3. use tar to move the files
cd /usr/local
tar cf - . | (cd /home/usr/local && tar xBf -)
  1. Be ABOSULUTELY positive this worked correctly.
cd /usr; rm -R /local;  ln -s local /home/usr/local

You really should either clean up junk on /usr, or add another disk or partition and move file over it the way I described. Using /home will be a mistake. NeutronScott gave you another way to play with partitions

Thanks, but two issues:

(1) This is a dedicated server, but it's in US. I am not. So I don't have physical access to the server to run a CD or something.

(2) This is a live production server, with some busy sites on it. (Which is why the problem to begin with..of a full /usr directory).

What else can I do? Thanks.

Jim, thanks for that. But I'd rather not do that linking type stuff. (What is "ln -x" anyway? The x switch? Or did you mean "ln -s"?)

ln -x is a typo - changed to ln -s. I still think you have user files the /usr filesystem.
Move them off if you can.

Hi.

For comparison, on a CentOS machine I use:

OS, ker|rel, machine: Linux, 2.6.32-220.el6.x86_64, x86_64
Distribution        : CentOS release 6.2 (Final)

using commands:

du -skh /usr/*|sort -rh

produces:

2.3G	/usr/share
913M	/usr/lib64
249M	/usr/bin
246M	/usr/lib
129M	/usr/include
59M	/usr/libexec
47M	/usr/src
23M	/usr/sbin
144K	/usr/local
4.0K	/usr/games
4.0K	/usr/etc
0	/usr/tmp

My include and lib64 might be a bit large because I have the boost libraries installed.

In looking at /usr/bin/* , after omitting script, dynamic, and symbolic lines, I find fewer than 20 items, out of more than 2000.

If you have directories that are in addition to these, or some that are far larger, that might be a starting point for jim's suggestion.

Best wishes ... cheers, drl

This is really a critical situation. What application does that server run? How big is your /usr/share ? Compared to other directories in /usr, moving /usr/share to another location and creating a symbolic link would be easier to avoid serious damage. You could curve out a little bit of space doing that while ensuring zero down time.

What version of CentOS are you using? I guess 5.x? For a permanent solution, I would go for LVM. But for that, you would have to spend a lot of time in single user mode to migrate the data and at the end things may not turn out as expected.

move /usr/share to some other location and link it to /usr/share ... use rsync for moving the files to another location