Writing Moblin (and Ubuntu) USB images using dd in OSX

Home / Apple / Writing Moblin (and Ubuntu) USB images using dd in OSX

I came across this problem this morning, while writing the newly downloaded moblin USB image file. The concept is straight forward, plugin a 1GB+ USB stick into a functioning Linux or Windows box, make sure the stick is not mounted and use dd to write the disk image to the stick. Under OSX however the instructions for unmounting are slightly different, so here are the quick steps:

  1. Download the desired .img file
  2. Open a Terminal (under Utilities)
  3. Run diskutil list to get the current list of devices
  4. Insert your flash media
  5. Run diskutil list again and determine the device node assigned to your flash media (e.g. /dev/disk2)
  6. Run diskutil unmountDisk /dev/diskN (replace N with the disk number from the last command; in the previous example, N would be 2)
  7. Execute sudo dd if=/path/to/downloaded.img of=/dev/diskN bs=1m (replace /path/to/downloaded.img with the path where the image file is located.
  8. Run diskutil eject /dev/diskN and remove your flash media when the command completes

That should do it…..

19 Comments

  • Many

    Hey Nick,

    Great, btw really nice work on moblin. I’ve been a bit of a OSX geek of late, but I have to say moblin is getting close and surpassing it in most ways. Can’t wait for the release.

    Keep up the good work :-)….

    TTYL
    Many

  • Biogeek

    … and how would one undo this?
    (I’m guessing that means reformatting it as a flash drive in some way)

  • Many

    Hey Biogeek,

    Yes, sorta……The dd image has two partitions on it, so a simple format will not do. You have to use linux’s fdisk utility to delete the partitions first (just delete the partitions, you don’t have to create a new one), then you can partition and reformat it to whatever you like.

    I tried to delete the partitions under OSX and it did not work, so Linux seems to be the solution…..Or maybe DOS or Windows Disk Manager (haven’t tried these though).

  • Christian Meredith

    Hey Many,
    I was trying to use this method on my 10.5.7 Mac Mini and after doing
    "sudo dd if=/random_destination/moblin_image.img of=/dev/disk2 bs=1m"
    Terminal just seems to hang with nothing but completely blank lines after the sudo password input. And then I just can't get the darn USB to boot. Could there be a step (e.g. something that's assumed knowledge) that I'm missing or could it be just a bad USB?

    Cheers,
    Christian

  • Many

    Hi Christian,

    Hmmm……strange…..Right after you type in the sudo password, do you see the blinky light on your USB stick going crazy? That would mean it's being written to. Try partitioning the stick from disk utilities with a DOS partition. It is possible (although unlikely) that the stick has a GPT partition on it that's confusing the boot process after you finish (MBR bootable partitions are needed to get linux to boot).

    Hopefully this helps….Let me know how you make out……

  • rakan21

    I was actually able to reformat my USB stick in OS X by using disk utility.
    All you have to do is just insert your usb
    then in disk utility it should show up
    click on it and on the tabs click erase
    In Volume Format choose MS-FAT
    and then name it whatever you want.
    Click Erase and then it should work.

    I had burnt Moblin to the USB and well after I plugged it into my other laptop that I was planning to install it onto. It boots up to the GRUB menu(I think thats what its called) I clicked Boot and Boot and Install, but then it would just restart my computer and then it was a cycle over and over again.

  • Aeka

    Thanks for the concise guide. In my opinion, Moblin will certainly help Linux gain a fair chunk of the netbook OS market share. I am in full support of Moblin.

  • DANiEL

    Have you tested this on Snow Leopard? I'm seeing extremely slow write times (38k/s). I've tried 2 different USB keys. One of these keys was used previously on a 10.5 install of OS X following the exact same set of commands on the exact same image file with speeds worthy of USB 2.0 (as opposed to crap). Any ideas? Thanks!

  • Many

    Hi Daniel,

    So what happens if you just copy a bunch of large files to these USB sticks…..Is it also slow? Maybe you have a USB 1.1 device sitting on that bus, that would slow down the whole bus aswell.

    I would try to just copy a large file to the sticks and see if it's slow. The dd command is just doing raw writes to the device at block level…..nothing special.

    Hope this helps….

    TTYL
    Many

  • Anonymous

    Is there a way to use a larger USB stick and use the remaining space under Moblin?

  • Many

    Hi Anonymous,

    Yes you can use a bigger stick. I'm not sure how you would expand the partition to include the extra space under mac, since it doesn't know any of the linux partition schemes, but you can probably use gparted under linux to expand the partition to include the empty space AFTER you write the image.

    TTYL
    Many

  • Anonymous

    Might want to update how Snow Leopard counts bytes.. bs=1m should be changed to bs=8192 ( 1024*8)

  • Anonymous

    after typing : sudo dd if=/Users/Fred/Desktop/moblin-2.1-final-20091103-002.img of=/dev/disk2/ bs=1m

    I've got this error : dd: /dev/disk2/: Not a directory

    I'm I doing something wrong here?

  • Many

    Hi Anonymous,

    Take out the extra slash after disk2…..it should read:

    sudo dd if=/Users/Fred/Desktop/moblin-2.1-final-20091103-002.img of=/dev/disk2 bs=1m

  • Anonymous

    so i run this and is says it transfers 0 bytes in0.0003 seconds, is that right??

  • Many

    Hi Anonymous,

    Nope that doesn't sound right….you might have missed something….

  • Nathan Nutter

    I just wanted to add a couple tips via Ubuntu's docs on this:

    – Instead of /dev/diskN you can possibly use /dev/rdiskN for faster writes.

    – You can convert an ISO image to a disk image by running 'hdiutil convert -format UDRW -o myImage myImage.iso'

Leave a Reply