Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 12 Sep 2002 08:56:02 +0100
From:      Matthew Seaman <m.seaman@infracaninophile.co.uk>
To:        "Riley J. McIntire" <rileyjmc@pacbell.net>
Cc:        John Mills <john.m.mills@alum.mit.edu>, Beech Rintoul <akbeech@sinbad.net>, FreeBSD Questions <freebsd-questions@FreeBSD.ORG>
Subject:   Re: Can't delete a directory
Message-ID:  <20020912075602.GA29787@happy-idiot-talk.infracaninophi>
In-Reply-To: <HEEELMCBPANKADCOBOFPGECLGFAA.rileyjmc@pacbell.net>
References:  <Pine.LNX.4.21.0209112153450.3060-100000@otter.mills-atl.com> <HEEELMCBPANKADCOBOFPGECLGFAA.rileyjmc@pacbell.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Sep 11, 2002 at 08:39:01PM -0700, Riley J. McIntire wrote:
> > How about:
> >   [ ]$ rm -rf <root_of_destruction> 
> >  - John Mills
> > 
> 
> root@wimp:obj# rm -rf usr/
> rm: usr/fsck_msdosfs: Directory not empty
> rm: usr/: Directory not empty
> root@wimp:obj#

If you've exhausted all other avenues then there is an extreme but
dangerous action you could take to get rid of your rogue directory.
You should understand that this procedure will deliberately corrupt
part of your filesystem and relies then on running fsck(8) to sort the
whole mess out.

First, make a note of the device your /usr filesystem resides on, and
of the inode number of the rogue directory:

    df /usr | sed -e 1d -e 's/  .*$//'
    ls -id /usr/obj/usr/fsck_msdosfs | sed -e 's/ .*$//'

Also, take a backup of your system before you do anything else. Now,
reboot the system and bring it up into single user mode, exactly as
you would for doing a 'make installworld'.  At this point it's worth
trying one last time to get rid of the directory by ordinary means:

    fsck -f %device%                    (ie. the device you noted above)
    mount -o rw -u /                    (having / read-write makes mount a
                                         lot friendlier...)
    mount /usr
    cd /usr/obj/usr
    rm -rf fsck_msdosfs

If that set of commands didn't succeed in getting rid of the
directory, then it's time to get nasty with the file system.  (If, on
the other hand, it did work then breath a huge sigh of relief and just
reboot and ignore the rest of this.)

    umount /usr
    clri %device% %inode%
    fsck -f %device% -y                (fingers crossed...)

This final fsck will come up with and hopefully fix a bunch of errors
you've deliberately introduced with clri(8).  However, the directory
will definitely be destroyed.

As ever, make sure you have good backups.  This procedure involves a
significant risk of trashing your system.  Did I mention that you need
good backups?

	Cheers,

	Matthew

-- 
Dr Matthew J Seaman MA, D.Phil.                       26 The Paddocks
                                                      Savill Way
                                                      Marlow
Tel: +44 1628 476614                                  Bucks., SL7 1TH UK

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020912075602.GA29787>