Just as a footnote, this is something that has always driven me crazy, in UNIX, in MS-DOS, and everywhere. Why can't there be a constant mapping between a slot and a drive?
Anyway, there is a program called pdisk(1) that may work. It prints the partition table from an attached drive whether it is mounted or not, and so it will probably work from rc.server. The table it prints out is like this:
Partition map (with 512 byte blocks) on '/dev/disk1'
#: type name length base ( size )
1: Apple_partition_map Apple 63 @ 1
2: Apple_Free 262144 @ 64 (128.0M)
3: Apple_HFS Untitled 104857600 @ 262208 ( 50.0G)
4: Apple_Free 262144 @ 105119808 (128.0M)
5: Apple_HFS Untitled 480690400 @ 105381952 (229.2G)
6: Apple_Free 16 @ 586072352
Device block size=512, Number of Blocks=312581808 (149.1G)
DeviceType=0x0, DeviceId=0x0
Note that while there are various useful clues, the actual volume name doesn't appear to be present. There is an option (-f) that is supposed to cause volume names to be printed, but this has no effect in early testing.
So one way to do this would be for the scheduled script to look for the devices by their mount names /Volumes/Clone and /Volumes/Snapshots, use mount to find the current name and partition numbers, use pdisk to compute the hash, which would be stored somewhere volatile but which would not yet be cleaned up in rc.server (?) or maybe just in /etc. Then when the system is booted, a simply loop would be run to find it, it would be mounted, and the backup would proceed.
Incidently, finding a directory like /tmp or /var/??? that gets cleaned up after rc.server is finished would be a great way to pass information to the maintenance script(s), since there's no other way that the info would be there, unless it was placed there just before booting. Note that the script can't really remove it, since the boot drive is still read-only. In fact, this implies that /tmp can be used for this purpose. To be tested...
Well, I'll be testing this all out tomorrow so will report either in a comment here or in another entry.
Here is an example of finding all disks' hashes:
for x in /dev/disk[0-9] ; do /bin/echo $x `/usr/sbin/pdisk $x -dump 2>/dev/null | /usr/bin/grep -v "/dev/disk" | /sbin/md5 -q` ; done
No comments:
Post a Comment