2006年2月19日 星期日

[MacOSX] 摘要 from Mac OSX Tiger for Unix Geeks, Chapter 3~5

File System
------------------------
Apple Double Format = xxxx and xxxx._filename

Startup
------------------------
開機時按
[蘋果鍵+V], 看Console輸出
[蘋果鍵+S], Single-user mode
修復磁碟, 開機時按C, 用安裝光碟開機,Installer->Open Disk Utility (不建議使用Single-user run fsck)

Booting Sequence:
- firmware
- BootX loader (/System/Library/CoreServices), load kernel extensions(kexts)
- kernel (/mach_kernel), init, mount root,
- first process (launchd)
- load /etc/rc (except single-user mode)
-- /etc/rc.common
-- /etc/hostconfig
-- fsck if needed, try fsck -fy if fsck fail.
-- mount local file systems

Launchd lanuches (use launchctl to load/unload)
/System/Library/LanuchDaemons, system installed daemons
/Library/LaunchDaemons, locally installed daemons

SystemStarer starts (config file:/etc/hostconfig, SystemStarter start/restart/stop)
/System/Library/StartupItems, for system
/Library/StartupItems, for locally installed app

LoginWindow
/System/Library/CoreServices/loginwindow.app

/etc/crontab was replaced with:
/System/Library/LaunchDaemons/com.apple.periodic-(daily/weekly/monthly).plist (don't change them)
To run these daily/weekly/monthly jobs by hand:
sudo periodic daily weekly monthly


Create our specific cron jabs:
/etc/daily.local
/etc/weekly.local
/etc/monthly.local

Edit cron jobs: crontab -e
List cron jobs: crontab -l

Directory Services
------------------------
NetInfo Command Line Tools:
dscl - for Directory Services
nicl - for NetInfo (can be used even when Dierctory Services is not running)
nidump
nifind
nigrep
niload
nireport
nituil


Backup NetInfo Database
(system will backup to /var/backups/local.nidump daily)
nidump -r / -t localhost/local > backup.nidump


Fix NetInfo Database
1. Boot in single-user mode
2. /sbin/fsck -fy (fix file system errors)
3. /sbin/mount -uw / (mount root as rw)
4. cd /var/db/netinfo/
5. mv local.nidb/ local.nidb.broken (backup broken db)
6. sh /etc/rc (Start system, let system create an empty NetInfo db)
7. Press Control+L or Return to get shell prompt back
8. /usr/bin/niload -d -r / . < /var/backups/local.nidump (Restore db)
9. touch /var/db/.AppleSetupDone (/etc/rc will remove .AppleSetupDone, recreate it)


Flush Directory Services catch
$ lookupd -flushcache
張貼留言