Drive becomes read-only

  • This topic has 24 replies, 8 voices, and was last updated Feb 28-7:28 pm by Brian Masinick.
Viewing 15 posts - 1 through 15 (of 25 total)
  • Author
    Posts
  • #77456
    Member
    roland

      On this pc with 4 HD drives (1 SSD, 3 rotating) I was copying a folder containing about 4000 files to /media/sdc1 when something went wrong, not certain what, but the outcome has been that sdc1 is now read-only although appears to be otherwise ok.

      I have looked at permissions in /media/sdc1 and at /dev/sdc1 but am unwilling to touch without knowledge. I attach screenshots of permissions and the refusal to write to the drive.

      I have had this condition in the past with removable SD media, but have got around it by writing a new partition table and making the default user the owner.

      Thanks in advance for all contibutions.

      #77461
      Member
      madibi
        Helpful
        Up
        1
        ::

        Hi Roland!
        From where did you copied the 4000 files?
        If I understand correctly your images, the owner of the hd is root.
        So the best for you is to learn how to use the command “chown” = change owner, in a recursive way, so that all the hd and sub directories will be owned by you.

        Another way to arrive to the very same result, is to open the /media/DISKINQUESTION/ with zzzfm with the root rights and change the owner (remember, always in a recursive way).

        Please let me know 🙂
        m

        #77482
        Member
        roland
          Helpful
          Up
          0
          ::

          I copied the files from another volume on the same PC, /media/sdd2.

          The ownership for /dev/sdc1 is root, which I would have expected and therefore was unwilling to change.

          The ownership for /media/sdc1 is roland (default user) which I also expected, hence the problem.

          Why can’t I write to it when I own it? And why the entire volume, and not simply the new folder written?

          The volume names in /media I set deliberately using Gparted to coincide with the labels assigned by the installer in /dev, to avoid confusion as to what is what.

          #77514
          Member
          madibi
            Helpful
            Up
            0
            ::

            and who is the owner of the written folder?
            can you operate in some of the sub-directories or every operation is forbidden?
            m

            #77515
            Member
            sybok
              Helpful
              Up
              1
              ::

              Hi, Linux can be tricky with permissions to files and/or (sub)folders.

              If you want to quickly find which files or folders are (not) owned by root, you can use the below *template for* a command:
              find <path to main folder> -name '*' -type <f|d> -exec ls -lh {} -- \; | grep [-v] "\<root\>"
              1) Find all files (if using ‘f’) or folders (if using ‘d’) and execute ‘ls -lh’ on each, prints to STDOUT/terminal.
              The output of ‘ls -lh’ contains information about the owner.
              2) ‘grep’ selects only certain records that contain string ‘root’; the optional switch ‘-v’ inverts/negates the selection to strings not containing ‘root’.
              The ‘\<…\>’ specifies that the enclosed content is a whole word.

              E.g. find all folders within my home directory that are not owned by root:
              find /home/sybok/ -name '*' -type d -exec ls -lh {} -- \; | grep -v "\<root\>"

              If you want to count the records, you simply pass the output (via pipe ‘|’) to ‘wc’ and count the lines because each record is on a separate line:
              find /home/sybok/ -name '*' -type d -exec ls -lh {} -- \; | grep -v "\<root\>" | wc -l

              This could help you to get an overview of the situation.

              Also, it could be worthwhile to explore the file ‘/etc/fstab’ which lists mounted drives and permissions.

              • This reply was modified 1 year, 2 months ago by sybok. Reason: Mention /etc/fstab
              #77524
              Moderator
              christophe
                Helpful
                Up
                0
                ::

                It sounds to me like root wrote files to sdc1, and “he” now owns those files. If it were me, and I simply wanted to change ownership back to Roland, I would do what madibi suggested – chown recursively on /media/sdc1.
                Though I’m sure sybok’s diagnostics would be very valuable.

                confirmed antiX frugaler, since 2019

                #77539
                Member
                sybok
                  Helpful
                  Up
                  0
                  ::

                  Hi,

                  the combination with find + exec can be used to block change ownership and/or group from terminal, e.g.

                  find /home/sybok/ -name '*' -type d -exec chown sybok {} -- \;
                  find /home/sybok/ -name '*' -type d -exec chgrp sybok {} -- \;

                  The same can be achieved with ‘-R’ in each of the two commands with less types
                  chown sybok -R /home/sybok/

                  • This reply was modified 1 year, 2 months ago by sybok.
                  #77636
                  Member
                  roland
                    Helpful
                    Up
                    0
                    ::

                    The problem gets more serious – the next time I came to look at it I could not even mount the volume.

                    However sdc2 is another volume on the same disk alongside sdc1, and while sdc2 can be mounted I cannot write a folder of files to it, an i-o error is produced at the first write attempt.

                    It looks as if the drive is corrupted in some way, although it is relatively new and a good make (Seagate I think). However the drives were very cheap from Aliexpress and may be quite old.

                    Has any contributor any suggestions for checking out the drive bearing in mind it will not mount?

                    #77639
                    Member
                    madibi
                      Helpful
                      Up
                      1
                      ::

                      Searching in google: “debian can’t read superblock”, I found a lot af answers. The following link seems exhaustive to me
                      https://www.linuxbabe.com/desktop-linux/fix-cant-read-superblock-error

                      As an alternative I suggest you to use some tool as Rescatux, that saved me a lot of times 🙂

                      m

                      #77642
                      Member
                      sybok
                        Helpful
                        Up
                        1
                        ::

                        Hi, I believe that I used ‘smartmontools’ (no-systemd version instalable in antiX) for scanning/examining health of a drive.
                        It does not do repairs; they can be attempted/done using ‘fsck’ (that comes in ‘util-linux’), see e.g.
                        https://recoverit.wondershare.com/harddrive-tips/repair-linux-disk.html

                        #77732
                        Member
                        roland
                          Helpful
                          Up
                          0
                          ::

                          I ran the superblock fix job suggested by Madibi, this is what happened:-

                          roland@antix1:~/Desktop
                          $ su
                          Password:
                          root@antix1:/home/roland/Desktop# parted -1
                          parted: invalid option — ‘1’
                          Usage: parted [-hlmsv] [-a<align>] [DEVICE [COMMAND [PARAMETERS]]…]
                          root@antix1:/home/roland/Desktop# sudo parted -1
                          parted: invalid option — ‘1’
                          Usage: parted [-hlmsv] [-a<align>] [DEVICE [COMMAND [PARAMETERS]]…]
                          root@antix1:/home/roland/Desktop# sudo mke2fs -n /dev/sdc1
                          mke2fs 1.44.5 (15-Dec-2018)
                          /dev/sdc1 contains a ext4 file system labelled ‘sdc1’
                          last mounted on /media/sdc1 on Tue Feb 15 16:41:59 2022
                          Proceed anyway? (y,N) y
                          Creating filesystem with 30517248 4k blocks and 7634944 inodes
                          Filesystem UUID: d4188145-12d3-43fa-8141-3b3dee11625b
                          Superblock backups stored on blocks:
                          32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
                          4096000, 7962624, 11239424, 20480000, 23887872

                          root@antix1:/home/roland/Desktop# sudo e2fsck -b 32768 /dev/sdc1
                          e2fsck 1.44.5 (15-Dec-2018)
                          Error reading block 1057 (Input/output error). Ignore error<y>? yes
                          Force rewrite<y>? yes
                          Superblock has an invalid journal (inode 8).
                          Clear<y>? yes
                          *** journal has been deleted ***

                          Resize inode not valid. Recreate<y>? yes
                          Pass 1: Checking inodes, blocks, and sizes
                          Error reading block 1058 (Input/output error) while getting next inode from scan. Ignore error<y>? yes
                          Force rewrite<y>? yes
                          Error reading block 1059 (Input/output error) while getting next inode from scan. Ignore error<y>? yes
                          Force rewrite<y>? yes
                          Error reading block 1060 (Input/output error) while getting next inode from scan. Ignore error<y>? yes
                          Force rewrite<y>? yes
                          Error reading block 1061 (Input/output error) while getting next inode from scan. Ignore error<y>? yes
                          Force rewrite<y>? yes
                          Error reading block 1062 (Input/output error) while getting next inode from scan. Ignore error<y>? yes
                          Force rewrite<y>? yes
                          Error reading block 1063 (Input/output error) while getting next inode from scan. Ignore error<y>? yes
                          Force rewrite<y>? yes
                          Error reading block 1064 (Input/output error) while getting next inode from scan. Ignore error<y>? yes
                          Force rewrite<y>? yes
                          Root inode is not a directory. Clear<y>? yes
                          Error reading block 1065 (Input/output error) while getting next inode from scan. Ignore error<y>? yes
                          Force rewrite<y>? yes
                          Error reading block 1066 (Input/output error) while getting next inode from scan. Ignore error<y>? yes
                          Force rewrite<y>? yes
                          Error reading block 1067 (Input/output error) while getting next inode from scan. Ignore error<y>? yes
                          Force rewrite<y>? yes
                          Error reading block 1068 (Input/output error) while getting next inode from scan. Ignore error<y>? yes
                          Force rewrite<y>? yes
                          Error reading block 1069 (Input/output error) while getting next inode from scan. Ignore error<y>? yes
                          Force rewrite<y>? yes
                          Error reading block 1070 (Input/output error) while getting next inode from scan. Ignore error<y>? yes
                          Force rewrite<y>? yes
                          Error reading block 1071 (Input/output error) while getting next inode from scan. Ignore error<y>? yes
                          Force rewrite<y>? yes
                          Error reading block 1072 (Input/output error) while getting next inode from scan. Ignore error<y>? yes
                          Force rewrite<y>? yes
                          Error reading block 1073 (Input/output error) while getting next inode from scan. Ignore error<y>? yes
                          Force rewrite<y>? yes
                          Error reading block 1074 (Input/output error) while getting next inode from scan. Ignore error<y>? yes
                          Force rewrite<y>? yes
                          Error reading block 1075 (Input/output error) while getting next inode from scan. Ignore error<y>? yes
                          Force rewrite<y>? yes
                          Error reading block 1076 (Input/output error) while getting next inode from scan. Ignore error<y>? yes
                          Force rewrite<y>? yes
                          Error reading block 1077 (Input/output error) while getting next inode from scan. Ignore error<y>? yes
                          Force rewrite<y>? yes
                          Error reading block 1078 (Input/output error) while getting next inode from scan. Ignore error<y>? yes
                          Force rewrite<y>? yes
                          Error reading block 1079 (Input/output error) while getting next inode from scan. Ignore error<y>? yes
                          Force rewrite<y>? yes
                          Error reading block 1080 (Input/output error) while getting next inode from scan. Ignore error<y>? yes
                          Force rewrite<y>? yes
                          Error reading block 1081 (Input/output error) while getting next inode from scan. Ignore error<y>? yes
                          Force rewrite<y>? yes
                          Error reading block 1082 (Input/output error) while getting next inode from scan. Ignore error<y>? yes
                          Force rewrite<y>? yes
                          Error reading block 1083 (Input/output error) while getting next inode from scan. Ignore error<y>? yes
                          Force rewrite<y>? yes
                          Error reading block 1084 (Input/output error) while getting next inode from scan. Ignore error<y>? yes
                          Force rewrite<y>? yes
                          Error reading block 1085 (Input/output error) while getting next inode from scan. Ignore error<y>? yes
                          Force rewrite<y>? yes
                          Error reading block 1086 (Input/output error) while getting next inode from scan. Ignore error<y>? yes
                          Force rewrite<y>? yes
                          Error reading block 1087 (Input/output error) while getting next inode from scan. Ignore error<y>? yes
                          Force rewrite<y>? yes
                          Error reading block 1088 (Input/output error) while getting next inode from scan. Ignore error<y>? yes
                          Force rewrite<y>? yes
                          Error reading block 1089 (Input/output error) while getting next inode from scan. Ignore error<y>? yes
                          Force rewrite<y>? yes
                          Error reading block 1090 (Input/output error) while getting next inode from scan. Ignore error<y>? yes
                          Force rewrite<y>? yes
                          Error reading block 1091 (Input/output error) while getting next inode from scan. Ignore error<y>? yes
                          Force rewrite<y>? yes
                          Error reading block 1092 (Input/output error) while getting next inode from scan. Ignore error<y>? yes
                          Force rewrite<y>? yes
                          Error reading block 1093 (Input/output error) while getting next inode from scan. Ignore error<y>? yes
                          Force rewrite<y>? yes
                          Error reading block 1094 (Input/output error) while getting next inode from scan. Ignore error<y>? yes
                          Force rewrite<y>? yes
                          Error reading block 1095 (Input/output error) while getting next inode from scan. Ignore error<y>? yes
                          Force rewrite<y>? yes
                          Error reading block 1096 (Input/output error) while getting next inode from scan. Ignore error<y>? yes
                          Force rewrite<y>? yes
                          Error reading block 1097 (Input/output error) while getting next inode from scan. Ignore error<y>? yes
                          Force rewrite<y>? yes
                          Error reading block 1098 (Input/output error) while getting next inode from scan. Ignore error<y>? yes
                          Force rewrite<y>? yes
                          Error reading block 1099 (Input/output error) while getting next inode from scan. Ignore error<y>? yes
                          Force rewrite<y>? yes
                          Error reading block 1100 (Input/output error) while getting next inode from scan. Ignore error<y>? yes
                          Force rewrite<y>? yes
                          Error reading block 1101 (Input/output error) while getting next inode from scan. Ignore error<y>? yes
                          Force rewrite<y>? yes
                          Error reading block 1102 (Input/output error) while getting next inode from scan. Ignore error<y>? yes
                          Force rewrite<y>? yes
                          Error reading block 1103 (Input/output error) while getting next inode from scan. Ignore error<y>? yes
                          Force rewrite<y>? yes
                          Error reading block 1104 (Input/output error) while getting next inode from scan. Ignore error<y>? yes
                          Force rewrite<y>? yes
                          Error reading block 1105 (Input/output error) while getting next inode from scan. Ignore error<y>? yes
                          Force rewrite<y>? yes
                          Error reading block 1106 (Input/output error) while getting next inode from scan. Ignore error<y>? yes
                          Force rewrite<y>? yes
                          Error reading block 1107 (Input/output error) while getting next inode from scan. Ignore error<y>? yes
                          Force rewrite<y>? yes
                          Error reading block 1108 (Input/output error) while getting next inode from scan. Ignore error<y>?

                          I gave up responding ‘y’ after block 1108 suspecting that there may be many more, or that the routine was failing.

                          Next I’ll give Sybok’ s suggestion a go.

                          Thanks for these suggestions.

                          #77733
                          Member
                          ModdIt
                            Helpful
                            Up
                            1
                            ::

                            Hi roland did you already check what your drive can tell you?.

                            # “X” represents your HDD’s label name
                            sudo smartctl -a /dev/sdX

                            Are you able to access the drive while running from a live stick,
                            the symptoms may point to a bigger issue than wrong permissions.

                            #77739
                            Member
                            Robin
                              Helpful
                              Up
                              1
                              ::

                              ModdIt is right, this issue might be bigger. Please check dmesg output, whether there are errors or repeated attempts of reinitialising the controller of the drive. I had to replace a brand new USB stick, since its controller didn’t respond correctly, producing exactly the behaviour you describe. The driver reinitialised the controller more than once per second, always getting strange responses from the drive. After replacement of the stick in store where I’ve bought it, this never happened again.

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

                              #77788
                              Moderator
                              Brian Masinick
                                Helpful
                                Up
                                1
                                ::

                                ModdIt wrote:

                                “Hi all,
                                best first read smart on the drive, if the self assessment passes then move on to
                                further checks.

                                In the output the below line is the one to look for.
                                SMART overall-health self-assessment test result: PASSED

                                Thanks for suggestion Robin,
                                USB sticks are somewhat different to diagnose device health as they do not have self test capability.

                                As roland has a drive recently put in service early failure is something to consider.
                                Reading out smart can, in some cases show the drive is not new and has high power on time
                                bad block count, error count. The readout is non destructive so no need to fear any data loss.

                                First check I do on any new drive, SMART check, the second on rotating disks is an extended self test.”

                                (was marked SPAM); I copied it and posted the note above so it is included in the discussion!)

                                --
                                Brian Masinick

                                #77792
                                Member
                                roland
                                  Helpful
                                  Up
                                  0
                                  ::

                                  Sorry for the slowness of my responses, at 76 I’m not so quick as I perhaps was and have other distractions just now, but I value the intelligent input I’m getting and will look at them all again in the morning (Feb21).

                                  The 260gb drive was a new one bought by post from AliExpress as are the other 3 in this PC, switch-on time has been minimal and that particular drive with its 2 volumes has hardly been written to. However I am aware this kind of think can affect any drive old or new, but I have a feeling, no idea why, that the drive is mechanically ok and that something has got written yo it that has corrupted important blocks.

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