How can I mount a partition on every reboot using Bash Script? [duplicate]











up vote
2
down vote

favorite













This question already has an answer here:




  • How to mount partition permanently?

    1 answer




I have a partition mounted with mount /mnt/filesys.bin /mnt/mymnt/



Each time I reboot, I need to remount. How can I keep this mounted after every reboot?










share|improve this question







New contributor




Onyic is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











marked as duplicate by muru, karel, Melebius, N0rbert, Charles Green 2 days ago


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.











  • 2




    Hello. Isn't it possible to add entry in /etc/fstab for that?
    – pa4080
    2 days ago






  • 1




    Can you explain more? I am new to Linux
    – Onyic
    2 days ago






  • 1




    I think /etc/fstab is the correct think to look for, not a Bash script.
    – iBug
    2 days ago















up vote
2
down vote

favorite













This question already has an answer here:




  • How to mount partition permanently?

    1 answer




I have a partition mounted with mount /mnt/filesys.bin /mnt/mymnt/



Each time I reboot, I need to remount. How can I keep this mounted after every reboot?










share|improve this question







New contributor




Onyic is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











marked as duplicate by muru, karel, Melebius, N0rbert, Charles Green 2 days ago


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.











  • 2




    Hello. Isn't it possible to add entry in /etc/fstab for that?
    – pa4080
    2 days ago






  • 1




    Can you explain more? I am new to Linux
    – Onyic
    2 days ago






  • 1




    I think /etc/fstab is the correct think to look for, not a Bash script.
    – iBug
    2 days ago













up vote
2
down vote

favorite









up vote
2
down vote

favorite












This question already has an answer here:




  • How to mount partition permanently?

    1 answer




I have a partition mounted with mount /mnt/filesys.bin /mnt/mymnt/



Each time I reboot, I need to remount. How can I keep this mounted after every reboot?










share|improve this question







New contributor




Onyic is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












This question already has an answer here:




  • How to mount partition permanently?

    1 answer




I have a partition mounted with mount /mnt/filesys.bin /mnt/mymnt/



Each time I reboot, I need to remount. How can I keep this mounted after every reboot?





This question already has an answer here:




  • How to mount partition permanently?

    1 answer








scripts filesystem partitions






share|improve this question







New contributor




Onyic is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question







New contributor




Onyic is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question






New contributor




Onyic is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 2 days ago









Onyic

255




255




New contributor




Onyic is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Onyic is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Onyic is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




marked as duplicate by muru, karel, Melebius, N0rbert, Charles Green 2 days ago


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






marked as duplicate by muru, karel, Melebius, N0rbert, Charles Green 2 days ago


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.










  • 2




    Hello. Isn't it possible to add entry in /etc/fstab for that?
    – pa4080
    2 days ago






  • 1




    Can you explain more? I am new to Linux
    – Onyic
    2 days ago






  • 1




    I think /etc/fstab is the correct think to look for, not a Bash script.
    – iBug
    2 days ago














  • 2




    Hello. Isn't it possible to add entry in /etc/fstab for that?
    – pa4080
    2 days ago






  • 1




    Can you explain more? I am new to Linux
    – Onyic
    2 days ago






  • 1




    I think /etc/fstab is the correct think to look for, not a Bash script.
    – iBug
    2 days ago








2




2




Hello. Isn't it possible to add entry in /etc/fstab for that?
– pa4080
2 days ago




Hello. Isn't it possible to add entry in /etc/fstab for that?
– pa4080
2 days ago




1




1




Can you explain more? I am new to Linux
– Onyic
2 days ago




Can you explain more? I am new to Linux
– Onyic
2 days ago




1




1




I think /etc/fstab is the correct think to look for, not a Bash script.
– iBug
2 days ago




I think /etc/fstab is the correct think to look for, not a Bash script.
– iBug
2 days ago










2 Answers
2






active

oldest

votes

















up vote
11
down vote



accepted










From man fstab:




The file /etc/fstab contains descriptive information about the filesystems the system can mount. fstab is only read by programs, and not written; it is the duty of the system administrator to properly create and maintain this file.




To do what you want you just need to add an entry for this mount in /etc/fstab as follows:




  1. Open new terminal window Ctrl+Alt+T.



  2. Open the file /etc/fstab for edit with root privileges, using nano:



    sudo nano /etc/fstab



  3. Go to the bottom of the file and add the following line - here I'm assuming it is an image file, so we need to use the loop option (reference):



    /mnt/filesys.bin /mnt/mymnt/ auto nofail,defaults,loop 0 0


    If you want to mount physical device (or partition), you can identify it by several different ways, for example by its UUID. To find the UUID use sudo blkid while the device is mounted (or use the GUI tool Disks). In this case the entry could look like:



    /dev/disk/by-uuid/a58b40e4-eb9b-4720-835b-785a3be3ae33 /mnt/mymnt/ auto nosuid,nodev,nofail 0 0


    or:



    UUID=a58b40e4-eb9b-4720-835b-785a3be3ae33 /mnt/mymnt/ auto nosuid,nodev,nofail 0 0


    Where a58b40e4-eb9b-4720-835b-785a3be3ae33 is the UUID of your device.



  4. Save the file: Ctrl+O, then exit from nano: Ctrl+X.


  5. Restart the system or type sudo mount -a to see the result.



Do not forgot to remove that entry if you remove the image file.






share|improve this answer



















  • 2




    For external media I use UUID and the 'nofail' option. To get the UUID, issue the blkid command in terminal, while the device is mounted,then to fstab use UUID=<uuid> /mnt/mymount auto nofail,defaults
    – Stephen Boston
    2 days ago








  • 1




    @StephenBoston, thanks for the suggestion. I've updated the answer according to your comment.
    – pa4080
    2 days ago


















up vote
2
down vote













@pa4080 is totally right, but the really easy solution is (running as the superuser, so sudo su first):



mount /mnt/filesys.bin /mnt/mymnt/
grep mymnt /etc/mtab >>/etc/fstab


The first line mounts your device with whatever other options you need, the second will put it into /etc/fstab with the same options so that it gets mounted on every reboot.






