Permissions can be a real PITA !!!

Discussion in 'Linux' started by smallhagrid, Jul 29, 2019.

  1. smallhagrid

    smallhagrid MDL Addicted

    Sep 14, 2013
    608
    445
    30
  2. Yen

    Yen Admin
    Staff Member

    May 6, 2007
    13,081
    13,979
    340
    #2 Yen, Jul 30, 2019
    Last edited: Jul 30, 2019
    Isn't it just the way how you mount the NTFS partition (mount options?)
    For instance r/w with exec attribute (assuming your uid=1000) Default owner would be root. Setting uid makes you grabbing the ownership. (If mounted already, unmount it first).

    Create a mount point:
    Code:
    sudo mkdir -p /mnt/sd2
    Code:
    sudo mount -o rw,user,uid=1000,umask=007,exec /dev/sda2 /mnt/sd2
    
    Or for everyone:
    Code:
    sudo mount -o rw,users,umask=000,exec /dev/sda2 /mnt/sd2
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. smallhagrid

    smallhagrid MDL Addicted

    Sep 14, 2013
    608
    445
    30
    Thanks for replying here Yen !!
    I've been manually creating mount points for needed network shares, but didn't think obout doing it for this purpose because I'd rather just be able to use the media as needed minus those extra steps.

    What I'll be doing will require mounting & removing different things often enough that it really needs to just happen on its own.

    Truly I see no need for any shifting around of either ownership or permissions when it is only me using my own PC with my own media - so avoiding that entire bunch of stuff is what will work best for me.

    I know that there is all this obsessive concern about security for many, many folks - but in my situation such worries are simply too extreme.
     
  4. Yen

    Yen Admin
    Staff Member

    May 6, 2007
    13,081
    13,979
    340
    #4 Yen, Jul 31, 2019
    Last edited: Jul 31, 2019
    The Linux family is just more organized and restrictive. This can be annoying the first time.
    For instance I ran a Linux PVR and some years later I purchased a Linux based media server.

    I simply wanted to copy the records made by the PVR onto the new HDD of the new media server.
    Therefore I connected both HDDs to my PC and booted Linux mint.

    I could NOT access MY recorded files nor I could access the media folder of the new HDD which has been EXT4 formatted by the server OS!!!
    The reason: I was not owner or any sysadmin?!? WTF!

    That time I connected both to my network and enabled FTP server. I copied the recorded media files from my PVR onto my Mint and then from there I uploaded them onto the new media server.:)
    Inconvenient, but it worked that time.

    Later I learned:
    To copy (up/download) via FTP circumvents permission issues AND partition issues due to different file systems. Also CIFS / NFS shares are locally FS independent since they have their own network format.
    Permissions: there are file permissions and folder permissions (chmod) and there is ownership (chown). There are classic permissions predefined by the OS. For instance 0644 for /system files.
    On Android you even get boot loops when doing them wrong.

    When coming from windows I (I guess most of us) wanted to have 0777 everywhere just to get rid of the restrictions, LOL.

    BUT there are also mount options.
    Back to my original problem I simply would have to mount the partitions correctly and there is access for the copy job. :)
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. smallhagrid

    smallhagrid MDL Addicted

    Sep 14, 2013
    608
    445
    30
    Hi Yen and thanks !!
    I am not a Linux newbie at all - certainly have no desire to set all perms at 0777 - being a webmaster has taught me the dangers of misguided perm usages.

    But as you said above - these are MY FILES, dammit !!!!!!

    I am doing the final move from an older PC to a new one with Linux and that one has a very nice removable drive bay for both common sizes of SATA drives.
    Many partitions of my original storage & archives have been NTFS - but now I'm copying all that will remain into new partitions formatted in exFAT.
    That should solve the entire SNAFU somewhat painlessly;
    Then I'll do a P2V using Todo Backup of that entire OS config & I'll have everything at hand whenever I need it.

    In a perfect world stuff could be OS-agnostic & everything would be able to run everywhere - but that just ain't how it is, I know.

    My last hurdle will be to choose which way I'll get Android device accesses on the new Linux box - since there are now lots of ways to do that to choose from.

    No hackintosh yet for me though - and no win-doze newer than XP - IMO it is now a Linux world & I'm good with that (mostly).
     
  6. John Sutherland

    John Sutherland MDL Addicted

    Oct 15, 2014
    867
    1,388
    30
    Just my 2 cents on the topic. First of all, you should avoid at all costs mounting the Windows C:\ system partition from your Linux OS, either temporarily using the command line or automatically using /etc/fstab. In this situation, reading or copying a file shouldn't create a problem, but making any changes to a file, like editing, renaming, or deleting it usually results in chaos the next time you boot into Windows. At best, you'll be prompted to run the chkdsk command, and at worst, you might find Windows unbootable. It all depends on which particular file you decided to monkey with. Using common sense and extreme caution is mandatory in this situation.

    A much better and safer approach is to create a shared data partition under Windows, then auto-mount it when you boot into Linux. It might sound difficult, but should only take a few minutes to do.

    1.) Create a new partition using Windows. Assign a drive letter and name (S for "Shared" works) and format it NTFS. Simple. Creating it under Windows means Windows permissions shouldn't be a problem.

    2.) Shut down Windows and boot into Linux. Start off by verifying that the package ntfs-3g is installed on the system. (It already should be, but verify this just the same). Open the Terminal and enter "sudo apt-get install ntfs-3g".

    3.) Now create a new Linux directory to mount the partition by entering "sudo mkdir /mnt/Shared".

    4.) Enter "sudo fdisk -l" in order to find the device identifier assigned to the new Windows partition you created in Step #1 above. In this example, I'll use /dev/sda3. You use what's appropriate for your system.

    5.) Now mount the new partition by entering "sudo mount /dev/sda3 mnt/Shared".

    6.) Important: Take ownership of the mount point and directory by entering "sudo chown -R <your root username>: mnt/Shared". (In my case, it would be "sudo chown -R john: /mnt/Shared")

    7.) Now the part people might have problems with. In order to auto-mount the new partition at boot, you'll need to find the UUID assigned to the partition and create a new entry in /etc/fstab. From the Terminal enter "sudo blkid", then find the UUID assigned to the new partition. Leave this Terminal open!

    8.) Now open a second Terminal - yes, you can do that! To edit /etc/fstab, use whatever text editor you're comfortable with, in this case I'll use nano. Enter "sudo nano /etc/fstab", then scroll all the way to the bottom of the file in order to create a new entry. Now enter "UUID= /mnt/Shared ntfs-3g defaults,windows_names,locale=en_US.utf8 0 0". Now comes the tricky part: Very carefully copy and paste the UUID from using blkid in the first Terminal and insert it immediately after "UUID=" in the new entry you created in /etc/fstab in the second Terminal. Take your time and be careful!

    9.) Close nano by pressing "Ctrl" and "x". Answer "Y" to the prompt asking if you want to save your changes, then press "Enter". If you did everything correctly, the partition will auto-mount every time you boot into Linux, and you should no longer have any issues with permissions.
    NOTE: I almost forgot: In the new entry in /etc/fstab, I used the locale for the USA. If yours is different, make the appropriate changes. Enter "locale" in the Terminal and copy/paste the results into /etc/fstab, then save the changes.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  7. Yen

    Yen Admin
    Staff Member

    May 6, 2007
    13,081
    13,979
    340
    I know that your not a newbie. But I know other readers who have their first interests at Linux do read here as well.

    I frequently post more generally than it would be needed addressing directly a member who has posted in a special thread.
    That's the way I post...
    Linux has own attributes, knowing them resolves 'issues'. It is restrictive per se.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  8. smallhagrid

    smallhagrid MDL Addicted

    Sep 14, 2013
    608
    445
    30
    Greetings to You John Sutherland and thanks for that amazing reply here !!
    I must wonder what prompted it - as I don't use win-doze that way.
    The 2 ways I use it are either via a VM - in which case shared files are on a USB stick or even a separate PC; or just using apps via WINE.
    Otherwise all the win-doze OS & stuff is kept separated.

    Thanks for clarifying Yen !!
    That makes LOADS of sense as you've described it.

    I'm always grateful for how much more resilient Linux is than win-doze in some ways - and in others I am completely baffled...

    Such as the time I installed Docky for a friend who likes it - and POOF! total compositor failure.

    Or another time when swapping out 1 screen for another, and then...nothing but blackness.

    Someone I know calls this all 'The Linux Adventures';
    I am mostly inclined to agree with him EXCEPT that sometimes the odd & totally unexpected can be a bit too unsettling.
    (VS absolutely ZERO BSODs though, EVER AGAIN - which is a HUGE improvement IMO.)
     
  9. gorski

    gorski MDL Guru

    Oct 21, 2009
    5,518
    1,453
    180
    Do you have a Synology NAS by any chance?

    If so, you should be able to copy to and fro, using the NAS, from both OSs... :)
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  10. smallhagrid

    smallhagrid MDL Addicted

    Sep 14, 2013
    608
    445
    30
    Hi Gorski !!
    Thanks for being so helpful.

    No NAS here (not really any room for it & the electric costs are already quite frightening every month.

    I did solve the dilemna well enough though by means of ExFAT.
    Not perfect - but until something better may arrive, it will do well enough.
     
  11. smallhagrid

    smallhagrid MDL Addicted

    Sep 14, 2013
    608
    445
    30
    So here I am again quite a while later - having tried exfat for a HDD partition...

    Seemed like it worked fine - until I had reason to look at the permissions {sigh} - only to see that it was showing ROOT as owner & no matter what I tried I could not change that.

    Always having been a devout user of EXT3 for HDD partitions 'till now, this really flummoxed me - and I did some searching with no working solution found.

    So=>
    Back to EXT3 that partition went, changed permissions to suit my needs, added sharing, and hopefully I can be done with this goofy stuff now.
     
  12. gorski

    gorski MDL Guru

    Oct 21, 2009
    5,518
    1,453
    180
    Why not EXT4?
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  13. smallhagrid

    smallhagrid MDL Addicted

    Sep 14, 2013
    608
    445
    30
    The important backup & imaging utilities that I use & prefer either refuse to work with EXT4 (like Macrium for example...), or have been known to have errors with it - and EXT3 is fine anyhow.
    I pretty much never have any trouble with it.
     
  14. gorski

    gorski MDL Guru

    Oct 21, 2009
    5,518
    1,453
    180
    #16 gorski, May 1, 2020
    Last edited: May 2, 2020
    Thanx!

    I use EXT4 on my multimedia devices and never had any problem with it.

    From what I read on the subject EXT4 is the improved and stable version of Linux formatting and it does seem strange that some piece of SW is refusing to work with it... But I did not use it in the same way, of course, so can't say anything about that. Have you tried similar SW for the same functions and got the same result?
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  15. smallhagrid

    smallhagrid MDL Addicted

    Sep 14, 2013
    608
    445
    30
    Specifically the version of Macrium Reflect that I use will not make any image of EXT4 without errors.

    I do use some older s/w like SystemBack that has no more modern replacement, works excellently, and doesn't 'know' about EXT4.

    That is also the tool I use most often in transplanting a fully configured system perfectly.

    Given that EXT3 has been working fine for so long for me, I see no need or reason to change.

    I've tried out several different FS choices and EXT3 ticks the most boxes for me.
    (Don't fix it if it ain't broke ??)
     
  16. gorski

    gorski MDL Guru

    Oct 21, 2009
    5,518
    1,453
    180
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  17. smallhagrid

    smallhagrid MDL Addicted

    Sep 14, 2013
    608
    445
    30
    #19 smallhagrid, May 2, 2020
    Last edited: May 2, 2020
    (OP)
    Great info, thanks Gorski.

    This info does not change my situation.
    There are things which I must accomplish, and to do them I require certain functions to be 100% successful.

    Those functions, when using the best tools that I have found, simply do not exist when using EXT4 - and there are no other tools which I've found that accommodate that FS & also do what I require so quickly & easily.

    Example:
    Using SystemBack, I am able to take an image of a fully configured OS with 4 partitions - place that onto a USB stick, then have that boot & install that exact configuration onto different h/w in just a few minutes.

    No other s/w tool does this as well, simply & quickly as SystemBack does.
    Sadly it is unlikely to be updated unless some clever coder takes an interest & forks it.

    And that is just ONE example - there are more.

    GParted can also copy one drive to another when both are connected to the same PC & its boot media is used, but it is very slow & not nearly as good at these operations as SystemBack is, IMO.

    And before it is suggested (yet again...) :
    Clonezilla is able to do this - but it is a PITA to use, very easy to do wrong, and frankly I have tried this with it too many times & learned to despise it after wasting all that time & those efforts.