0

Question is about block devices like HDD/SDD etc, not talking about filesystems here.

I wonder is it possible to write a SINGLE BIT or exact amount of data (eg. 7 bits) to block device like HDD? I read somewhere (can't tell where) that I could not and whatever I will do the whole block will be written.

Can someone explain it to me?

KaP
  • 387
  • 1
  • 2
  • 12
  • 2
    If you open the HDD/SDD for write as a block device then you always have to write in blocks. This means you will need to read the block where you want to write the 7 bits, replace 7 bits in the buffer with your 7 bits, writeback the modified block, then flush. If you need to write in character mode, you have to open the block device as a character device. Most bock devices have a corresponding character device. You have to treat the device like you would a tape device. – alvits Aug 25 '15 at 00:23
  • In linux you can define a set of hard disks as raw devices. This will allow opening them as character devices, usually named `/dev/raw*`. – alvits Aug 25 '15 at 00:30
  • Thanks for answer @alvits. Nonetheless character device still wouldn't allow me to save 1 bit. Am I right? I will be able to save 1 or more bytes depending on "character" size. Right? – KaP Aug 25 '15 at 00:34
  • By wikipedia (https://en.wikipedia.org/wiki/Device_file#Character_devices) from Character device: The character device for a hard disk, for example, will normally require that all reads and writes are aligned to block boundaries and most certainly will not let you read a single byte. – KaP Aug 25 '15 at 00:36

0 Answers0