Difference between revisions of "Deleting Linux Swap Partition on KVM"
From ProxCP Documentation
(Created page with "Coming soon") |
|||
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | + | This page is in reference to the fact that cloud-init KVM templates cannot have any disk partition after the root "/" partition. In many cases, the Linux swap partition is after the root partition therefore it needs to be deleted as expected by cloud-init. | |
+ | |||
+ | The root partition is important because cloud-init can grow the partition automatically from a template clone but only if it is the last partition on a disk. | ||
+ | |||
+ | == Steps == | ||
+ | |||
+ | * Delete the <code>swap</code> line from /etc/fstab | ||
+ | * Run <code>swapoff -a</code> | ||
+ | * Use fdisk on the disk in question, this is usually /dev/sda <code>fdisk /dev/sda</code> | ||
+ | * Execute the following commands in fdisk: | ||
+ | ** p (get partition number of the Linux swap partition) | ||
+ | ** d (delete the swap partition by number) | ||
+ | ** d (delete any other system partition; there should only be 1 partition left for "/") | ||
+ | ** w (write the new partition table) | ||
+ | * Do one of the following to resize the file system to the maximum size: | ||
+ | ** <code>resize2fs /dev/sdaX</code> where X is the number of the remaining partition | ||
+ | ** <code>growroot /dev/sda X</code> where X is the number of the remaining partition | ||
+ | ** If cloud-init is installed with growroot support, simply <code>reboot</code> | ||
+ | |||
+ | == Notes == | ||
+ | |||
+ | * The Linux swap partition is the main focus here, but any partition located after the root "/" partition needs to be deleted for cloud-init growroot to work correctly. These steps can be adapted to any other partition type as needed. |
Latest revision as of 00:06, 26 July 2020
This page is in reference to the fact that cloud-init KVM templates cannot have any disk partition after the root "/" partition. In many cases, the Linux swap partition is after the root partition therefore it needs to be deleted as expected by cloud-init.
The root partition is important because cloud-init can grow the partition automatically from a template clone but only if it is the last partition on a disk.
Steps
- Delete the
swap
line from /etc/fstab - Run
swapoff -a
- Use fdisk on the disk in question, this is usually /dev/sda
fdisk /dev/sda
- Execute the following commands in fdisk:
- p (get partition number of the Linux swap partition)
- d (delete the swap partition by number)
- d (delete any other system partition; there should only be 1 partition left for "/")
- w (write the new partition table)
- Do one of the following to resize the file system to the maximum size:
resize2fs /dev/sdaX
where X is the number of the remaining partitiongrowroot /dev/sda X
where X is the number of the remaining partition- If cloud-init is installed with growroot support, simply
reboot
Notes
- The Linux swap partition is the main focus here, but any partition located after the root "/" partition needs to be deleted for cloud-init growroot to work correctly. These steps can be adapted to any other partition type as needed.