Page 1 of 3 123 LastLast
Results 1 to 10 of 21

Thread: need help automounting drives using fstab

  1. #1
    Join Date
    Nov 2021
    Beans
    35

    need help automounting drives using fstab

    Hi everyone. I'm trying to mount my external drives (one 2TB and one 3TB) automatically on boot. I started with a video that shows you how to automount drives in a virtual machine, then googled for a few more specifics, but only root has write access to the first drive I created. Here's the video I watched, and this page was the second place I looked for more info, followed by this one. While none were specific to my exact needs, all three were helpful in getting me started.

    Now when my computer boots up, it automounts the 3TB drive to /home/USERNAME/3TB but the drive is read only by everyone but root. I want to make it writeable by me specifically, there are no other users. I'm using the /etc/fstab to automount the drive. Here is the line I have in /etc/fstab:

    Code:
    UUID=1df48e6a-8f70-4325-b00a-998cade164d7       /home/unknowable/3TB    ext4    defaults,nofail 0 0
    I have tried changing the options (currently defaults,nofail) to defaults,nofail,rw and rw,defaults,nofail and even rw,nofail but that's definitely not doing it. I'm pretty sure all I need is the correct option there in /etc/fstab but I can't figure out what the right option is. The places I've looked don't show how to do that specifically, or else they're way too technical and I can't understand them.

    If there's a better way to automount a drive other than /etc/fstab please let me know. Again, I'm the only user on the system but I definitely need write access all the time, especially so that an app I want to run can access the drive at startup. Your assistance is greatly appreciated. Thank you for taking time out of your day to help a noob.
    _____________________________________________

    EDIT: According to this page it looks like I just need to set the owner option, as right now the owner is root. My username is unknowable, but I haven't figured out how to set owner yet. Let me know if this is the quick answer, and thanks again.
    _____________________________________________

    EDIT: I tried setting the owner tag in the options field to defaults,nofail,owner=unknowable . That did give me ownership back but it didn't mount the drive. I then tried owner=unknowable,defaults,nofail but both of those didn't work, same result: my username as the owner, drive not mounted.
    _____________________________________________

    EDIT: Alright, I tried creating a new subdirectory in my home directory, ~/3_TB/ . I checked the owership (using ls -al) and it did show that I (unknowable) was the owner. I then changed the fstab to show the new directory and rebooted. It did properly mount the drive, but now the owner is root and I don't have write access to it. Should I just create a quick script file that mounts my drives and put the file into my startup applications? That would be less dangerous than editing the /etc/fstab file and not really too difficult... Maybe I'll try that next.
    Last edited by unknowable; December 2nd, 2021 at 05:04 PM.

  2. #2
    Join Date
    Jun 2009
    Location
    SW Forida
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: need help automounting drives using fstab

    With NTFS the permissions are set in mount by fstab.

    But with Linux formats you specify ownership & permissions.
    https://help.ubuntu.com/community/FilePermissions

    I do this on my data partitions that have mount point /mnt/data
    sudo mkdir /mnt/data
    # ( permissions stay with the partition not with the mountpoint ).
    # so chown & chmod after mounting either manually or via fstab
    sudo chown -R $USER:$USER /mnt/data
    # The big "X" will also not make files executable unless they were executable to begin with.
    sudo chmod -R a+rwX /mnt/data

    Note that the -R is recursion and all lower level folders are also changed.
    Never run on a system folder, only on data folders.

    In addition to nofail you may want either systemd-automount or autofs.
    https://wiki.archlinux.org/index.php...t_with_systemd
    https://help.ubuntu.com/community/Autofs
    UEFI boot install & repair info - Regularly Updated :
    https://ubuntuforums.org/showthread.php?t=2147295
    Please use Thread Tools above first post to change to [Solved] when/if answered completely.

  3. #3
    Join Date
    Jun 2007
    Location
    Arizona U.S.A.
    Beans
    5,141

    Re: need help automounting drives using fstab

    it looks like I just need to set the owner option, as right now the owner is root. My username is unknowable, but I haven't figured out how to set owner yet. Let me know if this is the quick answer, and thanks again.
    Use a terminal command. Assuming your user name is unknowable:

    Code:
    sudo chown -R unknowable:unknowable /home/unknowable/3TB
    The first unknowable changes the owner, the second after the : changes the group. The -R changes this for all existing folders and files on the mounted file system. Some distros don't have a group with the users name, so that could be changed to something else. What does your OS use as default for group in files you create? Use that if necessary. This is for only file systems without an OS - a disk you use for your own files.
    Last edited by Dennis N; December 2nd, 2021 at 05:14 PM.

  4. #4
    Join Date
    Nov 2021
    Beans
    35

    Re: need help automounting drives using fstab

    Alright, cool, thanks oldfred! That looks like exactly what I need to get this thing working, but it's going to take me a few minutes to read, understand, and implement what you told me - I'm new. I'll try that out and let you know what happens.

  5. #5
    Join Date
    Nov 2021
    Beans
    35

    Re: need help automounting drives using fstab

    Alright, thanks to both of you, I now have a totally writeable directory with the drive mounted. Now I just need to make that happen on boot every time. I guess for that I need a script file to run at login? Hmm....
    Last edited by unknowable; December 2nd, 2021 at 05:24 PM.

  6. #6
    Join Date
    Nov 2021
    Beans
    35

    Re: need help automounting drives using fstab

    AWESOME!! That did it! I just created a script file in my home directory using the two lines you two gave me to chmod and chown the directory (recursively as you suggested,) and when I rebooted it mounted the drive and i (unknowable) have write/execute access to it! WOW! Awesome, thanks to both of you for your help!

    I'm not going to mark this one resolved yet because I still have to mount my windows partition, ntfs. That should be pretty easy to do now that I know how, so I'll set it up, test it out, then let you know and mark it resolved.

    Thanks again to both of you for your help! I'm learning and it's really exciting!

  7. #7
    Join Date
    Jun 2007
    Location
    Arizona U.S.A.
    Beans
    5,141

    Re: need help automounting drives using fstab

    Quote Originally Posted by unknowable View Post
    Alright, thanks to both of you, I now have a totally writeable directory with the drive mounted. Now I just need to make that happen on boot every time. I guess for that I need a script file to run at login? Hmm....
    No, the fstab entry is fine. The change you made is permanent for every boot (unless you change it yourself).

    Edit: Except the last 0 in the entry should be a 1 (or 2) to enable file system check. And I don't know about the nofail option you are using. I use just defaults.
    Last edited by Dennis N; December 2nd, 2021 at 05:41 PM.

  8. #8
    Join Date
    Nov 2021
    Beans
    35

    Re: need help automounting drives using fstab

    Quote Originally Posted by Dennis N View Post
    No, the fstab entry is fine. The change you made is permanent for every boot (unless you change it yourself).

    Edit: Except the last 0 in the entry should be a 1 (or 2) to enable file system check. And I don't know about the nofail option you are using. I use just defaults.
    Ok, thanks, that helps me out. I read the nofail option allows the system to boot even if it can't mount the drive. It's supposed to be a failsafe in case I don't have the drive plugged in I think.

    I made the change you suggest, Dennis, changing the last 0 to a 1 to enable file system check. Just about to reboot and try out the ntfs partition.

  9. #9
    Join Date
    Jun 2007
    Location
    Arizona U.S.A.
    Beans
    5,141

    Re: need help automounting drives using fstab

    OK, nofail it is then. My data disk is internal so always connected. An NTFS partition is going to need a separate fstab entry. The one you display is only for an ext4 file system.

  10. #10
    Join Date
    Nov 2021
    Beans
    35

    Re: need help automounting drives using fstab

    Quote Originally Posted by Dennis N View Post
    OK, nofail it is then. My data disk is internal so always connected. An NTFS partition is going to need a separate fstab entry. The one you display is only for an ext4 file system.
    Yah, I just set the type to ntfs and rebooted, it mounted the drive fully writeable and executable. Now I only have one more drive - an external 2TB ext4 drive - to add, but that's gonna be the same as the first, so this is definitely resolved.

    Thank you both for your time and guidance. It was really helpful in resolving my issue.

Page 1 of 3 123 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •