Skip to content

Instantly share code, notes, and snippets.

@porteusconf
Forked from sj-dan/crosflex_downloader.sh
Created August 8, 2024 06:15
Show Gist options
  • Save porteusconf/b6707b315fb8f45c0e0521090700bdca to your computer and use it in GitHub Desktop.
Save porteusconf/b6707b315fb8f45c0e0521090700bdca to your computer and use it in GitHub Desktop.
Script to fetch and download the latest version of the Chrome OS Flex image
#!/bin/bash
URLs=$(curl "https://dl.google.com/dl/edgedl/chromeos/recovery/cloudready_recovery2.json" \
-s --output - | \
grep "^.*\"url\".*$" | \
sed "s/.*\"url\": \"\(.*\)\".*$/\1/g")
printf "\nPick which channel to download your image from. Channel name is near the end of the URL.\n\n"
select URL in $URLs;
do
if [[ $URL != "" ]]; then
printf "\nDownloading now...\n\n"
curl -L -C - -O $URL && break
else
printf "\nInvalid selection, please pick one of the above displayed numbers.\n\n"
fi
done
printf "\nFinished downloading!\n"
@porteusconf
Copy link
Author

porteusconf commented Aug 8, 2024

There is an alternative script that seems to download *bin.zip files ok for me. I used the chromiumos recovery.sh script at https://chromium.googlesource.com/chromiumos/user-recovery-tools/+/master/linux/recovery.sh And it can download the current newest DEV and/or STABLE chromeos-flex *bin.zip files with command-line argument --config URL where URL is https://dl.google.com/dl/edgedl/chromeos/recovery/cloudready_recovery2.conf as shown below. That is:

cd ~/Downloads # (or cd /Users/Shared or cd /tmp or cd /full-path-to-folder-where-script-is)
./recovery.sh --config "https://dl.google.com/dl/edgedl/chromeos/recovery/cloudready_recovery2.conf"
NOTE: To allow resuming partial downloads, it uses /tmp/tmp.crosrec by default as $WORKDIR. As a bonus, after the download it then optionally offers to write to a USB drive of your choice. I did not test the writing of usb yet, only the ability to download.
It is quite a nice little /bin/sh script: simple, but thorough and careful. It is designed to run on mac or linux. It does lots of sanity tests and error checking including checks of zipfilesize, unzipped filesize, checksum of zip file, and if there is enough room on usb flash drive to write the image. It uses dd to write the image to usb flash drive as fast as it can, with bs=4194304 (=1024*4096). Comments suggest in most cases sudo is not needed if you already have permissions for external drives.

Many BSD variants provide both normal /dev/FOO and raw /dev/rFOO devices,

with the raw path being much faster. If that device exists, we'll use it.

if [ -e /dev/r${user_choice} ]; then
user_choice="r${user_choice}"
fi
dd bs=4194304 of=/dev/${user_choice} if="$image_file" conv=sync ||
ufatal "Unable to write the image."
sync
...
Done. Remove the USB drive and insert it in your Chrome notebook.
Example transcript...

$ cd /tmp
$ curl "https://chromium.googlesource.com/chromiumos/user-recovery-tools/+/master/linux/recovery.sh?format=TEXT"
-s --output - | base64 --decode > recovery.sh
$ chmod a+x recovery.sh

$ ./recovery.sh --config "https://dl.google.com/dl/edgedl/chromeos/recovery/cloudready_recovery2.conf"
Working in /tmp/tmp.crosrec/
Downloading config file from https://dl.google.com/dl/edgedl/chromeos/recovery/cloudready_recovery2.conf

If you know the Model string displayed at the recovery screen,
type some or all of it; otherwise just press Enter:

This may take a few minutes to print the full list...

There are 3 recovery images to choose from:

0 -
1 - ChromeOS Flex
channel: LTC
2 - ChromeOS Flex
channel: LTR
3 - ChromeOS Flex
channel: STABLE

Please select a recovery image to download: 2
Downloading image zipfile from https://dl.google.com/dl/edgedl/chromeos/recovery/chromeos_15117.112.0_reven_recovery_stable-channel_mp-v2.bin.zip
% Total % Received % Xferd Average Speed Time Time Time Current

96 1151M 96 1110M 0 0 709k 0 0:27:42 0:26:44 0:00:58 594k
100 1151M 100 1151M 0 0 707k 0 0:27:46 0:27:46 --:--:-- 715k
Unpacking the zipfile
Archive: chromeos_15117.112.0_reven_recovery_stable-channel_mp-v2.bin.zip
inflating: chromeos_15117.112.0_reven_recovery_stable-channel_mp-v2.bin
I can't seem to find a valid USB drive. We need one with at least 6619MB capacity.

0 -

$. ls -lrt /tmp/tmp.crosrec/*.zip
1206930016 Dec 2 20:25 chromeos_15117.112.0_reven_recovery_stable-channel_mp-v2.bin.zip

$ ls /tmp/tmp.crosrec
chromeos_15117.112.0_reven_recovery_stable-channel_mp-v2.bin
chromeos_15117.112.0_reven_recovery_stable-channel_mp-v2.bin.zip
config.txt
debug.log
tmp.txt
version.txt
Note that tho I have very slow (2MBs/down) DSL internet, maybe google throttles downloads to even slower speeds??? More likely just my horrible speed of my declining century-link (aka brightspeed) ISP...
Here's the contents of short 2-entry cloudready_recovery2.conf file...

$ % curl -LGO https://dl.google.com/dl/edgedl/chromeos/recovery/cloudready_recovery2.conf
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 874 100 874 0 0 922 0 --:--:-- --:--:-- --:--:-- 938
$ cat cloudready_recovery2.conf
recovery_tool_version=0.9.2
recovery_tool_linux_version=0.9.2
recovery_tool_update=

name=ChromeOS Flex
version=14794.0.0
desc=
channel=DEV
hwidmatch=^REVEN($|-.*)
hwid=
md5=442e88dec2cf2201c82c60cc6ee9a8f6
sha1=93ebd1cf8c3463e668cc507f1b165ced6791831e
zipfilesize=1174071023
file=chromeos_14794.0.0_reven_recovery_dev-channel_mp-v2.bin
filesize=6939566592
url=https://dl.google.com/dl/edgedl/chromeos/recovery/chromeos_14794.0.0_reven_recovery_dev-channel_mp-v2.bin.zip

name=ChromeOS Flex
version=15117.112.0
desc=
channel=STABLE
hwidmatch=^REVEN($|-.*)
hwid=
md5=23cc0c6a0c0976e626e15f08b03a8691
sha1=99dd29cbc92df4a72f5c65348764a0b83a0f2bd5
zipfilesize=1206930016
file=chromeos_15117.112.0_reven_recovery_stable-channel_mp-v2.bin
filesize=6939566592
url=https://dl.google.com/dl/edgedl/chromeos/recovery/chromeos_15117.112.0_reven_recovery_stable-channel_mp-v2.bin.zip%
$
Note the zipfilesize=1206930016 matches the actual size of downloaded zip file. The recovery.sh script does warn if any of these are wrong: zipfilesize, filesize after unzip, checksum (md5 or sha1) of the zip file.

Running ./recovery.sh with no command-line arguments presents a menu of over 400 chromebook *bin.zip files to download...

$ cd /tmp
$ curl "https://chromium.googlesource.com/chromiumos/user-recovery-tools/+/master/linux/recovery.sh?format=TEXT"
-s --output - | base64 --decode > recovery.sh
$ chmod a+x recovery.sh
Working in /tmp/tmp.crosrec/
Downloading config file from https://dl.google.com/dl/edgedl/chromeos/recovery/recovery.conf
If you know the Model string displayed at the recovery screen,
type some or all of it; otherwise just press Enter:
This may take a few minutes to print the full list...
There are 442 recovery images to choose from:
...

0 -
1 - Dell Chromebook 13 (3380)
channel: STABLE
2 - ASUS Chromebook Flip CM3200FM1A
channel: STABLE
...
441 - Lenovo ThinkPad C13 Yoga Chromebook / Lenovo ThinkPad C13 Yoga Chromebook Enterprise
channel: STABLE
442 - NEC Chromebook Y1 Gen3A
channel: STABLE

Please select a recovery image to download: 244

Downloading image zipfile from https://dl.google.com/dl/edgedl/chromeos/recovery/chromeos_15117.111.0_octopus_recovery_stable-channel_mp-v31.bin.zip

% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed
100 1727M 100 1727M 0 0 220k 0 2:13:25 2:13:25 --:--:-- 85118
Unpacking the zipfile
Archive: chromeos_15117.111.0_octopus_recovery_stable-channel_mp-v31.bin.zip
inflating: chromeos_15117.111.0_octopus_recovery_stable-channel_mp-v31.bin

I can't seem to find a valid USB drive. We need one with at least 4773MB capacity.
0 -

Tell me what to do (or just press Enter to scan again): 0
$ ls -lrt *.zip
-rw-r--r-- 1 student wheel 293654528 Dec 2 19:24 chromeos_14794.0.0_reven_recovery_dev-channel_mp-v2.bin.zip

@porteusconf
Copy link
Author

porteusconf commented Aug 8, 2024

As an alternative to shell script, you can download flex recovery images in your browser using this non-google site https://chromeos.exerra.xyz/ It also lets you choose any of these 3: stable (newest), LTC (newer LongTermSupport Candidate, 3-month update) or LTR (older LongTermSupport Release, every 6 months) and shows you for each of the 3, the size, current versions of the recovery image. chrome version, hashes, etc. When I tested it seemed legit and safe as it actually did downloads directly from Google site https://dl.google.com/ with same download URL as the script got (below): for example https://dl.google.com/dl/edgedl/chromeos/recovery/chromeos_15662.115.0_reven_recovery_lts-channel_mp-v3.bin.zip

If you want to try the recovery.sh script instead, note that when I tested today, 2024-08-08, the downloads part of the script failed on a Chromebook in dev mode until I added -k option to curl and then I see this:

chronos@reven /mnt/stateful_partition/junk $ bash /usr/local/bin/recovery.sh --config "https://dl.google.com/dl/edgedl/chromeos/recovery/cloudready_recovery2.conf"
Working in /tmp/tmp.crosrec/
Downloading config file from https://dl.google.com/dl/edgedl/chromeos/recovery/cloudready_recovery2.conf

If you know the Model string displayed at the recovery screen,
type some or all of it; otherwise just press Enter:
This may take a few minutes to print the full list...
There are 3 recovery images to choose from:

0 -
1 - ChromeOS Flex
channel: LTC
2 - ChromeOS Flex
channel: LTR
3 - ChromeOS Flex
channel: STABLE

Please select a recovery image to download: 2
...
Unpacking the zipfile
Archive: chromeos_15662.115.0_reven_recovery_lts-channel_mp-v3.bin.zip
skipping: chromeos_15662.115.0_reven_recovery_lts-channel_mp-v3.bin need PK compat. v4.5 (can do v2.1)
The /tmp tmpfs partition on my flex laptop is only 1.9 gig, so it is a good thing the unzip fails because crew installed an ancient 2009 version 6 of unzip. However if you do crew install p7zip you can uncompress the zip file with 7z x chromeos*.zip (after moving to a partition with at least 8-9 gig free space, and able to hold a 9 gig file, (not a fat32 USB, tho maybe ExFAT might work).

@porteusconf
Copy link
Author

Info below about 3 versions available in 2025. (was translated from a russian zeroday website.. hard to find this info elsewhere ;-)

  • S (Stable, stable) — devices are automatically updated to the next stable version every month. Newer than LTC which is newer than LTS.

  • LTC (Long-term support candidate, long-term support candidate) — devices receive LTS functions 3 months before the release of the version on LTS. Devices are automatically updated to the next version of LTC. May have same or newer version of chromeos and chrome as LTS.

  • LTS (aka LTR) (Long-term support, long-term support) — devices are automatically updated to the next version of LTS every 6 months.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment