Ubuntu – My files permissions change spontaneously to read-only, sometimes

fsckhard drivemountread-only

This is very common, i have been doing my things when my files permissions changed to read-only. I reboot my pc immediately and this won't start, so i forced power off, then I typed fsck /dev/sda2. Where is the problem? Why this always happens? The pc is eight months old.

I am worried because my last time when I typed sudo fsck -f /dev/sda2 in Live Ubuntu, the output showed me this:

Pass 1: Checking inodes, blocks, and sizes 
Inode 19411393 seems to contain garbage.  Clear? yes 
...
Inode 19412112 seems to contain garbage.  Clear? yes 

...

Pass 2: Checking directory structure 
Entry 'Captura de pantalla de 2020-04-14 17-02-34.png' in /home/pasta/ImM-CM-!genes (19398749) has deleted/unused inode 19411936.  Clear? yes 

...

Entry 'bdcc59467787cae82ff54abaec1dd5497e4d0d' in /home/pasta/.cache/mesa_shader_cache/35 (19398823) has deleted/unused inode 19411992.  Clear? yes 
...

Pass 5: Checking group summary information 
Block bitmap differences:  -(625760--625791) ... -(500 OF THESE, MORE OR LESS) ... -(159426726--159426729) 
Fix? yes 

The output of dmesg, what caught my attention:

[   39.721010] pcieport 0000:00:1c.5: AER: PCIe Bus Error: severity=Corrected, type=Physical Layer, (Receiver ID)
[   39.721019] pcieport 0000:00:1c.5: AER:   device [8086:9d15] error status/mask=00000001/00002000
[   39.721024] pcieport 0000:00:1c.5: AER:    [ 0] RxErr            
...
[  170.652599] blk_update_request: I/O error, dev sdb, sector 4096 op 0x0:(READ) flags 0x80700 phys_seg 1 prio class 0
[  170.652736] blk_update_request: I/O error, dev sdb, sector 4096 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 0
[  170.652744] Buffer I/O error on dev sdb1, logical block 256, async page read

Output of sudo smartctl -a /dev/sda2 after sudo smartctl -t long /dev/sda2 :

smartctl 6.6 2016-05-31 r4324 [x86_64-linux-5.3.0-46-generic] (local build) 
Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org 

=== START OF INFORMATION SECTION === 
Device Model:     TOSHIBA MQ04ABF100 
Serial Number:    X8JBP3K2T 
LU WWN Device Id: 5 000039 8d268714d 
Firmware Version: JU001J 
User Capacity:    1.000.204.886.016 bytes [1,00 TB] 
Sector Sizes:     512 bytes logical, 4096 bytes physical 
Rotation Rate:    5400 rpm 
Form Factor:      2.5 inches 
Device is:        Not in smartctl database [for details use: -P showall] 
ATA Version is:   ACS-3 T13/2161-D revision 5 
SATA Version is:  SATA >3.2 (0x1ff), 6.0 Gb/s (current: 6.0 Gb/s) 
Local Time is:    Tue Apr 14 22:33:42 2020 -04 
SMART support is: Available - device has SMART capability. 
SMART support is: Enabled 

=== START OF READ SMART DATA SECTION === 
SMART overall-health self-assessment test result: PASSED 

General SMART Values: 
Offline data collection status:  (0x00) Offline data collection activity 
                    was never started. 
                    Auto Offline Data Collection: Disabled. 
Self-test execution status:      (   0) The previous self-test routine completed 
                    without error or no self-test has ever  
                    been run. 
Total time to complete Offline  
data collection:        (  120) seconds. 
Offline data collection 
capabilities:            (0x5b) SMART execute Offline immediate. 
                    Auto Offline data collection on/off support. 
                    Suspend Offline collection upon new 
                    command. 
                    Offline surface scan supported. 
                    Self-test supported. 
                    No Conveyance Self-test supported. 
                    Selective Self-test supported. 
SMART capabilities:            (0x0003) Saves SMART data before entering 
                    power-saving mode. 
                    Supports SMART auto save timer. 
Error logging capability:        (0x01) Error logging supported. 
                    General Purpose Logging supported. 
Short self-test routine  
recommended polling time:    (   2) minutes. 
Extended self-test routine 
recommended polling time:    ( 172) minutes. 
SCT capabilities:          (0x003d) SCT Status supported. 
                    SCT Error Recovery Control supported. 
                    SCT Feature Control supported. 
                    SCT Data Table supported. 

SMART Attributes Data Structure revision number: 16 
Vendor Specific SMART Attributes with Thresholds: 
ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE 
  1 Raw_Read_Error_Rate     0x000b   100   100   050    Pre-fail  Always       -       0 
  2 Throughput_Performance  0x0005   100   100   050    Pre-fail  Offline      -       0 
  3 Spin_Up_Time            0x0027   100   100   001    Pre-fail  Always       -       1294 
  4 Start_Stop_Count        0x0032   100   100   000    Old_age   Always       -       636 
  5 Reallocated_Sector_Ct   0x0033   100   100   050    Pre-fail  Always       -       0 
  7 Seek_Error_Rate         0x000b   100   095   050    Pre-fail  Always       -       0 
  8 Seek_Time_Performance   0x0005   100   100   050    Pre-fail  Offline      -       0 
  9 Power_On_Hours          0x0032   096   096   000    Old_age   Always       -       1743 
 10 Spin_Retry_Count        0x0033   112   100   030    Pre-fail  Always       -       0 
 12 Power_Cycle_Count       0x0032   100   100   000    Old_age   Always       -       451 
