Solution for 'how to remove a hard link on Sun BSD 4.2'

Jon Chang jonc at amdahl.uts.amdahl.com
Sun Jul 1 04:17:05 AEST 1990


This mail bounced in reply to a cry for help, so I hope Randy will see it
here.  This info may also be helpful to others.  If any Sun gurus out
there spot an error in this procedure, please point it out, or better yet,
give a documentation reference! 

| To:  randy at ai.dee.nrc.ca
| Subject: How to remove a hard link

I'll fell into this trap a few weeks ago and with many helpful suggestions
from fellow netters, I was able to fix it.  A hard link was created using:

	ln -f dir1 dir2

The exact steps I used to remove the hard link from a Sun 4.2 BSD system
were:

0. **** Back up the file system before anything else *****
1. Log in as root.
2. Identify the inode of the linked directory using:

        ls -i bad_dir_name

3. Bring the system down to init state  1:

        init 1

4. Unmount the file system:

        umount /usr

5. Clear the inode using:

        clri /usr 12345   <- substitute inode value from step #2

6. Run 'fsck' on the file system. You should see the inode number you just
   cleared.  Answer 'y' to tell fsck to actually remove it.

        fsck /usr

7. Mount the file system and bring the system back up to init state 3.

This is a hell of a fix for a dumb mistake, but all replies I got
suggested this procedure and it worked for me.  Proceed at your own risk.
Of course, you can also just leave the pesky link alone and rename the
directory to something exotic so you can ignore it.



More information about the Comp.sys.sun mailing list