LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 01-28-2014, 06:24 AM   #1
geekslinux
Member
 
Registered: Jun 2013
Posts: 63

Rep: Reputation: Disabled
Reducing LVM partition size


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.
 
Old 01-28-2014, 06:37 AM   #2
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 3,340

Rep: Reputation: Disabled
Have you seen this document?
 
Old 01-28-2014, 07:37 AM   #3
geekslinux
Member
 
Registered: Jun 2013
Posts: 63

Original Poster
Rep: Reputation: Disabled
Hi when i execute the command
#umount /usr
umount: /usr : device is busy

how to proceed further.
 
Old 01-28-2014, 07:45 AM   #4
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Boot into single user mode. Exactly how to do that depends on which distro you are running.
 
Old 01-28-2014, 07:50 AM   #5
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 3,340

Rep: Reputation: Disabled
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.
 
Old 01-28-2014, 08:00 AM   #6
geekslinux
Member
 
Registered: Jun 2013
Posts: 63

Original Poster
Rep: Reputation: Disabled
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.

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
sshd 1060 root txt REG 253,7 526008 130683 /usr/sbin/sshd
sshd 1060 root mem REG 253,7 175288 261415 /usr/lib64/libnssutil3.so
sshd 1060 root mem REG 253,7 1284048 261715 /usr/lib64/libnss3.so
sshd 1060 root mem REG 253,7 1662832 261773 /usr/lib64/libcrypto.so.1 .0.0
master 1137 root txt REG 253,7 155976 51 /usr/libexec/postfix/mast er
master 1137 root mem REG 253,7 175288 261415 /usr/lib64/libnssutil3.so
master 1137 root mem REG 253,7 1284048 261715 /usr/lib64/libnss3.so
master 1137 root mem REG 253,7 181168 261718 /usr/lib64/libsmime3.so
master 1137 root mem REG 253,7 221568 261719 /usr/lib64/libssl3.so
master 1137 root mem REG 253,7 1662832 261773 /usr/lib64/libcrypto.so.1 .0.0
master 1137 root mem REG 253,7 372488 261775 /usr/lib64/libssl.so.1.0. 0
master 1137 root mem REG 253,7 106160 261453 /usr/lib64/libsasl2.so.2. 0.23
master 1137 root mem REG 253,7 1582952 261826 /usr/lib64/mysql/libmysql client.so.16.0.0
crond 1145 root txt REG 253,7 59832 130680 /usr/sbin/crond
crond 1145 root mem REG 253,7 99158576 654389 /usr/lib/locale/locale-ar chive
pickup 1150 postfix txt REG 253,7 234440 54 /usr/libexec/postfix/pick up
pickup 1150 postfix mem REG 253,7 175288 261415 /usr/lib64/libnssutil3.so
pickup 1150 postfix mem REG 253,7 1284048 261715 /usr/lib64/libnss3.so
pickup 1150 postfix mem REG 253,7 181168 261718 /usr/lib64/libsmime3.so
pickup 1150 postfix mem REG 253,7 221568 261719 /usr/lib64/libssl3.so
pickup 1150 postfix mem REG 253,7 1662832 261773 /usr/lib64/libcrypto.so.1 .0.0
pickup 1150 postfix mem REG 253,7 372488 261775 /usr/lib64/libssl.so.1.0. 0
pickup 1150 postfix mem REG 253,7 106160 261453 /usr/lib64/libsasl2.so.2. 0.23
pickup 1150 postfix mem REG 253,7 1582952 261826 /usr/lib64/mysql/libmysql client.so.16.0.0
qmgr 1151 postfix txt REG 253,7 308104 71 /usr/libexec/postfix/qmgr
qmgr 1151 postfix mem REG 253,7 175288 261415 /usr/lib64/libnssutil3.so
qmgr 1151 postfix mem REG 253,7 1284048 261715 /usr/lib64/libnss3.so
qmgr 1151 postfix mem REG 253,7 181168 261718 /usr/lib64/libsmime3.so
qmgr 1151 postfix mem REG 253,7 221568 261719 /usr/lib64/libssl3.so
qmgr 1151 postfix mem REG 253,7 1662832 261773 /usr/lib64/libcrypto.so.1 .0.0
qmgr 1151 postfix mem REG 253,7 372488 261775 /usr/lib64/libssl.so.1.0. 0
qmgr 1151 postfix mem REG 253,7 106160 261453 /usr/lib64/libsasl2.so.2. 0.23
qmgr 1151 postfix mem REG 253,7 1582952 261826 /usr/lib64/mysql/libmysql client.so.16.0.0
login 1160 root mem REG 253,7 38712 261641 /usr/lib64/libcrack.so.2. 8.1
bash 1174 root mem REG 253,7 99158576 654389 /usr/lib/locale/locale-ar chive
bash 1174 root mem REG 253,7 26060 261397 /usr/lib64/gconv/gconv-mo dules.cache
sshd 1188 root txt REG 253,7 526008 130683 /usr/sbin/sshd
sshd 1188 root mem REG 253,7 38712 261641 /usr/lib64/libcrack.so.2. 8.1
sshd 1188 root mem REG 253,7 175288 261415 /usr/lib64/libnssutil3.so
sshd 1188 root mem REG 253,7 1284048 261715 /usr/lib64/libnss3.so
sshd 1188 root mem REG 253,7 1662832 261773 /usr/lib64/libcrypto.so.1 .0.0
bash 1190 root mem REG 253,7 99158576 654389 /usr/lib/locale/locale-ar chive
bash 1190 root mem REG 253,7 26060 261397 /usr/lib64/gconv/gconv-mo dules.cache
lsof 1214 root txt REG 253,7 141048 130692 /usr/sbin/lsof
lsof 1214 root mem REG 253,7 99158576 654389 /usr/lib/locale/locale-ar chive
lsof 1214 root mem REG 253,7 26060 261397 /usr/lib64/gconv/gconv-mo dules.cache
lsof 1215 root txt REG 253,7 141048 130692 /usr/sbin/lsof
lsof 1215 root mem REG 253,7 99158576 654389 /usr/lib/locale/locale-ar chive

how to proceed from this. thanks in advance. My distro is centos 6.4. hardware is ibm x 3610 on RAID 1E.

Last edited by geekslinux; 01-28-2014 at 08:03 AM. Reason: to update
 
Old 01-28-2014, 01:14 PM   #7
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
Please post (in code tags) output from:
Code:
# df -h
Run that within your normal OS environment (i.e. not within a live CD). We need to know which device/partition you have mounted to /usr.

Armed with that information, the filesystem resize can be completed using a live CD that supports LVM2.

What live CD are you intending to use? (I recommend Knoppix, Fedora live, or SystemRescueCd.)

Last edited by anomie; 01-28-2014 at 01:16 PM.
 
Old 01-29-2014, 04:52 AM   #8
geekslinux
Member
 
Registered: Jun 2013
Posts: 63

Original Poster
Rep: Reputation: Disabled
PFB,

Output of df -h from live server

Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_intranet-LogVol00_root
6.9G 1.3G 5.3G 20% /
tmpfs 7.8G 0 7.8G 0% /dev/shm
/dev/sda1 485M 32M 428M 7% /boot
/dev/mapper/vg_intranet-LogVol09_data
40G 21G 20G 53% /data
/dev/mapper/vg_intranet-LogVol01_home
1000G 764G 237G 77% /home
/dev/mapper/vg_intranet-LogVol02_opt
1008M 39M 918M 5% /opt
/dev/mapper/vg_intranet-LogVol03_tmp
1008M 71M 887M 8% /tmp
/dev/mapper/vg_intranet-LogVol04_usr
330G 164G 150G 53% /usr
/dev/mapper/vg_intranet-LogVol05_usr_local
2.0G 359M 1.6G 19% /usr/local
/dev/mapper/vg_intranet-LogVol06_var
30G 11G 19G 37% /var
/dev/mapper/vg_intranet-LogVol07_var_log
20G 8.8G 12G 44% /var/log
/dev/mapper/vg_intranet-LogVol08_mail
350G 287G 64G 82% /var/spool/mail

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.
 
Old 01-29-2014, 08:00 AM   #9
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
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.
 
Old 01-29-2014, 10:49 PM   #10
geekslinux
Member
 
Registered: Jun 2013
Posts: 63

Original Poster
Rep: Reputation: Disabled
PFA screenshot of lsof output in single user mode for test server the same is the setup in live environment.
Attached Thumbnails
Click image for larger version

Name:	lsof.jpg
Views:	13
Size:	129.3 KB
ID:	14640   Click image for larger version

Name:	lsof1.jpg
Views:	18
Size:	143.0 KB
ID:	14641  
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Shrink disk partition after reducing LVM jklaverstijn Linux - Server 6 01-22-2011 03:08 PM
Reducing size in LVM SBN Linux - General 8 07-28-2009 06:30 AM
LVM: The Impact of Reducing a Logical Volume Size? muff Linux - General 0 07-27-2007 02:18 AM
Reducing the Linux LVM(8e) partition itself (not PV, VG or LV). ajitkth Linux - General 1 03-08-2005 03:45 AM
Reducing size of PV (partition) in LVM clacour Linux - General 2 10-24-2003 08:19 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 04:02 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration