1

I am trying to change /var/log directory to symbolic link. As /var/log exists, I tried as below.

# cd /var
# mv log log.bk                             (1)
# ln -snf /path/to/somewhere/var/log log    (2)

This way does not work well because a new /var/log directory is created between (1) and (2) ( I guess some system daemon creates it ), the symbolic link is created inside /var/log directory.

# ls -l /var/log
     :
lrwxrwxrwx 1 root root    23 Sep  2 13:27 log -> /path/to/somewhere/var/log
-rw-r----- 1 root adm  38028 Sep  2 13:51 messages
     :

My expecting is as below.

# ls -l /var
    :
lrwxrwxrwx 1 root root    23 Sep  2 13:27 log -> /path/to/somewhere/var/log
drwxr-xr-x 8 root root  1680 Sep  2 06:25 log.bk
    :

How can I do this?

1

self resolved.

I use mount --bind instead of symbolic link.

mount --bind /path/to/somewhare/var/log log
0

If you really want to do what you say what you want to do (instead of what you settled for),

  1. Try it as one command line: mv log log.bk && ln -snf /path/to/somewhere/var/log log.
  2. Try it in single-user mode.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.