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

datePosted on 15:52, May 20th, 2009 by Many Ayromlou

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 Responses to “Writing Moblin (and Ubuntu) USB images using dd in OSX”

  1. Nick Richards on May 20th, 2009 at 18:15

    Hey Many, thanks for this. I added this info to the Moblin install page.

  2. Many on May 20th, 2009 at 18:27

    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

  3. Biogeek on May 31st, 2009 at 14:27

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

  4. Many on May 31st, 2009 at 15:54

    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).

  5. Christian Meredith on August 26th, 2009 at 12:29

    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

  6. Many on August 26th, 2009 at 15:53

    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……

  7. rakan21 on September 23rd, 2009 at 18:42

    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.

  8. Aeka on October 2nd, 2009 at 04:51

    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.

  9. DANiEL on October 29th, 2009 at 13:59

    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!

  10. Many on October 29th, 2009 at 16:03

    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

  11. Anonymous on November 6th, 2009 at 13:04

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

  12. Many on November 8th, 2009 at 22:00

    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

  13. Anonymous on November 21st, 2009 at 18:47

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

  14. Anonymous on January 12th, 2010 at 23:17

    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?

  15. Many on January 13th, 2010 at 08:05

    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

  16. Anonymous on February 7th, 2010 at 11:34

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

  17. Many on February 13th, 2010 at 21:38

    Hi Anonymous,

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

  18. Nathan Nutter on June 19th, 2010 at 19:16

    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'

  19. Anonymous on July 30th, 2010 at 15:00

    Thanks, it helped me with my job.

Leave a Reply

You must be logged in to post a comment.