I want to monitor a block storage device attached to a virtual linux server, and as a preliminary test, just to understand how this works, my idea is to Write an arbitrary amount of memory (on the order of KB) to the blockConfirm that the write succeeded (the block is accessible)Confirm that the amount of memory written was correct Delete the block of memoryConfirm that the amount deleted freed up the amount of space specifiedHow do I write specifically to the memory addresses in the block storage unit? I feel like I can do it with C or python. I can see the unit exists in /dev/vdc and /sys/block/vdc but I'm not sure how exactly to monitor it or whether my idea above is a good way. CentOS6/7
how can i write arbitrarily to a disk/block storage and check how the write went?
linux;block device
You can write and read blocks of memory with dd:dd if=/dev/zero of=/dev/vdc bs=512 count=2 seek=123writes 2 blocks of 512 bytes to blocks 123 and 124 on /dev/vdc using zeroes as input. You can use anything as input: /dev/urandom, some process that produces a bit pattern, ...You can read them back again with dd, and e.g. display them in hex:dd if=/dev/vdc bs=512 count=1 skip=123 | hexdump -CYou should see something like00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|*00000200because hexdump merges identical lines.More details with man dd.You may rethink your requirements to read and write blocks from memory, it's not that easy to reserve and access memory from the command line.If you want to do it in C or Python, please ask on stackoverflow, not here.