{"id":148,"date":"2013-09-19T12:35:03","date_gmt":"2013-09-19T09:35:03","guid":{"rendered":"http:\/\/www.melen.org\/u\/jan\/wp\/?p=148"},"modified":"2013-09-19T12:36:42","modified_gmt":"2013-09-19T09:36:42","slug":"recovering-gpart-partitions-with-gptboot","status":"publish","type":"post","link":"https:\/\/www.melen.org\/u\/jan\/wp\/?p=148","title":{"rendered":"Recovering GPT partitions with gpart"},"content":{"rendered":"<p>If one manages to destroy the GPT scheme partition tables you&#8217;ll still have few options to recover them. Since FreeBSD 9.x the default used by the installation CD is GPT. Just grab the FreeBSD installation CD and boot the system using that. When it boot&#8217;s up it gives you options to install, shell, and live CD. Select Live CD and log in as root. <\/p>\n<p>Now if you have previously made a backup of the partition table using gpart backup command then you are lucky and most likely few shell commands away from getting the system back online. If not then you have more things to do.<\/p>\n<p>The backup created by gpart backup command looks like this (backup_partition_table.ada0):<\/p>\n<pre>\r\nGPT 128\r\n1   freebsd-boot         40        128  \r\n2    freebsd-ufs        168 5851053944  \r\n3   freebsd-swap 5851054112    8388607 \r\n<\/pre>\n<p>Restoring partitions and bootcode from backup:<\/p>\n<pre>\r\ngpart restore -F ada0 &lt; backup_partition_table.ada0\r\ngpart bootcode -b \/boot\/pmbr -p \/boot\/gptboot -i 1 ada0\r\n<\/pre>\n<p>In the restore command -F option first flushes completely the existing data from the partition table and then recovers the table from the file.<\/p>\n<p>In case you haven&#8217;t saved the partition table then if you have used the installation defaults then the first partition should be the freebsd-boot and the size is most likely 64k then second partition is the root partition and the third is the swap. By default the boot partition is 64K size other partitions depend on your configuration.<\/p>\n<pre>\r\ngpart create -s gpt ada0\r\ngpart add -s 64k -t freebsd-boot ada0\r\ngpart add -s 2.7T -t freebsd-ufs ada0\r\ngpart add -t freebsd-swap ada0\r\ngpart bootcode -b \/boot\/pmbr -p \/boot\/gptboot -i 1 ada0\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>If one manages to destroy the GPT scheme partition tables you&#8217;ll still have few options to recover them. Since FreeBSD 9.x the default used by the installation CD is GPT. Just grab the FreeBSD installation CD and boot the system using that. When it boot&#8217;s up it gives you options to install, shell, and live [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[],"_links":{"self":[{"href":"https:\/\/www.melen.org\/u\/jan\/wp\/index.php?rest_route=\/wp\/v2\/posts\/148"}],"collection":[{"href":"https:\/\/www.melen.org\/u\/jan\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.melen.org\/u\/jan\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.melen.org\/u\/jan\/wp\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.melen.org\/u\/jan\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=148"}],"version-history":[{"count":7,"href":"https:\/\/www.melen.org\/u\/jan\/wp\/index.php?rest_route=\/wp\/v2\/posts\/148\/revisions"}],"predecessor-version":[{"id":156,"href":"https:\/\/www.melen.org\/u\/jan\/wp\/index.php?rest_route=\/wp\/v2\/posts\/148\/revisions\/156"}],"wp:attachment":[{"href":"https:\/\/www.melen.org\/u\/jan\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=148"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.melen.org\/u\/jan\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=148"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.melen.org\/u\/jan\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=148"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}