{"id":286,"date":"2025-09-29T12:16:45","date_gmt":"2025-09-29T10:16:45","guid":{"rendered":"https:\/\/34.75.207.203\/?p=286"},"modified":"2025-10-21T09:21:18","modified_gmt":"2025-10-21T07:21:18","slug":"extend-root-partition-ubuntu-24-04-lts-lvm","status":"publish","type":"post","link":"https:\/\/tillnet.se\/?p=286","title":{"rendered":"Extend root partition, Ubuntu 24.04 LTS, LVM"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">This applies to different scenarios but perhaps most common is a virtual machine which needs more disk space. This guide assumes you have extended the disk in your hypervisor.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Check disk by listing them with:<br><code>fdisk -l<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Partition size by running:<br><code>df -h<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If the new size isn&#8217;t listed\/shown, we have to scan for changes:<br><code>ls \/sys\/class\/scsi_device\/<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example output could be:<br><code>2:0:0:0\u00a0 3:0:0:0\u00a0 32:0:0:0<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The scan all devices individually:<br><code>echo 1 > \/sys\/class\/scsi_device\/2\\:0\\:0\\:0\/device\/rescan<br>echo 1 > \/sys\/class\/scsi_device\/3\\:0\\:0\\:0\/device\/rescan<br>echo 1 > \/sys\/class\/scsi_device\/32\\:0\\:0\\:0\/device\/rescan<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">After that we can use <code>cfdisk<\/code> to resize the root partition.<br>When you run that cmd you will enter that utility, use arrows to navigate.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Select ex. \/dev\/sda3 or your device for root partition.<\/li>\n\n\n\n<li>Select &#8220;Resize&#8221;.<\/li>\n\n\n\n<li>Select &#8220;Write&#8221;.<\/li>\n\n\n\n<li>Type &#8220;Yes&#8221;.<\/li>\n\n\n\n<li>Select &#8220;Quit&#8221; to exit.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Verify the changes by running:<br><code>fdisk -l<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The disk is now ok and we can move onto resizing the partition. Start utility:<br><code>parted<\/code><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Type &#8220;print&#8221; and enter. This lists the partitions.<\/li>\n\n\n\n<li>Type &#8220;resizepart&#8221; and enter. It asks you for the partition number, in my ex. &#8220;3&#8221; and enter.<\/li>\n\n\n\n<li>Type &#8220;quit&#8221; and enter.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Next, resize the physical volume:<br><code>pvresize \/dev\/sda3<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now, extend the logical volume (remember to edit to match your system):<br><code>lvextend -l +100%FREE \/dev\/mapper\/ubuntu--vg-ubuntu--lv<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Finally, run resize2fs to apply the changes:<br><code>resize2fs \/dev\/mapper\/ubuntu--vg-ubuntu--lv<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We are done. Verify free disk space with:<br><code>df -h<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This applies to different scenarios but perhaps most common is a virtual machine which needs more disk space. This guide assumes you have extended the &hellip;<\/p>\n","protected":false},"author":1,"featured_media":313,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-286","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-it"],"jetpack_featured_media_url":"https:\/\/tillnet.se\/wp-content\/uploads\/2025\/09\/linux-ubuntu-extend-disk-partition-more-disk-space-lvm.png","_links":{"self":[{"href":"https:\/\/tillnet.se\/index.php?rest_route=\/wp\/v2\/posts\/286","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tillnet.se\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tillnet.se\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tillnet.se\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tillnet.se\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=286"}],"version-history":[{"count":1,"href":"https:\/\/tillnet.se\/index.php?rest_route=\/wp\/v2\/posts\/286\/revisions"}],"predecessor-version":[{"id":287,"href":"https:\/\/tillnet.se\/index.php?rest_route=\/wp\/v2\/posts\/286\/revisions\/287"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/tillnet.se\/index.php?rest_route=\/wp\/v2\/media\/313"}],"wp:attachment":[{"href":"https:\/\/tillnet.se\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=286"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tillnet.se\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=286"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tillnet.se\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=286"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}