Announcement

Collapse
No announcement yet.

Automount everything BEFORE entering Plasma session

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Automount everything BEFORE entering Plasma session

    Hello,

    this is my first post here so please excuse me if I'm posting in the wrong place.

    I have a computer in my studio and I want to be able to remotely
    1. turn it on
    2. access every disk, partition and removable device
    3. turn it off


    I have found many instructions on how to make a Linux system automount everything, but I am wondering which one is the cleanest way.
    Plasma is already capable of automounting and I would like to make it automount everything before any Plasma session is started.
    Is this possible? If it is not, what is the most clean (not interfering with and resistant to updates) to accomplish that?
    Note that it is not possible for me to explicitly list every disk and partition in fstab, since partitions and removable devices may change.

    Thanks!

    #2
    It would be helpful to have some real information about what you're trying to accomplish. It's really impossible to make suggestions without details. You don't say how you are "remotely" doing this or why remotely. How do you plan on accessing the computer? Is it always on or are you remotely turning it off and on? How many drives and partitions are we talking about? How often are you going to re-partition or reformat and why?

    For removable devices a UDEV rule would be the most solid choice IMO.

    For every hard drive file system you simply do what is normal - add them to /etc/fstab. They will automount at boot time. Asking for the system to determine that you re-partitioned and changed the hard drive layout and auto-magically adjust and know without input what you want and how to mount everything is impossible IMO. You don't really expect an operating system to read your mind, do you? You either have to edit fstab along with the partition/file system change or take special care by following some rules.

    For example, fstab can mount a file system by device name, UUID, file system label and a few others. If you take care to use the same UUID or file system label the system won't even know a change has occurred. If you are adding or subtracting file system or partitions, you're also going to have to edit fstab. No way around it that I know of.

    Theoretically, you could write a script to read the needed information from the drives, create the mount points, and mount the drives, but it would not be a small task.

    Please Read Me

    Comment


      #3
      Originally posted by oshunluvr View Post
      It would be helpful to have some real information about what you're trying to accomplish. It's really impossible to make suggestions without details. You don't say how you are "remotely" doing this or why remotely. How do you plan on accessing the computer? Is it always on or are you remotely turning it off and on? How many drives and partitions are we talking about? How often are you going to re-partition or reformat and why?
      I'm turning the computer on via wakeonlan, I plan accessing it via ssh. The computer has 2 hard drives, one of which with more than 10 partitions. I don't know how often I am going to add or remove partitions, but I'm looking for a method to mount every partition, USB drives included.

      Originally posted by oshunluvr View Post
      You don't really expect an operating system to read your mind, do you? You either have to edit fstab along with the partition/file system change or take special care by following some rules.
      Plasma already has the capability of showing me drives and partitions that are not in fstab. When I open Dolphin, every disk and partition is listed as a device, even if they are not in fstab. I don't know how Plasma is doing this, so I am asking how can I make my system do the same thing (of which it is already capable, since Plasma can do it) before a Plasma session is started.

      Comment


        #4
        Well, Plasma can't do much if it is not loaded yet, so......


        Is there any specific need for mounting drives at login or as attached as per the System Settings' config?
        note that 'removable storage' oddly means anything not set in the fstab, so it shows hard drives partitions, etc. So unless you specifically *need* to access those drives regularly before your user logs in, either the udev rules or using the fstab is the way to go.
        I access my PC often (multiple times daily) via ssh, and it has three extra drives attached, I have one partition added to the fstab, with Plasma set to automount on login as well as on attach so usb sticks are taken care of.

        So Plasma can't mount things when it is not running yet, but of course Linux itself has many options.

        Comment


          #5
          Originally posted by claydoh View Post
          So Plasma can't mount things when it is not running yet, but of course Linux itself has many options.
          Which option would you suggest?

          Possibly, one that
          • does not interfere with Plasma automounting, when the computer is used locally and a Plasma session is started
          • resists to system updates
          • doesn't require days to study books of documentation

          Comment


            #6
            I suggest labelling all the partitions sensibly, and using them in /etc/fstab. With UUIDs it is error-prone to maintain /etc/fstab manually, but with labels it's fine. Here's mine:
            Code:
            # /etc/fstab: static file system information.
            # vim: ft=fstab
            # This fstab uses labels. Originally EFI was sda1, main was sda2,
            # and swap sda3
            #
            #file system   mount       type    options                      dump pass 
            LABEL=main     /           btrfs   defaults,subvol=@r,noatime     0   1
            LABEL=main     /home       btrfs   defaults,subvol=@h,noatime     0   2
            PARTLABEL=swap none        swap    sw                             0   0
            LABEL=EFI      /boot/efi   vfat    umask=000,noatime,noauto,user  0   1
            #
            #john's extra mounts
            # the true root of the btrfs volume for convenience
            LABEL=main     /t          btrfs   defaults,noatime               0   0
            # the new hard drive for miscellaneous stuff
            LABEL=stuff    /mnt/stuff  btrfs   defaults,noatime,noauto,user   0   2
            
            # mounts on the old Seagate, which is MBR
            LABEL=pics     /mnt/pics   ext4    defaults,noatime,noauto,user   0   2
            LABEL=vm       /mnt/vm     ext4    defaults,noatime,noauto,user   0   2  
            LABEL=work     /mnt/work   btrfs   defaults,noatime,noauto,user   0   2
            LABEL=qhome    /mnt/qhome  ext4    defaults,noatime,noauto,user   0   2
            You've said you don't want the "noauto" option, so you wouldn't have that. With a half-decent syntax colouring editor like vim or kate the format will be recognized and it's easy to see something out of place.
            Regards, John Little

            Comment


              #7
              Originally posted by jlittle View Post
              I suggest labelling all the partitions sensibly, and using them in /etc/fstab. With UUIDs it is error-prone to maintain /etc/fstab manually, but with labels it's fine.
              Thanks, but I need a solution to automount every partition (and removable device) without explicitly listing them.

              Comment


                #8
                Originally posted by ciacnorris View Post
                Plasma already has the capability of showing me drives and partitions that are not in fstab. When I open Dolphin, every disk and partition is listed as a device, even if they are not in fstab. I don't know how Plasma is doing this, so I am asking how can I make my system do the same thing (of which it is already capable, since Plasma can do it) before a Plasma session is started.
                Yes, Dolphin can be used by a user to locate and mount file systems but that's not what you asked for and no, "Plasma" can't do anything before it's started. Dolphin is a Plasma application so does not apply at all to what it seems you have asked for. You're mixing apples and oranges here. A GUI tool cannot be expected to behave as though a user is directing it without any actual input.

                If you're using the computer via ssh (I do this daily with my server) Plasma will not enter into it so we can just drop that part of the discussion.

                One way to mount a continuously changing set of file systems with no user input at boot time is to use a script will be needed that does all of these:
                • Detect all available filesystems and their types on all devices
                • Delete any existing mount points (clean up after previous session)
                • Create mount points for each discovered filesystem
                • Mount each of these with correct options


                Really not as complicated as it sounds, but it will take some trial and error.

                Please Read Me

                Comment


                  #9
                  Originally posted by ciacnorris View Post
                  Thanks, but I need a solution to automount every partition (and removable device) without explicitly listing them.
                  Do you mean something like
                  Code:
                  lsblk -lpno name,type,mountpoint | awk '$2 == "part" && $3 == "" {print $1}'  |
                              xargs -n 1 udisksctl mount -b
                  lsblk has many fields it can output (run lsblk --help to see them) and you could add more selections, f.ex. selecting only particular filesystems types.
                  Regards, John Little

                  Comment


                    #10
                    So jlittle has it more than half way there with one line!

                    Now it's just coming up with a mounting scheme. I'd simply delete /mnt (assuming you're not using it for something else, if so, make a new location altogether), recreate it, create new subfolders using the output from jlittles command, changing the /dev/ - so "/dev/sda3" results in "/mnt/sda3" and mounting. Something
                    like:

                    rm -rf /mnt
                    mkdir /mnt
                    for part in `lsblk -lpno name,type,mountpoint | awk '$2 == "part" && $3 == "" {print $1}' `
                    do
                    mount="${part//dev/mnt}"
                    mkdir "$mount"
                    mount "$part" "$mount"
                    done

                    jlitte usually has better ideas, but it's a start. If it were my system, I'd add in a whole bunch of error checks, logging, and test it profusely on a VM before going live.

                    Please Read Me

                    Comment


                      #11
                      You know it occurred to me; You didn't say WHY you would want to rearrange your partitions often - or at all. You might consider using btrfs and subvolumes on your fixed devices instead. Assuming that fits into your purposes, you could have a single mount point - een with multiple drives - mounted in fstab, and address the contents via subvolumes. Then you would just have to set UDEV to automount removable devices and you're done.

                      Please Read Me

                      Comment

                      Working...
                      X