- Blog

Keep it simple

Moving debian linux swap partition to the start of the disk

written on 22 November 2017
When I installed my virtual machine with debian, the setup created a swap partition (/dev/sda5) right after the actual partition (/dev/sda1). However, this makes resizing the main partition difficult, so I wanted to move the swap partition to the start of the disk: 1. Using GParted live: 1. Remove extended partition 2. Move /dev/sda1 to the right 3. Recreate extended partition and swap in empty space at start of disk 2. During the first boot, it will try to find the swap disk with a timeout of 1min 30sec 3. Recreate swap fs: ``` mkswap /dev/sda5 swapon /dev/sda5 ``` 4. Determine UUID of sda5 by looking at `ls -al /dev/disk/by-uuid` 5. Update swap UUIDs in `/etc/fstab` and `/etc/initramfs-tools/conf.d/resume` 6. Run `update-initramfs -u` 7. Reboot (Tested with Debian Stretch)