{"id":442,"date":"2016-05-22T14:04:52","date_gmt":"2016-05-22T13:04:52","guid":{"rendered":"http:\/\/www.flat-planet.net\/?p=442"},"modified":"2016-05-29T21:12:30","modified_gmt":"2016-05-29T20:12:30","slug":"taking-from-home-to-grow-the-root-partition","status":"publish","type":"post","link":"https:\/\/flat-planet.net\/?p=442","title":{"rendered":"Taking from \/home to grow the root partition"},"content":{"rendered":"<p>After a recent move from Wheezy to Jessie, the root partition was looking a little full &#8211; to the point where the GUI wasn&#8217;t working due to a lack of \/tmp space. So needed to take care of that while troubleshooting other issues.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n# df -h\r\nFilesystem\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Size\u00a0 Used Avail Use% Mounted on\r\n\/dev\/dm-0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 9.1G\u00a0 8.4G\u00a0 176M\u00a0 99% \/\r\nudev\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 10M\u00a0\u00a0\u00a0\u00a0 0\u00a0\u00a0 10M\u00a0\u00a0 0% \/dev\r\ntmpfs\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 402M\u00a0 6.5M\u00a0 396M\u00a0\u00a0 2% \/run\r\ntmpfs\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 1005M\u00a0\u00a0 68K 1005M\u00a0\u00a0 1% \/dev\/shm\r\ntmpfs\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 5.0M\u00a0 4.0K\u00a0 5.0M\u00a0\u00a0 1% \/run\/lock\r\ntmpfs\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 1005M\u00a0\u00a0\u00a0\u00a0 0 1005M\u00a0\u00a0 0% \/sys\/fs\/cgroup\r\n\/dev\/mapper\/thor-home\u00a0 904G\u00a0 511G\u00a0 347G\u00a0 60% \/home\r\n\/dev\/sde1\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 228M\u00a0\u00a0 47M\u00a0 170M\u00a0 22% \/boot\r\ntmpfs\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 201M\u00a0\u00a0\u00a0\u00a0 0\u00a0 201M\u00a0\u00a0 0% \/run\/user\/1024\r\ntmpfs\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 201M\u00a0 8.0K\u00a0 201M\u00a0\u00a0 1% \/run\/user\/1000\r\n<\/pre>\n<p>Given that there is plenty of room on the \/home partition and it&#8217;s all built on LVM, reallocating space from one to the other is fairly straightforward.<\/p>\n<p>While you can grow an EXT4 filesystem while it is mounted, you can&#8217;t shrink one &#8211; and given that \/home is constantly in use it was easier just to reboot into maintenance mode and take care of things that way.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n# Unmount the home partition\r\numount \/mnt\/home\r\n# Check the filesystem to make sure it is clean\r\ne2fsck -F \/dev\/mapper\/thor-home\r\n\r\n# Shrink the filesystem to the desired size - in this case I'm reducing it to 880G\r\nresize2fs -p \/dev\/mapper\/thor-home 880G\r\n\r\n# Shrink the logical volume to match\r\nlvreduce -L 880G \/dev\/mapper\/thor-home\r\n\r\n# Check the file system again. If there are problems because the partition is too small, we\r\n# can still recover by using lvextend until it succeeds e.g. lvextend -L +1G \/dev\/mapper\/thor-home\r\ne2fsck -F \/dev\/mapper\/thor-home\r\n<\/pre>\n<p>That was the dangerous part. Extending the root filesystem to use the newly freed space is quite simple, but this time we are first growing the logical volume, then expanding the filesystem<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n# Extend the logical volume to use all the free space\r\nlvextend -l +100%FREE \/dev\/mapper\/thor-root\r\n# Expand the filesystem\r\nresize2fs -p \/dev\/mapper\/thor-root\r\n<\/pre>\n<p>At this point a scan of the filesystem is a good idea, but unfortunately we can&#8217;t do that to a mounted filesystem, so instead we can trigger the check on reboot<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ntouch \/forcefsck\r\n<\/pre>\n<p>But in the meantime we can see that the root partition now has plenty of space<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n# df -h\r\nFilesystem\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Size\u00a0 Used Avail Use% Mounted on\r\n\/dev\/dm-0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 47G\u00a0 8.8G\u00a0\u00a0 36G\u00a0 20% \/\r\nudev\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 10M\u00a0\u00a0\u00a0\u00a0 0\u00a0\u00a0 10M\u00a0\u00a0 0% \/dev\r\ntmpfs\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 402M\u00a0 6.5M\u00a0 396M\u00a0\u00a0 2% \/run\r\ntmpfs\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 1005M\u00a0\u00a0 68K 1005M\u00a0\u00a0 1% \/dev\/shm\r\ntmpfs\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 5.0M\u00a0 4.0K\u00a0 5.0M\u00a0\u00a0 1% \/run\/lock\r\ntmpfs\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 1005M\u00a0\u00a0\u00a0\u00a0 0 1005M\u00a0\u00a0 0% \/sys\/fs\/cgroup\r\n\/dev\/mapper\/thor-home\u00a0 867G\u00a0 506G\u00a0 317G\u00a0 62% \/home\r\n\/dev\/sdb1\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 228M\u00a0\u00a0 47M\u00a0 170M\u00a0 22% \/boot\r\ntmpfs\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 201M\u00a0\u00a0\u00a0\u00a0 0\u00a0 201M\u00a0\u00a0 0% \/run\/user\/1024\r\ntmpfs\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 201M\u00a0 4.0K\u00a0 201M\u00a0\u00a0 1% \/run\/user\/1000\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>After a recent move from Wheezy to Jessie, the root partition was looking a little full &#8211; to the point where the GUI wasn&#8217;t working due to a lack of \/tmp space. So needed to take care of that while troubleshooting other issues. # df -h Filesystem\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Size\u00a0 Used Avail Use% Mounted on \/dev\/dm-0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 9.1G\u00a0 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[38],"tags":[273,274,275,42,268,269,270,271,272],"series":[],"class_list":["post-442","post","type-post","status-publish","format-standard","hentry","category-linux","tag-shrinking","tag-resizing","tag-sysadmin","tag-linux-2","tag-lvm","tag-ext4","tag-root-partition","tag-partitions","tag-expanding"],"_links":{"self":[{"href":"https:\/\/flat-planet.net\/index.php?rest_route=\/wp\/v2\/posts\/442","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/flat-planet.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/flat-planet.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/flat-planet.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/flat-planet.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=442"}],"version-history":[{"count":5,"href":"https:\/\/flat-planet.net\/index.php?rest_route=\/wp\/v2\/posts\/442\/revisions"}],"predecessor-version":[{"id":448,"href":"https:\/\/flat-planet.net\/index.php?rest_route=\/wp\/v2\/posts\/442\/revisions\/448"}],"wp:attachment":[{"href":"https:\/\/flat-planet.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=442"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/flat-planet.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=442"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/flat-planet.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=442"},{"taxonomy":"series","embeddable":true,"href":"https:\/\/flat-planet.net\/index.php?rest_route=%2Fwp%2Fv2%2Fseries&post=442"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}