share|improve this answer




























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    11
    down vote



    accepted










    From man fstab:




    The file /etc/fstab contains descriptive information about the filesystems the system can mount. fstab is only read by programs, and not written; it is the duty of the system administrator to properly create and maintain this file.




    To do what you want you just need to add an entry for this mount in /etc/fstab as follows:




    1. Open new terminal window Ctrl+Alt+T.



    2. Open the file /etc/fstab for edit with root privileges, using nano:



      sudo nano /etc/fstab



    3. Go to the bottom of the file and add the following line - here I'm assuming it is an image file, so we need to use the loop option (reference):



      /mnt/filesys.bin /mnt/mymnt/ auto nofail,defaults,loop 0 0


      If you want to mount physical device (or partition), you can identify it by several different ways, for example by its UUID. To find the UUID use sudo blkid while the device is mounted (or use the GUI tool Disks). In this case the entry could look like:



      /dev/disk/by-uuid/a58b40e4-eb9b-4720-835b-785a3be3ae33 /mnt/mymnt/ auto nosuid,nodev,nofail 0 0


      or:



      UUID=a58b40e4-eb9b-4720-835b-785a3be3ae33 /mnt/mymnt/ auto nosuid,nodev,nofail 0 0


      Where a58b40e4-eb9b-4720-835b-785a3be3ae33 is the UUID of your device.



    4. Save the file: Ctrl+O, then exit from nano: Ctrl+X.


    5. Restart the system or type sudo mount -a to see the result.



    Do not forgot to remove that entry if you remove the image file.






    share|improve this answer



















    • 2




      For external media I use UUID and the 'nofail' option. To get the UUID, issue the blkid command in terminal, while the device is mounted,then to fstab use UUID=<uuid> /mnt/mymount auto nofail,defaults
      – Stephen Boston
      2 days ago








    • 1




      @StephenBoston, thanks for the suggestion. I've updated the answer according to your comment.
      – pa4080
      2 days ago















    up vote
    11
    down vote



    accepted










    From man fstab:




    The file /etc/fstab contains descriptive information about the filesystems the system can mount. fstab is only read by programs, and not written; it is the duty of the system administrator to properly create and maintain this file.




    To do what you want you just need to add an entry for this mount in /etc/fstab as follows:




    1. Open new terminal window Ctrl+Alt+T.



    2. Open the file /etc/fstab for edit with root privileges, using nano:



      sudo nano /etc/fstab



    3. Go to the bottom of the file and add the following line - here I'm assuming it is an image file, so we need to use the loop option (reference):



      /mnt/filesys.bin /mnt/mymnt/ auto nofail,defaults,loop 0 0


      If you want to mount physical device (or partition), you can identify it by several different ways, for example by its UUID. To find the UUID use sudo blkid while the device is mounted (or use the GUI tool Disks). In this case the entry could look like:



      /dev/disk/by-uuid/a58b40e4-eb9b-4720-835b-785a3be3ae33 /mnt/mymnt/ auto nosuid,nodev,nofail 0 0


      or:



      UUID=a58b40e4-eb9b-4720-835b-785a3be3ae33 /mnt/mymnt/ auto nosuid,nodev,nofail 0 0


      Where a58b40e4-eb9b-4720-835b-785a3be3ae33 is the UUID of your device.



    4. Save the file: Ctrl+O, then exit from nano: Ctrl+X.


    5. Restart the system or type sudo mount -a to see the result.



    Do not forgot to remove that entry if you remove the image file.






    share|improve this answer



















    • 2




      For external media I use UUID and the 'nofail' option. To get the UUID, issue the blkid command in terminal, while the device is mounted,then to fstab use UUID=<uuid> /mnt/mymount auto nofail,defaults
      – Stephen Boston
      2 days ago








    • 1




      @StephenBoston, thanks for the suggestion. I've updated the answer according to your comment.
      – pa4080
      2 days ago













    up vote
    11
    down vote



    accepted







    up vote
    11
    down vote



    accepted






    From man fstab:




    The file /etc/fstab contains descriptive information about the filesystems the system can mount. fstab is only read by programs, and not written; it is the duty of the system administrator to properly create and maintain this file.




    To do what you want you just need to add an entry for this mount in /etc/fstab as follows:




    1. Open new terminal window Ctrl+Alt+T.



    2. Open the file /etc/fstab for edit with root privileges, using nano:



      sudo nano /etc/fstab



    3. Go to the bottom of the file and add the following line - here I'm assuming it is an image file, so we need to use the loop option (reference):



      /mnt/filesys.bin /mnt/mymnt/ auto nofail,defaults,loop 0 0


      If you want to mount physical device (or partition), you can identify it by several different ways, for example by its UUID. To find the UUID use sudo blkid while the device is mounted (or use the GUI tool Disks). In this case the entry could look like:



      /dev/disk/by-uuid/a58b40e4-eb9b-4720-835b-785a3be3ae33 /mnt/mymnt/ auto nosuid,nodev,nofail 0 0


      or:



      UUID=a58b40e4-eb9b-4720-835b-785a3be3ae33 /mnt/mymnt/ auto nosuid,nodev,nofail 0 0


      Where a58b40e4-eb9b-4720-835b-785a3be3ae33 is the UUID of your device.



    4. Save the file: Ctrl+O, then exit from nano: Ctrl+X.


    5. Restart the system or type sudo mount -a to see the result.



    Do not forgot to remove that entry if you remove the image file.






    share|improve this answer














    From man fstab:




    The file /etc/fstab contains descriptive information about the filesystems the system can mount. fstab is only read by programs, and not written; it is the duty of the system administrator to properly create and maintain this file.




    To do what you want you just need to add an entry for this mount in /etc/fstab as follows:




    1. Open new terminal window Ctrl+Alt+T.



    2. Open the file /etc/fstab for edit with root privileges, using nano:



      sudo nano /etc/fstab



    3. Go to the bottom of the file and add the following line - here I'm assuming it is an image file, so we need to use the loop option (reference):



      /mnt/filesys.bin /mnt/mymnt/ auto nofail,defaults,loop 0 0


      If you want to mount physical device (or partition), you can identify it by several different ways, for example by its UUID. To find the UUID use sudo blkid while the device is mounted (or use the GUI tool Disks). In this case the entry could look like:



      /dev/disk/by-uuid/a58b40e4-eb9b-4720-835b-785a3be3ae33 /mnt/mymnt/ auto nosuid,nodev,nofail 0 0


      or:



      UUID=a58b40e4-eb9b-4720-835b-785a3be3ae33 /mnt/mymnt/ auto nosuid,nodev,nofail 0 0


      Where a58b40e4-eb9b-4720-835b-785a3be3ae33 is the UUID of your device.



    4. Save the file: Ctrl+O, then exit from nano: Ctrl+X.


    5. Restart the system or type sudo mount -a to see the result.



    Do not forgot to remove that entry if you remove the image file.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited 2 days ago









    Community

    1




    1










    answered 2 days ago









    pa4080

    12.9k52460




    12.9k52460








    • 2




      For external media I use UUID and the 'nofail' option. To get the UUID, issue the blkid command in terminal, while the device is mounted,then to fstab use UUID=<uuid> /mnt/mymount auto nofail,defaults
      – Stephen Boston
      2 days ago








    • 1




      @StephenBoston, thanks for the suggestion. I've updated the answer according to your comment.
      – pa4080
      2 days ago














    • 2




      For external media I use UUID and the 'nofail' option. To get the UUID, issue the blkid command in terminal, while the device is mounted,then to fstab use UUID=<uuid> /mnt/mymount auto nofail,defaults
      – Stephen Boston
      2 days ago








    • 1




      @StephenBoston, thanks for the suggestion. I've updated the answer according to your comment.
      – pa4080
      2 days ago








    2




    2




    For external media I use UUID and the 'nofail' option. To get the UUID, issue the blkid command in terminal, while the device is mounted,then to fstab use UUID=<uuid> /mnt/mymount auto nofail,defaults
    – Stephen Boston
    2 days ago






    For external media I use UUID and the 'nofail' option. To get the UUID, issue the blkid command in terminal, while the device is mounted,then to fstab use UUID=<uuid> /mnt/mymount auto nofail,defaults
    – Stephen Boston
    2 days ago






    1




    1




    @StephenBoston, thanks for the suggestion. I've updated the answer according to your comment.
    – pa4080
    2 days ago




    @StephenBoston, thanks for the suggestion. I've updated the answer according to your comment.
    – pa4080
    2 days ago












    up vote
    2
    down vote













    @pa4080 is totally right, but the really easy solution is (running as the superuser, so sudo su first):



    mount /mnt/filesys.bin /mnt/mymnt/
    grep mymnt /etc/mtab >>/etc/fstab


    The first line mounts your device with whatever other options you need, the second will put it into /etc/fstab with the same options so that it gets mounted on every reboot.






    share|improve this answer

























      up vote
      2
      down vote













      @pa4080 is totally right, but the really easy solution is (running as the superuser, so sudo su first):



      mount /mnt/filesys.bin /mnt/mymnt/
      grep mymnt /etc/mtab >>/etc/fstab


      The first line mounts your device with whatever other options you need, the second will put it into /etc/fstab with the same options so that it gets mounted on every reboot.






      share|improve this answer























        up vote
        2
        down vote










        up vote
        2
        down vote









        @pa4080 is totally right, but the really easy solution is (running as the superuser, so sudo su first):



        mount /mnt/filesys.bin /mnt/mymnt/
        grep mymnt /etc/mtab >>/etc/fstab


        The first line mounts your device with whatever other options you need, the second will put it into /etc/fstab with the same options so that it gets mounted on every reboot.






        share|improve this answer












        @pa4080 is totally right, but the really easy solution is (running as the superuser, so sudo su first):



        mount /mnt/filesys.bin /mnt/mymnt/
        grep mymnt /etc/mtab >>/etc/fstab


        The first line mounts your device with whatever other options you need, the second will put it into /etc/fstab with the same options so that it gets mounted on every reboot.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 2 days ago









        Auspex

        35329




        35329















            Popular posts from this blog

            Quarter-circle Tiles

            build a pushdown automaton that recognizes the reverse language of a given pushdown automaton?

            Mont Emei