disk

How can I simulate a failed disk during testing?

雨燕双飞 提交于 2019-11-28 04:42:42
In a Linux VM (Vmware workstation or similar), how can I simulate a failure on a previously working disc? I have a situation happening in production where a disc fails (probably a controller, cable or firmware problem). Obviously this is not predictable or reproducible, I want to test my monitoring to ensure that it alerts correctly. I'd ideally like to be able to simulate a situation where it fails writes but succeeds reads, as well as a complete failure, i.e. the scsi interface reports errors back to the kernel. mark4o There are several layers at which a disk error can be simulated. If you

Force write of a file to disk

社会主义新天地 提交于 2019-11-28 04:31:00
问题 I'm currently implementing a ping/pong buffering scheme to safely write a file to disk. I'm using C++/Boost on a Linux/CentOS machine. Now I'm facing the problem to force the actual write of the file to disk. Is it possible to do so irrespective of all the caching policies of the filesystem (ext3/ext4) / SO custom rules / RAID controller / harddisk controller ? Is it best to use plain fread()/fwrite(), c++ ostream or boost filesystem? I've heard that simply flushing out the file (fflush())

How do we access MFT through C#

大兔子大兔子 提交于 2019-11-28 04:01:30
I need to access Windows MFT(Master File Table) using C# in my .net application. I have googled about this and couldn't find any good results. I have been searching for the information from the past 2 days but have been unable to find any information on the same. I am not looking for exact code to do the same, I am just looking for some information which can get me started. The only thing I have been able to figure out is that I have to use P/Invoke. I want to know the functions I would be using to have access to MFT. If you are able to provide some code sample then that would be great. First,

File.WriteAllText not flushing data to disk

一个人想着一个人 提交于 2019-11-28 03:05:31
问题 I've had 3 reports now of user's machines crashing while using my software.. the crashes are not related to my program but when they restart the config files my program writes are all corrupt. There is nothing special to how the files are being written, simply creating a Json representation and dumping it to disk using File.WriteAllText() // save our contents to the disk string json = JsonConvert.SerializeObject(objectInfo, Formatting.Indented); // write the contents File.WriteAllText(path,

Flush disk write cache

大城市里の小女人 提交于 2019-11-27 18:42:27
问题 When the policy for a disk in Windows XP and Vista is set to enable write caching on the hard disk, is there a way to flush a file that has just been written, and ensure that it has been committed to disk? I want to do this programmatically in C++. Closing the file does perform a flush at the application level, but not at the operating system level. If the power is removed from the PC after closing the file, but before the operating system has flushed the disk write cache, the file is lost,

How to correctly convert filesize in bytes into mega or gigabytes?

末鹿安然 提交于 2019-11-27 17:20:02
问题 I'm using the DriveInfo class in my C# project to retrieve the available bytes on given drives. How to I correctly convert this number into Mega- or Gigabytes? Dividing by 1024 will not do the job I guess. The results always differ from those shown in the Windows-Explorer. 回答1: 1024 is correct for usage in programs. The reason you may be having differences is likely due to differences in what driveinfo reports as "available space" and what windows considers available space. Note that only

Disable or flush page cache on Windows

安稳与你 提交于 2019-11-27 16:23:45
问题 I assume Windows has a similar concept to Linux's page cache for storing in memory data from disks, like files, executables and dynamic libraries. I wonder if it is possible at all to disable such cache or to the very least to clear/flush it. 回答1: This is called Standby List under windows. You can purge it globally, or for one volume, or for one file handle. Globally You can do it using a readily available program from Microsoft Technet, by selecting Empty → Empty Standby List

安装ubuntu/win7后选择win7出现 a read disk error occurred

房东的猫 提交于 2019-11-27 14:30:25
(本人百度ID:_铭_轩_)安装ubuntu/win7双系统后重启电脑ubuntu正常进入但选择win7 loader会提示:a read disk error的错误信息,无法进入win7系统,之前自己折腾双系统时也遇到过这情况,记得使用ultraiso做的U盘启动安装的ubuntu,网上也没有太多这问题的解决方法,最后偶然在ubuntu社区看到个方法,感觉应该适用于这个问题,试了一下~Ok了~这里贴出来分享给大家(在百度知道上我也贴了的说,当时自己解决没多久就发现也有人遇到这问题了),let's do it~ 开机进你的ubuntu win+alt+T进入shell终端 在shell下: sudo add-apt-repository ppa:yannubuntu/boot-repair && sudo apt-get update 完成后: sudo apt-get install -y boot-repair && boot-repair 软件会自动运行的。 这是一款linux下的boot修复软件,Boot-Repair,执行上面的2行代码后软件运行,选择recommended repair(推荐修复),默认下一步下一步就可以了,完成后reboot依然进入grub,但你现在再选择win7 loader时你会发现平稳进入win了^_^。双系统引导就修复好了。

How to empty/flush Windows READ disk cache in C#?

被刻印的时光 ゝ 提交于 2019-11-27 13:47:29
If I am trying to determine the read speed of a drive, I can code a routine to write files to a filesystem and then read those files back. Unfortunately, this doesn't give an accurate read speed because Windows does disk read caching. Is there a way to flush the disk read cache of a drive in C# / .Net (or perhaps with Win32 API calls) so that I can read the files directly from the drive without them being cached? Why DIY? If you only need to determine drive speed and not really interested in learning how to flush I/O buffers from .NET, you may just use DiskSpd utility from http://research

How to find the amount of free storage (disk space) left on Android?

ぃ、小莉子 提交于 2019-11-27 12:04:33
I am trying to figure out the available disk space on the Android phone running my application. Is there a way to do this programmatically? Thanks, Try StatFs.getAvailableBlocks . You'll need to convert the block count to KB with getBlockSize. Example: Getting human readable size like 1 Gb String memory = bytesToHuman(totalMemory()) /************************************************************************************************* Returns size in bytes. If you need calculate external memory, change this: StatFs statFs = new StatFs(Environment.getRootDirectory().getAbsolutePath()); to this: