View Single Post

   
  #3 (permalink)  
Old 02-20-2008, 05:43 PM
Sylvain Robitaille
 
Posts: n/a
Default Re: How do you recover from a hotplug disconnect without umount?

root (you wouldn't _really_ do things that don't require root privilege
as root, would you?) wrote:

> I was able to recover by restoring my complete /etc directory from
> backup, but there has to be a simpler way. I think it has to do with
> mtab, but just restoring that file isn't the trick.


See also /proc/mounts

I've never done what you're trying to recover from, so I'm not 100%
certain that you'll be able to do anything with that (virtual) file,
but it should give you the idea that you need to affect more than a
change to /etc/mtab.

> When you mount a device your system keeps information about
> the device in your file system.


Well, the system keeps a table of mounted file systems in the running
kernel. I'm quite certain that /etc/mtab exists primarily for the
convenience of the humans using the system. (and the umount command,
perhaps, though I'm surprised that doesn't just read /proc/mounts.)

> Upon umounting that device your system writes that information back
> to the device and releases the information from your system.


Almost: what it's writing to the disk at umount-time is any cached data
that were not yet written to the disk when the file system was in use.

> Without umounting that writeback doesn't occur and your file system
> is corrupted.


you're correct on this count. The more cached data that wasn't written,
the greater the file-system corruption. If the disk was mounted
read-only, for example, nothing will have changed on the filesystem
anyway, so there won't be any corruption, and you only need to convince
the system to unmount it. If the disk had synced before you prematurely
unplugged it, for example, it might also have very minimal file-system
corruption.

> What you have to do is reboot the system with a repair disk and run
> a file check on your file system.


You can fsck the file system without rebooting the system, but you need
to convince the system that the device that holds that filesystem isn't
already mounted. See the various options to umount for any that might
help (f?).

--
----------------------------------------------------------------------
Sylvain Robitaille syl@alcor.concordia.ca

Systems and Network analyst Concordia University
Instructional & Information Technology Montreal, Quebec, Canada
----------------------------------------------------------------------
Reply With Quote