The Perils of Swapping Swap Late at Night

I recount this as a)A cautionary tale b)A reminder to myself how to get out of this mess.

Following a recent system upgrade and more memory, it was time to increase swap space for my LMDE Linux install.

It was midnight, I’d been writing Android JAVA code all day and tired what could possibly go wrong….

My swap partition was on /dev/sda5 and there was insufficient room either side to increase it. But there was a spare chunk of unallocated disk further up. “Hey” I thought, I’ll just move swap to /dev/sda12 and delete the old one that will only take a few minutes.

Ahh I’d better  change the uuid of swap in fstab . Oh  and change /etc/initramfs-tools/conf.d/resume to point at the newly selected swap partition. So I did, and rebooted. Miserably failure number 1, forgot to update-initrams. Doh!

(why oh why didnt I just change the uuid of the new swap to be the same as the old one that would have saved so much misery and the typing of this blog entry)

The change did indeed only take a few minutes, I rebooted the system and the boot hung at the resume stage.

At this point I thought, “Oh Belgium!” and went to sleep. (if “Oh Belgium” doesn’t make sense you need to read more books or listen to the correct radio comedy, does 42 mean anything to you?)

Thus next morning the following steps were taken.

Fortunately I have my systems configured with a couple of Linux Installs and Clonezilla partition(which makes doing whole system backups a lot more convenient).

At this point the plans were:

Plan A

  • Restart System
  • Move swap back to where it was on /dev/sda5
  • Give the new dev/sda5 swap the same uuid as the old one

As I wrote that down, my asleep brain realised actually an easier way would be

Plan B

  • Give the new swap the UUID of the old one
  • Put the old uuid back into /etc/fstab
  • Put the old one back into the resume file sometime as well

Plan C

  • Some hacking to do initramfs on the non bootable system

Plan C too fiddly for my patience so A and B  looked the most straightforward  but both needed me to know the UUID of the old version of swap.

Thats OK I thought it will be in my backup of fstab.

More misery followed involving, encrypted backups, downloading the wrong version of the encryption tools and finding my Centos boot didnt have the commands I wanted.

Anyway to change the swap uuid , the usual way of changing disk uuid using tune2fs was a non starter as it doesnt like swap partitions.

So the way to do it is

mkswap /dev/sda5 -U theuuid

System now rebooted and back to the fun of Andriod and JAVA.

Next time I must just change the new swaps UUID instead, much easier.

::sigh::

 

 

This entry was posted in coding, computing, linux, LinuxMint and tagged , , . Bookmark the permalink.

Comments are closed.