Learn from my mistakes!
Tags: linux
Published: 2022-09-29 19:58:29

You might have heard that you should not do any IT maintenance while drunk, but what they never tell you is - **do not try to fix your computer while having a fever!**

**Below is a lot of techno jargon - so be warned!**

I did it in the past, outcomes were terrible. Did I learn from it? No! I did it again, and this time it was even worse. This post will show you how deep into [Hel](https://en.wikipedia.org/wiki/Hel_(location)) you may need to crawl as a punishment if you don't remember these two good pieces of advice. 
This is not a guide telling you what to do afterwards. My little story shows how much work the remediation took this time. 

A little context first: The seventh generation of ThinkPad X1 isn't among those with the best hardware support in Linux. This is not a general statement about Linux per se - it's valid on [Parrot OS](https://www.parrotsec.org/) - or at least it was two years ago when I bought this machine and set it up. Parrot is a Linux distribution based on Debian. Debian is known for updating much more slowly than others, which makes it more stable. Two years later, with two years' worth of updates - my notebook hardware support is much better. Which is probably the cause of the issue. All my workarounds and tuning were perhaps in the way of updated drivers and libraries. 

I spent about two days compelling the hardware to work when I bought this notebook. Power management and sleep mode weren't working out of the box and needed some convincing. Speakers and microphones basically didn't exist. To solve that, I needed a much newer version of the [Sound Open Firmware](https://github.com/thesofproject/sof) than Parrot provided. This also meant some extra, nonstandard lines in the configuration of Pulse Audio to tell it specifically what to do. The video was tearing (as Intel usually does) and needed another custom adjustment in configuration. And my idea of having mobile internet connectivity thanks to the built-in LTE modem or using a fingerprint or NFC reader was preposterous - no can do! 
Sure the community was working on LTE drivers ([they still are](https://github.com/xmm7360/xmm7360-pci)), the fingerprint reader was just waiting for new firmware, and NFC, what NFC? Although recently, I got some tips from Lenovo's Senior Linux Software Enginee for the NFC reader. So now, not even four years after the hardware was released, all the parts might work in Linux. 

This might sound like a short horror story, but it is not. Sure some parts of the hardware got rarely used in general. Weren't I working for Gemalto, I would never even think about using the NFC reader - I have never seen anyone outside of Gemalto use it on a notebook. But we were making NFC chips and using them for various purposes. I also never used the fingerprint reader. I just wanted to make it work, to learn something new. Admittedly, it's not a path many people want to take, learning about new stuff just because, but I like to gain new, sometimes very atypical, knowledge. 
In the end, this notebook is brilliant, and I'm happy I've bought it! 

I'll be referring to the computer's disk and its partitions (segments of the disk that can be managed separately) quite a lot, so some description might be in order.
Partitioning of the SSD before the incident: 
partition 1 - EFI - 100MB
partition 2+3+8 - Windows 10 - 64GB
partition 4 - Parrot OS - 64GB
partition 5 - reserved for another Linux - 64GB
partition 6 - home (user data) - 234GB (whatever remains)
parittion 7 - swap - 32GB

Let's get back to when I failed miserably, and my computer had a problem. The current crisis was the lack of sound after the last restart. Probably some update changes something. Usually, there is no issue with updates. I do them quite often. Much more often than I do, restart the computer. So usually, updates add to each other, and later it is much harder to find the cause of which change. This time the runtime of my notebook was about two months. This restart wasn't even voluntary - sleep mode failed - and after boot,  I had no sound coming out of the computer.

I'm unsure what I did in my first few attempts to fix the sound. As I've mentioned before, I had raised temperatures. But from the command line history, I can say there was a problem with the PulseAudio server not starting. Ultimately, I broke the whole system, and it was no longer booting. Not that it did not happen to me ever before. But this time, I didn't feel I had the energy and time to fix it. After two years of meddling, I may deserve a clean system.  
Installation of the second instance of Parrot sounded like the right idea - there was a reserved partition for it anyway. After downloading the latest release, I've prepared a bootable USB drive (one of the best things you can use Windows for). Little did I know that there was an [issue](https://community.parrotsec.org/t/parrotos-architect-stuck-during-installation/25189) in that one particular version. This, in the end, meant that I didn't manage to finish the installation and ended up with two broken Parrots. 
At that moment, I had no idea why it failed. Assuming it's some new hardware support issue, I decided to give it another go with Fedora. I've heard it is pretty progressive with hardware support, and they have even had help directly from Lenovo on it. Failed again and didn't manage to finish the installation. No particular reason was given, and I never investigated. It was, after all, a beta version and failure are to be expected. I was getting frustrated. I just wanted the sound to be working again. I never planned for something like this. 
The next idea was Manjaro. Manjaro is a Linux distribution based on Arch Linux, the most on-the-edge updated distribution I know of. This should for sure support all the hardware without failure. Who cares that I never used anything Arch based, and it will be something new to learn - worthy if it works. (Ok, I tried once but never even managed to get working networking.)  But the installer told me that my EFI partition needs at least 300MB in size, while mine is only 100MB. 
Oh crap, I had enough! Let's wipe it all and start from scratch! I will just back up my user home folder/partition and erase the entire disk! 
Just let me connect the external disk and copy it there. I might as well do it from the live instance of Manjaro that rejected to go with the installation. So I did just that. 
I've started the installation process again after a few minutes of waiting for the backing up to finish. My request was simple - use the whole disk, do whatever you want, just make it work. And it did! 
A few hours into fixing sound issues and finally had a working system with sound! Bliss! 
It almost felt like going through [DLL Hell](https://en.wikipedia.org/wiki/DLL_Hell) and finally starting the application you've just bought! 

It might have ended here, but no, I'm one of those who want more from their computers. I want more from my computer than just one working operating system. User data should be on a separate partition for one. And more diversity in the operating systems too. So, this is not the end of the story. Punishments should be longer than five hours! 
To resize the one partition going across the whole disk and create some new ones, I need a proper tool - [Gparted](https://gparted.org/index.php). Let's prepare another USB drive and reboot into Gparted. Resize that huge partition and make space for some new ones. 
In the meantime, I found another USB drive with a Windows installation image I made while creating system backups for my mom and my wife. Windows installed without any issues - which was a surprise for me. Considering how many times I had problems with Windows installations in the past. Looks like they put much more work into Windows 10 than I expected. 
This meant I had two working systems (with working sound) - already better than at the beginning of this story, but I wanted more. I always want more. Manjaro was more than a little unknown to me, and I wanted a fallback plan - Parrot would be lovely. 

The installation went smooth when I didn't use the latest version of Parrot. But there was a slight problem with updating. When you try to download updates, the system verifies if the server you're downloading your updates from is trusted. It was not. At least my old Parrot was convinced it's not. The certificate keys of the server were changed, and the new ones were unknown to him. 
There might be some proper procedure for dealing with this kind of server key replacement, but I was even more tired than before and wanted to sleep with having already updated systems. It was time for a brute force hack and slash solution: 
```
touch /etc/apt/apt.conf.d/99verify-peer.conf && echo >>/etc/apt/apt.conf.d/99verify-peer.conf "Acquire { https::Verify-Peer false }"
```
Which made updates go through. Updates worked even after removing this brutal workaround - happiness! 

At this point, the computer disk is divided like this: 
partition 1 - EFI - 300MB
partition 2 - Manjaro - 64GB
partition 3 - Parrot OS - 64GB
partition 4+5 - Windows 10 - 64GB
partition 6 - HOME - 268GB (whatever remains)
parittion 7 - swap - 16GB

Finally, time to sleep! 

Most of this martyrium happened because I wasn't thinking clearly enough and decided to fix something with a fever! I should have waited a few days, and I could use those eight hours doing something more pleasant than reinstalling everything. Don't make the same mistake. Learn from my suffering! 

There is, of course, more. As always, after a clean installation, nothing is configured to my liking; there are no applications installed I would like to have. But that's just a minor issue compared to all of the above. 

There is a silver lining too. During this long night, I made a discovery of the month! [Ventoy](https://www.ventoy.net/) - a beneficial tool for installing computers. Install Ventoy onto a USB drive and afterwards put any number of installation ISO files on the drive. Choose which ISO you want to boot into when booting from this USB. You don't need to prepare an installation USB ever again. Just copy all the installation ISOs you might need and choose on boot. One dongle to rule them all!