You are not logged in.

#1 2020-09-27 15:53:13

sleekmason
Member
Registered: 2018-05-22
Posts: 209

Small script for swap and resume after dual boot.

For the frequent installers of new and crazy distros:)

I wrote a small script to grab the swap uuid from blkid, keep it displayed as a single item in a terminal, while opening both /etc/fstab and /etc/initramfs-tools/conf.d/resume in a separate terminal as root using nano, so that when both are saved and closed, original terminal will ask to update both initramfs and grub. Whew!

Please note that for the "resume" part, this is for Debian Buster, as some of the others (ubuntu) don't necessarily use this location or method.

#!/bin/bash

sudo blkid -l -t TYPE=swap | awk '{printf $2}'
sudo lxterminal -e nano /etc/fstab /etc/initramfs-tools/conf.d/resume
echo ""
echo ""
echo "-------------Everything Groovy?-------------"
echo ""
read -p "Hit return to update initramfs and grub:)" ;
sudo update-initramfs -u -k all
sudo update-grub

Virtualbox doesn't like me or my computer:) So, over time, I dual-triple-quad a bunch of different desktops as one catches my interest.

After a new installation and until I can change the uuid in fstab and resume and then update, booting takes forever. Swap isn't read, Resume is messed up, and so on.

This will make it all a bit easier to do.

Originally I had thought to make this automatic, but after trying to learn awk for a few hours, that rabbit hole eluded me:) Just don't have any programming background! Also, if the auto editing somehow went wonky, you'd never know until you tried to reboot back into the same desktop.

So anyway, I keep this handy little script in ~/bin, and named it swapid. (don't forget to make it executable). An obligatory note here about being careful with root files, but I reckon if you are dual booting, you probably know that:)

After installing a new Debian build or other Distro, boot back into any of your already existing installs you regularly use, and providing you have copied the script to ~/bin in each, open a terminal and:

~/bin/swapid

So, when /etc/fstab and /etc/initramfs-tools/conf.d/resume open one after another,
Replace the uuid number, hit F2 in nano, then yes and save.

If everything is then groovy:), hit return at the prompt to update initramfs and grub, if installed.

*Note, recommend only installing grub to the mbr, from your primary desktop (the one that is staying no matter what:)

The other installations will be picked up when you update-grub, and if for some reason it is not, you can make an entry to read the specific partition easily.

Offline

#2 2020-09-27 19:55:22

Naik
Member
From: Lipsia
Registered: 2015-10-03
Posts: 270

Re: Small script for swap and resume after dual boot.

I have been there a lot and really understand what you are talking about..

sleekmason wrote:

Virtualbox doesn't like me or my computer:)

For me it is "me or my networkdevices". I never really managed to get any virtual machine with internet access...

Thanks for that!

Naik --greetz


"Kaum macht [Mensch]* es richtig, funktioniert es sofort!"
BL-Kitchen on GitHub

Online

Board footer

Powered by FluxBB