Fail-safe property of any startup (bootable) disk

I have multiple partitions on the internal and on two external drives.
Four of the partitions are startup disks as displayed by the StartupDisk.prefPane, which unfortunately, is not scriptable.
I need to generate the list of startup disks, in this example: {“HD-1”, “HD-3”, “MB-1”, “MB-3”}

tell application "System Events"
	get the name of every disk -- gets the list of all mounted disks.
	--> {"HD-1", "HD-2", "HD-3", "HD-4", "MB-1", "MB-2", "MB-3", "MB-4", "MB-5"}
	get the name of every disk whose startup is true -- gets the actual startup disk but, NOT THE OTHER THREE.
	--> {"HD-1"}
end tell

In the next scriptlet, I simply test for the “System” folder but, I’m sure, there is a bright spark out there to name a root folder “System” on a non-startup disk. Hard coding is not an option since the disk existence and names will differ.

tell application "Finder"
	tell application "System Events" to set DiskList to get the name of every disk
	--> {"HD-1", "HD-2", "HD-3", "HD-4", "MB-1", "MB-2", "MB-3", "MB-4", "MB-5"}
	set StartupDiskList to {}
	repeat with disk_i in DiskList
		if exists (alias disk_i as text) & "System:" then copy disk_i to end of StartupDiskList
	end repeat
	--> {"HD-1", "HD-3", "MB-1", "MB-3"}
	choose from list StartupDiskList with prompt "Choose a startup disk:"
	set chooseResult to result as text
	--> {"HD-3"} -- or whatever the choice is.
end tell

Is there a fail-safe property of any startup (bootable) disk, which I can test for? I can’t seem to find one in the relevant libraries.
Please prove me wrong or, some clever workaround.


you can retrieve the bootable volumes this way

set theDisks to paragraphs of (do shell script "ls /Volumes")
set blessList to {}
repeat with aDisk in theDisks
		do shell script "bless -info /Volumes/" & aDisk & "| grep '/System/Library/CoreServices/boot.efi'"
		set end of blessList to contents of aDisk
	end try
end repeat
choose from list blessList

Hello Stefan

It sounds odd.
I ran the posted script on my system with two bootable disks :

  • the internal mechanical one
  • the external SSD which I boot from.

The script returned an empty list.

Yvan KOENIG (VALLAURIS, France) jeudi 11 décembre 2014 16:58:43

PS :
I edited the main instruction :

 do shell script "bless -info /Volumes/'" & aDisk & "'| grep '/System/Library/CoreServices/boot.efi'"

and now it works.
The volume names embedded a space character

sorry, I forgot the quotation, I’d prefer

do shell script "bless -info " & quoted form of ("/Volumes/" & aDisk) & "| grep '/System/Library/CoreServices/boot.efi'"

Hi Stefan,
Many thanks. That’s the nice workaround I was hoping for :slight_smile:

Cheers, Chris