A command which checks that trim is working?












4















I have installed Ubuntu 14.04 LTS 64bit, and would like to make sure that TRIM is enabled (as much as I know - it is enabled by default). Is there some sort of command which would help me to find out if it is working correctly?










share|improve this question

























  • Read this

    – girardengo
    May 11 '14 at 12:45


















4















I have installed Ubuntu 14.04 LTS 64bit, and would like to make sure that TRIM is enabled (as much as I know - it is enabled by default). Is there some sort of command which would help me to find out if it is working correctly?










share|improve this question

























  • Read this

    – girardengo
    May 11 '14 at 12:45
















4












4








4








I have installed Ubuntu 14.04 LTS 64bit, and would like to make sure that TRIM is enabled (as much as I know - it is enabled by default). Is there some sort of command which would help me to find out if it is working correctly?










share|improve this question
















I have installed Ubuntu 14.04 LTS 64bit, and would like to make sure that TRIM is enabled (as much as I know - it is enabled by default). Is there some sort of command which would help me to find out if it is working correctly?







trim






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 8 '16 at 9:37









thirtythreeforty

1,132619




1,132619










asked May 11 '14 at 12:18









MariusMarius

484169




484169













  • Read this

    – girardengo
    May 11 '14 at 12:45





















  • Read this

    – girardengo
    May 11 '14 at 12:45



















Read this

– girardengo
May 11 '14 at 12:45







Read this

– girardengo
May 11 '14 at 12:45












3 Answers
3






active

oldest

votes


















5














You can perform a sudo fstrim -v / (replace "/" with other mountpoints, if you have any), to check if fstrim gives any errors.
If it doesn't, type in cat /etc/cron.weekly/fstrim which should give you an output like:



#!/bin/sh
# call fstrim-all to trim all mounted file systems which support it
set -e
#
# This only runs on Intel and Samsung SSDs by default, as some SSDs with
# faulty firmware may encounter data loss when running fstrim under high I/O
# load (e. g. https://launchpad.net/bugs/1259829). You can append the
# --no-model-check option here to disable the vendor check and run fstrim on
# all SSD drives Like this (remove the hash):
#exec fstrim-all --no-model-check
exec fstrim-all


If it does, it means, that your Ubuntu automatically recognized that you have an SSD and will trim it once a week as a cron job.



If you like to optimize your system for SSD, check out this article.






share|improve this answer

































    1














    I would suggest that a more direct, if somewhat more complex, way to ensure that trim is working is by creating a file, identifying precisely where this file is stored, checking the contents of the file at this location, deleting the file, and then re-checking the contents of the file's location. If trim is working, the original contents of the file will have been replaced by zeros. The method and the specific commands to conduct this test are documented at: http://andyduffell.com/techblog/?p=852. A specific example of the technique is provided at: https://linuxnorth.wordpress.com/2014/03/18/trim-your-ssd-down-to-size/






    share|improve this answer































      0
















      On 18.04, you may check it in syslog:



      cat /var/log/syslog | grep -a fstrim | tail


      if you see recent dates and all your SSD's mountpoints, it's working. Sample output:



      Oct  1 14:54:55 justapc fstrim[769]: /home: 80,1 GiB (86008037376 bytes) trimmed
      Oct 1 14:54:55 justapc fstrim[769]: /boot: 360,2 MiB (377663488 bytes) trimmed
      Oct 1 14:54:55 justapc fstrim[769]: /: 16,3 GiB (17486880768 bytes) trimmed
      Oct 8 08:16:01 justapc fstrim[792]: /home: 76,8 GiB (82423615488 bytes) trimmed
      Oct 8 08:16:01 justapc fstrim[792]: /boot: 360,1 MiB (377634816 bytes) trimmed
      Oct 8 08:16:01 justapc fstrim[792]: /: 15,9 GiB (17038168064 bytes) trimmed
      Oct 8 08:16:44 justapc ureadahead[283]: ureadahead:trimage_trimage.png: Ignored relative path
      Oct 15 20:14:00 justapc fstrim[749]: /home: 73,5 GiB (78863814656 bytes) trimmed
      Oct 15 20:14:00 justapc fstrim[749]: /boot: 360,1 MiB (377634816 bytes) trimmed
      Oct 15 20:14:00 justapc fstrim[749]: /: 16 GiB (17104076800 bytes) trimmed


      To be sure of any possible errors, verbose fstrim manually:



      for mountpoint in $(cat /etc/fstab | awk '/ext[0-9]/ {print $2}'); do sudo fstrim -v "$mountpoint"; done





      share|improve this answer

























        Your Answer








        StackExchange.ready(function() {
        var channelOptions = {
        tags: "".split(" "),
        id: "89"
        };
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function() {
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled) {
        StackExchange.using("snippets", function() {
        createEditor();
        });
        }
        else {
        createEditor();
        }
        });

        function createEditor() {
        StackExchange.prepareEditor({
        heartbeatType: 'answer',
        autoActivateHeartbeat: false,
        convertImagesToLinks: true,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: 10,
        bindNavPrevention: true,
        postfix: "",
        imageUploader: {
        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
        allowUrls: true
        },
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        });


        }
        });














        draft saved

        draft discarded


















        StackExchange.ready(
        function () {
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f464306%2fa-command-which-checks-that-trim-is-working%23new-answer', 'question_page');
        }
        );

        Post as a guest















        Required, but never shown

























        3 Answers
        3






        active

        oldest

        votes








        3 Answers
        3






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        5














        You can perform a sudo fstrim -v / (replace "/" with other mountpoints, if you have any), to check if fstrim gives any errors.
        If it doesn't, type in cat /etc/cron.weekly/fstrim which should give you an output like:



        #!/bin/sh
        # call fstrim-all to trim all mounted file systems which support it
        set -e
        #
        # This only runs on Intel and Samsung SSDs by default, as some SSDs with
        # faulty firmware may encounter data loss when running fstrim under high I/O
        # load (e. g. https://launchpad.net/bugs/1259829). You can append the
        # --no-model-check option here to disable the vendor check and run fstrim on
        # all SSD drives Like this (remove the hash):
        #exec fstrim-all --no-model-check
        exec fstrim-all


        If it does, it means, that your Ubuntu automatically recognized that you have an SSD and will trim it once a week as a cron job.



        If you like to optimize your system for SSD, check out this article.






        share|improve this answer






























          5














          You can perform a sudo fstrim -v / (replace "/" with other mountpoints, if you have any), to check if fstrim gives any errors.
          If it doesn't, type in cat /etc/cron.weekly/fstrim which should give you an output like:



          #!/bin/sh
          # call fstrim-all to trim all mounted file systems which support it
          set -e
          #
          # This only runs on Intel and Samsung SSDs by default, as some SSDs with
          # faulty firmware may encounter data loss when running fstrim under high I/O
          # load (e. g. https://launchpad.net/bugs/1259829). You can append the
          # --no-model-check option here to disable the vendor check and run fstrim on
          # all SSD drives Like this (remove the hash):
          #exec fstrim-all --no-model-check
          exec fstrim-all


          If it does, it means, that your Ubuntu automatically recognized that you have an SSD and will trim it once a week as a cron job.



          If you like to optimize your system for SSD, check out this article.






          share|improve this answer




























            5












            5








            5







            You can perform a sudo fstrim -v / (replace "/" with other mountpoints, if you have any), to check if fstrim gives any errors.
            If it doesn't, type in cat /etc/cron.weekly/fstrim which should give you an output like:



            #!/bin/sh
            # call fstrim-all to trim all mounted file systems which support it
            set -e
            #
            # This only runs on Intel and Samsung SSDs by default, as some SSDs with
            # faulty firmware may encounter data loss when running fstrim under high I/O
            # load (e. g. https://launchpad.net/bugs/1259829). You can append the
            # --no-model-check option here to disable the vendor check and run fstrim on
            # all SSD drives Like this (remove the hash):
            #exec fstrim-all --no-model-check
            exec fstrim-all


            If it does, it means, that your Ubuntu automatically recognized that you have an SSD and will trim it once a week as a cron job.



            If you like to optimize your system for SSD, check out this article.






            share|improve this answer















            You can perform a sudo fstrim -v / (replace "/" with other mountpoints, if you have any), to check if fstrim gives any errors.
            If it doesn't, type in cat /etc/cron.weekly/fstrim which should give you an output like:



            #!/bin/sh
            # call fstrim-all to trim all mounted file systems which support it
            set -e
            #
            # This only runs on Intel and Samsung SSDs by default, as some SSDs with
            # faulty firmware may encounter data loss when running fstrim under high I/O
            # load (e. g. https://launchpad.net/bugs/1259829). You can append the
            # --no-model-check option here to disable the vendor check and run fstrim on
            # all SSD drives Like this (remove the hash):
            #exec fstrim-all --no-model-check
            exec fstrim-all


            If it does, it means, that your Ubuntu automatically recognized that you have an SSD and will trim it once a week as a cron job.



            If you like to optimize your system for SSD, check out this article.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited May 11 '14 at 12:57









            karel

            60.5k13131155




            60.5k13131155










            answered May 11 '14 at 12:53









            BelfryGhostBelfryGhost

            1645




            1645

























                1














                I would suggest that a more direct, if somewhat more complex, way to ensure that trim is working is by creating a file, identifying precisely where this file is stored, checking the contents of the file at this location, deleting the file, and then re-checking the contents of the file's location. If trim is working, the original contents of the file will have been replaced by zeros. The method and the specific commands to conduct this test are documented at: http://andyduffell.com/techblog/?p=852. A specific example of the technique is provided at: https://linuxnorth.wordpress.com/2014/03/18/trim-your-ssd-down-to-size/






                share|improve this answer




























                  1














                  I would suggest that a more direct, if somewhat more complex, way to ensure that trim is working is by creating a file, identifying precisely where this file is stored, checking the contents of the file at this location, deleting the file, and then re-checking the contents of the file's location. If trim is working, the original contents of the file will have been replaced by zeros. The method and the specific commands to conduct this test are documented at: http://andyduffell.com/techblog/?p=852. A specific example of the technique is provided at: https://linuxnorth.wordpress.com/2014/03/18/trim-your-ssd-down-to-size/






                  share|improve this answer


























                    1












                    1








                    1







                    I would suggest that a more direct, if somewhat more complex, way to ensure that trim is working is by creating a file, identifying precisely where this file is stored, checking the contents of the file at this location, deleting the file, and then re-checking the contents of the file's location. If trim is working, the original contents of the file will have been replaced by zeros. The method and the specific commands to conduct this test are documented at: http://andyduffell.com/techblog/?p=852. A specific example of the technique is provided at: https://linuxnorth.wordpress.com/2014/03/18/trim-your-ssd-down-to-size/






                    share|improve this answer













                    I would suggest that a more direct, if somewhat more complex, way to ensure that trim is working is by creating a file, identifying precisely where this file is stored, checking the contents of the file at this location, deleting the file, and then re-checking the contents of the file's location. If trim is working, the original contents of the file will have been replaced by zeros. The method and the specific commands to conduct this test are documented at: http://andyduffell.com/techblog/?p=852. A specific example of the technique is provided at: https://linuxnorth.wordpress.com/2014/03/18/trim-your-ssd-down-to-size/







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Apr 28 '16 at 13:00









                    CentaurusACentaurusA

                    2,2451424




                    2,2451424























                        0
















                        On 18.04, you may check it in syslog:



                        cat /var/log/syslog | grep -a fstrim | tail


                        if you see recent dates and all your SSD's mountpoints, it's working. Sample output:



                        Oct  1 14:54:55 justapc fstrim[769]: /home: 80,1 GiB (86008037376 bytes) trimmed
                        Oct 1 14:54:55 justapc fstrim[769]: /boot: 360,2 MiB (377663488 bytes) trimmed
                        Oct 1 14:54:55 justapc fstrim[769]: /: 16,3 GiB (17486880768 bytes) trimmed
                        Oct 8 08:16:01 justapc fstrim[792]: /home: 76,8 GiB (82423615488 bytes) trimmed
                        Oct 8 08:16:01 justapc fstrim[792]: /boot: 360,1 MiB (377634816 bytes) trimmed
                        Oct 8 08:16:01 justapc fstrim[792]: /: 15,9 GiB (17038168064 bytes) trimmed
                        Oct 8 08:16:44 justapc ureadahead[283]: ureadahead:trimage_trimage.png: Ignored relative path
                        Oct 15 20:14:00 justapc fstrim[749]: /home: 73,5 GiB (78863814656 bytes) trimmed
                        Oct 15 20:14:00 justapc fstrim[749]: /boot: 360,1 MiB (377634816 bytes) trimmed
                        Oct 15 20:14:00 justapc fstrim[749]: /: 16 GiB (17104076800 bytes) trimmed


                        To be sure of any possible errors, verbose fstrim manually:



                        for mountpoint in $(cat /etc/fstab | awk '/ext[0-9]/ {print $2}'); do sudo fstrim -v "$mountpoint"; done





                        share|improve this answer






























                          0
















                          On 18.04, you may check it in syslog:



                          cat /var/log/syslog | grep -a fstrim | tail


                          if you see recent dates and all your SSD's mountpoints, it's working. Sample output:



                          Oct  1 14:54:55 justapc fstrim[769]: /home: 80,1 GiB (86008037376 bytes) trimmed
                          Oct 1 14:54:55 justapc fstrim[769]: /boot: 360,2 MiB (377663488 bytes) trimmed
                          Oct 1 14:54:55 justapc fstrim[769]: /: 16,3 GiB (17486880768 bytes) trimmed
                          Oct 8 08:16:01 justapc fstrim[792]: /home: 76,8 GiB (82423615488 bytes) trimmed
                          Oct 8 08:16:01 justapc fstrim[792]: /boot: 360,1 MiB (377634816 bytes) trimmed
                          Oct 8 08:16:01 justapc fstrim[792]: /: 15,9 GiB (17038168064 bytes) trimmed
                          Oct 8 08:16:44 justapc ureadahead[283]: ureadahead:trimage_trimage.png: Ignored relative path
                          Oct 15 20:14:00 justapc fstrim[749]: /home: 73,5 GiB (78863814656 bytes) trimmed
                          Oct 15 20:14:00 justapc fstrim[749]: /boot: 360,1 MiB (377634816 bytes) trimmed
                          Oct 15 20:14:00 justapc fstrim[749]: /: 16 GiB (17104076800 bytes) trimmed


                          To be sure of any possible errors, verbose fstrim manually:



                          for mountpoint in $(cat /etc/fstab | awk '/ext[0-9]/ {print $2}'); do sudo fstrim -v "$mountpoint"; done





                          share|improve this answer




























                            0












                            0








                            0









                            On 18.04, you may check it in syslog:



                            cat /var/log/syslog | grep -a fstrim | tail


                            if you see recent dates and all your SSD's mountpoints, it's working. Sample output:



                            Oct  1 14:54:55 justapc fstrim[769]: /home: 80,1 GiB (86008037376 bytes) trimmed
                            Oct 1 14:54:55 justapc fstrim[769]: /boot: 360,2 MiB (377663488 bytes) trimmed
                            Oct 1 14:54:55 justapc fstrim[769]: /: 16,3 GiB (17486880768 bytes) trimmed
                            Oct 8 08:16:01 justapc fstrim[792]: /home: 76,8 GiB (82423615488 bytes) trimmed
                            Oct 8 08:16:01 justapc fstrim[792]: /boot: 360,1 MiB (377634816 bytes) trimmed
                            Oct 8 08:16:01 justapc fstrim[792]: /: 15,9 GiB (17038168064 bytes) trimmed
                            Oct 8 08:16:44 justapc ureadahead[283]: ureadahead:trimage_trimage.png: Ignored relative path
                            Oct 15 20:14:00 justapc fstrim[749]: /home: 73,5 GiB (78863814656 bytes) trimmed
                            Oct 15 20:14:00 justapc fstrim[749]: /boot: 360,1 MiB (377634816 bytes) trimmed
                            Oct 15 20:14:00 justapc fstrim[749]: /: 16 GiB (17104076800 bytes) trimmed


                            To be sure of any possible errors, verbose fstrim manually:



                            for mountpoint in $(cat /etc/fstab | awk '/ext[0-9]/ {print $2}'); do sudo fstrim -v "$mountpoint"; done





                            share|improve this answer

















                            On 18.04, you may check it in syslog:



                            cat /var/log/syslog | grep -a fstrim | tail


                            if you see recent dates and all your SSD's mountpoints, it's working. Sample output:



                            Oct  1 14:54:55 justapc fstrim[769]: /home: 80,1 GiB (86008037376 bytes) trimmed
                            Oct 1 14:54:55 justapc fstrim[769]: /boot: 360,2 MiB (377663488 bytes) trimmed
                            Oct 1 14:54:55 justapc fstrim[769]: /: 16,3 GiB (17486880768 bytes) trimmed
                            Oct 8 08:16:01 justapc fstrim[792]: /home: 76,8 GiB (82423615488 bytes) trimmed
                            Oct 8 08:16:01 justapc fstrim[792]: /boot: 360,1 MiB (377634816 bytes) trimmed
                            Oct 8 08:16:01 justapc fstrim[792]: /: 15,9 GiB (17038168064 bytes) trimmed
                            Oct 8 08:16:44 justapc ureadahead[283]: ureadahead:trimage_trimage.png: Ignored relative path
                            Oct 15 20:14:00 justapc fstrim[749]: /home: 73,5 GiB (78863814656 bytes) trimmed
                            Oct 15 20:14:00 justapc fstrim[749]: /boot: 360,1 MiB (377634816 bytes) trimmed
                            Oct 15 20:14:00 justapc fstrim[749]: /: 16 GiB (17104076800 bytes) trimmed


                            To be sure of any possible errors, verbose fstrim manually:



                            for mountpoint in $(cat /etc/fstab | awk '/ext[0-9]/ {print $2}'); do sudo fstrim -v "$mountpoint"; done






                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited Feb 25 at 14:25

























                            answered Oct 21 '18 at 16:29









                            crysmancrysman

                            192113




                            192113






























                                draft saved

                                draft discarded




















































                                Thanks for contributing an answer to Ask Ubuntu!


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid



                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.


                                To learn more, see our tips on writing great answers.




                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function () {
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f464306%2fa-command-which-checks-that-trim-is-working%23new-answer', 'question_page');
                                }
                                );

                                Post as a guest















                                Required, but never shown





















































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown

































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown







                                Popular posts from this blog

                                flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

                                Mangá

                                Eduardo VII do Reino Unido