Accidentally used dd on my main OSX drive I've made a bit of a balls up...

When attempting to create a bootable Ubuntu usb drive I accidentally ran dd on my main system drive :(

sudo dd if=/path/to/image.img of=/dev/rdisk1 bs=1m


I realised what I'd done pretty quickly but everything seemed fine so I re-ran the command on the correct drive /dev/disk2 and thought "phew not sure how I got away with that"... Then things started going wrong... I could continue using the applications I had open but opening anything new / accessing the hdd caused that thing to lock.

Sadly I haven't been using time machine, lesson learnt! 

I spoke to AppleCare who said I need to reformat the machine but I'm really hoping there's some way to restore whatever 1m I destroyed (I'm assuming something to do with the partition information). Wishful thinking?

Also, AppleCare told me to restart, which means I can only user repair mode utils.

Help!
Sorry to hear of your situation. The first megabyte will have included the drive's partition and critical structural information.

If you can, dd all the remaining content to another drive as a back-up of sorts. Then I suspect your best choice is a professional repair service or a tool like DiskWarrior:


  DiskWarrior
  
  Everything just disappeared after your Mac went haywire. All your work documents. The music you most enjoy. The movie of your kid's first steps. It's your life and it's gone. Don't panic! DiskWarrior will recover your documents, photos, music and any other files when disaster strikes and you lose access to your files.


Recovering a Mac Drive on OS X

@DavidAnderson mentions in the comments below that recovery may be possible. This assumes your drive was GUID partitioned. The Cloudy Aide-Mémoire article, Recovering a non-readable disk on Mac OS X goes into more detail:


  
  Connect your external disk
  Start terminal and use the 3 commands in bold below:
  
  
  diskutil list
  sudo gpt recover /dev/disk1
  diskutil eject /dev/disk1
  
  If the last command was successful, disconnect and reconnect your disk, which >should now be OK
  
  
  An alternative to the second command (gpt) would be diskutil repairDisk /dev/disk1
  
  Note than the manpage for gpt does not cover the recover option whereas the manpage for diskutil does cover the repairDisk option.


Good luck – and be sure to back-up in the future!