Announcement

Collapse
No announcement yet.

lost hard drive ownership and permissions

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

    [SOLVED] lost hard drive ownership and permissions

    Hi,

    After upgrading from 20.04 to 22.04 I lost the ability to write on a secondary hard drive of my laptop. I can click it on Dolphin and read the contents but I can't change them. Bassically I want to able again to read and write on the directory "DATA" in "/media/tommy/DATA" (where "tommy" is my username, id = 1000). Here is some information

    Code:
    tommy@varanus:~$ cat /etc/fstab
    # /etc/fstab: static file system information.
    #
    # Use 'blkid' to print the universally unique identifier for a
    # device; this may be used with UUID= as a more robust way to name devices
    # that works even if disks are added and removed. See fstab(5).
    #
    # <file system> <mount point> <type> <options> <dump> <pass>
    # / was on /dev/sda2 during installation
    UUID=f8e96d97-318a-4af8-af32-357512834f82 / ext4 errors=remount-ro 0 1
    # /boot/efi was on /dev/sda1 during installation
    UUID=8224-3C30 /boot/efi vfat umask=0077 0 1
    # /home was on /dev/sda3 during installation
    UUID=e93a8dd8-7e60-4e75-8a4b-08b2f8918f1c /home ext4 defaults 0 2
    /swapfile none swap sw 0 0
    tommy@varanus:~$
    tommy@varanus:~$
    tommy@varanus:~$ df -h
    Filesystem Size Used Avail Use% Mounted on
    tmpfs 787M 2.2M 785M 1% /run
    /dev/sda2 37G 31G 4.8G 87% /
    tmpfs 3.9G 169M 3.7G 5% /dev/shm
    tmpfs 5.0M 4.0K 5.0M 1% /run/lock
    /dev/sda3 191G 158G 24G 87% /home
    /dev/sda1 511M 5.3M 506M 2% /boot/efi
    tmpfs 787M 76K 787M 1% /run/user/1000
    /dev/sdb1 916G 672G 198G 78% /media/tommy/DATA


    Thanks

    #2
    If this is a secondary drive - not a removable device - it should be in fstab rather than just clicking on it in Dolphin. This gives you more control. My recommendations:
    1. Make a mount folder for the partition.
    2. Set the mount point ownership to you.
    3. Add the entry in fstab.
    4. Mount it.
    The commands for the above;
    1. sudo mkdir /mnt/data
    2. sudo chown 1000:1000 /mnt/data
    3. kate /etc/fstab
    Now use Kate to add the entry something like:

    Code:
    /dev/sdb1 /mnt/data ext4 defaults 0 0
    Add it at the end and make sure there at least one extra line feed (blank line) at the end.

    The key will be in the fstab mount options. I assumed you used EXT4. If you don't want it mounted at boot, add "users,noauto" to the options and it will not mount at boot, but will allow you to mount it as a user rather than using "sudo" every time.

    Please Read Me

    Comment


      #3
      Originally posted by oshunluvr View Post
      […]
      The commands for the above;
      1. sudo mkdir /mnt/data
      2. sudo chown 1000:1000 /mnt/data
      3. kate /etc/fstab
      Now use Kate to add the entry something like:

      Code:
      /dev/sdb1 /mnt/data ext4 defaults 0 0
      […]
      Do follow the good instructions from oshunluvr - but I would advise you to do this with three little adjustments:
      1. sudo mkdir /mnt/data
      2. sudo chown 1000:1000 /mnt/data
      3. sudo cp /etc/fstab /etc/fstab.orig
      4. kate /etc/fstab
      Now use Kate to add the entry something like:

      UUID=the_UUID_of_your_partition_named_DATA /mnt/data ext4 defaults,noatime 0 0


      Why?

      a. It is always a good idea to make a backup of important system files before altering them
      (hence sudo cp /etc/fstab /etc/fstab.orig​ ).

      b. Mounting a partition by path (e.g. /dev/sdb1 ) is unreliable sometimes, as the path name can change between reboots (especially if you have multiple storage devices).
      It is much more reliable to mount them by UUID or by label - I use UUID in the following example, as most distributions do it this way nowadays (Kubuntu does, too):

      The UUID in your case would look something like ​de785a1a-52fa-4545-beb2-e2b8332cf3f0 for an ext4 partition.
      You can get it by lsblk -f and looking for the appropriate information of your partition named "DATA" (or sdb1 in your original post).

      c. Less important, but you could add "noatime" to the entry in /etc/fstab - it reduces disk access on a spinning hard disk drive and write operations on a solid state drive (gives a minimal performance boost for HDDs and reduces wearing for SSDs).
      Afaik only older mail servers rely on the atime information, and I guess you don't intend to operate one of those…


      -> The fstab entries are only valid if the partition is ext4 - the entries for ntfs (for example) would be different in /etc/fstab !
      Last edited by Schwarzer Kater; Dec 17, 2022, 07:53 PM. Reason: typos
      Debian KDE & LXQt • Kubuntu & Lubuntu • openSUSE KDE • Windows • macOS X
      Desktop: Lenovo ThinkCentre M75s • Laptop: Apple MacBook Pro 13" • and others

      get rid of Snap script (20.04 +)reinstall Snap for release-upgrade script (20.04 +)
      install traditional Firefox script (22.04 +)​ • install traditional Thunderbird script (24.04)

      Comment


        #4
        Dear oshunluvr & Schwarzer Kater,

        Thank you very much, I followed your instructions and the problem is solved now.

        Cheers

        Comment

        Working...
        X