Moving Disk Space in Linux
Hi,
I have the /usr and /var directories almost full, but the root directory / is only 34% full. What is the best way to move the extra space in the root / directory for /usr and /home directories? Alf |
Are those directories on separate partitions? If so, you can't really "move" empty space to another partition; you can resize partitions using programs like parted, but that can be somewhat dangerous, since data may get lost.
One easier solution (or hack) I can think of right now is to find some part of /usr or /var that is especially full, and move it to another directory mounted on the root / partition, and then use a symbolic link to it. For example, if /usr/local is pretty big, you could do this (as root): mkdir /usrlocal cp -R /usr/local/* /usrlocal (if everything copied okay, then...) rm -rf /usr/local ln -s /usrlocal /usr/local Then "/usr/local" will actually be a symbolic link to "/usrlocal", which is located on the root partition, and the /usr partition will have more free space. |
You also might want to look into the use of LVM (logical volume manager), which is included e.g. in the SuSE distributions (>= 8.1 at least).
Hint: please use the user profile facility of this site, it is easier to answer when one knows with what distribution etc. you do work. |
/usr is mounted on a partition under / in a folder called usr
All you need to do is unmount /usr and remount it somewhere else, then move all of the files in the new mount to /usr if it fits. Then edit the /etc/fstab file to remove /usr Code:
remove the /usr line from /etc/fstab check that all is ok. Then you can umount /usrtmp and rm /usrtmp and do what you want with the partition. |
Try as I might, I fail to understand your reasoning. Why don't you simply copy/move the files from the /usr partition to the /usr directory under / (or tar them, if that retains the symlinks correctly -- as an aside, tar works recursively, I presume)? :confused:
|
Right, that's what it's doing, moving the files to /usr. No big deal.
You just need to remount the partition off of the /usr folder first because cp /usr /usr will not work well. There are a number of ways to do the same thing as long as the files get put in the /usr folder. This will free the old /usr partition where it can be used for something else. Since /usr will not fit without consuming it maybe something else can go there, or it could be combined with the /home partition if it's adjacent and there is enough room somewhere to get it all moved over so the new partition can be created. The other post is doing the same thing, however to put the files in /usr not a linked folder you would need to move them twice. By remounting you can put them where they go by moving once. |
I see. Thank you. :)
|
All times are GMT -5. The time now is 10:31 AM. |