Unix administration - Deleting a hard link to a directory?

This is Interesting: Free IT Magazines  
Home > Archive > Unix administration > November 2007 > Deleting a hard link to a directory?





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Deleting a hard link to a directory?
Philip White

2007-11-23, 7:20 pm

Hi, all;

I don't know how, but a long time ago I made a hard link to a home
directory, like so:

$ ls -1i /
....
1224001 etc
2121601 home
2121601 hometest
767041 lib
....

Now I would really like to get rid of /hometest, but I have no idea how!
'rmdir' returns "rmdir: /hometest: Device or resource busy" (even though
'lsof' shows nothing as having any part of /hometest open), 'rm' tells me
that it's a directory, and 'rm -rf /homedir' is unacceptable for obvious
reasons.

Help!

--
PGP key: http://www.qnan.org/~pmw/pgp/public.asc
Barry Margolin

2007-11-23, 7:20 pm

In article <fi7a18$ccv$1@registered.motzarella.org>,
Philip White <pmw+news@qnan.org> wrote:

> Hi, all;
>
> I don't know how, but a long time ago I made a hard link to a home
> directory, like so:
>
> $ ls -1i /
> ...
> 1224001 etc
> 2121601 home
> 2121601 hometest
> 767041 lib
> ...
>
> Now I would really like to get rid of /hometest, but I have no idea how!
> 'rmdir' returns "rmdir: /hometest: Device or resource busy" (even though
> 'lsof' shows nothing as having any part of /hometest open), 'rm' tells me
> that it's a directory, and 'rm -rf /homedir' is unacceptable for obvious
> reasons.


Do you have an "unlink" command? This typically bypasses all the checks
and simply removes the link.

If not, try: PERL -e 'unlink "/hometest"'

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
Philip White

2007-11-23, 7:20 pm

On Fri, 23 Nov 2007 15:58:39 -0500, Barry Margolin wrote:
> Do you have an "unlink" command? This typically bypasses all the checks
> and simply removes the link.
>
> If not, try: PERL -e 'unlink "/hometest"'


I forgot to mention that I've tried that too. :/

# unlink hometest
unlink: cannot unlink `hometest': Is a directory

--
PGP key: http://www.qnan.org/~pmw/pgp/public.asc
Edward C. Otto III

2007-11-23, 7:20 pm

Philip White wrote:
> On Fri, 23 Nov 2007 15:58:39 -0500, Barry Margolin wrote:
>
> I forgot to mention that I've tried that too. :/
>
> # unlink hometest
> unlink: cannot unlink `hometest': Is a directory
>


Have you tried the following steps?

1) Take susyem down to console prompt;
2) umount /home
3) rm -rf /hometest

Ed
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com