I'm attempting to increase the amount of swap on a xen guest machine. At first I thought it'd be similar to increasing the hard drive space, which I do like this:
cd /srv/xen/domains/$host/
xm shutdown $host
cp disk.img disk.img.backup
dd if=/dev/zero of=ZeroContentFile bs=1024 count=$numberofextrabytes
cat ZeroContentFile >> disk.img
rm ZeroContentFile
resize2fs -f disk.img
fsck.ext3 disk.img
xm create $host.cfg
I've tried doing the same thing, but replacing disk.img with swap.img. This works fine up until the point I do the resizefs -f swap.img
, I get:
resize2fs 1.42.5 (29-Jul-2012)
resize2fs: Bad magic number in super-block while trying to open swap.img
Couldn't find valid filesystem superblock.
To be honest, I never expected this command to work exactly the same for swap as it did for ext3. However, if I leave it out, then the guest just ends up with the same amount of swap as it had before. What's the equivalent command I need to run to get the whole of swap.img recognised as swap space?