Tag Archives: diskutil

Hide Mac OS X Recovery partition

Sometimes the Mac OS X Recovery partition can be seen because it’s mounted automatically on boot. This is usually caused because you moved the operating system to another disk (clone) or because you used an app that changed the disks partitions (rEFInd in my case).

Recovery HD

To fix this you can run this script:

#!/bin/bash

PARTITION=`mount | grep "Recovery HD" | awk '{print $1}'`
if [ -n "$PARTITION" ]; then
    sudo diskutil unmount $PARTITION
    sudo asr adjust --target $PARTITION -settype Apple_Boot
fi

Then SHUTDOWN (don’t just reboot) and turn on the computer.

You can also unmount that partition from the Disk Utility if you enable the debug option from the command line, but this will only work one time as it will be mounted again on next boot:

$ defaults write com.apple.DiskUtility DUDebugMenuEnabled 1

Disk-Utility-Debug

Ref: http://automatica.com.au/2013/11/hide-recovery-hd-after-cloning-an-os-x-installation/
http://osxdaily.com/2011/09/23/view-mount-hidden-partitions-in-mac-os-x/

Changing rEFInd options

If you use rEFInd to boot multiple operating systems in a Mac you may want to change it’s options. For example the default 20 second timeout, in my opinion too long.

refind

Booting from Mac OS X you’ll have to mount the rEFInd partition. You can see which partition it is in with this command:

$ diskutil list | grep EFI
   1:                        EFI EFI                     209.7 MB   disk0s1

Now that we know it is in disk0s1 we mount it:

$ sudo mkdir /Volumes/EFI
$ sudo diskutil mount -mountPoint /Volumes/EFI /dev/disk0s1 

The main configuration file can be found in /Volumes/EFI/EFI/refind/refind.conf. Here you can change for example the timeout or the default menu selection (by default rEFInd remembers the last selected one):

timeout 5
default_selection 1

Once we change everything we want just unmout the partition:

$ sudo diskutil unmount /Volumes/EFI

Create a bootable Ubuntu USB drive from an ISO in Mac OS X

Some months ago I burned a Xubuntu distro into a USB drive to use an old barebone computer (BTW I used this link as a guide).

usb-drive

To do that from a Mac OS X system first you have to convert the ISO image to a UDRW format:

$ hdiutil convert -format UDRW -o target xubuntu-10.04-desktop-i386.iso

Then insert the USB drive and list all connected disks:

$ diskutil list
/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *320.1 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:                  Apple_HFS Macintosh HD            319.2 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3
/dev/disk1
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                            Xubuntu 10.04 i3       *2.1 GB     disk1

Once you know the USB drive’s identifier (disk1 in my case) unmount it, inject the image you created before and eject the drive.

$ diskutil unmountDisk /dev/disk1
$ sudo dd if=target.dmg of=/dev/rdisk1 bs=1m
$ diskutil eject /dev/disk1

We can use now that drive to boot on any computer.

Install Raspbian RAW image into an SD Card in Mac OS X

First download a Raspbian RAW image from here: http://www.raspberrypi.org/downloads

SDHC_memory_card_-_8GB

Plug-in your SD card into your Mac. Then use diskutil to see the name of the disk device of it:

$ diskutil list
/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *320.1 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:                  Apple_HFS Macintosh HD            319.2 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3
/dev/disk1
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *4.0 GB     disk1
   1:             Windows_FAT_32                         4.0 GB     disk1s1

In my case it is /dev/disk1.

Unmount it so we can write the image into it:

$ diskutil unmountdisk /dev/disk1
Unmount of all volumes on disk1 was successful

Now copy the image (it will take quite long and you won’t get any feedback until the end so be patient):

$ sudo dd if=2013-09-25-wheezy-raspbian.img of=/dev/disk1 bs=1m
4297+0 records in
4296+0 records out
2199552 bytes transferred in 1.877077 secs (1171796 bytes/sec)

Finally eject the disk:

$ diskutil eject /dev/disk1