cancel
Showing results for 
Search instead for 
Did you mean: 

Trim function works well on Linux/Ubuntu 9.10 64-bit

idata
Esteemed Contributor III

For those waiting for an updated TRIM enabled firmware for their x25-m 80gb g2 postville:

I flashed my drive and am trimming away!

If you track the conversation from here onwards you should be all set: http://www.ocztechnologyforum.com/forum/showthread.php?t=60882&page=10

1) download hdparm 9.27

2) make, make install

3) apply the latest patch mentioned in the thread above as presented on page 10 by danekl

4) copy wiper.sh to usr/local/bin

5) run from terminal: sudo wiper.sh --commit / or sudo wiper.sh --commit /dev/sdaN (where sdaN is your ssd)

BTW, this is not real TRIM but gives the same effect. I run this each time at system start up.

Skip Windows, go Ubuntu!

16 REPLIES 16

idata
Esteemed Contributor III

I can confirm that there seems to be a problem with the 2.6.32-kernel in Ubuntu

I get input/output-errors (though not always, some of the TRIM commands succeed) with 2.6.32. But using 2.6.35-rc1, all TRIM commands succeed.

idata
Esteemed Contributor III

# !/bin/bash

# # SATA SSD free-space TRIM utility, by Mark Lord

VERSION=2.5

# Copyright (C) 2009 Mark Lord. All rights reserved.# # Requires gawk, a really-recent hdparm, and various other programs.# This needs to be redone entirely in C, for 64-bit math, someday.# # This program is free software; you can redistribute it and/or# modify it under the terms of the GNU General Public License Version 2,# as published by the Free Software Foundation.# # This program is distributed in the hope that it would be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the# GNU General Public License for more details.# # You should have received a copy of the GNU General Public License# along with this program; if not, write to the Free Software Foundation,# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

export LANG=C

# The usual terse usage information:

# function usage_error(){ echo >&2 echo "Linux tune-up (TRIM) utility for SATA SSDs" echo "Usage: $0 [--verbose] [--commit] " >&2 echo " Eg: $0 /dev/sda1" >&2 echo >&2 exit 1}

# Parameter parsing for the main script.

# Yeah, we could use getopt here instead, but what fun would that be?#

echo

echo "${0# */}: Linux SATA SSD TRIM utility, version $VERSION, by Mark Lord."

verbose=0

commit=""argc=$# arg=""while [ $argc -gt 0 ]; do if [ "$1" = "--commit" ]; then commit=yes elif [ "$1" = "--verbose" ]; then verbose=1 elif [ "$1" = "" ]; then usage_error else if [ "$arg" != "" ]; then echo "$1: too many arguments, aborting." >&2 exit 1 fi arg="$1" fi argc=$((argc - 1)) shiftdone[ "$arg" = "" ] && usage_error

# Find a required program, or else give a nicer error message than we'd otherwise see:

# function find_prog(){ prog="$1" if [ ! -x "$prog" ]; then prog="${prog# */}" p=`type -f -P "$prog" 2>/dev/null` if [ "$p" = "" ]; then echo "$1: needed but not found, aborting." >&2 exit 1 fi prog="$p" [ $verbose -gt 0 ] && echo " --> using $prog instead of $1" >&2 fi echo "$prog"}

# Ensure we have most of the necessary utilities available before trying to proceed:

# hash -r # Refresh bash's cached PATH entriesHDPARM=`find_prog /sbin/hdparm` || exit 1FIND=`find_prog /usr/bin/find` || exit 1STAT=`find_prog /usr/bin/stat` || exit 1GAWK=`find_prog /usr/bin/gawk` || exit 1BLKID=`find_prog /sbin/blkid` || exit 1GREP=`find_prog /bin/grep` || exit 1ID=`find_prog /usr/bin/id` || exit 1LS=`find_prog /bin/ls` || exit 1DF=`find_prog /bin/df` || exit 1RM=`find_prog /bin/rm` || exit 1

# I suppose this will confuse the three SELinux users out there:

# if [ `$ID -u` -ne 0 ]; then echo "Only the super-user can use this (try \"sudo $0\" instead), aborting." >&2 exit 1fi

# We need a very modern hdparm, for its --fallocate and --trim-sector-ranges-stdin flags:

# Version 9.25 added automatic determination of safe max-size of TRIM commands.# HDPVER=`$HDPARM -V | $GAWK '{gsub("[^0-9.]","",$2); if ($2 > 0) print ($2 * 100); else print 0; exit(0)}'`if [ $HDPVER -lt 925 ]; then echo "$HDPARM: version >= 9.25 is required, aborting." >&2 exit 1fi

# Convert relative path "$1" into an absolute pathname, resolving all symlinks:

# function get_realpath(){ iter=0 p="$1" while [ -e "$p" -a $iter -lt 100 ]; do # Strip trailing slashes: while [ "$p" != "/" -a "$p" != "${p%%/}" ]; do p="${p%%/}" done # Split into directory:leaf portions: d="${p%/*}" t="${p# */}" # If the split worked, then cd into the directory portion: if [ "$d" != "" -a "$d" != "$p" ]; then cd -P "$d" || exit p="$t" fi # If what we have left is a directory, then cd to it and print realpath: if [ -d "$p" ]; then cd -P "$p" || exit pwd -P exit # Otherwise if it is a symlink, read the link and loop again: ...