Execute command before auto mounting a disk drive

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
2
down vote

favorite












I have many external hard drives that often I need to run sudo ntfsfix /dev/sdf2 on after coming from a windows boot.



I do shutdown windows, but still this error persists.



I would like to have this command run before the drive auto loads, thus enabling me to use the drive as normal.







share|improve this question
























    up vote
    2
    down vote

    favorite












    I have many external hard drives that often I need to run sudo ntfsfix /dev/sdf2 on after coming from a windows boot.



    I do shutdown windows, but still this error persists.



    I would like to have this command run before the drive auto loads, thus enabling me to use the drive as normal.







    share|improve this question






















      up vote
      2
      down vote

      favorite









      up vote
      2
      down vote

      favorite











      I have many external hard drives that often I need to run sudo ntfsfix /dev/sdf2 on after coming from a windows boot.



      I do shutdown windows, but still this error persists.



      I would like to have this command run before the drive auto loads, thus enabling me to use the drive as normal.







      share|improve this question












      I have many external hard drives that often I need to run sudo ntfsfix /dev/sdf2 on after coming from a windows boot.



      I do shutdown windows, but still this error persists.



      I would like to have this command run before the drive auto loads, thus enabling me to use the drive as normal.









      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 13 at 23:10









      Jamie Hutber

      1001212




      1001212




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          1
          down vote













          While not a simple answer,you can add udev rules to accomplish this.



          I looked around and couldn't find any NTFS disks to write an example, but the ceph project uses this for auto-mounting disks.



          Their needs are far broader than yours but look through these files.



          https://github.com/ceph/ceph/tree/master/udev



          With the caveat that I am unable to test, the rule you will need to add will look similar to this.



          ACTION=="add", ENVID_FS_TYPE=="ntfs", RUN+="/bin/ntfsfix /dev/%k"





          share|improve this answer




















          • That was my idea, too, but I see the problem that the automounting has to be delayed somehow. I guess if the block device is opened by fsck then a mount would fail. Maybe the device name could be something which the automounter ignores and be changed after the fsck run is finished.
            – Hauke Laging
            Jan 14 at 11:25

















          up vote
          1
          down vote













          This usually happens if you have Fast Startup enabled in Windows (as it is by default in Windows 8 and 10).



          When shutting down with Fast Startup enabled, Windows does not really perform the complete shut-down procedure. Instead, it ends the user session, minimizes its memory footprint and essentially hibernates. What it does not do, is the equivalent of properly unmounting any local filesystems. If Windows is the only OS on the system, that's not a problem; but if you're dual-booting, it causes the exact problem you seem to be having.



          Disabling Fast Startup should elimenate the requirement to routinely run ntfsfix.






          share|improve this answer




















            Your Answer







            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "106"
            ;
            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',
            convertImagesToLinks: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );








             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f416932%2fexecute-command-before-auto-mounting-a-disk-drive%23new-answer', 'question_page');

            );

            Post as a guest






























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            1
            down vote













            While not a simple answer,you can add udev rules to accomplish this.



            I looked around and couldn't find any NTFS disks to write an example, but the ceph project uses this for auto-mounting disks.



            Their needs are far broader than yours but look through these files.



            https://github.com/ceph/ceph/tree/master/udev



            With the caveat that I am unable to test, the rule you will need to add will look similar to this.



            ACTION=="add", ENVID_FS_TYPE=="ntfs", RUN+="/bin/ntfsfix /dev/%k"





            share|improve this answer




















            • That was my idea, too, but I see the problem that the automounting has to be delayed somehow. I guess if the block device is opened by fsck then a mount would fail. Maybe the device name could be something which the automounter ignores and be changed after the fsck run is finished.
              – Hauke Laging
              Jan 14 at 11:25














            up vote
            1
            down vote













            While not a simple answer,you can add udev rules to accomplish this.



            I looked around and couldn't find any NTFS disks to write an example, but the ceph project uses this for auto-mounting disks.



            Their needs are far broader than yours but look through these files.



            https://github.com/ceph/ceph/tree/master/udev



            With the caveat that I am unable to test, the rule you will need to add will look similar to this.



            ACTION=="add", ENVID_FS_TYPE=="ntfs", RUN+="/bin/ntfsfix /dev/%k"





            share|improve this answer




















            • That was my idea, too, but I see the problem that the automounting has to be delayed somehow. I guess if the block device is opened by fsck then a mount would fail. Maybe the device name could be something which the automounter ignores and be changed after the fsck run is finished.
              – Hauke Laging
              Jan 14 at 11:25












            up vote
            1
            down vote










            up vote
            1
            down vote









            While not a simple answer,you can add udev rules to accomplish this.



            I looked around and couldn't find any NTFS disks to write an example, but the ceph project uses this for auto-mounting disks.



            Their needs are far broader than yours but look through these files.



            https://github.com/ceph/ceph/tree/master/udev



            With the caveat that I am unable to test, the rule you will need to add will look similar to this.



            ACTION=="add", ENVID_FS_TYPE=="ntfs", RUN+="/bin/ntfsfix /dev/%k"





            share|improve this answer












            While not a simple answer,you can add udev rules to accomplish this.



            I looked around and couldn't find any NTFS disks to write an example, but the ceph project uses this for auto-mounting disks.



            Their needs are far broader than yours but look through these files.



            https://github.com/ceph/ceph/tree/master/udev



            With the caveat that I am unable to test, the rule you will need to add will look similar to this.



            ACTION=="add", ENVID_FS_TYPE=="ntfs", RUN+="/bin/ntfsfix /dev/%k"






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Jan 14 at 4:19









            gdahlm

            50136




            50136











            • That was my idea, too, but I see the problem that the automounting has to be delayed somehow. I guess if the block device is opened by fsck then a mount would fail. Maybe the device name could be something which the automounter ignores and be changed after the fsck run is finished.
              – Hauke Laging
              Jan 14 at 11:25
















            • That was my idea, too, but I see the problem that the automounting has to be delayed somehow. I guess if the block device is opened by fsck then a mount would fail. Maybe the device name could be something which the automounter ignores and be changed after the fsck run is finished.
              – Hauke Laging
              Jan 14 at 11:25















            That was my idea, too, but I see the problem that the automounting has to be delayed somehow. I guess if the block device is opened by fsck then a mount would fail. Maybe the device name could be something which the automounter ignores and be changed after the fsck run is finished.
            – Hauke Laging
            Jan 14 at 11:25




            That was my idea, too, but I see the problem that the automounting has to be delayed somehow. I guess if the block device is opened by fsck then a mount would fail. Maybe the device name could be something which the automounter ignores and be changed after the fsck run is finished.
            – Hauke Laging
            Jan 14 at 11:25












            up vote
            1
            down vote













            This usually happens if you have Fast Startup enabled in Windows (as it is by default in Windows 8 and 10).



            When shutting down with Fast Startup enabled, Windows does not really perform the complete shut-down procedure. Instead, it ends the user session, minimizes its memory footprint and essentially hibernates. What it does not do, is the equivalent of properly unmounting any local filesystems. If Windows is the only OS on the system, that's not a problem; but if you're dual-booting, it causes the exact problem you seem to be having.



            Disabling Fast Startup should elimenate the requirement to routinely run ntfsfix.






            share|improve this answer
























              up vote
              1
              down vote













              This usually happens if you have Fast Startup enabled in Windows (as it is by default in Windows 8 and 10).



              When shutting down with Fast Startup enabled, Windows does not really perform the complete shut-down procedure. Instead, it ends the user session, minimizes its memory footprint and essentially hibernates. What it does not do, is the equivalent of properly unmounting any local filesystems. If Windows is the only OS on the system, that's not a problem; but if you're dual-booting, it causes the exact problem you seem to be having.



              Disabling Fast Startup should elimenate the requirement to routinely run ntfsfix.






              share|improve this answer






















                up vote
                1
                down vote










                up vote
                1
                down vote









                This usually happens if you have Fast Startup enabled in Windows (as it is by default in Windows 8 and 10).



                When shutting down with Fast Startup enabled, Windows does not really perform the complete shut-down procedure. Instead, it ends the user session, minimizes its memory footprint and essentially hibernates. What it does not do, is the equivalent of properly unmounting any local filesystems. If Windows is the only OS on the system, that's not a problem; but if you're dual-booting, it causes the exact problem you seem to be having.



                Disabling Fast Startup should elimenate the requirement to routinely run ntfsfix.






                share|improve this answer












                This usually happens if you have Fast Startup enabled in Windows (as it is by default in Windows 8 and 10).



                When shutting down with Fast Startup enabled, Windows does not really perform the complete shut-down procedure. Instead, it ends the user session, minimizes its memory footprint and essentially hibernates. What it does not do, is the equivalent of properly unmounting any local filesystems. If Windows is the only OS on the system, that's not a problem; but if you're dual-booting, it causes the exact problem you seem to be having.



                Disabling Fast Startup should elimenate the requirement to routinely run ntfsfix.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jan 14 at 7:57









                telcoM

                10.8k11132




                10.8k11132






















                     

                    draft saved


                    draft discarded


























                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f416932%2fexecute-command-before-auto-mounting-a-disk-drive%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Popular posts from this blog

                    How to check contact read email or not when send email to Individual?

                    Displaying single band from multi-band raster using QGIS

                    How many registers does an x86_64 CPU actually have?