Originally Posted by farnsy
I figured I have some bad blocks or something, but when I run fsck with the -c option, it checks the partition and doesn't find anything wrong.
You could be right about this being related to bad blocks. This could be what's happening:
- The drive has started developing bad sectors at the very beginning of the drive surface
- A bad sector is detected by the drive when the OS tries to read it, and it is then marked for replacement by the drive firmware
- Since the bad sector is in the middle of the partition table, the partitions appear to have "disappeared", but no data besides the primary copy of the partition table is actually lost
- When you rewrite the partition table, the drive performs a sector reallocation and the write operation succeeds
If this is indeed what's been happening, there should be traces of it in the logs. Check /var/log/messages
or whatever log file is appropriate for your distribution) for signs of read errors or ATA timeouts.
Also, smartctl -a /dev/sda | grep _Sector
will tell if you how many sectors have been reallocated, and if any are pending (assuming the drive in question is /dev/sda
, of course).