[CentOS-virt] Need to unmount an LV from host system

Wed Mar 6 15:54:27 UTC 2013
Jeff Boyce <jboyce at meridianenv.com>

  ----- Original Message ----- 
  From: SilverTip257 
  To: Discussion about the virtualization on CentOS 
  Cc: jboyce at meridianenv.com 
  Sent: Tuesday, March 05, 2013 4:21 PM
  Subject: Re: [CentOS-virt] Need to unmount an LV from host system

  On Tue, Mar 5, 2013 at 3:24 PM, <jboyce at meridianenv.com> wrote:

    Greetings -

    Ok, I made a mistake that I need to fix.  Fortunately it is not a
    destructive mistake, but I need some advice on how to correct the problem.

    CentOS 6.3 host system named Earth

    I was creating some new logical volumes within my exiting volume group for
    a new virtual machine using the LVM GUI.  When I created the LV that I
    plan to use for root partition of the new VM (Bacteria) I mistakenly
    clicked on the box to mount the LV, and specified the mount point as /.

  So you mounted that new LV as / (or over the existing root) on your host node?

  You may end up needing to boot to a rescue CD, mount, and rsync files from Bacteria's root to Earth's [real] root.  ( I wonder if anything is being written to Bacteria's root since it's mounted over the real root. )

    [root at earth ~]# df -h
    Filesystem            Size  Used Avail Use% Mounted on
                          5.0G  3.9G  880M  82% /
    tmpfs                 5.9G  276K  5.9G   1% /dev/shm
    /dev/sda1             485M  116M  344M  26% /boot
                          3.0G  748M  2.1G  27% /var
                          5.0G  3.9G  880M  82% /

    I tried to unmount the device, but as shown below, it is busy.

    [root at earth ~]# umount /dev/mapper/vg_mei-lv_bacteriaroot
    umount: /: device is busy.
            (In some cases useful info about processes that use
             the device is found by lsof(8) or fuser(1))

  I would have expected you could unmount it given that you're umounting by the device name.  Having it mounted on or over root likely makes this a bit finicky.

    I tried to force unmount the device, but that failed also.

    [root at earth ~]# umount -f /dev/mapper/vg_mei-lv_bacteriaroot
    umount2: Device or resource busy
    umount: /: device is busy.
            (In some cases useful info about processes that use
             the device is found by lsof(8) or fuser(1))
    umount2: Device or resource busy

    What other options are there.  Is there are way to get this unmounted
    without having to shutdown my host system and boot into rescue mode.  I
    don't really want to shutdown my active VM's while other staff are working
    on them right now.

  Take the advice of the output you pasted ... check the output from lsof and see if you can't narrow down the problem.

  After you accidentally mounted that LV on root did you change your directory?  Something is hanging on to that device.

    Please cc me directly as I only receive the daily digest.  Thanks.

    Meridian Environmental

    CentOS-virt mailing list
    CentOS-virt at centos.org

  //  SilverTip257  // 

  Thanks for the insight.  I had tried the advice from the output to use lsof and fuser, that is what led me to try the force unmount.  In the end I realized that the only way to unmount a / partition is to be off of it entirely, meaning you must be booted to a live rescue disk such as SystemRescue CD.  I ended up solving this by checking to make sure that /etc/fstab did not have an entry for the Bacteria LV, then shutting down the system and rebooting it late at night when there was no one on the system and no scheduled system activity.  A reboot brought everything back up normal, so I didn't even have to resort to using a Live CD.  Sorry for all the noise.

  Meridian Environmental
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.centos.org/pipermail/centos-virt/attachments/20130306/b32937ab/attachment-0004.html>