ubuntu_extend_default_lvm_space
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
ubuntu_extend_default_lvm_space [2023/06/29 18:11] – created wikiadmin | ubuntu_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 ====== | ||
- | </code> | + | 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. |
+ | |||
+ | 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:// | ||
+ | |||
+ | |||
+ | This first example below involves a 1TB physical drive of which Ubuntu' | ||
+ | |||
+ | First run df -h | ||
+ | |||
+ | <code> | ||
$ df -h | $ df -h | ||
+ | </ | ||
+ | |||
+ | < | ||
Filesystem | Filesystem | ||
tmpfs 791M 1.2M 790M 1% /run | tmpfs 791M 1.2M 790M 1% /run | ||
Line 10: | Line 24: | ||
/ | / | ||
tmpfs 791M 4.0K 791M 1% / | tmpfs 791M 4.0K 791M 1% / | ||
- | frank@only1: | + | </code> |
- | | + | |
- | /run/ | + | Next run vgdisplay |
- | frank@only1:/ | + | |
- | [sudo] password for frank: | + | < |
+ | user@svr1:~$ sudo vgdisplay | ||
+ | |||
+ | [sudo] password for user: | ||
+ | </ | ||
+ | |||
+ | < | ||
--- Volume group --- | --- Volume group --- | ||
VG Name | VG Name | ||
Line 35: | Line 55: | ||
Free PE / Size | Free PE / Size | ||
VG UUID | VG UUID | ||
+ | </ | ||
+ | |||
+ | Next run lvdisplay | ||
+ | |||
+ | < | ||
+ | user@svr1: | ||
+ | </ | ||
- | frank@only1:/ | + | < |
--- Logical volume --- | --- Logical volume --- | ||
LV Path / | LV Path / | ||
Line 53: | Line 80: | ||
- currently set to 256 | - currently set to 256 | ||
Block device | Block device | ||
+ | </ | ||
- | frank@only1:/ | + | Switching to root user |
- | frank@only1:~$ sudo su | + | |
- | root@only1:/home/frank# cd | + | < |
- | root@only1:~# lvextend -l +100%FREE / | + | user@svr1:~$ sudo su |
+ | root@svr1:/home/user# cd | ||
+ | root@svr1:~# | ||
+ | </ | ||
+ | |||
+ | Run the following to extend the LV to the maximum size usable. | ||
+ | |||
+ | < | ||
+ | root@svr1:~# lvextend -l +100%FREE / | ||
+ | </ | ||
+ | |||
+ | |||
+ | < | ||
Size of logical volume ubuntu-vg/ | Size of logical volume ubuntu-vg/ | ||
Logical volume ubuntu-vg/ | Logical volume ubuntu-vg/ | ||
- | root@only1:~# | + | root@svr11:~# |
</ | </ | ||
+ | |||
+ | Run lvdisplay once more to verify that that the logical volume was successfully resized. | ||
+ | |||
+ | < | ||
+ | root@svr1: | ||
+ | --- Logical volume --- | ||
+ | LV Path / | ||
+ | LV Name ubuntu-lv | ||
+ | VG Name ubuntu-vg | ||
+ | LV UUID xUUIxr-wnDl-7ZNk-EQpK-gAwb-Wug0-a7JSTb | ||
+ | LV Write Access | ||
+ | LV Creation host, time ubuntu-server, | ||
+ | LV Status | ||
+ | # open 1 | ||
+ | LV Size <929.00 GiB | ||
+ | Current LE | ||
+ | Segments | ||
+ | Allocation | ||
+ | Read ahead sectors | ||
+ | - currently set to 256 | ||
+ | Block device | ||
+ | |||
+ | root@svr1: | ||
+ | </ | ||
+ | |||
+ | 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 / | ||
+ | |||
+ | 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. | ||
+ | |||
+ | < | ||
+ | ~$ sudo su | ||
+ | [sudo] password for user: | ||
+ | root@svr1:/ | ||
+ | </ | ||
+ | |||
+ | Run df -h to see where we are. Notice that ubuntu--vg-ubuntu--lv | ||
+ | |||
+ | < | ||
+ | root@svr11: | ||
+ | Filesystem | ||
+ | tmpfs 791M 1.2M 790M 1% /run | ||
+ | / | ||
+ | tmpfs 3.9G | ||
+ | tmpfs 5.0M | ||
+ | / | ||
+ | tmpfs 791M 4.0K 791M 1% / | ||
+ | </ | ||
+ | |||
+ | Let's check vgdisplay | ||
+ | |||
+ | < | ||
+ | root@svr1: | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | --- Volume group --- | ||
+ | VG Name | ||
+ | System ID | ||
+ | Format | ||
+ | Metadata Areas 1 | ||
+ | Metadata Sequence No 3 | ||
+ | VG Access | ||
+ | VG Status | ||
+ | MAX LV 0 | ||
+ | Cur LV 1 | ||
+ | Open LV 1 | ||
+ | Max PV 0 | ||
+ | Cur PV 1 | ||
+ | Act PV 1 | ||
+ | VG Size < | ||
+ | PE Size 4.00 MiB | ||
+ | Total PE 237823 | ||
+ | Alloc PE / Size | ||
+ | Free PE / Size 0 / 0 | ||
+ | VG UUID | ||
+ | </ | ||
+ | |||
+ | Let's check lvdisplay | ||
+ | |||
+ | < | ||
+ | root@svr1: | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | --- Logical volume --- | ||
+ | LV Path / | ||
+ | LV Name ubuntu-lv | ||
+ | VG Name ubuntu-vg | ||
+ | LV UUID xUUIxr-wnDl-7ZNk-EQpK-gAwb-Wug0-a7JSTb | ||
+ | LV Write Access | ||
+ | LV Creation host, time ubuntu-server, | ||
+ | LV Status | ||
+ | # open 1 | ||
+ | LV Size <929.00 GiB | ||
+ | Current LE | ||
+ | Segments | ||
+ | Allocation | ||
+ | Read ahead sectors | ||
+ | - currently set to 256 | ||
+ | Block device | ||
+ | </ | ||
+ | |||
+ | Now, run the following command to resize the file system to the full size of the resized volume. | ||
+ | |||
+ | < | ||
+ | root@svr1: | ||
+ | resize2fs 1.46.5 (30-Dec-2021) | ||
+ | Filesystem at / | ||
+ | old_desc_blocks = 13, new_desc_blocks = 117 | ||
+ | The filesystem on / | ||
+ | |||
+ | root@svr1: | ||
+ | </ | ||
+ | |||
+ | Run df -h | ||
+ | |||
+ | And notice that ' | ||
+ | |||
+ | < | ||
+ | root@svr1: | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | Filesystem | ||
+ | tmpfs 791M 1.2M 790M 1% /run | ||
+ | / | ||
+ | tmpfs 3.9G | ||
+ | tmpfs 5.0M | ||
+ | / | ||
+ | tmpfs 791M 4.0K 791M 1% / | ||
+ | root@svr1: | ||
+ | |||
+ | </ | ||
+ | |||
+ | **End of resizing on the 1TB physical drive. | ||
+ | |||
+ | |||
+ | 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). | ||
+ | |||
+ | 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 / | ||
+ | |||
+ | Here are the new readings for ' | ||
+ | |||
+ | < | ||
+ | |||
+ | Logical volume ubuntu-vg/ | ||
+ | root@svr3: | ||
+ | --- Logical volume --- | ||
+ | LV Path / | ||
+ | LV Name ubuntu-lv | ||
+ | VG Name ubuntu-vg | ||
+ | LV UUID 0FjNEm-jrLm-tYWv-AzHT-TZmm-l9bx-aVWpyR | ||
+ | LV Write Access | ||
+ | LV Creation host, time ubuntu-server, | ||
+ | LV Status | ||
+ | # open 1 | ||
+ | LV Size <1.82 TiB | ||
+ | Current LE | ||
+ | Segments | ||
+ | Allocation | ||
+ | Read ahead sectors | ||
+ | - currently set to 256 | ||
+ | Block device | ||
+ | |||
+ | root@svr3: | ||
+ | Filesystem | ||
+ | tmpfs 1.6G 1.2M 1.6G 1% /run | ||
+ | / | ||
+ | tmpfs 7.8G | ||
+ | tmpfs 5.0M | ||
+ | / | ||
+ | tmpfs 1.6G 4.0K 1.6G 1% / | ||
+ | </ | ||
+ | |||
+ | Now, run the following command to extend your filesystem. | ||
+ | |||
+ | < | ||
+ | root@svr3: | ||
+ | </ | ||
+ | |||
+ | Results | ||
+ | |||
+ | < | ||
+ | resize2fs 1.46.5 (30-Dec-2021) | ||
+ | Filesystem at / | ||
+ | old_desc_blocks = 13, new_desc_blocks = 233 | ||
+ | The filesystem on / | ||
+ | </ | ||
+ | |||
+ | Run df -h again. | ||
+ | |||
+ | < | ||
+ | root@svr3: | ||
+ | Filesystem | ||
+ | tmpfs 1.6G 1.2M 1.6G 1% /run | ||
+ | / | ||
+ | tmpfs 7.8G | ||
+ | tmpfs 5.0M | ||
+ | / | ||
+ | tmpfs 1.6G 4.0K 1.6G 1% / | ||
+ | root@nc3:~# | ||
+ | </ | ||
+ | |||
+ | Run vgdisplay again | ||
+ | |||
+ | < | ||
+ | root@svr3: | ||
+ | --- Volume group --- | ||
+ | VG Name | ||
+ | System ID | ||
+ | Format | ||
+ | Metadata Areas 1 | ||
+ | Metadata Sequence No 3 | ||
+ | VG Access | ||
+ | VG Status | ||
+ | MAX LV 0 | ||
+ | Cur LV 1 | ||
+ | Open LV 1 | ||
+ | Max PV 0 | ||
+ | Cur PV 1 | ||
+ | Act PV 1 | ||
+ | VG Size < | ||
+ | PE Size 4.00 MiB | ||
+ | Total PE 476287 | ||
+ | Alloc PE / Size | ||
+ | Free PE / Size 0 / 0 | ||
+ | VG UUID | ||
+ | </ | ||
+ | |||
+ | Run lvdisplay again | ||
+ | |||
+ | < | ||
+ | root@svr3: | ||
+ | --- Logical volume --- | ||
+ | LV Path / | ||
+ | LV Name ubuntu-lv | ||
+ | VG Name ubuntu-vg | ||
+ | LV UUID 0FjNEm-jrLm-tYWv-AzHT-TZmm-l9bx-aVWpyR | ||
+ | LV Write Access | ||
+ | LV Creation host, time ubuntu-server, | ||
+ | LV Status | ||
+ | # open 1 | ||
+ | LV Size <1.82 TiB | ||
+ | Current LE | ||
+ | Segments | ||
+ | Allocation | ||
+ | Read ahead sectors | ||
+ | - currently set to 256 | ||
+ | Block device | ||
+ | |||
+ | root@svr3: | ||
+ | </ | ||
+ | |||
+ | VG Size and LV Size are both <1.82 TiB | ||
+ | |||
+ | I believe we're done here. | ||
+ |
ubuntu_extend_default_lvm_space.1688062275.txt.gz · Last modified: 2023/06/29 18:11 by wikiadmin