├── README.md
├── cros_pre_90
└── trimly.sh
├── manifest.xml
├── trimly.sh
├── trimly.svg
└── ver_hist.txt
/README.md:
--------------------------------------------------------------------------------
1 | # TrImLy
2 |
3 |
4 | __==__ __Your fstrim automator and defrag script for ChomiumOS!__ ___\*yay\*___ __==__
5 |
6 | # Function #
7 | -This shell util is intended to be used as a manually-run replacement for https://chromium.googlesource.com/chromiumos/platform2/+/refs/heads/master/trim/scripts/chromeos-trim/
8 |
9 | -ALSO featuring defrag (e4defrag) for people running Chromium OS or derivatives on hard drives. Chromebooks almost universally (except for some very old models) use SSDs, but CrOS source code only contains code to trim a solid state storage device after one or all of three conditions are met, but sometimes it does not do its job well, and of course has no optimization features for HDDs. This shell script presents the option to defrag your drive, and an option to trim your drive. You can do either or both, depending on your needs and whether you've got an SSD or traditional HDD.
10 |
11 | # Usage #
12 | _...enable dev mode, and enter crosh (terminal) first, obviously..._
13 |
14 | Simply copy trimly.sh to /usr/local/bin with `sudo cp ~/Downloads/trimly.sh /usr/local/bin/`, run `sudo chmod +x trimly.sh` to make it executable, and then run `sudo trimly.sh`.
15 | ## IMPORTANT UPDATE ##
16 | -ChromiumOS and ChromeOS use 12 partitions, whereas CloudReady up until ver. 89.4.44 used 27. Since Neverware's merge with Google, they are making their release timing to be more in tune with Google's, as well as changing the partition layout to the "standard GPT CrOS layout." Firstly, I was not thinking of this during initial development, as the motivation for this came from conversations on the CloudReady forums, and personal use of this script was always on CloudReady. Secondly, the partition numbers in the script would have never worked on ChromiumOS or ChromeOS, and now as of June 18, with the release of 90.1.42, won't work on CloudReady either. To fix all of this, I am making a copy of the current script (ver. 0.4) under the new folder "cros_pre_90", specifically for users who can't (i.e. 32 bit users), or don't want to upgrade. Everyone else (the majority), just use the regular TrImLy script.
17 |
18 | -Version history can be found in ver_hist.txt
19 |
20 | # Yessir #
21 | ...This project is FOSS, and is intended to be used with CloudReady https://www.neverware.com/ and Chromium OS https://www.chromium.org/chromium-os/, builds of which can be downloaded here > https://arnoldthebat.co.uk/wordpress/chromiumos-special-builds/
22 |
23 | Amazing what can be done with bash, huh?
24 |
--------------------------------------------------------------------------------
/cros_pre_90/trimly.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | ## TrImLy
4 | # trimly.sh
5 | ## VER. 0.4.1
6 |
7 | # constants (for coloring stdout)
8 | RED='\033[0;31m' # Red
9 | YEL='\033[1;33m' # Yellow
10 | NC='\033[0m' # No Color
11 |
12 | #start
13 | printf "${RED}--------------------------------------------------------------------------------${NC}\n"
14 | printf "\n"
15 |
16 | printf "${RED}== TrImLy - Your fstrim automator and defrag script for ChomiumOS ==${NC}\n"
17 | printf "\n"
18 | printf "Note: This script must be placed in /usr/local/bin,\n made executable with 'sudo chmod +x trimly.sh',\n and run with sudo (root) priveleges.\n"
19 | printf "\n"
20 |
21 | # conditional defrag (*will not work entirely on bind mounts used on /)
22 | printf "${YEL}You may optionally run e4defrag -v on the stateful_partition and root (/), note this will take some time, and\n is not needed very often on SSDs, but one should use this if installed to an HDD, as ChromiumOS has no auto-defrag. \nPlease answer 1 or 2.▼${NC}\n"
23 | printf "\n"
24 | select yn in "Yes" "No"; do
25 | case $yn in
26 | Yes ) printf "\n" && printf "${YEL}Defragmenting HDD...${NC}" && printf "\n" && e4defrag -v /dev/sda16 && printf "\n ${RED}Continuing...${NC}" && printf "\n"; break;;
27 | No ) printf "\n ${RED}Continuing...${NC}" && printf "\n"; break;;
28 | esac
29 | done
30 |
31 | # conditional trim (for SSD performance and longevity)
32 | # -run fstrim on all relevant partitions and mount points.
33 | # -mount rootfs to temp dir and fstrim them.
34 | printf "\n${YEL}You may now optionally run fstrim on all relevant partitions, mount points,\n and the two rootfs partitions A and B. Note that the time for completion\n depends on SSD size/speed, and the amount of deletions made since last trim. \nPlease answer 1 or 2.▼${NC}\n"
35 | printf "\n"
36 | select yn in "Yes" "No"; do
37 | case $yn in
38 | Yes ) printf "\n" && printf "${YEL}TRIMming SSD...${NC}\n" && fstrim -a -v && fstrim -v /mnt/stateful_partition/encrypted && fstrim -v /usr/share/oem && fstrim -v /mnt/stateful_partition && fstrim -v / && mkdir /rootfs_A && mount /dev/sda18 /rootfs_A && fstrim -v /rootfs_A && umount /dev/sda18 && mkdir /rootfs_B && mount /dev/sda20 /rootfs_B && fstrim -v /rootfs_B && umount /dev/sda20 && printf "fstrim -v completed successfully with status code 0" && printf "\n"; break;;
39 | No ) printf "\n ${RED}Skipping TRIM...${NC}" && printf "\n"; break;;
40 | esac
41 | done
42 |
43 | # cleanup and exit
44 | printf "\n"
45 | printf "\n ${RED}Done!${NC}\n"
46 | printf "\n-Cleaning up temporary rootfs mountpoints... (if you used TRIM)\n"
47 | rmdir /rootfs_A
48 | rmdir /rootfs_B
49 | printf "\n${YEL}TrImLy has optimized your storage device for faster I/O operations!${NC} *yay*\n"
50 | printf "${RED}--------------------------------------------------------------------------------${NC}\n"
51 | exit
52 |
53 | # Thanks to Ted Larson for motivating me to make this, my fellow nerd dad for too much to list here, and JCloud for fun chitchat.
54 | # Ted Larson and JCloud are users on the CloudReady user forums.
55 |
--------------------------------------------------------------------------------
/manifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | fstrim automator and defrag script for ChomiumOS
6 |
7 |
8 |
--------------------------------------------------------------------------------
/trimly.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Copyright (c) 2023 Alex313031
4 |
5 | ## TrImLy
6 | # trimly.sh
7 | ## VER. 0.5.2
8 |
9 | # constants (for coloring stdout)
10 | YEL='\033[1;33m' # Yellow
11 | CYA='\033[1;96m' # Cyan
12 | RED='\033[1;31m' # Red
13 | GRE='\033[1;32m' # Green
14 | c0='\033[0m' # Reset Text
15 | bold='\033[1m' # Bold Text
16 | underline='\033[4m' # Underline Text
17 | NC='\033[0m' # No Color
18 |
19 | #start
20 | printf "${RED}--------------------------------------------------------------------------------${NC}\n"
21 | printf "\n"
22 |
23 | printf "${RED}== TrImLy - Your fstrim automator and defrag script for ChromiumOS ==${NC}\n"
24 | printf "\n"
25 | printf "${RED}Note: This script must be placed in /usr/local/bin,\n made executable with 'sudo chmod +x trimly.sh',\n and run with sudo (root) priveleges.\n"
26 | printf "\n"
27 |
28 | # conditional defrag (*will not work entirely on bind mounts used on /)
29 | printf "${YEL}You may optionally run e4defrag -v on the stateful_partition and root (/), note this will take some time, and\n is not needed very often on SSDs, but one should use this if installed to an HDD, as ChromiumOS has no auto-defrag. \nPlease answer 1 or 2.▼${NC}\n"
30 | printf "\n"
31 | select yn in "Yes" "No"; do
32 | case $yn in
33 | Yes ) printf "\n" && printf "${YEL}Defragmenting HDD...${NC}" && printf "\n" && e4defrag -v /dev/sda1 && printf "\n ${RED}Continuing...${NC}" && printf "\n"; break;;
34 | No ) printf "\n ${RED}Continuing...${NC}" && printf "\n"; break;;
35 | esac
36 | done
37 |
38 | # conditional trim (for SSD performance and longevity)
39 | # -run fstrim on all relevant partitions and mount points.
40 | # -mount rootfs to temp dir and fstrim them.
41 | printf "\n${YEL}You may now optionally run fstrim on all relevant partitions, mount points,\n and the two rootfs partitions A and B. Note that the time for completion\n depends on SSD size/speed, and the amount of deletions made since last trim. \nPlease answer 1 or 2.▼${NC}\n"
42 | printf "\n"
43 | select yn in "Yes" "No"; do
44 | case $yn in
45 | Yes ) printf "\n" && printf "${YEL}TRIMming SSD...${NC}\n" && fstrim -a -v && fstrim -v /mnt/stateful_partition/encrypted && fstrim -v /usr/share/oem && fstrim -v /mnt/stateful_partition && fstrim -v / && mkdir /rootfs_A && mount /dev/sda3 /rootfs_A && fstrim -v /rootfs_A && umount /dev/sda3 && mkdir /rootfs_B && mount /dev/sda5 /rootfs_B && fstrim -v /rootfs_B && umount /dev/sda5 && printf "fstrim -v completed successfully with status code 0" && printf "\n"; break;;
46 | No ) printf "\n ${RED}Skipping TRIM...${NC}" && printf "\n"; break;;
47 | esac
48 | done
49 |
50 | # cleanup and exit
51 | printf "\n"
52 | printf "\n ${RED}Done!${NC}\n"
53 | printf "\n-Cleaning up temporary rootfs mountpoints... (if you used TRIM)\n"
54 | rmdir /rootfs_A
55 | rmdir /rootfs_B
56 | printf "\n${YEL}TrImLy has optimized your storage device for faster I/O operations!${NC} *yay*\n"
57 | printf "${RED}--------------------------------------------------------------------------------${NC}\n"
58 | exit
59 |
60 | # Thanks to Ted Larson for motivating me to make this, my fellow nerd dad for too much to list here, and JCloud for fun chitchat.
61 | # Ted Larson and JCloud are users on the CloudReady user forums.
62 |
--------------------------------------------------------------------------------
/trimly.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
54 |
--------------------------------------------------------------------------------
/ver_hist.txt:
--------------------------------------------------------------------------------
1 | # TrImLy
2 | --Version History--
3 |
4 | 0.5.1 & 0.4.1 - Added fstrim -a -v in fromt of the other fstrim lines to make sure we don't miss anything in older or future ChromiumOS versions.
5 | - Will also trim any other TRIMable drives/partitions attached to the system.
6 |
7 | 0.5 - Updated partition numbers to reflect correct layouts.
8 | -Added cros_90_dev dir and moved original trimly.sh to it.
9 | -Code refactoring, more comments and cleanup.
10 |
11 | 0.4 - Made trim conditional (this release will stay in cros_pre_90)
12 | -Backported refactoring and comments from 0.5.
13 |
14 | 0.3 - Cleaned up stuff & added coloured text and comments.
15 | -Thank yous and \n (new line characters) added.
16 |
17 | 0.2 - Added comments, made defrag conditional. (first actual upload)
18 | -Added manifest.xml for possible future use.
19 |
20 | 0.1 - First release (not uploaded)
21 | -Writen on cloudready with Text and Quantum code editors from web store.
22 |
23 | ----------------------------------------------------------------
24 |
--------------------------------------------------------------------------------