$ echo hugo >/dev/loop0 $ dd if=/dev/loop0 bs=1 count=4 hugo Our most basic access test will be to write bytes, and then read them back. The mapping can be torn down later with losetup -d /dev/loop0. Loop0 can now be used as a normal block device. $ dd if=/dev/zero of=myfile bs=1M count=32 $ losetup -show -f myfile /dev/loop0 $ ls -al /dev/loop0 brw-rw. We will use dd to create a 32MB file with zeros and map it to block device /dev/loop0. Probably the most simple way to play with block devices is to create a normal file, and have it then mapped to a block device. Let’s assume we want to practice how to replace failed discs in a mdadm raid setup - for such a setup we need a few fast and disposable block devices. This flexibility is one of Linux’s strengths! Spawning block devices for testing Other layers like LVM can be used on top. Many of the software pieces mentioned here take existing block devices, and make a new device available, for example providing transparent compression between both devices. A user on the Linux system can then open the device, seek to the place which should be accessed, and read or write data. For example, hard disk or NVMe drivers can present the disk contents for read/write access via device node /dev/sda, and we can imagine the block device as representing the disk as a long lineup of bytes. For block devices, communication is in entire blocks. In this article, I try to point at some recent developments and give ideas for debugging and available tools.Įver wondered how to do checksumming on a block device? How to have a device appear bigger than the underlying disk? How to compress your disk? This article has something new for everybody.įor character devices, the driver sends/receives single bytes. Like CPUs and memory, block devices have been with us in the Linux and UNIX world for a long time, and are going to stay.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |