Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I want to reduce the partition mounted at /tmp to 10GB and add all unused space to the / partition.

If I umount -l /tmp and run fsck.ext3 -f /dev/privg/lv_tmp, I get this:

fsck.ext3: Device or resource busy while trying to open /dev/privg/lv_tmp
Filesystem mounted or opened exclusively by another program?

What are the correct steps to do LVM repartitioning?

$ df -hl
Filesystem                 Size  Used Avail Use% Mounted on
/dev/mapper/privg-lv_root   12G  4.2G  6.9G  38% /
/dev/mapper/privg-lv_tmp    29G  3.2G   24G  12% /tmp
/dev/mapper/privg-lv_var   3.9G  1.5G  2.3G  40% /var
/dev/sda1                  494M   40M  429M   9% /boot
tmpfs                       16G     0   16G   0% /dev/shm
share|improve this question
    
Have you seen/tried this? –  sr_ Nov 2 '11 at 8:08
    
There's no win manager/admin tools installed. It's running on run level 3. OS is RHEL5. –  user11496 Nov 2 '11 at 9:04
add comment

2 Answers

You need to unmount the ext3 filesystem in order to shrink it. umount -l means that the filesystem will be unmounted when there is no more open file on it.

Run lsof /tmp to see what files are open on /tmp. If you're running an X server, you'll see its socket /tmp/.X11-unix/X0. You can't remove that socket¹ and still be able to connect to the X server. Other than that, most files tend to be short-lived or to belong to programs that can be restarted.

If you really want to perform the operation on a live system, you'll need to migrate to a different /tmp filesystem, at least for the duration of the operation. You could transition to tmpfs, in which /tmp is stored in RAM or swap; see this guide. In fact, tmpfs for /tmp is a common setup; you might want to stick to that and remove the /tmp partition altogether (and perhaps enlarge your swap a little instead).

Once you've been able to close everything from /tmp, you'll be able to unmount it. Don't use umount -l, it's useless here since it frees the mount point but not the device, whereas what you want is to free the device. Once /tmp is unmounted, run fsck, run resize2fs to shrink it, and shrink the LVM logical volume accordingly. Or you might in fact save time by directly shrinking the LVM volume and creating a new filesystem for /tmp. (If you have any data you want to keep in /tmp, you're doing it wrong. /tmp is for data that need not be saved between reboots, and closed files in /tmp are fair game for deletion.)

If all this seems daunting, reboot to a recovery system (live CD or USB) and operate from there.

¹ Nor can you move it to another filesystem: that would be removing the original and creating a new socket.

share|improve this answer
add comment

You can't unmount /tmp on a running system. You need to boot from a LiveCD or rescue CD and do it there.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.