Is it possible to run fstrim in stock android 4.3 from adb shell?

I understand it runs every 24 hours when the device is plugged in and idle but I would like to run on demand to test a few theories.

  • What phone are you using?
    – geffchang
    Commented Aug 10, 2013 at 6:35
  • Any updates from your end? Don't forget to upvote and accept answer if it works.
    – geffchang
    Commented Aug 12, 2013 at 6:52

3 Answers 3


WARNING: I have not tested this procedure.

You would need to have fstrim in system/bin. This XDA post has a DropBox download link.

start up adb and then switch users to root.

$ adb shell from your os terminal.

$ su to switch to the root user.

To copy fstrim to your /system/bin path you first need to mount the system path as Read/Write from adb or some other file manager

# mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system to mount /system as R/W

Then copy fstrim to the system path.

# cp <pathtofstrim>/fstrim /system/bin

Next you need to change permissions of fstrim to include execute.

# chmod 766 /system/bin/fstrim to make fstrim executable by root

After setting the correct permissions on fstrim you can run these commands from adb (as root):

# fstrim -v /data
# fstrim -v /cache
# fstrim -v /system

OR, you could go the EASY WAY. Install the LagFix app, and trigger fstrim on demand, provided your device has fstrim support!

  • I'm running stock 4.3 and LagFix fails with permission error even though it has root. That looks promising but but I'm super hesitant given it has no comments. Not saying it's bad but I need to backup first. looking at it in a hex editor it has a number of good strings but since it's compiled who knows what it does :)
    – hoss
    Commented Aug 10, 2013 at 4:56
  • @hoss If you want to read more comments about LagFix, the developer has a thread for the app on XDA: forum.xda-developers.com/showthread.php?t=2104326 I say it's safe to use it. :)
    – geffchang
    Commented Aug 10, 2013 at 6:34
  • Finally got LagFix working, I had to white list the app in su then clear the LagFix data then try again. Before I was getting a permission denied error even though it was white listed. I'll try this answer and see if it does as advertised.
    – hoss
    Commented Aug 10, 2013 at 17:59
  • I made some edits after doing some testing. The binary seems to be benign in that it doesn't seem to do anything malicious, and it seems to report that it did something but it's impossible to know if it did anything useful. I'll award this for the use of LagFix and if anyone can find an official fstrim bin that would complete the answer.
    – hoss
    Commented Aug 12, 2013 at 16:15
  • @hoss Did LagFix work? Did you download the fstrim on your phone, or did you download it on a Windows PC and copy it to your phone?
    – geffchang
    Commented Aug 12, 2013 at 16:24

On newer versions, Android runs fstrim with a daily schedule, provided that the conditions meet. Or it should run on a reboot if not run for 3+ days. See this answer for details.

However if you want to do TRIM manually, use Android's commandline tool sm fstrim. Previously this was vdc fstrim dotrim but added to Storage Manager in Oreo (1) and removed from vold in Pie (2).

In order to send FITRIM ioctl to selected filesystem(s) only, use fstrim tool; a busybox applet.

Both commands require root, or sm fstrim can be executed from adb shell.


vold, the (disk/eMMC) volume management daemon, has this built in. Its shell client is called "vdc" (vold controller I guess, akin to rndc, remote name daemon controller for BIND). The command and its relevant arguments, as the superuser, would be:

vdc fstrim dotrim

Note that at least on my tablet, 4.4.4, this will only trim /cache and /data, but this is mostly what I think you'd want. You can see its progress with logcat (e.g., logcat from a shell on the device or adb logcat on a USB connected host). Vold will output a message about each volume it trims and the fact that it's finished (in logcat).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .