17 October 2006

Set Boot Volume in the command line

I haven't found this anywhere, so I will throw it out to the Googlesphere here.

Say you want to restart a Mac and boot from CD. Say it doesn't have a display and keyboard attached and you don't have Remote Desktop around (you should though).

You can always ssh in and do the following: Insert the CD. Run diskutil list to see wether the CD mounted and note the partition number (something like /dev/disk1s2 though the numbers will vary. Then to actually set the next boot drive use:

sudo bless --device /dev/disk1s2 --setBoot

and do a sudo reboot to restart. There is also a --mount option which will take the mount point, e.g. "/Volumes/Mac OS X Server Install/". To do a Netboot do:

sudo bless --netboot --server bsdp://

You can replace the 255's with the NetBoot server's IP address if you want to boot off a specific server.

The bless command has another option --nextonly which will only remember the setting for one boot. Read the bless man page for more details.


Abelardo said...


Anonymous said...

I found this entry while desperately trying to boot a Powerboook that wouldn't go past "Starting up Mac OS X". It wouldn't let me use any start up keyboard shortcuts (target disk, safe mode, booting from CD, external HDs, etc.) except command-s. I've never used the command line ever -- I wouldn't have minded keeping it that way, either, but what choice did I have. After learning about logging in from the prompt, fsck, repairing permissions and volumes, and trying to order it into target mode from the command line, I finally found this post.

This was the ONLY thing that worked! I finally was able to boot from another drive -- my Tiger DVD -- and reinstalled the OS. I still don't know what happened or why, but at this point I don't care.

Thank you so much!

Marty M.

123 123 said...

Nice blog as for me. It would be great to read a bit more concerning this topic.
By the way check the design I've made myself London escorts

Anonymous said...

Thank you! This worked for me when my iMac got locked into some bizarre state where I couldn't get it to boot to CD, but it would let me ssh in.

It really appreciate it!