{"id":399,"date":"2024-01-07T22:24:00","date_gmt":"2024-01-07T20:24:00","guid":{"rendered":"https:\/\/pauli.work\/?p=399"},"modified":"2025-01-02T22:25:26","modified_gmt":"2025-01-02T20:25:26","slug":"lvm-disk-resizing-without-reboot","status":"publish","type":"post","link":"https:\/\/pauli.work\/?p=399","title":{"rendered":"LVM disk resizing, without reboot."},"content":{"rendered":"\n<p>Or I wished&#8230; <\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 0: Safety Third:<\/h3>\n\n\n\n<p>First I backed up VM. I can be a bit monkey brain so critical step.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"862\" height=\"210\" src=\"https:\/\/pauli.work\/wp-content\/uploads\/2025\/01\/image.png\" alt=\"\" class=\"wp-image-400\" srcset=\"https:\/\/pauli.work\/wp-content\/uploads\/2025\/01\/image.png 862w, https:\/\/pauli.work\/wp-content\/uploads\/2025\/01\/image-300x73.png 300w, https:\/\/pauli.work\/wp-content\/uploads\/2025\/01\/image-768x187.png 768w\" sizes=\"auto, (max-width: 862px) 100vw, 862px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Step 1: Changes in the file system:<\/h3>\n\n\n\n<p>VM off and added 10gb to the disk<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"696\" height=\"277\" src=\"https:\/\/pauli.work\/wp-content\/uploads\/2025\/01\/image-1.png\" alt=\"\" class=\"wp-image-401\" srcset=\"https:\/\/pauli.work\/wp-content\/uploads\/2025\/01\/image-1.png 696w, https:\/\/pauli.work\/wp-content\/uploads\/2025\/01\/image-1-300x119.png 300w\" sizes=\"auto, (max-width: 696px) 100vw, 696px\" \/><\/figure>\n\n\n\n<p>After booting VM we can verify that the disk has become bigger<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>root@bitwarden ~# <strong>lsblk<\/strong>\nNAME\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 MAJ:MIN RM\u00a0 SIZE RO TYPE MOUNTPOINT\nsda\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 8:0\u00a0\u00a0\u00a0 0\u00a0\u00a0 35G\u00a0 0 disk\n\u251c\u2500sda1\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 8:1\u00a0\u00a0\u00a0 0\u00a0\u00a0\u00a0 1M\u00a0 0 part\n\u251c\u2500sda2\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 8:2\u00a0\u00a0\u00a0 0\u00a0\u00a0\u00a0 1G\u00a0 0 part \/boot\n\u2514\u2500sda3\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 8:3\u00a0\u00a0\u00a0 0\u00a0\u00a0 24G\u00a0 0 part\n\u00a0 \u2514\u2500ubuntu--vg-ubuntu--lv 253:0\u00a0\u00a0\u00a0 0\u00a0\u00a0 20G\u00a0 0 lvm\u00a0 \/\nroot@bitwarden ~# <strong>fdisk -l \/dev\/sda<\/strong>\nGPT PMBR size mismatch (52428799 != 73400319) will be corrected by write.\nThe backup GPT table is not on the end of the device. This problem will be corrected by write.\nDisk \/dev\/sda: 35 GiB, 37580963840 bytes, 73400320 sectors\nDisk model: QEMU HARDDISK\u00a0\u00a0\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: gpt\nDisk identifier: 16DB24D7-666C-459B-A2A3-89FCD57DDD3F\n\nDevice\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Start\u00a0\u00a0\u00a0\u00a0\u00a0 End\u00a0 Sectors Size Type\n\/dev\/sda1\u00a0\u00a0\u00a0\u00a0 2048\u00a0\u00a0\u00a0\u00a0 4095\u00a0\u00a0\u00a0\u00a0 2048\u00a0\u00a0 1M BIOS boot\n\/dev\/sda2\u00a0\u00a0\u00a0\u00a0 4096\u00a0 2101247\u00a0 2097152\u00a0\u00a0 1G Linux filesystem\n\/dev\/sda3\u00a0 2101248 52426751 50325504\u00a0 24G Linux filesystem\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Step 2: We delete everything<\/h3>\n\n\n\n<p>2.1.2025: I recommend to use cfdisk instead now. Since resizing is simpler with cf disk. <code># cfdisk \/dev\/sda<\/code> -&gt; resize (Will select the highest capacity) -&gt; write (confirm with yes)<\/p>\n\n\n\n<pre class=\"wp-block-code has-d-4-d-4-d-4-color has-text-color has-875-rem-font-size\"><code>root@bitwarden ~# <strong>fdisk \/dev\/sda<\/strong>\n... truncated output ...\nGPT PMBR size mismatch (52428799 != 73400319) will be corrected by write.\nThe backup GPT table is not on the end of the device. This problem will be corrected by write.\n\n<strong>Command (m for help): p<\/strong>\n\nDisk \/dev\/sda: 35 GiB, 37580963840 bytes, 73400320 sectors\nDisk model: QEMU HARDDISK\u00a0\u00a0\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: gpt\nDisk identifier: 16DB24D7-666C-459B-A2A3-89FCD57DDD3F\n\nDevice\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Start\u00a0\u00a0\u00a0\u00a0\u00a0 End\u00a0 Sectors Size Type\n\/dev\/sda1\u00a0\u00a0\u00a0\u00a0 2048\u00a0\u00a0\u00a0\u00a0 4095\u00a0\u00a0\u00a0\u00a0 2048\u00a0\u00a0 1M BIOS boot\n\/dev\/sda2\u00a0\u00a0\u00a0\u00a0 4096\u00a0 2101247\u00a0 2097152\u00a0\u00a0 1G Linux filesystem\n\/dev\/sda3\u00a0 2101248 52426751 50325504\u00a0 24G Linux filesystem\n\n<strong>Command (m for help): d<\/strong>\nPartition number (1-3, default 3): 3\n\nPartition 3 has been deleted.\n\n<strong>Command (m for help): n<\/strong>\nPartition number (3-128, default 3):\nFirst sector (2101248-73400286, default 2101248):\nLast sector, +\/-sectors or +\/-size{K,M,G,T,P} (2101248-73400286, default 73400286):\n\nCreated a new partition 3 of type 'Linux filesystem' and of size 34 GiB.\nPartition #3 contains a LVM2_member signature.\n\n<strong>Do you want to remove the signature? &#91;Y]es\/&#91;N]o: N<\/strong>\n\n<\/code><\/pre>\n\n\n\n<p>Answer no, or it will delete everything. I messed up here and deleted everything. Had to recover from a backup.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>Command (m for help): f<\/strong>\nf: unknown command\n<strong>\nCommand (m for help): t<\/strong>\nPartition number (1-3, default 3):\nPartition type (type L to list all types): 31\n\nChanged type of partition 'Linux filesystem' to 'Linux LVM'.\n<strong>\nCommand (m for help): w<\/strong>\nThe partition table has been altered.\nSyncing disks.\nroot@bitwarden ~#<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Step 3: Resizing LVM<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>root@bitwarden ~# <strong>partprobe \/dev\/sda<\/strong>\nroot@bitwarden ~# <strong>vgs<\/strong>\n&nbsp; VG&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #PV #LV #SN Attr&nbsp;&nbsp; VSize&nbsp;&nbsp; VFree\n&nbsp; ubuntu-vg&nbsp;&nbsp; 1&nbsp;&nbsp; 1&nbsp;&nbsp; 0 wz--n- &lt;<strong>24.00g<\/strong> &lt;4.00g\nroot@bitwarden ~# <strong>pvresize \/dev\/sda3<\/strong>\n&nbsp; Physical volume \"\/dev\/sda3\" changed\n&nbsp; 1 physical volume(s) resized or updated \/ 0 physical volume(s) not resized\nroot@bitwarden ~# <strong>vgs<\/strong>\n&nbsp; VG&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #PV #LV #SN Attr&nbsp;&nbsp; VSize&nbsp;&nbsp; VFree&nbsp;\n&nbsp; ubuntu-vg&nbsp;&nbsp; 1&nbsp;&nbsp; 1&nbsp;&nbsp; 0 wz--n- &lt;<strong>34.00g<\/strong> &lt;14.00g\nroot@bitwarden ~# <strong>lvresize -l +100%FREE \/dev\/mapper\/ubuntu--vg-ubuntu--lv<\/strong>\n&nbsp; Size of logical volume ubuntu-vg\/ubuntu-lv changed from 20.00 GiB (5120 extents) to &lt;<strong>34.00<\/strong> GiB (8703 extents).\n&nbsp; Logical volume ubuntu-vg\/ubuntu-lv successfully resized.\nroot@bitwarden ~# pvs\n&nbsp; PV&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; VG&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Fmt&nbsp; Attr PSize&nbsp;&nbsp; PFree\n&nbsp; \/dev\/sda3&nbsp; ubuntu-vg lvm2 a--&nbsp; &lt;<strong>34.00g<\/strong>&nbsp;&nbsp;&nbsp; 0\nroot@bitwarden ~#<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Step 4: And now for the magic<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>root@bitwarden ~# <strong>resize2fs \/dev\/mapper\/ubuntu--vg-ubuntu--lv<\/strong>\nresize2fs 1.45.5 (07-Jan-2020)\nFilesystem at \/dev\/mapper\/ubuntu--vg-ubuntu--lv is mounted on \/; on-line resizing required\nold_desc_blocks = 3, new_desc_blocks = 5\nThe filesystem on \/dev\/mapper\/ubuntu--vg-ubuntu-t-lv is now 8911872 (4k) blocks long.\n\nroot@bitwarden ~# <strong>df -h \/<\/strong>\nFilesystem&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Size&nbsp; Used Avail Use% Mounted on\n\/dev\/mapper\/ubuntu--vg-ubuntu--lv&nbsp;&nbsp; 34G&nbsp;&nbsp; 17G&nbsp;&nbsp; 16G&nbsp; 52% \/\nroot@bitwarden ~#<\/code><\/pre>\n\n\n\n<p>And now we can enjoy larger disk.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Ending Notes<\/h2>\n\n\n\n<p>I have truncated some command outputs for example lsblk displays docker containers and tmpfs but I have removed them.<\/p>\n\n\n\n<p>2.1.2025: Needed this again, decided to put here since search it here first, after realizing it in my nextcloud. Rewrote some bits and made better <em>flow<\/em>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Sources<\/h3>\n\n\n\n<p>Help from <a href=\"https:\/\/linuxhandbook.com\/resize-lvm-partition\/\"><u>https:\/\/linuxhandbook.com\/resize-lvm-partition\/<\/u><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Or I wished&#8230; Step 0: Safety Third: First I backed up VM. I can be a bit monkey brain so critical step. Step 1: Changes in the file system: VM off and added 10gb to the disk After booting VM we can verify that the disk has become bigger Step 2: We delete everything 2.1.2025: [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":406,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[20,18,17,21,12,13,19],"class_list":["post-399","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","tag-disk-resize","tag-fs-resize","tag-lvm","tag-lvm-resize","tag-proxmox","tag-pve","tag-ubuntu"],"_links":{"self":[{"href":"https:\/\/pauli.work\/index.php?rest_route=\/wp\/v2\/posts\/399","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pauli.work\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pauli.work\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pauli.work\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pauli.work\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=399"}],"version-history":[{"count":6,"href":"https:\/\/pauli.work\/index.php?rest_route=\/wp\/v2\/posts\/399\/revisions"}],"predecessor-version":[{"id":408,"href":"https:\/\/pauli.work\/index.php?rest_route=\/wp\/v2\/posts\/399\/revisions\/408"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/pauli.work\/index.php?rest_route=\/wp\/v2\/media\/406"}],"wp:attachment":[{"href":"https:\/\/pauli.work\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=399"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pauli.work\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=399"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pauli.work\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=399"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}