Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have extended /usr partition and the size is around 300GB. I have used around 140GB. Now am planning to reduce the size of the usr partition by 100GB as i require space for other partitions. Can anyone help me to fix this.
Unmounting /usr is only possible if none of the files in /usr in any of its subdirectories are in use. You can use lsof to find out which files are in use (lsof /usr should work since it's a mount point).
It probably isn't possible to close all files in /usr and be logged in at the same time, so you should probably just to boot to single user mode or use a live CD/DVD to shrink the file system.
I tried in single user mode it says the same device busy. I tried with rescue system it said the same after mounting chroot /mnt/sysimage.
wheni gave lsof /usr it shows the following output.
Also I found an unorthodox way of unmounting /usr.
My original data in /usr partition was around 30GB in live server and I tried the following in test server.
Created a new LVM with 80G space; put an entry in /etc/fstab and mounted it to the folder /forusr. I copied the all the files & folders from /usr to /forusr. I created a folder usr_old in the system.
After that in /etc/fstab i changed the mountpoint entry for /forusr to /usr and /usr to /usr_old and restarted the server.
Now the space can be freed after umount.
I want to know whether the method am doing is correct and will it work in live server.
The method you used is ingenious and would probably work. There is a small danger that you did not get a consistent set of files when you copied from /usr to /forusr. Some may have been being written at the time. Others may need to be relates -- such as a file of data and a file which is an index to that data; if you copied the data file and later copied the index file after the data file had been changed the pair would not be consistent.
As a variation on your method you could mount /usr read only ...
But the lsof output does not suggest the system was in true single user mode; at leas ssh, cron and postfix daemons were running. Which distro are you using and what did you do to get into single user mode? If that is as close to traditional single user mode as your distro gets you could try stopping and daemons/services that are running and re-checking with lsof.
Are both your test and live systems local or do you have to connect over a network?
I no longer see any advantage in having /usr as a separate file system from / but that's another story.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.