{"id":3196,"date":"2020-04-09T10:46:16","date_gmt":"2020-04-09T15:46:16","guid":{"rendered":"http:\/\/www.incredigeek.com\/home\/?p=3196"},"modified":"2020-04-09T10:47:51","modified_gmt":"2020-04-09T15:47:51","slug":"ubuntu-expand-disk-space-command-line","status":"publish","type":"post","link":"https:\/\/www.incredigeek.com\/home\/ubuntu-expand-disk-space-command-line\/","title":{"rendered":"Ubuntu expand disk space &#8211; Command Line"},"content":{"rendered":"\n<p>Warning: Be extremely careful when making changes to partitions and disk as it can lead to broken systems and lost data.  Make sure you have a backup.<\/p>\n\n\n\n<p>This scenario is done on a basic Ubuntu install.  No fancy LVM stuff going on.  If you need that, refer to <a href=\"https:\/\/www.incredigeek.com\/home\/how-to-add-extra-space-to-linux-vm-in-xenserver\/\">here<\/a><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Disk \/dev\/sda: <strong>64 GiB<\/strong>, 68719476736 bytes, 134217728 sectors\nUnits: sectors of 1 * 512 = 512 bytes\nSector size (logical\/physical): 512 bytes \/ 512 bytes\nI\/O size (minimum\/optimal): 512 bytes \/ 512 bytes\nDisklabel type: dos\nDisk identifier: 0x2062ec28\nDevice     Boot    Start      End  Sectors  Size Id Type\n\/dev\/sda1  *        2048 65011711 65009664   <strong>31G<\/strong> 83 Linux\n\/dev\/sda2       65013758 67106815  2093058 1022M  5 Extended\n\/dev\/sda5       65013760 67106815  2093056 1022M 82 Linux swap \/ Solaris<\/pre>\n\n\n\n<p>From the above output of fdisk -l, we see that the disk has 64GiB available, but the primary partition is only 31G.  To make the primary partition larger we need to <\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Run fdisk &#8220;fdisk \/dev\/sda&#8221;<\/li><li>Delete partitions 2 and 5, <\/li><li>Delete Partition 1<\/li><li>Create Partition 1 again on the same starting boundary<\/li><li>Put the end boundary close to the end so we end up with ~62GiB for that partition<\/li><li>Recreate sda2, the 1GiB extended partition<\/li><li>Write changes to disk<\/li><li>Run resize2fs to resize the filesystem<\/li><\/ul>\n\n\n\n<p>You may need to boot up in recovery to get this command working.  Also if you boot up in recovery, you&#8217;ll need to remount the root \/ partition read\/write.  More info <a href=\"https:\/\/www.incredigeek.com\/home\/resize2fs-read-only-file-system-while-checking-for-on-line-resizing-support\/\">here<\/a>.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>resize2fs<\/code> \/dev\/sda1<\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>Helpful Links<br><a href=\"https:\/\/access.redhat.com\/articles\/1190213\">https:\/\/access.redhat.com\/articles\/1190213<\/a><br><a href=\"https:\/\/access.redhat.com\/articles\/1196353\">https:\/\/access.redhat.com\/articles\/1196353<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Warning: Be extremely careful when making changes to partitions and disk as it can lead to broken systems and lost data. Make sure you have a backup. This scenario is done on a basic Ubuntu install. No fancy LVM stuff &hellip; <a href=\"https:\/\/www.incredigeek.com\/home\/ubuntu-expand-disk-space-command-line\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,28],"tags":[401,87,965,395,90,399,960],"class_list":["post-3196","post","type-post","status-publish","format-standard","hentry","category-linux","category-ubuntu","tag-disk","tag-fdisk","tag-grow","tag-harddrive","tag-partition","tag-partitioning","tag-resize"],"_links":{"self":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/3196","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/comments?post=3196"}],"version-history":[{"count":2,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/3196\/revisions"}],"predecessor-version":[{"id":3208,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/3196\/revisions\/3208"}],"wp:attachment":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/media?parent=3196"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/categories?post=3196"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/tags?post=3196"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}