-
-
Save DennisLfromGA/c14b5ec1e2c2de97cca05fdc4e512c59 to your computer and use it in GitHub Desktop.
########################################################################## | |
### THIS SCRIPT NO LONGER WORKS DUE TO RECENT CHANGES IN CHROMEOS Flex ### | |
########################################################################## | |
### Script to add cros_debug / dev mode option in grub.cfg | |
### ( Each Flex update removes cros_debug / dev mode option | |
### Be sure to run this script AFTER each update and BEFORE rebooting ) | |
ANS= | |
ROOTDEVICE= | |
ROOTDEVICEPREFIX= | |
P12MOUNTPOINT=/var/p12 | |
GRUBCFGPATH=$P12MOUNTPOINT/efi/boot | |
GRUBCFGFILE=grub.cfg | |
# Exits the script with return code $1, spitting out message $@ to stderr | |
error() { | |
local ecode="$1" | |
shift | |
echo "$*" 1>&2 | |
return "$ecode" | |
} | |
# Find the root device | |
# Sets: | |
# - $ROOTDEVICE as the root device (e.g. /dev/sda or /dev/mmcblk0) | |
# - $ROOTDEVICEPREFIX as a prefix for partitions (/dev/sda, /dev/mmcblk0p) | |
findrootdevice() { | |
ROOTDEVICE="`rootdev -d -s`" | |
if [ -z "$ROOTDEVICE" ]; then | |
error 1 "Cannot find root device." | |
fi | |
if [ ! -b "$ROOTDEVICE" ]; then | |
error 1 "$ROOTDEVICE is not a block device." | |
fi | |
# If $ROOTDEVICE ends with a number (e.g. mmcblk0), partitions are named | |
# ${ROOTDEVICE}pX (e.g. mmcblk0p1). If not (e.g. sda), they are named | |
# ${ROOTDEVICE}X (e.g. sda1). | |
ROOTDEVICEPREFIX="$ROOTDEVICE" | |
if [ "${ROOTDEVICE%[0-9]}" != "$ROOTDEVICE" ]; then | |
ROOTDEVICEPREFIX="${ROOTDEVICE}p" | |
fi | |
} | |
findrootdevice | |
if [ ! -d $P12MOUNTPOINT ]; then | |
# Make mountpoint | |
echo "Making directory to mount partition 12" | |
sudo mkdir -p $P12MOUNTPOINT | |
elif [ ! -d $GRUBCFGPATH ]; then | |
# Mount EFI partition | |
echo "Mounting ${ROOTDEVICEPREFIX}12 on $P12MOUNTPOINT" | |
sudo mount ${ROOTDEVICEPREFIX}12 $P12MOUNTPOINT | |
fi | |
# Check for cros_debug option, need 5 | |
DEBUGCOUNT="$(grep 'cros_efi cros_debug' $GRUBCFGPATH/$GRUBCFGFILE | wc -l)" | |
if [ "$DEBUGCOUNT" -eq 5 ]; then | |
echo "cros_debug has been added to $GRUBCFGFILE, no changes needed." | |
exit | |
fi | |
# grub.cfg needs editing | |
echo "Editing $GRUBCFGFILE to add 'cros_debug' option." | |
echo " | |
PLEASE NOTE: | |
I claim no responsibility for any damage or harm that may occur to your | |
device as a result of running this script. PROCEED AT YOR OWN RISK. | |
" | |
echo -n "[ press ENTER to continue - Ctrl-C to abort ] "; read ANS | |
cp $GRUBCFGPATH/$GRUBCFGFILE /tmp | |
# vi /tmp/$GRUBCFGFILE | |
sed -e 's/cros_efi /cros_efi cros_debug /' -e 's/cros_efi root/cros_efi cros_debug root/' /tmp/$GRUBCFGFILE | |
sudo cp $GRUBCFGPATH/$GRUBCFGFILE $GRUBCFGPATH/${GRUBCFGFILE}.bak | |
sudo cp /tmp/$GRUBCFGFILE $GRUBCFGPATH/ | |
echo "Done, you can reboot now." | |
exit |
@idarek
Sorry, I should take it down since it no longer works.
The devs have made changes to Flex with ownership and mount points that prevent this script from working correctly now.
Please leave it up as it is a top hit in google search, and if nothing else will help spread the word that cros_debug option no longer seems to boot dev mode. If and when we find how to turn on developer mode on newer flex versions we can link it here. No answers yet at:
https://support.google.com/chromeosflex/thread/285244470/unable-to-enter-developer-mode-on-chromeos-flex-version-126?hl=en#redirected=true
The cros_debug flag may be enabling shell at crosh prompt again ;-) At least for me, as of Feb 2025. I have dev-channel flex on old intel efi thinkpad, that today updated to Version 134.0.6998.5 (Official Build) dev (64-bit). I dual-boot to linux (using refind), and manually edited grub.cfg (typically in /dev/sda12 partition) adding in 5 places "cros_debug" (after cros_efi). Doing ctrl-alt-T at crosh prompt the shell command gave me a bash prompt. I was getting seg faults but fixed it per https://superuser.com/questions/1842739/chromeos-after-update-segmentation-fault-for-all-shell-commands. Chromebrew is only reason I want dev-mode, and so I am happy it works again :-)
CREW_FORCE_INSTALL=1 bash <(curl -Ls git.io/vddgY) && . ~/.bashrc
crosh> shell
Starting Chromebrew bash.
chronos@localhost / $ date
Mon Feb 10 04:32:36 -00 2025
chronos@localhost / $ crew install btop
Btop installed!
Just tested again for new install of flex on a second laptop, and the "cros_debug" let me get shell at crosh prompt. But then flex updated itself to 236 and after update I no longer got shell at crosh prompt, as apparently the update removed cros_debug. But good news is after I added back cros_debug, I was able to get /bin/bash shell at crosh prompt in newest flex os on my old thinkpad. Also, I think the sed command to use might better be something like this:
# I think sed below does this: for each line: if the line already has "cros_debug" do nothing (skip to next line)
# But If line does not have "cros_debug" then change "cros_efi" to "cros_efi cros_debug"
sed "/cros_debug/! s/cros_efi/cros_efi cros_debug/g"
# Should prevent issues if script is run more than once, ensuring grub.cfg has only one "grub_debug" per line.
I'll update with step-by-step howto and details when I have a chance. But it seems the "BROKEN" warning might be removed for now ;-)
Even after recent 133 update I still can type "shell" at crosh prompt and get bash prompt. Around 2025-02-28, several 10-15 year old laptops updated to 133 version of chromeos-flex. for example: .
- OS variant: Chrome OS
- OS version: reven-release/R133-16151.53.0
- OS channel: stable-channel
BUT, after updates I did have to re-edit grub.cfg (by choosing to boot to Linux in refind). Sometimes, even after the edit, crosh still would not run the shell command. But I did a second edit, and after 2nd reboot, crosh gave me a shell prompt. So, seems like Google and/or the chromium-os folks have (unofficially) restored ability to get dev-mode (shell at crosh prompt) and this ability is no longer broken, at least for most of 2025 for all my 5 or so ChromeOS-flex laptops. And chromebrew can install and run any of the crew packages, including Firefox/brave, etc, on all of them. It is nice not to have to use chrome on flex (or even non-flex) Chromebooks ;-)
Hi. A simple (may be silly question) but how to run this script in ChromeOS Flex environment?