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
5
votes
2 answers

Block device information without mounting in Linux

I am trying to get some information (specifically block size) of block device in linux, in C++. Is it possible to get block size of a device without mounting it and possibly without looking into dynamic files (like the ones in /sys), but with a…
j_kubik
  • 6,062
  • 1
  • 23
  • 42
5
votes
2 answers

How to combine multiple struct BIOs into a single struct request?

I'm working on Linux kernel version 2.6.39.1, and am developing a block device driver. In this regard, I want to combine multiple struct bios into a single struct request, which is then added to the request_queue for processing by the device driver,…
5
votes
0 answers

Linux Block Device - Looking for a Simple Example

I was trying for a linux virtual block device, My requirement is while running cat /dev/mydevice must return some string which I created in the kernel program, (I dont have to write any data to drive, Basically create a Block device which helps to…
5
votes
0 answers

NodeJS: Unable to write to Windows 8 block device

I'm looking forward to write directly to a raw windows block device. I can successfully do so with dd for windows: > dd.exe if=myData.dat of=\\.\PhysicalDrive1 However I'm unable to do so using NodeJS. I'm using node-blockdevice in the following…
jviotti
  • 17,881
  • 26
  • 89
  • 148
5
votes
1 answer

wait_for_completion for submit_bio in make_request not returning

I am writing a custom block driver in the Linux kernel and in my make_request routine, on writes I need to read the data of the bio's specified sector (from the physical drive) prior to writing the new data. My excerpt below showcases most of what I…
4
votes
1 answer

Concurrent writes to a file using multiple threads

I have a userlevel program which opens a file using the flags O_WRONLY|O_SYNC. The program creates 256 threads which attempt to write 256 or more bytes of data each to the file. I want to have a total of 1280000 requests, making it a total of about…
user745878
  • 213
  • 3
  • 12
4
votes
0 answers

When two processes read the same file simultaneously, will Linux kernel save one device I/O?

I have a generic question about Linux kernel's handling of file I/O. So far my understanding is that, in an ideal case, after process A reads a file, data is loaded into page cache, and if process B reads the same page before it is reclaimed, it…
QnA
  • 1,035
  • 10
  • 25
4
votes
1 answer

Possible sources for CHS disk geometry

I am trying to determine the "correct" CHS from a block device: #include #include #include #include #include #include int main(int argv, char **argv) { int r; int f; …
lash
  • 746
  • 1
  • 7
  • 23
4
votes
1 answer

Kernel block device - Falling in deadlock using spinlock

I just implemented a virtual block device and I would like to play with it in order to explore how linux kernel handles block devices. My device is just a memory zone divided in two 512 bytes sectors. I'm using a global structure to store device…
Arkaik
  • 852
  • 2
  • 19
  • 39
4
votes
1 answer

How to attach a block device to qemu VM through qemu command line?

I want to configure the qemu to attach a specific block device to the VM? Following is the command I am using now: qemu-system-x86_64 -enable-kvm -machine type=pc,accel=kvm -cpu host -nographic -k de -usb -m 2048 …
aMa
  • 629
  • 3
  • 10
  • 19
4
votes
2 answers

Working with block special files/devices to implement a filesystem

I've implemented a basic filesystem using FUSE, with all foreseeable POSIX functionality implemented [naturally I haven't even profiled yet ;)]. Currently I'm able to run the filesystem on a regular file (st_mode & S_IFREG), but the next step in…
Matt Joiner
  • 112,946
  • 110
  • 377
  • 526
4
votes
3 answers

How to get disk name programmatically in Linux(Like "/dev/sda" or "/dev/sdb")?

I am trying out to find information related to Disk and partitions. Following are my code. But problem is that, I am passing disk name through command line by querying disk name from "/proc/partitions". Is there any api which can give me disk name…
Ravi Bhushan
  • 253
  • 3
  • 17
4
votes
2 answers

Linux Kernel: Get real path behind a symlink

I'm working on some linux kernel stuff and I have a fake path called /dev/blah/whatever that points to /dev/block/real_device The issue is that lookup_bdev will fail to follow the symlink so I'd like to massage the path upfront by getting the real…
David
  • 3,324
  • 2
  • 27
  • 31
4
votes
3 answers

How to use dd to fill a disk with a specific char?

I know i can fill an entire disk with 0x0 like this: dd if=/dev/zero of=/dev/sda bs=4k conv=notrunc Is there a way to fill the entire disk with a char of my choice?
yonigo
  • 987
  • 1
  • 15
  • 30
4
votes
2 answers

How to get raw disk or block device size in Windows with Python

How do I get the size from a block device or raw disk in Windows if I only know the device name is "\.\PhysicalDrive0" with no file system on it or volume label? I tried the following: fd = os.open(r"\.\PhysicalDrive0", os.O_RDONLY) os.lseek(fd,…
kli
  • 283
  • 1
  • 5
  • 16
1
2
3
9 10