You are not logged in.

#1 2011-09-26 19:21:46

gjd
Member
Registered: 2011-09-20
Posts: 5

Paging `dd` gurus: How did this use of `dd` destroy my Macbook Air HD?

Hi all,

edit: tl;dr:

1) What code tells the Macbook Air (or any PC?) how to boot from a flash drive in the USB port? That wouldn't live on the hard drive or be a part of the MBR or GPT would it? I would have thought that lives in the Macbook's firmware somewhere.

2) Can `dd` change a computer's firmware?

end tl;dr

I'm brand new to Arch Linux, but really like it so far. I got it running nice and smooth on my 4 year old Macbook, so I tried installing it on my Macbook Air.

Long story short, I apparently permanently incapacitated my late 2010 Macbook Air's hard drive from a poor use of `dd`. A new hard drive is on the way and will be taken care of, but I'm curious to learn what exactly my actions did.

After my unfortunate actions, the macbook after powering on would just hang at a gray screen. Tapping the power button didn't do anything, but holding the power button turned it off. I tried putting in the system restore USB stick that came with it, and rebooted while holding down c, and nothing happened. Rebooting while holding down option didn't bring up the boot disk menu. Holding down Cmd+Shift+P+R seemed to reset the PRAM (at least, it restarted like it's supposed to), but didn't fix anything.

I took it into my local Apple store and the Genius at the Genius Bar didn't know what to do. He said we couldn't boot from a restore USB drive, which also means we couldn't boot into target disk mode. He took it to the back area and confirmed the issue is solely with the hard drive, but didn't know of any way to fix the drive (some sort of weird 'blade' drive?). The only thing we could do was order a new drive to replace it.

So my question:

WHAT did my use of `dd` DO, to so permanently mess up the drive? I would have thought it would make a non-functional partition, or at worst mess up the MBR/GPT, but I thought that I'd still be able to boot up with the system restore drive and reformat and fix everything. Isn't booting from a USB drive taken care of by the EFI firmware? Could `dd` really corrupt that?

From memory, below are the detailed steps of what I did. Step 10 is where I typed the `dd` command that I think was the end of my poor drive.

1) Use OS X's Disk Utility program to shrink my OS X partition, leaving about 50 GB of free space.

2) Following (https://wiki.archlinux.org/index.php/US … n_Mac_OS_X), I put an Arch image on my USB flash drive.

3) I installed rEFIt.

4) I booted up with the flash drive inserted, and used rEFIt to select the flash drive.

5) Arch Linux came up. I fire up parted, and saw partition 1 was the EFI partition, 2 was my OS X partition, 3 was some sort of "Recovery CD" partition, and the rest was free space. I typed

 mkpart 4 ext4 nnnnnMB -0 

(after setting MB as the default unit), and then quit.

6) I restarted, and used rEFIt's tool to MBR <> GPT sync.

7) I restarted, now there were three options: OS X, Linux on the hard drive, and Linux on the flash drive. Both of the Linux options at this point resulted in "No operating system found" if I tried to load them. I understood the new empty partition would be like that, but I'm not sure why the flash drive no longer worked.

8) Puzzled, I booted OS X to search the web. An Ubuntu tutorial somewhere suggested `dd`-ing the .iso into an empty partition. I figured that since I could boot just fine from the USB drive, the first time, maybe if I put the Arch .iso in my new partition I'd be able to boot into it... (I'm thinking now there might have been filesystem issues with that idea.)

9) I opened Disk Utility and saw beneath the icon for my hard drive two entries: My Mac partition, and one called /dev/disk0s4. The flash drive, when it was in there earlier was known as /dev/disk1, and in the linux side I would have thought the new ext4 partition I created would be called /dev/sda4. I therefore assumed /dev/disk0s4 referred to my newly created partition.

10) I opened my terminal and typed

sudo dd if=arch.iso of=/dev/disk0s4 bs=8192

. It waited a while and then it gave the summary of how much it wrote. I didn't pay attention to the output, other than that it looked fairly normal, and I don't remember now what it said exactly.

11) I rebooted.

12) DISASTER

Thanks,

Gabe

Last edited by gjd (2011-09-26 20:08:52)

Offline

#2 2011-09-26 19:26:55

Inxsible
Forum Fellow
From: Chicago
Registered: 2008-06-09
Posts: 9,183

Re: Paging `dd` gurus: How did this use of `dd` destroy my Macbook Air HD?

tl;dr

gjd wrote:

I therefore assumed /dev/disk0s4 referred to my newly created partition.

Assumption is the mother of all fuck-ups !!


Forum Rules

There's no such thing as a stupid question, but there sure are a lot of inquisitive idiots !

Offline

#3 2011-09-26 20:07:45

gjd
Member
Registered: 2011-09-20
Posts: 5

Re: Paging `dd` gurus: How did this use of `dd` destroy my Macbook Air HD?

Assumption is the mother of all fuck-ups !!

Heh, well that's certainly true!

tl;dr

Understood. My questions boil down to:

1) What code tells the Macbook Air (or any PC?) how to boot from a flash drive in the USB port? That wouldn't live on the hard drive or be a part of the MBR or GPT would it? I would have thought that lives in the Macbook's firmware somewhere.

2) Can `dd` change a computer's firmware?

If the answer to (1) is "it's in the firmware" and (2) is "no", then how can I have messed things up so badly? The world has presented me with a fact that tells me my mental model of the systems involved is wrong somehow, somewhere.

Arch is great because it's causing me to learn so many new things. A *lot* happens between hitting the power button and getting to the log-in screen that I never was really cognizant of. I'm just trying to learn what happened here.

