unlink a directory

Polytropon freebsd at edvax.de
Thu Nov 28 10:19:22 UTC 2013


On Thu, 28 Nov 2013 04:04:47 -0500 (EST), Darrel wrote:
> I can not recall how to unlink a directory.  Installed a FreeBSD10 system 
> from memory and when making the kernel link went to /root/kernels and 
> linked rather than /usr/src/sys/amd64.
> 
> Now I have this:
> 
> (120) @ 4:01:40> ls -L conf
> conf
> (121) @ 4:01:43> ls -P conf
> conf
> (122) @ 4:01:56> ll conf
> lrwxr-xr-x  1 root  wheel    24B Nov 24 22:57 conf@ -> 
> /usr/src/sys/amd64/conf/
> (123) @ 4:02:09> pwd
> /usr/src/sys/amd64
> (124) @ 4:04:22> cd conf
> conf: Too many levels of symbolic links.

If I understand this correctly, you have:

	/usr/src/sys/amd64/conf -> /usr/src/sys/amd64/conf/

So

	/usr/src/sys/amd64> cd conf

will result in an attempt to cd to

	/usr/src/sys/amd64/(conf=/usr/src/sys/amd64/)(conf=/usr/src/sys/amd64/)...

This obviously looks wrong. :-)



Probably you should try to remove the conf@ symlink (note:
just a symbolic link, not a "real" directory!) by invoking

	/usr/src/sys/amd64> rm conf

or

	/usr/src/sys/amd64> unlink conf

With "man unlink" you'll see that the rm and unlink commands
can easily remove a symbolik link. :-)



If this _fails_, you can try the following, which is a little bit
dangerous and you should know what you're doing: Use a live system
or single user mode (/usr partition _not_ mounted), and call

	# fdsb <device>

Then in this program, navigate to /usr/src/sys/amd64 (or to
/src/sys/amd64 if /usr is on its own parition), for example by

	cd /src/sys/amd64

and then use the

	del conf

command. When the change has been writte to the file system,
perform a file system check

	# fsck <device>

Then you should be able to mount it again.

Note again: This is an extremely dirty method! See "man fsdb"
for details.

But I assume you won't have to do this.




-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...


More information about the freebsd-questions mailing list