var directory deleted

Discussion in 'macOS' started by andreshermoso, May 7, 2010.

  1. andreshermoso macrumors newbie

    Joined:
    May 7, 2010
    #1
    I need help recovering the /var directory that I have accidentally deleted. Please help.
     
  2. spinnerlys Guest

    spinnerlys

    Joined:
    Sep 7, 2008
    Location:
    forlod bygningen
    #2
    The var folder in Macintosh HD / private / var?

    Do you still have your install DVD? Maybe you can use that, and if you have Mac OS X 10.6, a re-install is quite easy.
    But to make matters more interesting, what Mac OS X do you have?
     
  3. Hal Itosis macrumors 6502a

    Hal Itosis

    Joined:
    Feb 20, 2010
    #3
    On the off-chance you merely deleted Apple's symlink, here's how a repair might go:

    sudo ln -sfh private/var /var

    If you're doing that from single-user mode, skip the sudo but run mount -uw / first.
    Actually deleting that "/private/var/" directory would take some doing (by a superuser).
     
  4. andreshermoso thread starter macrumors newbie

    Joined:
    May 7, 2010
    #4
    Thanks for the quick reply.
    It will be the /var folder right at / (root) folder. I've thought /private/var was somehow a symlink but I proved wrong. I have a MacBook Pro 15" (2006) Intel Core Duo A1150 running OS X 10.4.11
     
  5. andreshermoso thread starter macrumors newbie

    Joined:
    May 7, 2010
    #5
    Thanks for the quick reply, I bet it would.
    It will be the /var folder right at / (root) folder.
    I need to make sure /var is actually a symlink to /private/var
    Do you know that for sure? I'm doubting it, and need help ...
    As you will see it seems to me that the system created /var when I entered the Taget Disk Mode. Browsing /private/var everything seems to be there, so I think I can breath again ....

    I have a MacBook Pro 15" (2006) Intel Core Duo A1150 running OS X 10.4.11
    I have a mac mini host running 10.4.11 and the MacBook Pro as a Target Disk both FireWire linked. I'm browsing the MBP disk and this is what I see:

    MINI-1:/ administrator$ mount
    /dev/disk0s3 on / (local, journaled)
    devfs on /dev (local)
    fdesc on /dev (union)
    <volfs> on /.vol
    automount -nsl [180] on /Network (automounted)
    automount -fstab [184] on /automount/Servers (automounted)
    automount -static [184] on /automount/static (automounted)
    /dev/disk1s1 on /Volumes/NO NAME (local, nodev, nosuid)
    /dev/disk3s2 on /Volumes/Macintosh-HD (local, nodev, nosuid, journaled)
    MINI-1:/ administrator$
    MINI-1:/ administrator$ cd /Volumes/Macintosh-HD/
    MINI-1:/Volumes/Macintosh-HD administrator$ ls
    Applications Library bin mach.sym space2
    BitTorrent.app Network cores mach_kernel tmp
    Desktop DB System dev opt upnp.log
    Desktop DF User Guides And Information etc private usr
    Developer Users initfile.xml sbin var
    External Volumes lib space wireless
    Installer Log File automount mach space1
    MINI-1:/Volumes/Macintosh-HD administrator$
    MINI-1:/Volumes/Macintosh-HD administrator$ ls -R var
    root

    var/root:
    Library

    var/root/Library:
    Autosave Information Caches Preferences

    var/root/Library/Autosave Information:

    var/root/Library/Caches:
    PerianUpdateChecker

    var/root/Library/Caches/PerianUpdateChecker:
    01 13

    var/root/Library/Caches/PerianUpdateChecker/01:
    14

    var/root/Library/Caches/PerianUpdateChecker/01/14:
    3825993498-2811841262.cache

    var/root/Library/Caches/PerianUpdateChecker/13:
    03

    var/root/Library/Caches/PerianUpdateChecker/13/03:
    4127968977-0580983351.cache

    var/root/Library/Preferences:
    ByHost com.apple.HIToolbox.plist org.perian.Perian.plist
    QuickTime Preferences com.apple.print.PrintingPrefs.plist

    var/root/Library/Preferences/ByHost:
    MINI-1:/Volumes/Macintosh-HD administrator$
    MINI-1:/Volumes/Macintosh-HD administrator$ ls private/
    etc tftpboot tmp var
    MINI-1:/Volumes/Macintosh-HD administrator$ ls private/var
    at audit backups cron db empty launchd lib log mail msgs named netboot root run rwho samba spool tmp vm xgrid yp
    MINI-1:/Volumes/Macintosh-HD administrator$

    Please advise
    andres.hermoso@gmail.com
     
  6. J the Ninja macrumors 68000

    Joined:
    Jul 14, 2008
    #6
    Code:
    drwxrwxr-x+ 75 root  admin      2550 Apr 30 07:58 Applications
    drwxrwxr-x@ 17 root  admin       578 Apr  6 07:18 Developer
    drwxrwxr-t+ 60 root  admin      2040 Apr 30 07:50 Library
    drwxr-xr-x@  2 root  wheel        68 Apr  4 15:53 Network
    drwxr-xr-x   4 root  wheel       136 Mar 29 10:06 System
    drwxr-xr-x   5 root  admin       170 Dec 21 20:38 Users
    drwxrwxrwt@  5 root  admin       170 May  8 15:39 Volumes
    drwxr-xr-x@ 39 root  wheel      1326 Mar 29 10:03 bin
    drwxrwxr-t@  2 root  admin        68 Jun 22  2009 cores
    dr-xr-xr-x   3 root  wheel      4210 May  6 14:43 dev
    lrwxr-xr-x@  1 root  wheel        11 Dec 21 20:28 etc -> private/etc
    dr-xr-xr-x   2 root  wheel         1 May  6 14:44 home
    -rw-r--r--@  1 root  wheel  18659362 Feb  3 22:19 mach_kernel
    dr-xr-xr-x   2 root  wheel         1 May  6 14:44 net
    drwxr-xr-x@  3 root  admin       102 Jan  1 02:25 opt
    drwxr-xr-x@  6 root  wheel       204 Dec 21 20:38 private
    drwxr-xr-x@ 64 root  wheel      2176 Mar 29 10:03 sbin
    lrwxr-xr-x@  1 root  wheel        11 Dec 21 20:28 tmp -> private/tmp
    drwxr-xr-x@ 14 root  wheel       476 Apr  6 07:21 usr
    lrwxr-xr-x@  1 root  wheel        11 Dec 21 20:28 var -> private/var
    
    It is most definitely a symlink to /private/var.

    P.S. posting your email on an public web site is a good way for it to get picked up by a spam bot.
     
  7. Hal Itosis macrumors 6502a

    Hal Itosis

    Joined:
    Feb 20, 2010
    #7
    Yep, 110% sure.


    Eyeballing those listings, my guess is that some installer (Perian's perhaps?) has removed the symlink and replaced it with a folder. IOW, you now have two "var" directories:

    /var
    /private/var

    That is a bad config. Apple has deliberately abstracted the /var directory by shifting it over to /private/var and added that symlink so that programs which expect pathnames (such as /var/run) to work will still work. The situation you have now must be corrected.

    One could try (i suppose) to "patch up" the mistake by moving items from the bogus /var folder over to the /private/var folder where Apple would have wanted them... and then delete that /var folder and restore the symlink as i advised in post #3.

    idunno about the patching part, but really... that /var folder needs to go, and the symlink does need to be restored.
     
  8. andreshermoso thread starter macrumors newbie

    Joined:
    May 7, 2010
    #8
    Thanks for the quick reply.
    Sure posting the email was a dumb idea under a desperate situation.
    I'll clone that hard drive and make sure I'll watch myself when using terminal next time. I'm not exactly sure about how to fix this situation.
    Hal Itosis told me to sudo ln -sfh private/var /var
    Now I'm asking myself about the owner/group/permissions
    I think your "ls" output would help me out here.
    Please advise.
    Andres
     
  9. Hal Itosis macrumors 6502a

    Hal Itosis

    Joined:
    Feb 20, 2010
    #9
    Advise what? The "owner/group/permissions" on a symlink? Upon creation they will be derived from the effective user privileges, the group of the parent directory and the current umask (or some such criteria). But what would that matter? The purpose of a symlink is to transport action toward the target... so the target's perms etc., are what's most important... and we can always use Disk Utility to reset those modes for us (if necessary).

    What may happen is that the newly created symlink will end up being visible... so some additional step may be needed to hide it. Worry about that if/when you get there (as that is purely a cosmetic issue, not critical for any function).
     
  10. andreshermoso thread starter macrumors newbie

    Joined:
    May 7, 2010
    #10
    Thanks Hal.
    I'll do what you told me before and I'll post the results so everybody will be able to read them and know.
    Thanks again.
    Andres.
     

Share This Page