Last active
March 3, 2021 15:54
-
-
Save wimvds/8f5bf05dea6c708573cb1c894896b2db to your computer and use it in GitHub Desktop.
Extend a VM disk using fdisk
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Extend the disk using fdisk (after the disk image itself has been extended): | |
fdisk -u /dev/sda | |
- Use the option p to print the partition table (you will need the start position later) | |
- Delete the partition with option d | |
- Add a new partition with option n | |
- Create a primary partition with P and give this the partition number 1 | |
- For the first sector, use the start position from step 2 | |
- Use the defaultvalue for the last sector | |
- Check your changes by printing the partition table again | |
- Write the table to the disk with option w and reboot when asked | |
Extend the physical volume. Eg: pvresize /dev/sda5 | |
Use pvdisplay to check how much free space you can assign to the logical volume | |
Eg: Free PE 320 | |
By using lvextend, you can add the Free PE to the logical volume (with lvdisplay you can find the correct logical volume name) | |
Eg: lvextend –l +1281 /dev/mapper/data-data | |
Finally (only for extX file systems): resize2fs /dev/mapper/data-data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment