{"id":302,"date":"2010-09-04T03:50:24","date_gmt":"2010-09-04T03:50:24","guid":{"rendered":"http:\/\/poojanwagh.opalstacked.com\/techblog\/un\/partitioning-with-gpt\/"},"modified":"2010-09-04T03:54:11","modified_gmt":"2010-09-04T03:54:11","slug":"partitioning-with-gpt","status":"publish","type":"post","link":"https:\/\/tech.poojanblog.com\/blog\/un\/partitioning-with-gpt\/","title":{"rendered":"Partitioning with gpt"},"content":{"rendered":"<p>Sometime ago, I setup a ZFS system using glabel on FreeBSD. I recently stumbled across <a title=\"The FreeBSD Diary -- ZFS: do not give it all your HDD\" href=\"http:\/\/www.freebsddiary.org\/zfs-with-gpart.php\" target=\"_blank\">this FreeBSD diary entry<\/a>, which describes to do almost the same thing using gpt. I like this method better, because it results in a partition that is on a 4kB boundary, which works better for some hard drives (whose sector size is 4kB).<\/p>\n<p>Here\u2019s what I did:<\/p>\n<code><\/p>\n<p>#gpart show da0<br \/>\n=&gt;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 63\u00a0 1953525105\u00a0 da0\u00a0 MBR\u00a0 (932G)<br \/>\n63\u00a0 1953525105\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8211; free &#8211;\u00a0 (932G)\u00a0 <\/code>\n<p>OK: that&#8217;s the starting point. I have a MBR-style partition which is set up as one 932G partition and some free space.<\/p>\n<p>I wasn&#8217;t sure exactly how to get rid of it, so I tried:<\/p>\n<code><\/p>\n<p># gpart delete -i 1 da0<br \/>\nda0s1 deleted<\/p>\n<p><\/code>\n<p>I still have a MBR-style partition table. Next, as I read in the FreeBSD diary, I need to figure out how many sectors I have:<\/p>\n<code><\/p>\n<p># dmesg | grep &#8220;da0&#8221;<br \/>\nda0 at umass-sim0 bus 0 scbus0 target 0 lun 0<br \/>\nda0: &lt;Hitachi HDS721010CLA332 &gt; Fixed Direct Access SCSI-2 device<br \/>\nda0: 40.000MB\/s transfers<br \/>\nda0: 953869MB (1953525168 512 byte sectors: 255H 63S\/T 121601C)<\/p>\n<p><\/code>\n<p>OK: 1953525168 sectors of 512 bytes each. However, for some reason, that isn&#8217;t what gpt shows:<\/p>\n<code><br \/>\n# gpart show da0<br \/>\n=&gt;        34  1953525101  da0  GPT  (932G)<br \/>\n          34  1953525101       &#8211; free &#8211;  (932G)<br \/>\n<\/code>\n<p>I&#8217;m not sure if this smaller size is because 34 sectors are taken up by the partition table, or if it&#8217;s a cylinder-boundary thing.<\/p>\n<p>As the article recommends, I want to leave the first 1MB free (Windows does this, too). I also want to leave around 200MB free at the end of the disk (to allow for some slack in case I want to replace this disk). So, I have 1953525168 sectors (total) &#8211; 2048 sectors (1MB) &#8211; 409600 (200MB) = 1953113453 sectors:<\/p>\n<p><code><br \/>\nfbsd2# gpart add -b 2048 -s 1953113453 -t freebsd-zfs -l Hitachi_1TB da0<br \/>\nda0p1 added<br \/>\n<\/code><br \/>\n<code><br \/>\n# gpart show da0<br \/>\n=&gt;        34  1953525101  da0  GPT  (932G)<br \/>\n          34        2014       &#8211; free &#8211;  (1.0M)<br \/>\n        2048  1953113453    1  freebsd-zfs  (931G)<br \/>\n  1953115501      409634       &#8211; free &#8211;  (200M)<br \/>\n<\/code><\/p>\n<p>Looks good: the partition is 931GB large. I have 200MB of slack at the end, and it starts 1MB into the disk. Now, let&#8217;s replace the old glabel-based partition with this one:<\/p>\n<p><code><br \/>\n# zpool replace tank label\/hitachi_1tb gpt\/Hitachi_1TB<br \/>\n<\/code><br \/>\n<code><br \/>\n# zpool status<br \/>\n  pool: tank<br \/>\n state: DEGRADED<br \/>\nstatus: One or more devices is currently being resilvered.  The pool will<br \/>\n        continue to function, possibly in a degraded state.<br \/>\naction: Wait for the resilver to complete.<br \/>\n scrub: resilver in progress for 0h0m, 0.01% done, 95h54m to go<br \/>\nconfig:<\/p>\n<p>        NAME                     STATE     READ WRITE CKSUM<br \/>\n        tank                     DEGRADED     0     0     0<br \/>\n          raidz1                 DEGRADED     0     0     0<br \/>\n            label\/fantom_500gb   ONLINE       0     0     0  6.27M resilvered<br \/>\n            replacing            DEGRADED     0     0     0<br \/>\n              label\/hitachi_1tb  OFFLINE      0 1.83K     0<br \/>\n              gpt\/Hitachi_1TB    ONLINE       0     0     0  9.41M resilvered<br \/>\n            label\/fantom_1tb     ONLINE       0     0     0  6.25M resilvered<br \/>\n<\/code><\/p>\n<p>Pretty cool.<\/p>\n<div class='wp_likes' id='wp_likes_post-302'><a class='like' href=\"javascript:wp_likes.like(302);\" title='' ><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/tech.poojanblog.com\/blog\/wp-content\/plugins\/wp-likes\/images\/like.png\" alt='' border='0'\/><\/a><span class='text'>Be the first to like.<\/span><\/p>\n<div class='like' ><a href=\"javascript:wp_likes.like(302);\">Like<\/a><\/div>\n<div class='unlike' ><a href=\"javascript:wp_likes.unlike(302);\">Unlike<\/a><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Sometime ago, I setup a ZFS system using glabel on FreeBSD. I recently stumbled across this FreeBSD diary entry, which describes to do almost the same thing using gpt. I like this method better, because it results in a partition that is on a 4kB boundary, which works better for some hard drives (whose sector [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-302","post","type-post","status-publish","format-standard","hentry","category-un"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/posts\/302","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/comments?post=302"}],"version-history":[{"count":3,"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/posts\/302\/revisions"}],"predecessor-version":[{"id":304,"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/posts\/302\/revisions\/304"}],"wp:attachment":[{"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/media?parent=302"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/categories?post=302"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/tags?post=302"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}