{"id":374,"date":"2018-01-28T20:08:28","date_gmt":"2018-01-28T13:08:28","guid":{"rendered":"http:\/\/www.st.ac.th\/krubuncha\/?p=374"},"modified":"2018-01-28T20:08:28","modified_gmt":"2018-01-28T13:08:28","slug":"%e0%b8%81%e0%b8%b2%e0%b8%a3%e0%b9%80%e0%b8%9e%e0%b8%b4%e0%b9%88%e0%b8%a1%e0%b8%82%e0%b8%99%e0%b8%b2%e0%b8%94%e0%b8%82%e0%b8%ad%e0%b8%87-harddisk-%e0%b8%9a%e0%b8%99-freebsd","status":"publish","type":"post","link":"https:\/\/www.st.ac.th\/krubuncha\/%e0%b8%81%e0%b8%b2%e0%b8%a3%e0%b9%80%e0%b8%9e%e0%b8%b4%e0%b9%88%e0%b8%a1%e0%b8%82%e0%b8%99%e0%b8%b2%e0%b8%94%e0%b8%82%e0%b8%ad%e0%b8%87-harddisk-%e0%b8%9a%e0%b8%99-freebsd\/","title":{"rendered":"\u0e01\u0e32\u0e23\u0e40\u0e1e\u0e34\u0e48\u0e21\u0e02\u0e19\u0e32\u0e14\u0e02\u0e2d\u0e07 HardDisk \u0e1a\u0e19 FreeBSD"},"content":{"rendered":"<div class=\"titlepage\">\n<div>\n<div>\n<h2 class=\"title\">\nResizing and Growing Disks<\/h2>\n<\/div>\n<div><span class=\"authorgroup\">\u0e17\u0e35\u0e48\u0e21\u0e32 <a href=\"https:\/\/www.freebsd.org\/doc\/handbook\/disks-growing.html\">https:\/\/www.freebsd.org\/doc\/handbook\/disks-growing.html<\/a><br \/>\nOriginally contributed by\u00a0<span class=\"author\"><span class=\"firstname\">Allan<\/span>\u00a0<span class=\"surname\">Jude<\/span><\/span>.<\/span><\/div>\n<\/div>\n<\/div>\n<p>A disk&#8217;s capacity can increase without any changes to the data already present. This happens commonly with virtual machines, when the virtual disk turns out to be too small and is enlarged. Sometimes a disk image is written to a\u00a0<acronym class=\"acronym\">USB<\/acronym>\u00a0memory stick, but does not use the full capacity. Here we describe how to resize or\u00a0<span class=\"emphasis\"><em>grow<\/em><\/span>\u00a0disk contents to take advantage of increased capacity.<\/p>\n<p>Determine the device name of the disk to be resized by inspecting\u00a0<code class=\"filename\">\/var\/run\/dmesg.boot<\/code>. In this example, there is only one\u00a0<acronym class=\"acronym\">SATA<\/acronym>\u00a0disk in the system, so the drive will appear as\u00a0<code class=\"filename\">ada0<\/code>.<\/p>\n<p>List the partitions on the disk to see the current configuration:<\/p>\n<pre class=\"screen\"><code class=\"prompt\">#<\/code> <strong class=\"userinput\"><code>gpart show <em class=\"replaceable\">ada0<\/em><\/code><\/strong> =&gt; 34 83886013 ada0 GPT (48G) [CORRUPT] 34 128 1 freebsd-boot (64k) 162 79691648 2 freebsd-ufs (38G) 79691810 4194236 3 freebsd-swap (2G) 83886046 1 - free - (512B)<\/pre>\n<div class=\"note\">\n<h3 class=\"admontitle\">Note:<\/h3>\n<p>If the disk was formatted with the\u00a0<a class=\"link\" href=\"http:\/\/en.wikipedia.org\/wiki\/GUID_Partition_Table\" target=\"_top\"><acronym class=\"acronym\">GPT<\/acronym><\/a>\u00a0partitioning scheme, it may show as\u00a0<span class=\"quote\">\u201ccorrupted\u201d<\/span>\u00a0because the\u00a0<acronym class=\"acronym\">GPT<\/acronym>\u00a0backup partition table is no longer at the end of the drive. Fix the backup partition table with\u00a0<code class=\"command\">gpart<\/code>:<\/p>\n<pre class=\"screen\"><code class=\"prompt\">#<\/code> <strong class=\"userinput\"><code>gpart recover <em class=\"replaceable\">ada0<\/em><\/code><\/strong> ada0 recovered<\/pre>\n<\/div>\n<p>Now the additional space on the disk is available for use by a new partition, or an existing partition can be expanded:<\/p>\n<pre class=\"screen\"><code class=\"prompt\">#<\/code> <strong class=\"userinput\"><code>gpart show <em class=\"replaceable\">ada0<\/em><\/code><\/strong> =&gt; 34 102399933 ada0 GPT (48G) 34 128 1 freebsd-boot (64k) 162 79691648 2 freebsd-ufs (38G) 79691810 4194236 3 freebsd-swap (2G) 83886046 18513921 - free - (8.8G)<\/pre>\n<p>Partitions can only be resized into contiguous free space. Here, the last partition on the disk is the swap partition, but the second partition is the one that needs to be resized. Swap partitions only contain temporary data, so it can safely be unmounted, deleted, and then recreated after resizing other partitions.<\/p>\n<pre class=\"screen\"><code class=\"prompt\">#<\/code> <strong class=\"userinput\"><code>swapoff <em class=\"replaceable\">\/dev\/ada0p3<\/em><\/code><\/strong> <code class=\"prompt\">#<\/code> <strong class=\"userinput\"><code>gpart delete -i <em class=\"replaceable\">3<\/em> <em class=\"replaceable\">ada0<\/em><\/code><\/strong> ada0p3 deleted <code class=\"prompt\">#<\/code> <strong class=\"userinput\"><code>gpart show <em class=\"replaceable\">ada0<\/em><\/code><\/strong> =&gt; 34 102399933 ada0 GPT (48G) 34 128 1 freebsd-boot (64k) 162 79691648 2 freebsd-ufs (38G) 79691810 22708157 - free - (10G)<\/pre>\n<div class=\"warning\">\n<h3 class=\"admontitle\">Warning:<\/h3>\n<p>There is risk of data loss when modifying the partition table of a mounted file system. It is best to perform the following steps on an unmounted file system while running from a live\u00a0<acronym class=\"acronym\">CD-ROM<\/acronym>\u00a0or\u00a0<acronym class=\"acronym\">USB<\/acronym>\u00a0device. However, if absolutely necessary, a mounted file system can be resized after disabling GEOM safety features:<\/p>\n<pre class=\"screen\"><code class=\"prompt\">#<\/code> <strong class=\"userinput\"><code>sysctl kern.geom.debugflags=16<\/code><\/strong><\/pre>\n<\/div>\n<p>Resize the partition, leaving room to recreate a swap partition of the desired size. This only modifies the size of the partition. The file system in the partition will be expanded in a separate step.<\/p>\n<pre class=\"screen\"><code class=\"prompt\">#<\/code> <strong class=\"userinput\"><code>gpart resize -i <em class=\"replaceable\">2<\/em> -a 4k -s <em class=\"replaceable\">47G<\/em> <em class=\"replaceable\">ada0<\/em><\/code><\/strong> ada0p2 resized <code class=\"prompt\">#<\/code> <strong class=\"userinput\"><code>gpart show <em class=\"replaceable\">ada0<\/em><\/code><\/strong> =&gt; 34 102399933 ada0 GPT (48G) 34 128 1 freebsd-boot (64k) 162 98566144 2 freebsd-ufs (47G) 98566306 3833661 - free - (1.8G)<\/pre>\n<p>Recreate the swap partition:<\/p>\n<pre class=\"screen\"><code class=\"prompt\">#<\/code> <strong class=\"userinput\"><code>gpart add -t freebsd-swap -a 4k <em class=\"replaceable\">ada0<\/em><\/code><\/strong> ada0p3 added <code class=\"prompt\">#<\/code> <strong class=\"userinput\"><code>gpart show <em class=\"replaceable\">ada0<\/em><\/code><\/strong> =&gt; 34 102399933 ada0 GPT (48G) 34 128 1 freebsd-boot (64k) 162 98566144 2 freebsd-ufs (47G) 98566306 3833661 3 freebsd-swap (1.8G) <code class=\"prompt\">#<\/code> <strong class=\"userinput\"><code>swapon <em class=\"replaceable\">\/dev\/ada0p3<\/em><\/code><\/strong><\/pre>\n<p>Grow the\u00a0<acronym class=\"acronym\">UFS<\/acronym>\u00a0file system to use the new capacity of the resized partition:<\/p>\n<div class=\"note\">\n<h3 class=\"admontitle\">Note:<\/h3>\n<p>Growing a live\u00a0<acronym class=\"acronym\">UFS<\/acronym>\u00a0file system is only possible in FreeBSD 10.0-RELEASE and later. For earlier versions, the file system must not be mounted.<\/p>\n<\/div>\n<pre class=\"screen\"><code class=\"prompt\">#<\/code> <strong class=\"userinput\"><code>growfs <em class=\"replaceable\">\/dev\/ada0p2<\/em><\/code><\/strong> Device is mounted read-write; resizing will result in temporary write suspension for \/. It's strongly recommended to make a backup before growing the file system. OK to grow file system on \/dev\/ada0p2, mounted on \/, from 38GB to 47GB? [Yes\/No] <strong class=\"userinput\"><code>Yes<\/code><\/strong> super-block backups (for fsck -b #) at: 80781312, 82063552, 83345792, 84628032, 85910272, 87192512, 88474752, 89756992, 91039232, 92321472, 93603712, 94885952, 96168192, 97450432<\/pre>\n<p>Both the partition and the file system on it have now been resized to use the newly-available disk space.<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>Resizing and Growing Disks \u0e17\u0e35\u0e48\u0e21\u0e32 https:\/\/www.freebsd.org\/doc\/handbook\/disks-growing.html Originally contributed by\u00a0Allan\u00a0Jude. A disk&#8217;s capacity can increase without any changes to the data already present. This happens commonly <a class=\"mh-excerpt-more\" href=\"https:\/\/www.st.ac.th\/krubuncha\/%e0%b8%81%e0%b8%b2%e0%b8%a3%e0%b9%80%e0%b8%9e%e0%b8%b4%e0%b9%88%e0%b8%a1%e0%b8%82%e0%b8%99%e0%b8%b2%e0%b8%94%e0%b8%82%e0%b8%ad%e0%b8%87-harddisk-%e0%b8%9a%e0%b8%99-freebsd\/\" title=\"\u0e01\u0e32\u0e23\u0e40\u0e1e\u0e34\u0e48\u0e21\u0e02\u0e19\u0e32\u0e14\u0e02\u0e2d\u0e07 HardDisk \u0e1a\u0e19 FreeBSD\">[\u0e2d\u0e48\u0e32\u0e19\u0e15\u0e48\u0e2d]<\/a><\/p>\n<\/div>","protected":false},"author":1,"featured_media":311,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"footnotes":""},"categories":[3],"tags":[],"class_list":["post-374","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category--freebsd"],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/www.st.ac.th\/krubuncha\/wp-content\/uploads\/sites\/19\/2015\/02\/freebsd-logo2-e1470190174543.jpg?fit=200%2C200&ssl=1","blog_post_layout_featured_media_urls":{"thumbnail":["https:\/\/i0.wp.com\/www.st.ac.th\/krubuncha\/wp-content\/uploads\/sites\/19\/2015\/02\/freebsd-logo2-e1470190174543.jpg?resize=150%2C150&ssl=1",150,150,true],"full":["https:\/\/i0.wp.com\/www.st.ac.th\/krubuncha\/wp-content\/uploads\/sites\/19\/2015\/02\/freebsd-logo2-e1470190174543.jpg?fit=200%2C200&ssl=1",200,200,false]},"categories_names":{"3":{"name":"\u0e1a\u0e31\u0e19\u0e17\u0e36\u0e01\u0e0a\u0e48\u0e27\u0e22\u0e08\u0e33 FreeBSD","link":"https:\/\/www.st.ac.th\/krubuncha\/category\/%e0%b8%9a%e0%b8%b1%e0%b8%99%e0%b8%97%e0%b8%b6%e0%b8%81%e0%b8%8a%e0%b9%88%e0%b8%a7%e0%b8%a2%e0%b8%88%e0%b8%b3-freebsd\/"}},"tags_names":[],"comments_number":0,"wpmagazine_modules_lite_featured_media_urls":{"thumbnail":["https:\/\/i0.wp.com\/www.st.ac.th\/krubuncha\/wp-content\/uploads\/sites\/19\/2015\/02\/freebsd-logo2-e1470190174543.jpg?resize=150%2C150&ssl=1",150,150,true],"cvmm-medium":["https:\/\/i0.wp.com\/www.st.ac.th\/krubuncha\/wp-content\/uploads\/sites\/19\/2015\/02\/freebsd-logo2-e1470190174543.jpg?resize=200%2C200&ssl=1",200,200,true],"cvmm-medium-plus":["https:\/\/i0.wp.com\/www.st.ac.th\/krubuncha\/wp-content\/uploads\/sites\/19\/2015\/02\/freebsd-logo2-e1470190174543.jpg?resize=200%2C200&ssl=1",200,200,true],"cvmm-portrait":["https:\/\/i0.wp.com\/www.st.ac.th\/krubuncha\/wp-content\/uploads\/sites\/19\/2015\/02\/freebsd-logo2-e1470190174543.jpg?resize=200%2C200&ssl=1",200,200,true],"cvmm-medium-square":["https:\/\/i0.wp.com\/www.st.ac.th\/krubuncha\/wp-content\/uploads\/sites\/19\/2015\/02\/freebsd-logo2-e1470190174543.jpg?resize=200%2C200&ssl=1",200,200,true],"cvmm-large":["https:\/\/i0.wp.com\/www.st.ac.th\/krubuncha\/wp-content\/uploads\/sites\/19\/2015\/02\/freebsd-logo2-e1470190174543.jpg?resize=200%2C200&ssl=1",200,200,true],"cvmm-small":["https:\/\/i0.wp.com\/www.st.ac.th\/krubuncha\/wp-content\/uploads\/sites\/19\/2015\/02\/freebsd-logo2-e1470190174543.jpg?resize=130%2C95&ssl=1",130,95,true],"full":["https:\/\/i0.wp.com\/www.st.ac.th\/krubuncha\/wp-content\/uploads\/sites\/19\/2015\/02\/freebsd-logo2-e1470190174543.jpg?fit=200%2C200&ssl=1",200,200,false]},"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p5Mvvj-62","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/www.st.ac.th\/krubuncha\/wp-json\/wp\/v2\/posts\/374","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.st.ac.th\/krubuncha\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.st.ac.th\/krubuncha\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.st.ac.th\/krubuncha\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.st.ac.th\/krubuncha\/wp-json\/wp\/v2\/comments?post=374"}],"version-history":[{"count":2,"href":"https:\/\/www.st.ac.th\/krubuncha\/wp-json\/wp\/v2\/posts\/374\/revisions"}],"predecessor-version":[{"id":376,"href":"https:\/\/www.st.ac.th\/krubuncha\/wp-json\/wp\/v2\/posts\/374\/revisions\/376"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.st.ac.th\/krubuncha\/wp-json\/wp\/v2\/media\/311"}],"wp:attachment":[{"href":"https:\/\/www.st.ac.th\/krubuncha\/wp-json\/wp\/v2\/media?parent=374"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.st.ac.th\/krubuncha\/wp-json\/wp\/v2\/categories?post=374"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.st.ac.th\/krubuncha\/wp-json\/wp\/v2\/tags?post=374"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}