Partition erweitern (AlmaLinux/CentOS): Unterschied zwischen den Versionen
(Die Seite wurde neu angelegt: „You can do this without rebooting in CentOS 7. Assuming your disk is /dev/vda and standard RHEL/CentOS partitioning: Extend partition # fdisk /dev/vda Enter p to print your initial partition table. Enter d (delete) followed by 2 to delete the existing partition definition (partition 1 is usually /boot and partition 2 is usually the root partition). Enter n (new) followed by p (primary) followed by 2 to re-create partition number 2 and enter to accept t…“) |
KKeine Bearbeitungszusammenfassung Markierung: Manuelle Zurücksetzung |
||
(4 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
Zeile 1: | Zeile 1: | ||
__NOINDEX__ | |||
You can do this without rebooting in CentOS 7. Assuming your disk is /dev/vda and standard RHEL/CentOS partitioning: | You can do this without rebooting in CentOS 7. Assuming your disk is /dev/vda and standard RHEL/CentOS partitioning: | ||
Extend partition | Extend partition<syntaxhighlight lang="bash"> | ||
fdisk /dev/sda | |||
</syntaxhighlight> | |||
Enter d (delete) followed by 2 to delete the existing partition definition (partition 1 is usually /boot and partition 2 is usually the root partition). | # Enter p to print your initial partition table. | ||
# Enter d (delete) followed by 2 to delete the existing partition definition (partition 1 is usually /boot and partition 2 is usually the root partition). | |||
Enter n (new) followed by p (primary) followed by 2 to re-create partition number 2 and enter to accept the start block and enter again to accept the end block which is defaulted to the end of the disk. | # Enter n (new) followed by p (primary) followed by 2 to re-create partition number 2 and enter to accept the start block and enter again to accept the end block which is defaulted to the end of the disk. | ||
# Wollen Sie die Signatur entfernen? Nein | |||
Enter t (type) then 2 then 8e to change the new partition type to "Linux LVM". | # Enter t (type) then 2 then 8e to change the new partition type to "Linux LVM". | ||
# Enter p to print your new partition table and make sure the start block matches what was in the initial partition table printed above. | |||
Enter p to print your new partition table and make sure the start block matches what was in the initial partition table printed above. | # Enter w to write the partition table to disk. You will see an error about Device or resource busy which you can ignore. | ||
Enter w to write the partition table to disk. You will see an error about Device or resource busy which you can ignore. | |||
Update kernel in-memory partition table | Update kernel in-memory partition table | ||
After changing your partition table, run the following command to update the kernel in-memory partition table | After changing your partition table, run the following command to update the kernel in-memory partition table<syntaxhighlight lang="bash"> | ||
partx -u /dev/sda | |||
</syntaxhighlight>Resize physical volume | |||
Resize physical volume | Resize the PV to recognize the extra space<syntaxhighlight lang="bash"> | ||
Resize the PV to recognize the extra space | pvresize /dev/sda2 | ||
</syntaxhighlight>Resize LV and filesystem | |||
In this command centos is the PV, root is the LV and /dev/vda2 is the partition that was extended. Use pvs and lvs commands to see your physical and logical volume names if you don't know them. The -r option in this command resizes the filesystem appropriately so you don't have to call resize2fs or xfs_growfs separately<syntaxhighlight lang="bash"> | |||
Resize LV and filesystem | df -h | ||
In this command centos is the PV, root is the LV and /dev/vda2 is the partition that was extended. Use pvs and lvs commands to see your physical and logical volume names if you don't know them. The -r option in this command resizes the filesystem appropriately so you don't have to call resize2fs or xfs_growfs separately | </syntaxhighlight><syntaxhighlight lang="bash"> | ||
/dev/mapper/almalinux-root 45G 20G 26G 44% / | |||
</syntaxhighlight><syntaxhighlight lang="bash"> | |||
lvextend -r /dev/mapper/almalinux-root /dev/sda2 | |||
</syntaxhighlight> | |||
https://serverfault.com/questions/861517/centos-7-extend-partition-with-unallocated-space | https://serverfault.com/questions/861517/centos-7-extend-partition-with-unallocated-space |
Aktuelle Version vom 15. Dezember 2022, 12:40 Uhr
You can do this without rebooting in CentOS 7. Assuming your disk is /dev/vda and standard RHEL/CentOS partitioning:
Extend partition
fdisk /dev/sda
- Enter p to print your initial partition table.
- Enter d (delete) followed by 2 to delete the existing partition definition (partition 1 is usually /boot and partition 2 is usually the root partition).
- Enter n (new) followed by p (primary) followed by 2 to re-create partition number 2 and enter to accept the start block and enter again to accept the end block which is defaulted to the end of the disk.
- Wollen Sie die Signatur entfernen? Nein
- Enter t (type) then 2 then 8e to change the new partition type to "Linux LVM".
- Enter p to print your new partition table and make sure the start block matches what was in the initial partition table printed above.
- Enter w to write the partition table to disk. You will see an error about Device or resource busy which you can ignore.
Update kernel in-memory partition table
After changing your partition table, run the following command to update the kernel in-memory partition table
partx -u /dev/sda
Resize physical volume Resize the PV to recognize the extra space
pvresize /dev/sda2
Resize LV and filesystem In this command centos is the PV, root is the LV and /dev/vda2 is the partition that was extended. Use pvs and lvs commands to see your physical and logical volume names if you don't know them. The -r option in this command resizes the filesystem appropriately so you don't have to call resize2fs or xfs_growfs separately
df -h
/dev/mapper/almalinux-root 45G 20G 26G 44% /
lvextend -r /dev/mapper/almalinux-root /dev/sda2
https://serverfault.com/questions/861517/centos-7-extend-partition-with-unallocated-space