Questions tagged [block-device]

A block device is a computer data storage device. It organizes data into fixed sized blocks that are typically 512 or 4096 bytes long. Data is indexed by a logical block address. Block storage devices are widely available, including spinning hard drives or solid-state devices. They may be used directly by applications or may have a filesystem or other data structure layered on top of them.

139 questions
2
votes
1 answer

How to programmatically find mount/eject usb device on macOS?

I am trying to unmount/eject usb device programmatically on macOS. Using IOkit I tried to register to IOServiceMatching(kIOUSBInterfaceClassName) and iterate over all devices and for each device i tried getting the BSD name and go from…
puris
  • 29
  • 1
2
votes
1 answer

When should I use REQ_OP_FLUSH in a kernel blockdev driver? (Do REQ_OP_FLUSH bio's flush dirty RAID controller caches?)

When should I use REQ_OP_FLUSH in my kernel blockdev driver, and what is the expected behavior of the hardware that receives the REQ_OP_FLUSH (or equivalent SCSI cmd)? In the Linux kernel, when a struct bio is flagged as REQ_OP_FLUSH is passed to a…
KJ7LNW
  • 1,437
  • 5
  • 11
2
votes
1 answer

Find device file from the st_dev field in a file contained in the device

I want to access a device (opening it) with the only information about the device being an st_dev field in a file stat struct. int fd; char *path; struct stat buf; stat("/path/to/my/file", &buf); // do some things with buf.st_dev // then either path…
Blumer
  • 75
  • 7
2
votes
1 answer

What is the purpose of the function "blk_rq_map_user" in the NVME disk driver?

I am trying to understand the nvme linux drivers. I am now tackling the function nvme_user_submit_cmd, which I report partially here: static int nvme_submit_user_cmd(struct request_queue *q, struct nvme_command *cmd, void __user *ubuffer, …
Fra93
  • 1,992
  • 1
  • 9
  • 18
2
votes
1 answer

Bash: Find the disk a certain partition is on and put result into a variable

What are some (reliable) tests to find the disk a certain partition is on and put that result into a variable? For example, output of lsblk: ... sda 8:0 0 9.1T 0 disk └─sda1 8:1 0 9.1T 0 part /foopath ... mmcblk0 …
nooblag
  • 678
  • 3
  • 23
2
votes
1 answer

Virtual block device backed by multiple files

On Linux (say, Ubuntu/Debian) I would like to create a virtual block device (let's say /dev/mapper/myvbd ) that is backed by a bunch of files on the user's home (say /home/myuser/myvbdfiles/file[1...100] ). If it were a single file I could do it…
zambowalla
  • 21
  • 4
2
votes
1 answer

What is USEC_INITIALIZED property?

I am getting the following output for udevadm info -q property -n /dev/sda DEVLINKS=/dev/disk/by-path/pci-0000:00:1f.2-ata-1 /dev/disk/by-id/wwn-0x5000c500a90b2880…
Akhil Mohan
  • 105
  • 2
  • 11
2
votes
1 answer

Block device driver - Understanding received ioctl

I just implemented a virtual block device and as I was playing with it I seen and strange behaviour related to ioctls. My device is just a memory zone divided in two 512 bytes sectors. I can currently read/write from/to it at a specific offset using…
Arkaik
  • 852
  • 2
  • 19
  • 39
2
votes
2 answers

Does blockdev --flushbufs reliably sync to disk?

I am using blockdev --flushbufs /dev/mmcblk0p1 in one of our shell scripts. I have assumed that it has same effect as sync for raw block device access. I wonder whether it's safe to assume at the end of blockdev --flushbufs all delayed writes are…
ART
  • 1,509
  • 3
  • 29
  • 47
2
votes
1 answer

Treat Windows CDROM Drive as Block File?

I'm attempting to use a Python module (python-dvdvideo to be exact) to clone an ISO image. The provided class works fine if I pass it a filepath to an ISO file that is already on my computer, but it throws an exception if I attempt to pass it the…
Christopher Sheaf
  • 185
  • 1
  • 3
  • 13
2
votes
1 answer

Understanding zram concepts in embedded system

I'm new to zram concept. Basically I'm understanding memory allocation for zram devices and usage in Embedded system. I Googled to find maximum size that can be assigned to disksize /sys/block/zram/disksize but its in vain. I have few basic doubts .…
vinay hunachyal
  • 3,781
  • 2
  • 20
  • 31
2
votes
0 answers

File System Block Size while creating the File System using mkfs

I am trying to use BUSE (with NBD) to create a block device in user space. I am not clearly understanding the block access patterns when creating a file system. As shown in the example when I mount the nbd device and create a ext4 file system with a…
2
votes
1 answer

Linux Block Device Driver: how to handle REQ_DISCARD

I have a block device driver which is working in a commercial product for more than a year. Recently I tried to add support for thin-provisioning by enabling discards and handling requests with the REQ_DISCARD flag. Whenever I call any variation of…
2
votes
3 answers

How to create a "Block device" in Windows

For those familiar with Linux, it is possible to create a module and register it as a block device. This allows the user to mount it as a regular disk (while all the block I/O is handled by the module, e.g. USB mass storage). Is there a way to do…
Boris
  • 3,163
  • 5
  • 37
  • 46
2
votes
1 answer

Get filesystem hex ID of a block device as shown by e.g. "fdisk"

Is there an easy way to determine the hexadecimal ID of the filesystem for a given partition? Say, I have a /dev/sda1 partition which is of "Linux" type having the filesystem ID of 83 (as shown by fdisk for example). I need to get this number from a…
azerIO
  • 519
  • 1
  • 9
  • 19