Partition damage by unplugging while reading

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
~
Member
Member
Posts: 1228
Joined: Tue Mar 06, 2007 11:17 am
Libera.chat IRC: ArcheFire

Partition damage by unplugging while reading

Post by ~ »

What can be the reasons for a partition to become damaged if an external disk is unplugged while simply reading data?

Could it be damage to the suddenly turned off media, or are there other things in the background that operating systems use to write anyway even if we are just reading data, not writing files?

What is the role of journaling in these cases? Are read operations logged by journaling or not normally?
LtG
Member
Member
Posts: 384
Joined: Thu Aug 13, 2015 4:57 pm

Re: Partition damage by unplugging while reading

Post by LtG »

Damaged in what way? What do you base your assertion that it's damaged on?

You said partition, you mean FS? If so, what FS?

I would expect reading to not create journaling, but how are you sure there was no other background write-op happening?
alexfru
Member
Member
Posts: 1112
Joined: Tue Mar 04, 2014 5:27 am

Re: Partition damage by unplugging while reading

Post by alexfru »

The OS may want to update access times.
simeonz
Member
Member
Posts: 360
Joined: Fri Aug 19, 2016 10:28 pm

Re: Partition damage by unplugging while reading

Post by simeonz »

With exception to files opened in unbuffered mode or requests followed by flush, writes are lazy. The contents are only marked dirty in the fs cache and repeated or incremental updates to the same block are combined there.

Reads for files opened in unbuffered mode flush and discard the corresponding cache pages and thus cause writes. Furthermore, writes can result from memory pressure, which can be the result of anything, including reads. For example, the cache pages for the read data can be acquired by evicting the contents of a dirty page, which causes a write.

The journal will guarantee consistent fs structure after a crash even if it is written out lazily, because its operation depends only on correct sequencing. However, the user data will be lost/corrupted unless the filesystem is explicitly configured to journal it as well.

The sysctl parameters vm.dirty_writeback_centisecs, vm.dirty_expire_centisecs can be used to control the flush frequency on Linux. Windows can disable the file cache on a per device basis and configure certain quotas, but lacks fine grained timing control.
User avatar
Geri
Member
Member
Posts: 442
Joined: Sun Jul 14, 2013 6:01 pm

Re: Partition damage by unplugging while reading

Post by Geri »

most operating systems are caching the disk writes.
also disk write occur if you read the files (to maintain access time for example).

thats why i decided my os not to do such things, so its safe to take out the disks whenever the user wants to.
Operating system for SUBLEQ cpu architecture:
http://users.atw.hu/gerigeri/DawnOS/download.html
Post Reply