191 G-Sense_Error_Rate      0x0032   100   100   000    Old_age   Always       -       1359 
192 Power-Off_Retract_Count 0x0032   100   100   000    Old_age   Always       -       23 
193 Load_Cycle_Count        0x0032   095   095   000    Old_age   Always       -       50104 
194 Temperature_Celsius     0x0022   100   100   000    Old_age   Always       -       35 (Min/Max 13/45) 
196 Reallocated_Event_Count 0x0032   100   100   000    Old_age   Always       -       0 
197 Current_Pending_Sector  0x0032   100   100   000    Old_age   Always       -       0 
198 Offline_Uncorrectable   0x0030   100   100   000    Old_age   Offline      -       0 
199 UDMA_CRC_Error_Count    0x0032   200   200   000    Old_age   Always       -       0 
220 Disk_Shift              0x0002   100   100   000    Old_age   Always       -       0 
222 Loaded_Hours            0x0032   097   097   000    Old_age   Always       -       1533 
223 Load_Retry_Count        0x0032   100   100   000    Old_age   Always       -       0 
224 Load_Friction           0x0022   100   100   000    Old_age   Always       -       0 
226 Load-in_Time            0x0026   100   100   000    Old_age   Always       -       264 
240 Head_Flying_Hours       0x0001   100   100   001    Pre-fail  Offline      -       0 

SMART Error Log Version: 1 
ATA Error Count: 1 
    CR = Command Register [HEX] 
    FR = Features Register [HEX] 
    SC = Sector Count Register [HEX] 
    SN = Sector Number Register [HEX] 
    CL = Cylinder Low Register [HEX] 
    CH = Cylinder High Register [HEX] 
    DH = Device/Head Register [HEX] 
    DC = Device Command Register [HEX] 
    ER = Error register [HEX] 
    ST = Status register [HEX] 
Powered_Up_Time is measured from power on, and printed as 
DDd+hh:mm:SS.sss where DD=days, hh=hours, mm=minutes, 
SS=sec, and sss=millisec. It "wraps" after 49.710 days. 

Error 1 occurred at disk power-on lifetime: 1096 hours (45 days + 16 hours) 
  When the command that caused the error occurred, the device was active or idle. 

  After command completion occurred, registers were: 
  ER ST SC SN CL CH DH 
  -- -- -- -- -- -- -- 
  04 31 00 02 59 d7 a9 

  Commands leading to the command that caused the error were: 
  CR FR SC SN CL CH DH DC   Powered_Up_Time  Command/Feature_Name 
  -- -- -- -- -- -- -- --  ----------------  -------------------- 
  ea 00 00 00 00 00 a0 00      05:01:42.830  FLUSH CACHE EXT 
  61 58 30 38 f9 20 40 00      05:01:42.830  WRITE FPDMA QUEUED 
  61 08 80 08 f9 1b 40 00      05:01:42.829  WRITE FPDMA QUEUED 
  61 08 78 a0 b8 52 40 00      05:01:42.788  WRITE FPDMA QUEUED 
  61 30 70 58 0c 50 40 00      05:01:42.788  WRITE FPDMA QUEUED 

SMART Self-test log structure revision number 1 
Num  Test_Description    Status                  Remaining  LifeTime(hours)  LBA_of_first_error 
# 1  Extended offline    Completed without error       00%      1743         - 
# 2  Extended offline    Completed without error       00%      1728         - 

SMART Selective self-test log data structure revision number 1 
 SPAN  MIN_LBA  MAX_LBA  CURRENT_TEST_STATUS 
    1        0        0  Not_testing 
    2        0        0  Not_testing 
    3        0        0  Not_testing 
    4        0        0  Not_testing 
    5        0        0  Not_testing 
Selective self-test flags (0x0): 
  After scanning selected spans, do NOT read-scan remainder of disk. 
If Selective self-test is pending on power-up, resume after 0 minute delay. 

Best Answer

The OS remounts your root partition as read-only when it detected a file system problem during boot time or during runtime if the access to disk was lost for more than a certain time. The output of smartctl you've shown does not indicate problems on the disk counters (yet) but the SMART logs show a disk access problem in the no so far past.

Try running a full SMART check on your drive: smartctl -t long /dev/sda. If that doesn't find anything, you should boot a Live Linux (e.g. Knoppix, Linux Mint, etc) and run a fsck -f on your non-mounted drive.

Losing access to the drive is in most cases caused by a defective drive, much less caused by a defective SATA cable or controller.