Solved: problem mounting directories to /sda5

Forum › Forums › New users › New Users and General Questions › Solved: problem mounting directories to /sda5

  • This topic has 23 replies, 5 voices, and was last updated Sep 1-4:51 pm by Brian Masinick.
Viewing 15 posts - 1 through 15 (of 24 total)
  • Author
    Posts
  • #184682
    stevesr0
    Member

      UPDATED TITLE: my goal was to display TWO music directories (mounted on /sda5), as if they were subdirectories in the entries for my /home/stevesr0 mounted on /sda4.

      I mounted TWO directories to /sda5 and this didn’t work properly. The newer directory overwrote the entries in the first directory.

      **I didn’t understand that mounting a partition to a directory ties the WHOLE partition to that directory! Multiple directories require creating SUBdirectories within the “primary” directory which “owns” the partition mounted to it.

      Noobie ignorance.

      There are other approaches, but they weren’t used in this thread.

      End of update.

      ————————————————————————

      Question triggered by the following.

      1. I wanted to set up a partition to hold music so I could play while on computer and get rid of bunch of CDs. So, in Gparted, I carved out a roughly 100 gig partition. Then I created a music directory (/media/Music) and mounted it to the 100 gig partition.

      2. When I tried to add music to this directory, I was told that this was owned by root.

      3. I now wish to “relocate” the directory to a location that I (the regular user) owns so I don’t have to use Sudo to manage or play music.

      4. So I used mkdir to create a mymusic directory within my home directory. Then I created I copied the music to that directory.

      5. Worked fine.

      HOWEVER,

      6. I noticed I had some music VIDEOS also. SO, I made a SECOND directory in sda5 (the 100 gig partition) entitled myVideos.

      7. When I copied the videos to this new directory, it changed the contents of the mymusic directory to the videos.

      So, I want to learn how to set up the two directories on the 100 gig partition, so they DON’T overwrite each other. This hasn’t happened when I have used /media or /mount as the “base”, so I am puzzled why it doesn’t work with /home/stevesr0.

      N.B. Both /media and /mount and /home are located on 30 Gig partitions.

      • This topic was modified 1 year ago by stevesr0.
      #184683
      Xunzi_23
      Member

        Hi steves the leading slash indicates root /media/Music

        Make that read and writable for your user using rox as root,
        you have the right click menu and can set pemissions.

        That should (famous last words) fix the problem

        #184687
        stevesr0
        Member

          Hi Xunzi,

          I had reset permissions to make stevesr0 the owner with recursion.

          But want to make these music (and music video) files show up in my home directory while “living” in the sda5 (94 gig) partition, rather than the 30 gig sda4 partition which houses my /home directory.

          I have kind of gotten it working without the two separate directories (Music and Music Video) overwriting each other, by creating a subdirectory for the music in the music video directory.

          As a permanent noobie who only infrequently does this and forgets a lot in between, I don’t understand whether there is a reason we are supposed to use /media or /mount for setting things up on a particular hardware location (dev/xyz), rather than using /home/user, if we want it to appear in the /home/user directory listing.

          Or alternatively, what I did wrong that I couldn’t set up two different directories for music and music videos in /home/stevesr0 and “locate” them on the partition of my choice.

          #184688
          PPC
          Member

            I would just try to follow this tutorial about symlinks: https://www.howtogeek.com/287014/how-to-create-and-use-symbolic-links-aka-symlinks-on-linux/

            Also I think that creating a single partition, with a video folder and a music folder would really is the way to go. So, create a partition (you already know how to do that), create a video folder inside it and then create a music folder inside it (you can do it using the File Manager or the Terminal), create links to each folder from your home folder (or from whatever place you want) adapting the information from the howtogeek tutorial and you are set (hopefully, I did not test this).

            P.

            • This reply was modified 1 year ago by PPC.
            #184689
            Brian Masinick
            Moderator

              @stevesr0 wrote: “As a permanent newbie who only infrequently does this and forgets a lot in between, I don’t understand whether there is a reason we are supposed to use /media or /mount for setting things up on a particular hardware location (dev/xyz), rather than using /home/user, if we want it to appear in the /home/user directory listing.”

              When you are mounting any file system, as far as the mount command itself is concerned, it doesn’t matter what the directory name is for the target – /media, /mount, /mnt – when I’m manually mounting other filesystems, most of the time I repeatedly use /mnt simply because it’s available to me.

              The only reason to use other names would be because a particular tool uses a specific directory and manages the creation (and/or removal) of that directory; otherwise it makes no difference at all; it simply has to exist.

              --
              Brian Masinick
              Alternate "Search B":
              This search page

              #184690
              Brian Masinick
              Moderator

                So IF you want to use /home/user, there’s nothing preventing that, other than appropriate directory existence and permissions.

                --
                Brian Masinick
                Alternate "Search B":
                This search page

                #184696
                stevesr0
                Member

                  Hi Brian,

                  I am puzzled by the fact that after using mkdir to create two separate directories in /home/stevesr0, and mounting each, the later one overwrote the contents of the previous one.

                  That is, I created /home/stevesr0/MyMusic, filled it with my audio music and then created /home/stevesr0/MyVideos and filled it with my music videos. Then, when I checked, BOTH directories only contained the music Videos.

                  N.B. I mounted these directories on /sda5, while /home is on /sda4.

                  So I assume, I am doing something very basically wrong.

                  (Putting the music in a subdirectory of the music video worked, but I would like to understand why I couldn’t have separate directories in /home/stevesr0 that didn’t mess with each other.

                  IF, there is something “special” about the /Mtn and /media directories, then I would like to understand that.

                  Hi PPC,

                  Going the route of symlinks did occur to me.

                  However, I figured that the simplest approach was to “simply” mount the directories “logically” in the user directory and place it “physically” on the large partition I created for its exclusive use.

                  I am unclear how to create a directory in a specific partition except by using the mount approach:

                  sudo mount /dev/sda5 /home/stevesr0/Music

                  Thanks for all comments.

                  • This reply was modified 1 year ago by stevesr0.
                  #184699
                  Robin
                  Member

                    I am unclear how to create a directory in a specific partition except by using the mount approach:

                    $ mkdir '/home/stevesr0/Music'
                    $ sudo mount '/dev/sda5 /home/stevesr0/Music'

                    This is perfectly right. Let follow these commands to get full read/write access to the drive for users, since mount itself doesn’t do that:

                    $ sudo setfacl -m u::rwx,g::rwx,o::r-x '/home/stevesr0/Music'
                    $ sudo setfacl -d -m u::rwx,g::rwx,o::r-x '/home/stevesr0/Music'
                    $ sudo chown stevesr0:users '/home/stevesr0/Music'
                    $ sudo chmod g+rwx '/home/stevesr0/Music'

                    For this to work, the partition must be mounted already.
                    (This sequence is e.g. precisely what antiX USB maker processes, immediately after creating an additional data partition on the device.)

                    Furthermore, if you want to have it loaded automatically on each next boot, or at least configured for easy mounting, you could add a line to the /etc/fstab file:

                    First run the following command, this will return the needed UUID for the fstab entry:

                    $ blkid -o export /dev/sda5 | grep ^UUID
                    UUID=12bc7b9e-b51a-e4bb-812e-f6f32766a22c

                    (Alternatively you can use the command
                    $ lsblk -f
                    to see a complete survey of your partitions, also showing their UUIDs.)

                    Put the result into the line below:

                    UUID=12bc7b9e-b51a-e4bb-812e-f6f32766a22c /home/stevesr0/Music ext4 users,noauto,exec 0 0

                    and add the line to fstab. In case of different file system type replace ext4 by your actual finding from the lsblk -f command. If you don’t plan to run programs stored on this partition, replace exec by noexec additionally.

                    Then you can actually mount it by the command (no root needed)
                    $ mount /home/stevesr0/Music
                    and unmount it the same way:
                    $ umount /home/stevesr0/Music
                    whenever needed.

                    Replace noauto by auto in the fstab line, to have it mounted at boot time automatically.

                    Windows is like a submarine. Open a window and serious problems will start.

                    #184700
                    Brian Masinick
                    Moderator

                      @stevesr0 I’m going to make an “educated guess” about what may have happened.
                      I’m not 100% positive it’s correct, but based on your description it’s a
                      possible explanation for what happened.

                      You created two separate directories, which is fine.
                      Then you said:
                      “N.B. I mounted these directories on /sda5, while /home is on /sda4”

                      Since both are mounted on /sda5, it’s possible that these weren’t
                      properly differentiated in your copies, thus the contents actually
                      went into the same directory.

                      Let me give you a practical example of how I handle my copies; maybe this will help.

                      df
                      Filesystem     1K-blocks     Used Available Use% Mounted on
                      udev             7510684        0   7510684   0% /dev
                      tmpfs            1509968     1152   1508816   1% /run
                      /dev/nvme0n1p4  97845532 17540708  75288404  19% /
                      tmpfs               5120       16      5104   1% /run/lock
                      none                 248       90       154  37% /sys/firmware/efi/efivars
                      tmpfs            3019920        0   3019920   0% /dev/shm

                      This is the setup I’m logged into right now. It happens to be running antiX Sid.

                      On /dev/nvme0n1p2 I have antiX 23.2 Full Runit, which is my primary setup.

                      So when I first set up the system I’m using now, I wanted to copy a bunch
                      of things from there. Here’s an example of how I accomplished this:

                      sudo mount /dev/nvme0n1p2 /mnt
                      cd /mnt/home/masinick
                      cp -R .bashrc .profile bin Downloads Pictures .config ~

                      The commands above mount the antiX 23.2 partition to /mnt,
                      making all of it available, so IF I want to copy stuff from
                      other directories there too, I CAN, if I use sudo for anything
                      owned by anything other than my UID.

                      Next for convenience I change directories to my home directory
                      on antiX 23.2. Then I recursively copy stuff. The .bashrc
                      and .profile are simply hidden files in the home directory,
                      so -R has no special effect, but it doesn’t hurt; the other
                      entries are directories, so the -R copies the contents of the
                      entire directories, creating the directories if necessary
                      to complete the operation, and overwriting any existing files
                      or directories. That’s what I want, so in three fairly
                      quick commands I copy quite a few files.

                      I have some custom apps, some of which have .deb packages,
                      several don’t. I copy them from /usr/local/bin and/or
                      /usr/bin; some of them have content in /usr/share or
                      /usr/local/share, so I have to use sudo to copy them,
                      but I otherwise use a procedure very similar to above.

                      This is how I can rapidly hack together a very usable
                      configuration within one to two hours at most, including
                      installation, then custom configuration time.

                      I didn’t share every step, but I did explain the concept
                      that I use to copy stuff between two or three different
                      partitions. If more than two partitions are used, I usually
                      either use different mount steps, but more often I take
                      them one at a time so I don’t accidentally copy something
                      to the wrong place. I hope this is helpful.

                      --
                      Brian Masinick
                      Alternate "Search B":
                      This search page

                      #184702
                      Brian Masinick
                      Moderator

                        Hi @robin, what you describe is a convenient way if you always
                        want to mount another partition and use it. If that’s the case,
                        your approach works great.

                        In my case, I definitely do not want to do that, because
                        I do a lot of copying around, and I frequently copy privileged
                        files, so I’d much rather explicitly mount and unmount partitions,
                        keeping them active only for as long as I’m performing my copies.

                        On my current system I happen to have six total partitions; I DO NOT
                        want them all mounted. If I happen to do some numbskull operation;
                        doesn’t happen often, but I’ve done it before. Having everything
                        mounted is a good way for a runaway procedure that contains a mistake
                        to walk it’s way through all the partitions, something I explicitly
                        DO NOT want to do, so I’d rather perform my mounts, dismounts,
                        user and system file copies with only the stuff I’m copying or exchanging.
                        There’s a risk even when doing that, but it’s confined to those moments;
                        I try to do that kind of activity when I’m alert; I’ve broken things
                        more than once when I’ve NOT been totally alert; in those cases, my
                        effective backup strategy HAS worked, but it took hours to set each
                        individual system up once again, so I don’t want those mistakes to
                        happen often, even if I can recover from them!

                        So your advice is still solid, but that’s my personal reason for
                        explicitly mounting and removing mount points when I’m done copying
                        or moving information; it’s safer and exposes less information.

                        --
                        Brian Masinick
                        Alternate "Search B":
                        This search page

                        #184720
                        Robin
                        Member

                          what you describe is a convenient way if you always
                          want to mount another partition and use it.
                          …
                          In my case, I definitely do not want to do that

                          You are absolutely right about that, Brian. I have updated the posting above, since I had accidentally set noauto in the fstab line, which means, it must be mounted later manually, but with a simplyfied mount command then, by non-root users. This is what antiX defaults to (so I have always to add “mount=all” to the Live boot.)

                          To have the partition actually mounted at boot time, you’d have to replace noauto by auto.

                          But you are right, depending on your workflow and tasks, it can be wise not to have mounted all drives continuously while working, and mount/umount them only when needed like you do. A really good advice. So the original noauto was fine, while it was not what I had promised originally 🙂

                          Windows is like a submarine. Open a window and serious problems will start.

                          #184766
                          stevesr0
                          Member

                            Hi Robin and Brian,

                            Thanks very much for your comments.

                            While I opted to follow Robin’s step-by-step instructions, I will chew on (and hopefully incorporate your advice, Brian).

                            Initially, there was no entry in fstab for sda5. After using blkid to discover the UUID, I edited the fstab file in accordance with with your example (using auto) and after rebooting, found that I did have a new directory which I owned located in /sda5 and linked to /home/stevesr0.

                            Bizarrely (to this noobie), the prior directories which contained my music had “vanished”. However, equally bizarrely to this noobie, all the music now was in the new directory.

                            I haven’t checked whether I can add more directories to sda5 in the same fashion. That would be of academic interest to me, as it isn’t obvious that I could <g>.

                            #184767
                            Brian Masinick
                            Moderator

                              @stevesr0 since you have a music directory on a different partition (sda5) than your home directory, you have a different setup than I do; in your case you have one distribution utilizing multiple partitions for different purposes, so absolutely it makes sense to consistently mount sda5 so you have the music available to you.

                              Concerning Robin’s comments about which options to use for mounting, if you want the music to always be mounted, as he mentioned, in that case the auto option makes sense; conversely, if you want the music partition easily accessible, but not necessarily mounted all the time, then having the noauto option will take care of that, but since it’s still in the mount table, it’ll be super quick to mount it; the choice on that is yours to make.

                              Our other conversation between Robin and me was about automatically including the mount points. For me, I suppose I could put them in my mount table too, and make mine noauto; as he and I discussed, my scenarios are different than yours and that’s why I manually add and remove mount points. I believe you’re understanding all of this well, and also the reasons for different approaches.

                              Once again I find all of this super cool; this is precisely the reason I was SO HAPPY the day I got my first personal Linux system. I was already a UNIX systems engineer, and our super clustered servers had rows of disk drives connected to servers that were a fraction of the size of those disk servers in those days. Now a rack of drives, where each individual drive might be 2 1/2″ round (if that), that whole rack, taking up LESS room than one of those old servers and 1000 times less room than those disk farms, can hold enough data to run an entire enterprise. So what we need in comparison to all of that is minuscule. The little disk on the laptop I’m using probably has enough room to play music or movies all day long, though that’s not how I use mine; I have two antiX images, an Endeavour OS image, a Slackware image and an MX Linux image on the system I’m using now. The Endeavour OS image is my open slot to test and run stuff; much as I like Endeavour OS, it isn’t one of my core systems; sometimes I put Cachy OS there, sometimes I put a test antiX image there, and other times I experiment with stuff that gets a day (if that); if I don’t like what I try out, either antiX or Endeavour OS gets the slot back; anyway, that’s what I do with this system – my main antiX image is my “regular” system; my other one is a cutting edge test instance, and if I have a third, it’s experimental.

                              That’s what this “oldie” geek does when I’m stirring the bits and bytes here.

                              --
                              Brian Masinick
                              Alternate "Search B":
                              This search page

                              #184777
                              stevesr0
                              Member

                                Hi Brian,

                                Your exposition of different use cases is important. It is so useful to many users that the thread you started, “What are you “here” with today?” has more than 6000 entries. That is a level of focus way higher than I usually have in computing. For me, using Linux has been something I was proud to be able to do within the limited amount of time that I felt I could apply to it (excuse of course) and the lack of serious computer training or use in my education or work life (excuse #2).

                                So, although I consider myself knowledgeable in some spheres, I have remained a noobie in the use of computers. I can look up solutions that others have offered and occasionally use them on my own successfully, but always aware that my problem solving skills are very limited.

                                So, my visualization of a problem is often at a very simplistic level and possibly ass-backwards.

                                In the case of this thread that I started, I didn’t understand why the second music directory I mounted to the partition that already had a directory mounted in it, couldn’t have its own contents, but had them “overwritten” by the second directory.

                                In the course of this thread, it occurs to me (perhaps wrongly or oversimplistically), that a “directory” mounted to a partition, “owns” that WHOLE partition. So, if a second directory is subsequently created and mounted to the same partition, it can’t have its own independent files. What one has to do, is create subdirectories within that directory.

                                But, I haven’t looked that up (yet) and I might be wrong <g>.

                                To both you, Brian and Robin, thanks for the assistance in getting my directory working so I could play the music as a regular user rather than root (assuming that it is still working the next time I boot it up and try to just play something).

                                #184782
                                Brian Masinick
                                Moderator

                                  Hi @Stevesr0

                                  You are an intelligent person. It’s merely a question of having or lacking gained experience that may potentially lead to increased knowledge. Because you do read and you do experiment, whether you know it or not, you’ve actually learned and acquired quite a bit.

                                  This particular exercise is another opportunity to add another incremental tidbit to that expanding knowledge base.

                                  a “directory” mounted to a partition, “owns” that WHOLE partition.

                                  That’s very close, but not 100% accurate. When you create a mount point, that mount point has access to the resource that is selected. Anything that is within that mount point is therefore accessible.

                                  Given that, here’s an additional statement that may help. When you mount sda5 to /mnt, for example, you have access to everything in /mnt, so in this instance it means everything on sda5. But it also means that you have to be much more explicit to actually access exactly what you want.

                                  Here’s an extreme example. So if you mount sda5 to /mnt, then type in sudo rm -rf /mnt/* that’s going to remove everything (-rf means recursively force) everything under /mnt, so all of sda5 gets WIPED in one shot!

                                  Given this, it means that you have to specify more, so if you want ONLY music, you reference /mnt/”the path to music”, of course replacing “the path to music” with whatever that path is, so if it’s /music, it’d be /mnt/music, if it’s /home/steve/music, it’d be /mnt/home/steve/music, and so on. If it’s a different directory, specify that instead.

                                  I hope that makes matters one step closer to correct, but language and explanations are a tricky matter. What’s 100% clear to one person is illegible to someone else. My recent conversations with Marcelo frequently remind me of this, so please write in your own words what you receive from this; based on your response, I’ll be able to notice whether I’ve clarified or muddied the details. Thanks!

                                  --
                                  Brian Masinick
                                  Alternate "Search B":
                                  This search page

                                Viewing 15 posts - 1 through 15 (of 24 total)
                                • You must be logged in to reply to this topic.