Hey I'm just finishing up this process with my G5 H830 (T-Mobile).. hopefully this helps someone.
Important: when I downgraded from Android 8 to 7, the phone was forced into factory reset. Definitely make a backup of anything you don't want to be erased.
The phone was left to me by my dad and was on android 8. I found a code somewhere (I'll paste below) that allowed me to check the anti-rollback version of the phone and it was 1. Depending on your carrier, I believe there are different codes you input using the dial pad to reveal the anti-rollback "ARB" version. I would double check the firmware you're downloading matches, but from what I've seen, android 8 and 7 both ship as ARB 1. The way it works is the number can go forwards but not backwards. ARB 1 system can flash ARB 2, but then once you have 2, you can't go back to 1. This code is supposed to be for both AT&T and T-mobile: *#*#244773825625#*#* it worked for me. I was able to find the H83020a android 7 KDZ and flash it with LGUP. Still took me hours of work after that and switching between windows 10 and linux mint to root from there, but android 7 took easily. LGUP is only windows. but the ADB commands for dirty cow would not complete for me in windows. It would always hang on "adb logcat -s recowvery". I decided to try the dirty cow commands using linux mint with the ADB 1.0.39 (I believe current) and everything worked as stated in the post. The only difference in command for linux (which to me was actually easier) is that you only "cd" into the dirty cow folder and adb runs from the base terminal.
This was the only tutorial that worked for me and even at that it didn't work on the first PC I was trying it on.
The phone was on android 8, and now it's android 7 nougat with TWRP on the screen.
UPDATE:
I flashed Lineage through TWRP without wiping the phone, and Lineage used some sort of encryption. I would power on the device, and when Lineage loads, it asks for a password. There is no password. I had a lot of trouble getting back to TWRP recovery because of LG's extremely limited recovery handling system. You can't just hold down buttons during power on to get to the proper recovery menu. Once I figured out the button combo, (power + volume down, release power, hold power again), I was able to get to the LG menu to choose the option to factory wipe the phone. That sent me back to TWRP, and there I did an advanced wipe before trying Lineage a second time. After doing a complete wipe and format of the internal storage and then loading the Lineage zip back onto the phone, I was able to flash it again as normal through TWRP and the OS runs as it should. Clean and smooth. I still don't know what encryption was carried over, as I just did a factory reset to downgrade to the 20a nougat firmware, but Lineage seems to need the advanced wipe option in TWRP that formats the internal storage and erases any encryption. At least in my case, it was neccesary. Luckily, you can access internal storage via USB with TWRP running so you can copy off any important files before wiping.