Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

A friend of mine used my USB stick to install a new version of OS X on his mac. Now that I got it back, I wanted to wipe it (I use Linux myself). However, I'm having a bit of trouble doing so. The first thing I did was write a Fedora LiveCD to it, using dd:

# dd if=Fedora.iso of=/dev/sdb

This, I thought, would overwrite the partition table which lies at the beginning of the device and consequently delete the partitions the OS X installer had created. However, I was wrong, the partitions were still there. So I looked up GUID partition tables and realized they add headers not only at the beginning of the device, but at the end, too. So I did:

$ sudo dd if=/dev/zero of=/dev/sdb
dd: writing to `/dev/sdb': No space left on device
15687681+0 records in
15687680+0 records out
8032092160 bytes (8.0 GB) copied, 1354.82 s, 5.9 MB/s

After this I removed the USB stick from the computer and plugged it back in. Running blkid now would yield no partitions on the device. However, after writing the Fedora image again, the OS X partitions are back:

$ sudo blkid
/dev/sdb1: LABEL="Fedora-17-x86_64-Live-Desktop.is" TYPE="iso9660" 
/dev/sdb2: SEC_TYPE="msdos" LABEL="EFI" UUID="B368-CE08" TYPE="vfat" 
/dev/sdb3: UUID="f92ff3eb-0250-303f-8030-7d063e302ccf" LABEL="Fedora 17" TYPE="hfsplus"

I suspect this has something to do with that Protective MBR bit in the wikipedia page above. How can I get rid of it?

Update

I ultimately ran parted and deleted the GPT from there. I did get spewed with warnings about a corrupted GPT (probably from zeroing it) but that "signatures" were there.

So I ultimately restored my USB stick, but it would still be nice if someone could shed some light on what exactly happened, where were those signatures stored?

share|improve this question
2  
The Protecive MBR is simply a normal MBR set up to satisfy BIOS based booting. The dd if=/dev/zero should have overwritten it (and everything else). Did you check the state of the USB stick after dd but before removing it from the computer? –  StarNamer Aug 21 '12 at 10:41
    
@StarNamer what do you mean by check the state? Just to be safe I ran sync and made sure the little blue light on the stick wasn't flashing (I waited ~20 seconds). –  Felix Aug 21 '12 at 13:49
1  
blkid uses a cache file /etc/blkid.tab. It may have been displaying cached values. To force a re-read you should use sudo blkid -c /dev/null. –  StarNamer Aug 21 '12 at 16:15
    
BTW, I would have checked the state of the USB stick using sudo sfdisk -d /dev/sdb or something similar to read the actual partition table on the device. –  StarNamer Aug 21 '12 at 16:16
    
I don't think the cache file could have been the problem: the extra partitions were shown after unplugging and plugging the USB stick. Also, after reconnecting the stick, I used fdisk on it and it displayed the extra partitions as well. –  Felix Aug 21 '12 at 16:35
add comment

2 Answers

up vote 1 down vote accepted

Found the answer: the Fedora ISO contains a GUID Partition Table with a partition layout very similar to that of OS X. Because of this, I confused the partitions created by

dd if=Fedora.iso of=/dev/sdb

with the ones created by the OS X installer. The confusion was furthered by the fact that one of the partitions has a HFS+ filesystem, which is specific to OS X. What's even more curious is the fact that running parted after writing the ISO to the stick yields:

$ sudo parted /dev/sdb
GNU Parted 2.3
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print                                                            
Warning: /dev/sdb contains GPT signatures, indicating that it has a GPT table.  However, it does not have a valid fake msdos partition table, as it should.  Perhaps it was corrupted --
possibly by a program that doesn't understand GPT partition tables.  Or perhaps you deleted the GPT table, and are now using an msdos partition table.  Is this a GPT partition table?
Yes/No?

Anyway, the point is that the partitions were not magically reinstated after zeroing the entire device, instead they were created when dd-ing the ISO.

share|improve this answer
    
I got your question, but I didn't get why your answer fits. E.g. "partitions were not magically reinstated after zeroing the entire device" is probably wrong. Did you try dd if=/dev/sdb of=sdb.img bs=4k count=10; hexdump -Cv sdb.img to check if GPT was there after zeroing de device? –  m-ric Mar 6 '13 at 17:08
    
@m-ric no, but there's no way it could have been. The partitions of the OS X installer exactly matched those of the Fedora installer, which is why I got confused, and thought the partitions were coming back somehow. Now that I understood where they were coming from, I feel kinda stupid for thinking "they were coming back" in the first place :). –  Felix Mar 10 '13 at 10:06
add comment

sfdisk command can dump and restore partion table on sector 0:

sfdisk -d YOU_DEV > your_file # dump ypur partion table
sfdisk YOUR_DEV < your_file #restore your partition table

Always i have a backup of my partition table. Such as:

sfdisk -d /dev/sda > mytable.dump

Wipe your Partition Table :

dd if=/dev/zero of=/dev/sdb count=1 bs=512
share|improve this answer
    
Have you even read the question? I want to get rid of my partition table. –  Felix Aug 21 '12 at 9:26
    
you need to delete 3 partitions? –  Mohsen Pahlevanzadeh Aug 21 '12 at 9:51
    
I need to wipe the partition table. –  Felix Aug 21 '12 at 13:46
1  
I already did that.. seriously, please read the (entire) question. –  Felix Aug 21 '12 at 16:37
1  
bs=512 means to write chunks up to 512 bytes at a time, according to the man page, and has nothing to do with where the writing actually starts. Or am I missing something? –  Felix Aug 22 '12 at 13:24
show 9 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.