Mac OS X

Recovery HFS partition table

First think, scan your damage disk with a tool like “testdisk” (http://www.cgsecurity.org/wiki/TestDisk) look for lost partitions, unfortunately HFS is not fully supported by this great tool, then you need to use pdisk or other partition software.

Disk /dev/rdisk3 – 1000 GB / 931 GiB – CHS 121601 255 63
Partition Start End Size in sectors
>P HFS 262208 1953525151 1953262944

In my case, I’ve used pdisk directly on OS X:

leobook4-w:~ root# pdisk /dev/rdisk3
pdisk: No valid block 1 on ‘/dev/rdisk3’
Edit /dev/rdisk3 –
Command (? for help): i
A physical block is 512 bytes:
A logical block is 512 bytes:
size of ‘device’ is 1953525168 blocks (512 byte blocks):
new size of ‘device’ is 1953525168 blocks (512 byte blocks)
Command (? for help): c
First block: 262208
Length in blocks: 1953262944
Name of partition: recover_leo
Command (? for help): w
Writing the map destroys what was there before. Is that okay? [n/y]: y
The partition table has been altered!

Command (? for help): q

Mac OS X – Time Machine network backup without Time Capsule

From OS X 10.5 (Leopard) Apple introduced Time Machine: a great combination of rsync/rsnapshot and a beautiful user interface.
Time Machine works in two modes: 1. local volume on local area or 2. Time Capsule over network.
Now I don’t wanna buy another box with apple logo over it for much $$$ when I have a lot of file servers on my network.

Now I explain a few hoops to get this system to work:

First: persuade Time Machine to see the SMB share as a Time Machine destination by activating the unsupported network drives feature by this console command:

# defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1

Second: set up the file server with SMB dedicated share to Time Machine, create an appropriate disk image locally (see below) and copy it into share.

To create the disk image, you’ll need to find out two pieces of information about the computer you want to backup: its Computer Name and its Ethernet ID (Ethernet MAC address). The Computer Name is the one that you set in the Sharing System Preferences pane. For example my is “LeoBook2”.

You can get the Ethernet ID by this command (use wired mac nic even if you’ll be using wifi connection):

# ifconfig en0 | grep ether | sed s/://g | sed s/ether//

Compose image name following this syntax:
Computer Name, followed by an underscore, followed by the Ethernet ID without the colons, followed by .sparsebundle (Ex. “LeoBook2_000d9358ca26.sparsebundle”).

Now go to Terminal and type the following commands:

# DISK_IMAGE_NAME="LeoBook2_000d9358ca26.sparsebundle"
# DISK_SIZE=200000
# hdiutil create -library SPUD -megabytes $DISK_SIZE -fs HFS+J -type SPARSEBUNDLE -volname "$DISK_IMAGE_NAME" "$DISK_IMAGE_NAME"

After you’ve run this command, you should end up with a disk image in your Home. It looks like a single file, but it’s actually a directory (just like a application). Don’t forget to copy this disk image to the appropriate share on your server. Just dragging and dropping from the Finder should work fine.

Now you are able to use the share as Time Machine backup volume.

Have a fun
Leo

Mac OS X – Cisco VPN Client

If you are running Cisco’s VPN Client on Mac OSX, you might be familiar with (or tormented by) “Error 51: Unable to communicate with the VPN subsystem”. The simple fix is to quit VPN Client, open a Terminal window, (Applications -> Utilities -> Terminal) and type the following from root user:

# /System/Library/StartupItems/CiscoVPN/CiscoVPN restart

Stopping Cisco Systems VPN Driver
kextunload: unload kext /System/Library/Extensions/CiscoVPN.kext succeeded
Starting Cisco Systems VPN Driver
kextload: /System/Library/Extensions/CiscoVPN.kext loaded successfully

Mac OS X – your network have been changed by another application

Dopo l’aggiornamento sulla sicurezza 2008-006 versione del sistema 10.4.11 e’ insorto un problema nelle preferenze di sistema, sezione network:

All’apertura si verifica questo errore “your network have been changed by another application” non reversibile con gli strumenti messi a disposizione per intenderci il tasto “OK”

Questo succede per dei monivi di sicurezza dato che le preferenze di rete interagiscono in continuazione con il portachiavi di sistema, vedi per le password PPP, le chiavi Airport e altre configurazioni di accesso.

La cosa piu’ sbrigativa sarebbe tenere le configurazioni bloccate con il lucchettino, ma risulta molto scomodo dover autenticare ogni modifica.

Come soluzione definitiva si puo’ procedere in questo modo:
Cercare la seguente cartella

/Library/Preferences/SystemConfiguration

Cancellare i seguenti file:

com.apple.airport.preferences.plist
NetworkInterfaces.plist
preferences.plist
com.apple.nat.plist

Dopo aver fatto questo e’ necessario cancellare tutto il database del portachiavi di sistema, o almeno la definizione delle password legate ai servizi di rete. Attenzione i dati di autenticazione dovranno essere reiseriti al fine di ricostruire con i giusti privilegi il db.

Mac OS X – Verbose Boot

Be l’os x anche se propio non sembra un sistema unix a causa di tutta questa bella grafica, in realta’ lo e’ fino all’osso, quindi nel caso si volesse visualizzare il verbose mode del boot ecco come fare:

Da terminale in modalita’ root:

Per abilitare:

# nvram boot-args=”-v”

Per disabilitare:

# nvram boot-args=

Per la versione del firmware:

# nvram -p

Mac OS X – Flush DNS Cache

Ecco i comandi vari ed eventuali sempre utili, ovviamente eseguiti da terminale:

Leopard 10.5

# dscacheutil -flushcache

Tiger 10.4

# lookupd -flushcache