Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 21

Thread: need help automounting drives using fstab

  1. #11
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: need help automounting drives using fstab

    Looks like you are getting good help already. I didn't notice all the posts until I'd written this, walked away, came back. Anyway, I'd already written it. Feel free to ignore it completely.

    To be pedantic, "automount" is something very specific in Unix/Linux. There is a daemon that handles mounting on an "as-needed" basis, then it removes the mount when they aren't needed anymore. "ubuntu autofs" are the search terms for this. autofs is the same across all Linux (and probably Unix). I use it for all USB and networked storage, since those connections are flaky.

    But I don't think you are interested in autofs. Sounds like you just want a simple /etc/fstab setup to mount storage at boot, before any users have logged in. I'm not a fan of using UUIDs for external storage mounts. I much prefer LABELs, since humans think in those terms much easier. gparted can set a LABEL on a partition. Https://ubuntuforums.org/showthread....9#post14048909 explains how to use the LABEL= for mounts.
    Code:
    LABEL=Extern3TB       /media/unknowable/3TB    ext4    nofail,noatime,errors=remount-ro  0 2
    Hope that helps. Do not mount storage under a user's HOME directory. There will be problems. Actually, we shouldn't mount it under /media/ either, but that's one of the "bless" areas for snap packages to access, so we can be practical (so it works) or we can be "right" (and snaps will never be allowed to access a more "correct" location.

    I see reference to NTFS. You should probably format the partition to use ext4 instead of whatever the USB HDD came with. gparted can do that. NTFS may not be the best choice. It seldom is for a number of reasons. NTFS brings permission issues for Linux. But if you must use it, I suppose it can work. Linux prefers native file systems. They are better supported with expected capabilities, not reverse engineered and faster. Linux can use enterprise storage volume managers with native storage too, but that choice has to be made BEFORE the file system. If you use NTFS, chown, chmod, chgrp, will never work with anything in that storage area. But if you use ext4 or any other native Linux file system, all those permission/owner/group commands and ACLs plus xattrs will work as Linux programs expect.

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

    Re: need help automounting drives using fstab

    Once you reset ownership & permissions, you do not have to redo them.

    I do often download something or use sudo (when I should not) and root takes ownership.
    So I occasionally rerun commands, as a quick way to reset several files.

    You can see settings with ll or ls -l.
    I also like to add to file browser the extra fields of ownership & permissions.
    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. #13
    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.
    Hey Dennis, the thought occurs to me... If it were me, I'd still add nofail to your fstab options, even on an internal drive. What if the drive goes bad, or fails on you somehow? Then your system wouldn't boot, would it? I know that's a bit of a long shot, but that's what failsafe is for - it's a failsafe.

    Obviously you know way, WAAAY more about this than I do on this subject, but it seems to me, as a layman, that it's always better to be safe than sorry.

    Either way, I really appreciate your help. Thanks again.

    ______________________

    SIDE NOTE: time to eat. I'll be back to read those last replies in a few minutes. Looks like you have something really valuable for me, TheFu, so I'll check it out when I get back.
    Last edited by unknowable; December 2nd, 2021 at 07:10 PM.

  4. #14
    Join Date
    Nov 2021
    Beans
    35

    Re: need help automounting drives using fstab

    Quote Originally Posted by TheFu View Post
    To be pedantic, "automount" is something very specific in Unix/Linux. There is a daemon that handles mounting on an "as-needed" basis, then it removes the mount when they aren't needed anymore. "ubuntu autofs" are the search terms for this. autofs is the same across all Linux (and probably Unix). I use it for all USB and networked storage, since those connections are flaky.

    But I don't think you are interested in autofs. Sounds like you just want a simple /etc/fstab setup to mount storage at boot, before any users have logged in. I'm not a fan of using UUIDs for external storage mounts. I much prefer LABELs, since humans think in those terms much easier. gparted can set a LABEL on a partition. Https://ubuntuforums.org/showthread....9#post14048909 explains how to use the LABEL= for mounts.
    Code:
    LABEL=Extern3TB       /media/unknowable/3TB    ext4    nofail,noatime,errors=remount-ro  0 2
    Yah, that's exactly right. autofs won't work for me in this case because I have to make it run every time I want to use it. The main reason I'm doing all this is so that I can use an app that will run at startup and access all my drives. If I have to make it run by trying to open a drive, that defeats the purpose. It has to run on its own at startup so that my app (which also runs at startup) can access all the drives. As far as labels vs UUID's go, it probably would have been slightly easier to use labels instead of UUID's, but I just copy/pasted them where they needed to go. Thanks for the info though.

    Quote Originally Posted by TheFu View Post
    Hope that helps. Do not mount storage under a user's HOME directory. There will be problems. Actually, we shouldn't mount it under /media/ either, but that's one of the "bless" areas for snap packages to access, so we can be practical (so it works) or we can be "right" (and snaps will never be allowed to access a more "correct" location.
    Don't mount my storage under the home directory? This is my personal machine and nobody else will ever log into it, so my home directory will always be accessible. I can see how that would be an issue if I had another user logging in, but it's just me. Will that still cause problems in the future?

    Quote Originally Posted by TheFu View Post
    I see reference to NTFS. You should probably format the partition to use ext4 instead of whatever the USB HDD came with. gparted can do that. NTFS may not be the best choice. ...
    Heh. Yes, I am at least slightly aware of the shortcomings in using NTFS in Linux, but that's my Windows drive. It won't use ext4 at all and as far as I know and NTFS was my only real choice in setting up the Windows partition. I mean I could have used FAT, but really? Oh, and that one is internal instead of USB based, so I would think it should be ok.
    Last edited by unknowable; December 2nd, 2021 at 07:59 PM.

  5. #15
    Join Date
    Nov 2021
    Beans
    35

    Re: need help automounting drives using fstab

    Quote Originally Posted by oldfred View Post
    You can see settings with ll or ls -l.
    Yah, every time I want to see stuff I just use ls-al |more.

    Quote Originally Posted by oldfred View Post
    I also like to add to file browser the extra fields of ownership & permissions.
    That's a great idea. I'm definitely going to do that right now. Thanks!

  6. #16
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: need help automounting drives using fstab

    Quote Originally Posted by unknowable View Post
    Yah, that's exactly right. autofs won't work for me in this case because I have to make it run every time I want to use it. The main reason I'm doing all this is so that I can use an app that will run at startup and access all my drives. If I have to make it run by trying to open a drive, that defeats the purpose. It has to run on its own at startup so that my app (which also runs at startup) can access all the drives. As far as labels vs UUID's go, it probably would have been slightly easier to use labels instead of UUID's, but I just copy/pasted them where they needed to go. Thanks for the info though.
    autofs mounts whenever **any** process requests access. No user has to do anything. If samba tries to access the storage, for any reason and it isn't mounted, then it will be, automatically. If samba isn't serving files off storage under autofs, then when the last process closes the last file, it will wait a few minutes, then umount it. If the entire point of this is to have samba make this storage available, there is little difference between using fstab and autofs ... except the fstab is easier to setup.

    Quote Originally Posted by unknowable View Post
    Don't mount my storage under the home directory? This is my personal machine and nobody else will ever log into it, so my home directory will always be accessible. I can see how that would be an issue if I had another user logging in, but it's just me. Will that still cause problems in the future?
    Yes. You will have issues in the future. There's a thread here from a guy who was sharing some storage in his home and got into some issues. Then there is the entire backup problem. Especially on a single-user box, the most important data backed up for any desktop will be in the users' HOME. By mounting added, huge, storage there, your backup scripts need to specifically exclude those mounts. The solution for is well traveled. Put the mount in /media/somewhere, then create a symbolic link from /media/somewhere to your $HOME. That makes access to the other mount easy and backup programs will just see the link as ... a link.

    Whether a Windows OS partition should be mounted is a different question - my answer for this is NO WAY. Windows data partitions can be mounted with little risk, but not the OS partition. It is so easy to trash Windows due to an accidental mouse action. I've seen that a few times in businesses.

    Quote Originally Posted by unknowable View Post
    Heh. Yes, I am at least slightly aware of the shortcomings in using NTFS in Linux, but that's my Windows drive. It won't use ext4 at all and as far as I know and NTFS was my only real choice in setting up the Windows partition. I mean I could have used FAT, but really? Oh, and that one is internal instead of USB based, so I would think it should be ok.
    To my knowledge, there aren't any safe ext4 drivers for Windows. FAT is ambiguous. FAT16, FAT12, FAT32, exFAT? At this stage, exFAT should be used only for flash storage that has to be shared between different OSes. Some devices only support FAT32 and the EFI partition **must** be FAT32, regardless of OS. However, Linux has f2fs for flash storage. It is native Linux, friendly towards flash (keeps write counts low) and supports all the expected Linux/POSIX file system stuff. Some Android devices support f2fs, though some vendors go out of their way to disable it (f2fs is part of the default Android builds for the last few years). They did this purely to ensure we didn't make that microSD slot into a place with 256G of storage, all native to Android so programs could be loaded there. They want to charge $50 more between the 32G and 64G internal storage models. f2fs breaks that price model.

    I've heard that MSFT is working to support native Linux file systems under Windows. That would have been nice a few decades ago. At this point, we barely use Windows - only for financial programs and video editing. The video editing stuff is nearly gone as of this week, but most people aren't a tenacious about NOT using Windows.

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

    Re: need help automounting drives using fstab

    Quote Originally Posted by unknowable View Post
    Hey Dennis, the thought occurs to me... If it were me, I'd still add nofail to your fstab options, even on an internal drive. What if the drive goes bad, or fails on you somehow? Then your system wouldn't boot, would it?
    It won't boot completely, but far enough to allow you to fix it. It your data partition isn't mountable for some reason, then you probably end up in "Emergency Mode". If you then choose "Maintainance", you can immediately edit the fstab with a terminal based editor like nano to fix an incorrect entry, or comment it out to bypass the mounting. Then issue a reboot command and you will boot to your desktop as usual.

    On where to mount, I have always used a subdirectory of /mnt

    Code:
    # data LV
    LABEL=Common-Files /mnt/Common-Files ext4 defaults 0 2
    # Virtual Machine Location
    LABEL=VM-Disks2 /mnt/VM-Disks2 ext4 defaults 0 2
    Last edited by Dennis N; December 2nd, 2021 at 09:03 PM.

  8. #18
    Join Date
    Nov 2021
    Beans
    35

    Re: need help automounting drives using fstab

    Quote Originally Posted by TheFu View Post
    autofs mounts whenever **any** process requests access. No user has to do anything. If samba tries to access the storage, for any reason and it isn't mounted, then it will be, automatically. If samba isn't serving files off storage under autofs, then when the last process closes the last file, it will wait a few minutes, then umount it.
    Oh, cool. So my app would still work fine if I used autofs. That's good to know for the future. Thanks!

    Quote Originally Posted by TheFu View Post
    If the entire point of this is to have samba make this storage available, there is little difference between using fstab and autofs ... except the fstab is easier to setup.
    Well that's good to know. My understanding is that if you screw up fstab at all the system won't boot, but this was pretty straightforward and I didn't have any issues. Yes, it was pretty easy to setup after I learned the necessary stuff.

    Quote Originally Posted by TheFu View Post
    Yes. You will have issues in the future. There's a thread here from a guy who was sharing some storage in his home and got into some issues. Then there is the entire backup problem. Especially on a single-user box, the most important data backed up for any desktop will be in the users' HOME. By mounting added, huge, storage there, your backup scripts need to specifically exclude those mounts. The solution for is well traveled. Put the mount in /media/somewhere, then create a symbolic link from /media/somewhere to your $HOME. That makes access to the other mount easy and backup programs will just see the link as ... a link.
    Huh that's important, I hadn't even thought of that. Don't want to backup every drive I'm connected to. Thanks!

    Quote Originally Posted by TheFu View Post
    Whether a Windows OS partition should be mounted is a different question - my answer for this is NO WAY. Windows data partitions can be mounted with little risk, but not the OS partition. It is so easy to trash Windows due to an accidental mouse action. I've seen that a few times in businesses.
    Hm. Unfortunately all my Windows stuff is in one partition. That being said, I've cloned all the partitions that Windows uses, so I'm not too worried about it. If I do screw it up, it's small enough that I can restore the image in less than an hour. No big.

    Quote Originally Posted by TheFu View Post
    I've heard that MSFT is working to support native Linux file systems under Windows. That would have been nice a few decades ago. At this point, we barely use Windows - only for financial programs and video editing. The video editing stuff is nearly gone as of this week, but most people aren't a tenacious about NOT using Windows.
    Yes, in Windows 10 (at least, maybe sooner) if you install Windows *after* installing Linux, Windows will write almost 7,000 files to the grub and efi directories. I know this from experience. It's not accessible to the user in Windows *yet*, but they already know how to write to (and mess up) your Linux boot partition. As far as NOT using Windows, I can't find a complete image organization tool that does everything the way I want it to like I had in Windows, so I'm still using that app for my images. Not very convenient, but like I said, I can't find a Linux app that does *everything* my old Windows app did, so I'm still using Windows. Not fun to reboot every time I want to mess with my pics, but workable. Everything else is moved over and working great in what I'm using, so I'm happy.

  9. #19
    Join Date
    Nov 2021
    Beans
    35

    Re: need help automounting drives using fstab

    Quote Originally Posted by Dennis N View Post
    It won't boot completely, but far enough to allow you to fix it. It your data partition isn't mountable for some reason, then you probably end up in "Emergency Mode". If you then choose "Maintainance", you can immediately edit the fstab with a terminal based editor like nano to fix an incorrect entry, or comment it out to bypass the mounting. Then issue a reboot command and you will boot to your desktop as usual.
    Oh ok, good. I knew you knew more than me.

    Quote Originally Posted by Dennis N View Post
    On where to mount, I have always used a subdirectory of /mnt

    Code:
    # data LV
    LABEL=Common-Files /mnt/Common-Files ext4 defaults 0 2
    # Virtual Machine Location
    LABEL=VM-Disks2 /mnt/VM-Disks2 ext4 defaults 0 2
    Yah that makes sense. TheFu told me about issues with backing up, and you both make sense. It will only take a few minutes to change them over, so I think I'll do that. Thanks for the tip.

  10. #20
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: need help automounting drives using fstab

    Quote Originally Posted by unknowable View Post
    <snip>
    Yes, in Windows 10 (at least, maybe sooner) if you install Windows *after* installing Linux, Windows will write almost 7,000 files to the grub and efi directories. I know this from experience. It's not accessible to the user in Windows *yet*, but they already know how to write to (and mess up) your Linux boot partition. As far as NOT using Windows, I can't find a complete image organization tool that does everything the way I want it to like I had in Windows, so I'm still using that app for my images. Not very convenient, but like I said, I can't find a Linux app that does *everything* my old Windows app did, so I'm still using Windows. Not fun to reboot every time I want to mess with my pics, but workable. Everything else is moved over and working great in what I'm using, so I'm happy.
    Whenever I'm forced back to Windows, there are hundreds of Linux tools that I miss. Goes to show that it is purely a matter of perspective.

    Image organization is a complex issue. I use EXIF search tools and keep all the tags inside the base image file. Been burned a few times when photo organization tools destroyed the DB.

Page 2 of 3 FirstFirst 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
  •