{"id":559,"date":"2024-10-25T09:10:39","date_gmt":"2024-10-25T15:10:39","guid":{"rendered":"https:\/\/www.scottharvanek.com\/?p=559"},"modified":"2024-10-25T09:10:39","modified_gmt":"2024-10-25T15:10:39","slug":"extending-an-lvm-xfs-mount-partition-online-in-rocky-linux","status":"publish","type":"post","link":"https:\/\/www.scottharvanek.com\/?p=559","title":{"rendered":"Extending an LVM \/ XFS mount\/partition online in Rocky Linux"},"content":{"rendered":"\n<p>Scenario: You have a VM and you&#8217;ve increased the disk size in the hypervisor and want to extend the LVM and partition in the guest.<\/p>\n\n\n\n<p><strong>LVM is the last partition so we can grow it versus creating a new partition and adding it to the VolGroup:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>(parted) p                                                                \nModel: Xen Virtual Block Device (xvd)\nDisk \/dev\/xvda: 335544320s\nSector size (logical\/physical): 512B\/512B\nPartition Table: msdos\nDisk Flags: \n\nNumber  Start     End         Size        Type     File system  Flags\n 1      2048s     2099199s    2097152s    primary  xfs          boot\n 2      2099200s  167772159s  165672960s  primary               lvm<\/code><\/pre>\n\n\n\n<p><strong>The easiest way to extend this is via the growpart tool, found in the <code>cloud-utils-growpart<\/code> package in AppStream<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>dnf install cloud-utils-growpart\nLast metadata expiration check: 3:13:02 ago on Fri 25 Oct 2024 04:47:25 AM MST.\nDependencies resolved.\n==============================================================================\n Package                                                                               Architecture                                                            Version                                                                      Repository                                                                  Size\n==============================================================================\nInstalling:\n cloud-utils-growpart                                                                  noarch                                                                  0.33-0.el8                                                                   appstream                                                                   35 k\n\nTransaction Summary\n==============================================================================\nInstall  1 Package\n\nTotal download size: 35 k\nInstalled size: 75 k\nIs this ok &#91;y\/N]: y\nDownloading Packages:\ncloud-utils-growpart-0.33-0.el8.noarch.rpm                                                                                                                                                                                                                                                    78 kB\/s |  35 kB     00:00    \n------------------------------------------------------------------------------\nTotal                                                                                                                                                                                                                                                                                         47 kB\/s |  35 kB     00:00     \nRunning transaction check\nTransaction check succeeded.\nRunning transaction test\nTransaction test succeeded.\nRunning transaction\n  Preparing        :                                                                                                                                                                                                                                                                                                     1\/1 \n  Installing       : cloud-utils-growpart-0.33-0.el8.noarch                                                                                                                                                                                                                                                              1\/1 \n  Running scriptlet: cloud-utils-growpart-0.33-0.el8.noarch                                                                                                                                                                                                                                                              1\/1 \n  Verifying        : cloud-utils-growpart-0.33-0.el8.noarch                                                                                                                                                                                                                                                              1\/1 \n\nInstalled:\n  cloud-utils-growpart-0.33-0.el8.noarch                                                                                                                                                                                                                                                                                     \n\nComplete!<\/code><\/pre>\n\n\n\n<p><strong>Now extend partition #2 with the tool:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>growpart \/dev\/xvda 2\nCHANGED: partition=2 start=2099200 old: size=165672960 end=167772159 new: size=333445087 end=335544286<\/code><\/pre>\n\n\n\n<p><strong>That&#8217;s it, the partition is now extended, next up, extend the LV:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>lvextend -l +100%FREE \/dev\/mapper\/rl-root \n  Size of logical volume rl\/root changed from &lt;71.12 GiB (18206 extents) to &lt;151.12 GiB (38686 extents).\n  Logical volume rl\/root successfully resized.<\/code><\/pre>\n\n\n\n<p><strong>Finally grow the XFS file system via xfs_growfs<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>xfs_growfs \/\nmeta-data=\/dev\/mapper\/rl-root    isize=512    agcount=4, agsize=4660736 blks\n         =                       sectsz=512   attr=2, projid32bit=1\n         =                       crc=1        finobt=1, sparse=1, rmapbt=0\n         =                       reflink=1    bigtime=0 inobtcount=0\ndata     =                       bsize=4096   blocks=18642944, imaxpct=25\n         =                       sunit=0      swidth=0 blks\nnaming   =version 2              bsize=4096   ascii-ci=0, ftype=1\nlog      =internal log           bsize=4096   blocks=9103, version=2\n         =                       sectsz=512   sunit=0 blks, lazy-count=1\nrealtime =none                   extsz=4096   blocks=0, rtextents=0\ndata blocks changed from 18642944 to 39614464\n<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Scenario: You have a VM and you&#8217;ve increased the disk size in the hypervisor and want to extend the LVM and partition in the guest. LVM is the last partition so we can grow it versus creating a new partition &hellip; <a href=\"https:\/\/www.scottharvanek.com\/?p=559\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-559","post","type-post","status-publish","format-standard","hentry","category-opensource"],"_links":{"self":[{"href":"https:\/\/www.scottharvanek.com\/index.php?rest_route=\/wp\/v2\/posts\/559","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.scottharvanek.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.scottharvanek.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.scottharvanek.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.scottharvanek.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=559"}],"version-history":[{"count":1,"href":"https:\/\/www.scottharvanek.com\/index.php?rest_route=\/wp\/v2\/posts\/559\/revisions"}],"predecessor-version":[{"id":560,"href":"https:\/\/www.scottharvanek.com\/index.php?rest_route=\/wp\/v2\/posts\/559\/revisions\/560"}],"wp:attachment":[{"href":"https:\/\/www.scottharvanek.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=559"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.scottharvanek.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=559"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.scottharvanek.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=559"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}