The other day I was thinking about how with chrome dismantling the framework utilized by adblockers the chromebooks i would often recommend to family and those less tech savvy are no longer something I can rely on. (Plus it’s made by google so long term support isn’t reliable on that front either.)
So this lead me to thinking about making Linux laptops more user friendly on a commercial front. The idea of a simple “factory reset” is a technical process usually left to the user. Our much maligned competition in Windows land seems to have this process somewhat figured out and it gave me a fairly simple idea… why don’t we have this feature set up by the installer when you install Linux? It would be handy even for seasoned veterans as instead of fumbling for a usb drive with your live ISO on it, it will already be waiting for you in a separate dedicated partition.
Thinking about how to implement this, I remembered our good friend the GRUB2 bootloader is capable of directly booting from an ISO image that’s sitting on a partition. This would be a simple way to have an immutable image always on hand to reference the state of your system and do on-demand reinstalls or a live environment to troubleshoot from. Storage is relatively cheap nowadays so about say… 6GB or so wouldn’t really be missed as a partition to tack on.
(I chose this value somewhat arbitrarily, as most Ubuntu installers are about the size of a DVD (4.7GB) so this would allow space to grow in the future. If we’re planning for really long term say 10 years or so perhaps this size should be increased for added flexibility, or if we wanted other specialized ISOs to boot from like… super grub disk or whatever)
So my first step was to set up a partition which was fast enough and then configure grub to boot from an ISO. Some internet searching led me to a fairly comprehensive article on the subject: https://www.linuxbabe.com/desktop-linux/boot-from-iso-files-using-grub2-boot-loader
and I put my menu entry into /etc/grub.d/40_custom
then update-grub and a reboot to test!
Unfortunately the way grub indexes disks and partitions isn’t exactly straightforward and easily to reference once you are outside of grub. So that brings me to my first hurdle and it would make a lot more sense to test in a VM which is where I’m currently at. I’ll update this article periodically as I continue work on this project.
Well it’s certainly easier in a VM with only 1 disk because you can just assume it’s on hd0, and since my rescue partition was the first one I created it would be (hd0,1) because the drives are indexed starting and 0 and the partitions are indexed starting at 1. Consistency is key ๐
Anyway with the right parameters and ISO name I was able to successfully create a menu entry in grub and boot to it. A simple run of the live ISO’s installer program and we can simply use the “reinstall” option for partitioning if we were careful enough to choose a separate /home partition when we first installed as I did. Otherwise that’s yet another nuisance for end users that would be easy enough to work around!
Actually it seems that if you want to reinstall with a separate home partition you have to specify so this will be a manual process I’d have to walk an end user through all the same as things stand. That’s aggravating but still should be possible to work around in the future with refinement to the ubuntu installer.
Anyway this proves that the concept is possible to implement easily enough with a little foresight. This refinement would make it easier for less technical users to reinstall their systems in the unlikely event there’s a major issue with their Linux installation (or its just time to clean everything up and start over, totally been there).
Leave a Reply