ubuntu_extend_default_lvm_space

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
ubuntu_extend_default_lvm_space [2023/06/29 18:25] wikiadminubuntu_extend_default_lvm_space [2023/06/29 20:01] (current) wikiadmin
Line 1: Line 1:
 ====== Ubuntu - Extend Your Default LVM Space ====== ====== Ubuntu - Extend Your Default LVM Space ======
 +
 +So, like me, you installed Ubuntu and accepted the installers default selections for lvm and now your operating volume is very small and the Ubuntu installer did not utilize the entire physical drive. There is a ton of space that is not being utilized.  And,  possibly, your freshly installed cloud application (NextCloud) will soon exceed the allotted space within the first week or so as a result of data uploading or synchronization.
 +
 +All credit for the concepts and sequences of commands goes to the publishers of the article that you can find by clicking the following link:
 +
 +[[https://packetpushers.net/ubuntu-extend-your-default-lvm-space/]]
 +
 +
 +This first example below involves a 1TB physical drive of which Ubuntu's default partitioning only allotted 98GB to the operating volume shown as 'ubuntu--vg-ubuntu--lv' below.
 +
 +First run df -h 
  
 <code> <code>
Line 14: Line 25:
 tmpfs                              791M  4.0K  791M   1% /run/user/1000 tmpfs                              791M  4.0K  791M   1% /run/user/1000
 </code> </code>
 +
 +Next run vgdisplay
  
 <code> <code>
Line 44: Line 57:
 </code> </code>
  
 +Next run lvdisplay
  
 <code> <code>
Line 67: Line 81:
   Block device           253:0   Block device           253:0
 </code> </code>
 +
 +Switching to root user
  
 <code> <code>
Line 73: Line 89:
 root@svr1:~# root@svr1:~#
 </code> </code>
 +
 +Run the following to extend the LV to the maximum size usable.
  
 <code> <code>
Line 82: Line 100:
   Size of logical volume ubuntu-vg/ubuntu-lv changed from 100.00 GiB (25600 extents) to <929.00 GiB (237823 extents).   Size of logical volume ubuntu-vg/ubuntu-lv changed from 100.00 GiB (25600 extents) to <929.00 GiB (237823 extents).
   Logical volume ubuntu-vg/ubuntu-lv successfully resized.   Logical volume ubuntu-vg/ubuntu-lv successfully resized.
-root@only1:~#+root@svr11:~#
  
 </code> </code>
Line 89: Line 107:
  
 <code> <code>
-root@only1:~# lvdisplay+root@svr1:~# lvdisplay
   --- Logical volume ---   --- Logical volume ---
   LV Path                /dev/ubuntu-vg/ubuntu-lv   LV Path                /dev/ubuntu-vg/ubuntu-lv
Line 107: Line 125:
   Block device           253:0   Block device           253:0
  
-root@only1:~#+root@svr1:~#
 </code> </code>
 +
 +At this point you have increased the size of the block volume where your root filesystem resides, but you still need to extend the filesystem on top of it. 
 +
 +First, run df -h to verify your (almost full) root file system, then run resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv to extend your filesystem, and run df -h one more time to make sure you’re successful.
 +
 +This is a continuation of the above: now extending the file system to utilize the entire resized volume on a 1TB physical drive.
 +
 +Re-established remote ssh connection and want to again switch to root user.
 +
 +<code>
 +~$ sudo su
 +[sudo] password for user:
 +root@svr1:/home/user# cd
 +</code>
 +
 +Run df -h to see where we are.  Notice that ubuntu--vg-ubuntu--lv   is still only 98G.  We still need to extend the filesystem to match the resized LV.
 +
 +<code>
 +root@svr11:~# df -h
 +Filesystem                         Size  Used Avail Use% Mounted on
 +tmpfs                              791M  1.2M  790M   1% /run
 +/dev/mapper/ubuntu--vg-ubuntu--lv   98G  7.0G   86G   8% /
 +tmpfs                              3.9G      3.9G   0% /dev/shm
 +tmpfs                              5.0M      5.0M   0% /run/lock
 +/dev/sda2                          2.0G  130M  1.7G   8% /boot
 +tmpfs                              791M  4.0K  791M   1% /run/user/1000
 +</code>
 +
 +Let's check vgdisplay
 +
 +<code>
 +root@svr1:~# vgdisplay
 +</code>
 +
 +<code>
 +  --- Volume group ---
 +  VG Name               ubuntu-vg
 +  System ID
 +  Format                lvm2
 +  Metadata Areas        1
 +  Metadata Sequence No  3
 +  VG Access             read/write
 +  VG Status             resizable
 +  MAX LV                0
 +  Cur LV                1
 +  Open LV               1
 +  Max PV                0
 +  Cur PV                1
 +  Act PV                1
 +  VG Size               <929.00 GiB
 +  PE Size               4.00 MiB
 +  Total PE              237823
 +  Alloc PE / Size       237823 / <929.00 GiB
 +  Free  PE / Size       0 / 0
 +  VG UUID               rF3fw2-13h2-kAiL-aeWA-KyDZ-5HQU-GwvKDe
 +</code>
 +
 +Let's check lvdisplay
 +
 +<code>
 +root@svr1:~# lvdisplay
 +</code>
 +
 +<code>
 +  --- Logical volume ---
 +  LV Path                /dev/ubuntu-vg/ubuntu-lv
 +  LV Name                ubuntu-lv
 +  VG Name                ubuntu-vg
 +  LV UUID                xUUIxr-wnDl-7ZNk-EQpK-gAwb-Wug0-a7JSTb
 +  LV Write Access        read/write
 +  LV Creation host, time ubuntu-server, 2023-06-28 23:21:26 +0000
 +  LV Status              available
 +  # open                 1
 +  LV Size                <929.00 GiB
 +  Current LE             237823
 +  Segments               1
 +  Allocation             inherit
 +  Read ahead sectors     auto
 +  - currently set to     256
 +  Block device           253:0
 +</code>
 +
 +Now, run the following command to resize the file system to the full size of the resized volume.
 +
 +<code>
 +root@svr1:~# resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv
 +resize2fs 1.46.5 (30-Dec-2021)
 +Filesystem at /dev/mapper/ubuntu--vg-ubuntu--lv is mounted on /; on-line resizing required
 +old_desc_blocks = 13, new_desc_blocks = 117
 +The filesystem on /dev/mapper/ubuntu--vg-ubuntu--lv is now 243530752 (4k) blocks long.
 +
 +root@svr1:~#
 +</code>
 +
 +Run df -h
 +
 +And notice that 'ubuntu--vg-ubuntu--lv'  is now 914G
 +
 +<code>
 +root@svr1:~# df -h
 +</code>
 +
 +<code>
 +Filesystem                         Size  Used Avail Use% Mounted on
 +tmpfs                              791M  1.2M  790M   1% /run
 +/dev/mapper/ubuntu--vg-ubuntu--lv  914G  7.0G  869G   1% /
 +tmpfs                              3.9G      3.9G   0% /dev/shm
 +tmpfs                              5.0M      5.0M   0% /run/lock
 +/dev/sda2                          2.0G  130M  1.7G   8% /boot
 +tmpfs                              791M  4.0K  791M   1% /run/user/1000
 +root@svr1:~#
 +
 +</code>
 +
 +**End of resizing on the 1TB physical drive.  IF EVERYTHING WENT WELL, THEN STOP HERE.**
 +
 +
 +FOLLOWING IS ANOTHER UNRELATED EXAMPLE OF THE SECOND PART OF THE PROCESS:
 +
 +Example 2:
 +
 +Note:  The following operations and output involves a 2TB physical drive instead of 1TB (like above).  This is a different server where **only the second part of this resizing job is depicted below**, likewise properly finished by extending the file system on top of the block volume that you just extended. 
 +
 +Again, at this point we have increased the size of the block volume where your root filesystem resides, but you still need to extend the filesystem on top of it. 
 +
 +First, run df -h to verify your (almost full) root file system, then run resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv to extend your filesystem, and run df -h one more time to make sure you’re successful.
 +
 +Here are the new readings for 'svr3' (using a pair of 2TB Drives on a hardware RAID-1 Array -- which matters not.) 
 +
 +<code>
 +
 +  Logical volume ubuntu-vg/ubuntu-lv successfully resized.
 +root@svr3:~# lvdisplay
 +  --- Logical volume ---
 +  LV Path                /dev/ubuntu-vg/ubuntu-lv
 +  LV Name                ubuntu-lv
 +  VG Name                ubuntu-vg
 +  LV UUID                0FjNEm-jrLm-tYWv-AzHT-TZmm-l9bx-aVWpyR
 +  LV Write Access        read/write
 +  LV Creation host, time ubuntu-server, 2023-06-18 18:42:52 +0000
 +  LV Status              available
 +  # open                 1
 +  LV Size                <1.82 TiB
 +  Current LE             476287
 +  Segments               1
 +  Allocation             inherit
 +  Read ahead sectors     auto
 +  - currently set to     256
 +  Block device           253:0
 +
 +root@svr3:~# df -h
 +Filesystem                         Size  Used Avail Use% Mounted on
 +tmpfs                              1.6G  1.2M  1.6G   1% /run
 +/dev/mapper/ubuntu--vg-ubuntu--lv   98G   12G   82G  13% /
 +tmpfs                              7.8G      7.8G   0% /dev/shm
 +tmpfs                              5.0M      5.0M   0% /run/lock
 +/dev/sda2                          2.0G  253M  1.6G  14% /boot
 +tmpfs                              1.6G  4.0K  1.6G   1% /run/user/1000
 +</code>
 +
 +Now, run the following command to extend your filesystem.
 +
 +<code>
 +root@svr3:~# resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv
 +</code>
 +
 +Results
 +
 +<code>
 +resize2fs 1.46.5 (30-Dec-2021)
 +Filesystem at /dev/mapper/ubuntu--vg-ubuntu--lv is mounted on /; on-line resizing required
 +old_desc_blocks = 13, new_desc_blocks = 233
 +The filesystem on /dev/mapper/ubuntu--vg-ubuntu--lv is now 487717888 (4k) blocks long.
 +</code>
 +
 +Run df -h again.
 +
 +<code>
 +root@svr3:~# df -h
 +Filesystem                         Size  Used Avail Use% Mounted on
 +tmpfs                              1.6G  1.2M  1.6G   1% /run
 +/dev/mapper/ubuntu--vg-ubuntu--lv  1.8T   12G  1.8T   1% /
 +tmpfs                              7.8G      7.8G   0% /dev/shm
 +tmpfs                              5.0M      5.0M   0% /run/lock
 +/dev/sda2                          2.0G  253M  1.6G  14% /boot
 +tmpfs                              1.6G  4.0K  1.6G   1% /run/user/1000
 +root@nc3:~#
 +</code>
 +
 +Run vgdisplay again
 +
 +<code>
 +root@svr3:~# vgdisplay
 +  --- Volume group ---
 +  VG Name               ubuntu-vg
 +  System ID
 +  Format                lvm2
 +  Metadata Areas        1
 +  Metadata Sequence No  3
 +  VG Access             read/write
 +  VG Status             resizable
 +  MAX LV                0
 +  Cur LV                1
 +  Open LV               1
 +  Max PV                0
 +  Cur PV                1
 +  Act PV                1
 +  VG Size               <1.82 TiB
 +  PE Size               4.00 MiB
 +  Total PE              476287
 +  Alloc PE / Size       476287 / <1.82 TiB
 +  Free  PE / Size       0 / 0
 +  VG UUID               bK42QC-L9pu-bEiA-ndU0-j3v7-3XWU-tAO6R5
 +</code>
 +
 +Run lvdisplay again
 +
 +<code>
 +root@svr3:~# lvdisplay
 +  --- Logical volume ---
 +  LV Path                /dev/ubuntu-vg/ubuntu-lv
 +  LV Name                ubuntu-lv
 +  VG Name                ubuntu-vg
 +  LV UUID                0FjNEm-jrLm-tYWv-AzHT-TZmm-l9bx-aVWpyR
 +  LV Write Access        read/write
 +  LV Creation host, time ubuntu-server, 2023-06-18 18:42:52 +0000
 +  LV Status              available
 +  # open                 1
 +  LV Size                <1.82 TiB
 +  Current LE             476287
 +  Segments               1
 +  Allocation             inherit
 +  Read ahead sectors     auto
 +  - currently set to     256
 +  Block device           253:0
 +
 +root@svr3:~#
 +</code>
 +
 +VG Size and LV Size are both <1.82 TiB
 +
 +I believe we're done here.
 +
ubuntu_extend_default_lvm_space.1688063150.txt.gz · Last modified: 2023/06/29 18:25 by wikiadmin