{"id":347,"date":"2011-10-26T17:04:43","date_gmt":"2011-10-26T17:04:43","guid":{"rendered":"http:\/\/blog.cyberwizzard.nl\/?p=347"},"modified":"2016-03-17T21:55:33","modified_gmt":"2016-03-17T20:55:33","slug":"clearing-gpt-from-harddisk-without-destroying-mbr","status":"publish","type":"post","link":"https:\/\/blog.cyberwizzard.nl\/?p=347","title":{"rendered":"Clearing GPT from harddisk without destroying MBR"},"content":{"rendered":"<p>For some reason, my attempts to use GPT with Windows 7 ran aground and I ended up with a working Master Boot Record (MBR) and an empty GPT. While Windows 7 was quite happy with this, the Ubuntu installer detected the GPT and attempts to use it &#8211; which effectively prevents me from installing it unless I wipe the entire hard drive for Ubuntu.<\/p>\n<p>In this little article I will clear the GPT from the disk so only the MBR remains. <strong>This is an advanced technique which WILL destroy your partition layout and thus your data when it fails. Make very <em>very<\/em> sure you understand each step and have backups.<\/strong><\/p>\n<p>Start by making a backup of your MBR, which is 512 bytes long at the start of the disk:<br \/>\n<code class=\"not-hl\">sudo dd if=\/dev\/sda of=disk_mbr.raw bs=512 count=1<\/code><br \/>\nI made a backup of the MBR and the GPT as well, just in case (GPT is 512 bytes for the header followed by 16kB of content, total with MBR is 17kB):<br \/>\n<code class=\"not-hl\">sudo dd if=\/dev\/sda of=disk_mbr_gpt.raw bs=1024 count=17<\/code><br \/>\nThe GPT is present at the start and end of the disk. Lets start by erasing the GPT from the start:<br \/>\n<code class=\"not-hl\">sudo dd if=\/dev\/zero of=\/dev\/sda bs=512 seek=1 count=33<\/code><br \/>\nNow find the end of your disk, use <code class=\"not-hl\">fdisk \/dev\/sda<\/code> and note the number of bytes on the disk. In my case it is: 240,057,409,536 bytes, since I want to use kilobytes with dd, lets convert it to kB: 234,431,064 kB. We need to erase the last 16.5 kB, but 16kB will suffice (as the header is in the last 512 bytes).<\/p>\n<p>So subtracts 16 from the drive size to generate the GPT offset for the end of the disk and zero-fill it to the end: <code class=\"not-hl\">sudo dd if=\/dev\/zero of=\/dev\/sda seek=234431048 bs=1024 count=17<\/code><\/p>\n<p>All done! Now fdisk will no longer complain the drive has a GPT table and the Ubuntu installer will only find the MBR and happily install using that.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>For some reason, my attempts to use GPT with Windows 7 ran aground and I ended up with a working Master Boot Record (MBR) and an empty GPT. While Windows 7 was quite happy with this, the Ubuntu installer detected the GPT and attempts to use it &#8211; which effectively prevents me from installing it [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-347","post","type-post","status-publish","format-standard","hentry","category-linux-gentoolinux"],"views":3907,"_links":{"self":[{"href":"https:\/\/blog.cyberwizzard.nl\/index.php?rest_route=\/wp\/v2\/posts\/347","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.cyberwizzard.nl\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.cyberwizzard.nl\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.cyberwizzard.nl\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.cyberwizzard.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=347"}],"version-history":[{"count":3,"href":"https:\/\/blog.cyberwizzard.nl\/index.php?rest_route=\/wp\/v2\/posts\/347\/revisions"}],"predecessor-version":[{"id":523,"href":"https:\/\/blog.cyberwizzard.nl\/index.php?rest_route=\/wp\/v2\/posts\/347\/revisions\/523"}],"wp:attachment":[{"href":"https:\/\/blog.cyberwizzard.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=347"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.cyberwizzard.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=347"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.cyberwizzard.nl\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=347"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}