Offline

#4 2011-09-27 05:54:25

steve_v
Member
Registered: 2006-02-11
Posts: 80

Re: Paging `dd` gurus: How did this use of `dd` destroy my Macbook Air HD?

Is that mkpart form gnu parted? If so what does -0 signify?
Just a stab in the dark, but what if the partition you created overlapped the wherever-apple-put-something-important partition. All may be well untill you write something to it...
Still curious to know what it was that went missing, some kind of bootloader?
I guess you could put the usb boot code on disk, sorta defeats the purpose of usb boot though.

Offline

#5 2011-09-27 05:59:09

lifeafter2am
Member
From: 127.0.0.1
Registered: 2009-06-10
Posts: 1,332

Re: Paging `dd` gurus: How did this use of `dd` destroy my Macbook Air HD?

I don't know about MacBook Air's, but I know back when I had my unibody MacBook Pro I changed the hard drive in it like 10 times and never had issues with it booting.  So, at least in that case, it's not anything that was on the hard drive that was allowing me to boot.


#binarii @ irc.binarii.net
Matrix Server: https://matrix.binarii.net
-------------
Allan -> ArchBang is not supported because it is stupid.

Offline

#6 2011-09-27 09:43:02

PSW
Member
From: Brighton
Registered: 2011-06-15
Posts: 32

Re: Paging `dd` gurus: How did this use of `dd` destroy my Macbook Air HD?

gjd wrote:

WHAT did my use of `dd` DO, to so permanently mess up the drive? I would have thought it would make a non-functional partition, or at worst mess up the MBR/GPT

This would be my thought too. Unless the Hard Drives in Macs are fundamentally different from those in PCs dd shouldn't break the drive. At most it would corrupt the fuck out of the files on it. Nothing a little partitioning and formatting wont take care of. Is it possible to remove the HDD from a Mac? My first thought would be to plug it into another computer and see exactly what's going on with it.

Offline

#7 2011-09-27 11:19:39

gjd
Member
Registered: 2011-09-20
Posts: 5

Re: Paging `dd` gurus: How did this use of `dd` destroy my Macbook Air HD?

steve_v wrote:

Is that mkpart form gnu parted? If so what does -0 signify?

Yes, I believe GNU parted. Whatever comes on the Arch installation image when you type `parted`. When you use a negative number it counts backwards from the end of the disk, and -0 means the last sector. So I tried to make a partition that took up the remainder of the disk. I believe I got that usage from the man page.

Just a stab in the dark, but what if the partition you created overlapped the wherever-apple-put-something-important partition. All may be well untill you write something to it...

That was what I assumed happened, but I didn't imagine that even messing that up would keep the machine from booting from a USB flash drive. Hypothetically, even if you had a completely zeroed-out hard drive, wouldn't you still be able to boot from a flash drive in order to re-format it?

Still curious to know what it was that went missing, some kind of bootloader?

I guess you could put the usb boot code on disk, sorta defeats the purpose of usb boot though.

Oh, I should have made this explicit. I was only using the USB flash drive to install Arch. The Macbook Air doesn't have a CD or DVD drive so I couldn't burn a boot CD and install the usual way.

Thanks for your response.

Offline

#8 2011-09-27 11:22:25

gjd
Member
Registered: 2011-09-20
Posts: 5

Re: Paging `dd` gurus: How did this use of `dd` destroy my Macbook Air HD?

lifeafter2am wrote:

I don't know about MacBook Air's, but I know back when I had my unibody MacBook Pro I changed the hard drive in it like 10 times and never had issues with it booting.  So, at least in that case, it's not anything that was on the hard drive that was allowing me to boot.

Thanks for the datapoint. In fact, today I'm putting in a replacement hard drive and the Apple Genius guy said that should fix it.

However, I don't see how a brand new, empty hard drive would be any better/worse than a hard drive with bad data on it from my pitiful `dd` usage. We'll see...

Offline

#9 2011-09-27 11:30:45

gjd
Member
Registered: 2011-09-20
Posts: 5

Re: Paging `dd` gurus: How did this use of `dd` destroy my Macbook Air HD?

PSW wrote:
gjd wrote:

WHAT did my use of `dd` DO, to so permanently mess up the drive? I would have thought it would make a non-functional partition, or at worst mess up the MBR/GPT

This would be my thought too. Unless the Hard Drives in Macs are fundamentally different from those in PCs dd shouldn't break the drive. At most it would corrupt the fuck out of the files on it. Nothing a little partitioning and formatting wont take care of.

I'm relieved to hear my understanding of booting is not too off base.

Is it possible to remove the HDD from a Mac? My first thought would be to plug it into another computer and see exactly what's going on with it.

It is possible to remove, although they're somewhat non-standard in shape (See: MBA's blade-type drives, http://www.wired.com/gadgetlab/2010/11/ … o-anyone/), so I'm not sure how I'd be able to use it on another computer.

However, today at the Apple store they're putting in a brand new drive, which is supposed to fix the problem. If my MBA can boot a brand new drive, I don't see why it wouldn't be able to boot my corrupted drive. I guess this raises two questions for me:

1) When brand new hard drives are shipped, do they generally come zeroed out? Do they have unspecified data? Is there some sort of MBR structure already on them? I realize Apple might be different here, but what about your standard PC drive?

2) Could dd have somehow caused a hardware failure of the drive? From, I don't know, overheating or something? My drive was a SSD, if that matters.

Thanks for your response.

Offline

Board footer

Powered by FluxBB