reynhout / chrx

Chromebook Unix
419 stars 56 forks source link

[Feature Request] Add existing chroot detection BEFORE formatting /dev/xxx7 and offer to mount chroot for "recovery" instead #113

Open espoelstra opened 3 years ago

espoelstra commented 3 years ago

While debugging how to get EFI booting via the AltFW functionality of a newer Chromebook I would have loved to have this to edit the existing grub.cfg and packages rather than wait 10+ minutes to fully redo the Chrx installation of the Linux OS (I have pretty fast internet and an NVME).

I eventually (if you do something painful more than 3 times, automate it) threw together a script to mount things similar to what chrx-install sets up for chrx-install-chroot but instead of running a script I just drop into the $CHRX_INSTALL_ROOT on /dev/sda7 or /dev/nvme0n1p7 (dual booting and not using external media... yet) and end up with the ability to apt install packages and work with files in /boot and /etc.

https://gist.github.com/espoelstra/79a00f372cf6adb815b2815c2fbee215

I think to implement this "safety net" there would be a new flag called "--force-reinstall" or "--ignore-existing" that would trigger a format of the /dev/sda1 or /dev/sda7 (USB vs internal) similar to the current (scary) auto-nuke behavior, but instead of wiping a user's data if they accidentally run chrx and hit Enter instead of Ctrl+C or closing the Crosh window after they set up their dual boot, it will keep their data intact unless they REALLY want to blow it away.

Since ChromeOS doesn't use /boot I think a quick mount of the $CHRX_TARGET_DISK ROOT-C partition and looking for the /boot folder should be a fairly robust way of detecting something other than ChromeOS is present there. I think this slightly "slower" check that requires a mount makes more sense than assuming that just because we have the ROOT-C label that there was a successful installation.