Step 1: Increase Disk Size in Proxmox
- Shutdown the VM: Ensure it's powered off.
- Adjust Disk Size:
- Navigate to the VM in Proxmox.
- Go to "Hardware" -> "Hard Disk".
- Adjust the size and confirm changes.
Step 2: Resize Partition and Filesystem in Debian
Access the VM: SSH or use the console. A like to my tutorial can be found here.
Install Parted Utility: Use
sudo apt install parted
to install the Parted Utility.Parted Utility: Use
parted
to manage partitions.sudo parted
Remove Unnecessary Partitions (if applicable):
(parted) rm [partition_number]
Resize the Primary Partition:
(parted) resizepart 1 100%
Exit
parted
withquit
.
Resize the Filesystem:
sudo resize2fs /dev/sda1
Step 3: Configure Swap File
Create a Swap File:
sudo dd if=/dev/zero of=/swapfile bs=1G count=2 status=progress
(Adjust
count
to the desired swap size in GB.)If there's insufficient space:
- Check space with
df -h
. - Investigate usage and adjust accordingly.
- Check space with
Set Permissions and Make Swap:
sudo chmod 600 /swapfile sudo mkswap /swapfile sudo swapon /swapfile
Persist Swap Across Reboots:
Open
/etc/fstab
with a text editor, likenano
:sudo nano /etc/fstab
Add the swap entry:
/swapfile none swap sw 0 0
Save and exit.
Step 4: Verification and Finalization
Verify Disk and Swap:
- Check disk space:
df -h
. - Check memory and swap:
free -m
.
- Check disk space:
Reboot the VM:
sudo reboot
Verify Again:
- Ensure the filesystem and swap are as expected after the reboot.
Additional Notes
- Backups: Ensure you backup critical data before performing disk operations.
- Swap Size: Adjust based on your specific use and available memory.
- Docker: If using Docker, manage resources and volumes to optimize disk usage.
Considerations for Future Work
- Routine Monitoring: Regularly check disk usage, especially with applications that dynamically generate data or logs.
- Docker Management: Periodically prune unused Docker objects and manage image and container storage efficiently.
Adam Malin
You can find me on Twitter or on Nostr at
npub15jnttpymeytm80hatjqcvhhqhzrhx6gxp8pq0wn93rhnu8s9h9dsha32lx
You can view and write comments on this or any other post by using the Satcom browser extention.
value4value Did you find any value from this article? Click here to send me a tip!