Is a block_device mapping a physical disk or a partition of the disk? [closed]

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












1















In the ULK(Understanding Linux Kernel) book, the author says each block device has its own driver. The question is, does the block device here represent a physical disk or just a partition of the disk?



It's written in the book that struct block_device can be a partition or the disk(signified by "bd_contains" attribute). However, the struct gendisk can also represent a disk. I'm quite confused that is "the disk" these two structs refers to the same thing?










share|improve this question















closed as too broad by G-Man, RalfFriedl, LukeM, Archemar, msp9011 Jan 23 at 8:53


Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.













  • 1





    I am not familiar with the book, but a block device can represent an entire physical disk or a partition as well. If you go to /dev you will see that there is an entry for /dev/sdX which represents an entire physical disk as well as entries for /dev/sdXY which represent a partition of that disk

    – akabhirav
    Jan 22 at 5:51











  • It has a driver. Own makes it sound like they all have a different one, and this is not true. All sata devices will share a driver, and all partitions will share a driver.

    – ctrl-alt-delor
    Jan 22 at 9:05











  • Each disk has a block device, each partition has a block device, each LVM logical disk has a block device...

    – AlexP
    Jan 22 at 9:27











  • Do you mean Understanding the Linux Kernel?

    – Jeff Schaller
    Jan 22 at 12:11











  • Right @Schaller

    – asap diablo
    Jan 23 at 1:47















1















In the ULK(Understanding Linux Kernel) book, the author says each block device has its own driver. The question is, does the block device here represent a physical disk or just a partition of the disk?



It's written in the book that struct block_device can be a partition or the disk(signified by "bd_contains" attribute). However, the struct gendisk can also represent a disk. I'm quite confused that is "the disk" these two structs refers to the same thing?










share|improve this question















closed as too broad by G-Man, RalfFriedl, LukeM, Archemar, msp9011 Jan 23 at 8:53


Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.













  • 1





    I am not familiar with the book, but a block device can represent an entire physical disk or a partition as well. If you go to /dev you will see that there is an entry for /dev/sdX which represents an entire physical disk as well as entries for /dev/sdXY which represent a partition of that disk

    – akabhirav
    Jan 22 at 5:51











  • It has a driver. Own makes it sound like they all have a different one, and this is not true. All sata devices will share a driver, and all partitions will share a driver.

    – ctrl-alt-delor
    Jan 22 at 9:05











  • Each disk has a block device, each partition has a block device, each LVM logical disk has a block device...

    – AlexP
    Jan 22 at 9:27











  • Do you mean Understanding the Linux Kernel?

    – Jeff Schaller
    Jan 22 at 12:11











  • Right @Schaller

    – asap diablo
    Jan 23 at 1:47













1












1








1








In the ULK(Understanding Linux Kernel) book, the author says each block device has its own driver. The question is, does the block device here represent a physical disk or just a partition of the disk?



It's written in the book that struct block_device can be a partition or the disk(signified by "bd_contains" attribute). However, the struct gendisk can also represent a disk. I'm quite confused that is "the disk" these two structs refers to the same thing?










share|improve this question
















In the ULK(Understanding Linux Kernel) book, the author says each block device has its own driver. The question is, does the block device here represent a physical disk or just a partition of the disk?



It's written in the book that struct block_device can be a partition or the disk(signified by "bd_contains" attribute). However, the struct gendisk can also represent a disk. I'm quite confused that is "the disk" these two structs refers to the same thing?







linux-kernel hard-disk block-device






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 23 at 1:59







asap diablo

















asked Jan 22 at 3:48









asap diabloasap diablo

63




63




closed as too broad by G-Man, RalfFriedl, LukeM, Archemar, msp9011 Jan 23 at 8:53


Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.









closed as too broad by G-Man, RalfFriedl, LukeM, Archemar, msp9011 Jan 23 at 8:53


Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.









  • 1





    I am not familiar with the book, but a block device can represent an entire physical disk or a partition as well. If you go to /dev you will see that there is an entry for /dev/sdX which represents an entire physical disk as well as entries for /dev/sdXY which represent a partition of that disk

    – akabhirav
    Jan 22 at 5:51











  • It has a driver. Own makes it sound like they all have a different one, and this is not true. All sata devices will share a driver, and all partitions will share a driver.

    – ctrl-alt-delor
    Jan 22 at 9:05











  • Each disk has a block device, each partition has a block device, each LVM logical disk has a block device...

    – AlexP
    Jan 22 at 9:27











  • Do you mean Understanding the Linux Kernel?

    – Jeff Schaller
    Jan 22 at 12:11











  • Right @Schaller

    – asap diablo
    Jan 23 at 1:47












  • 1





    I am not familiar with the book, but a block device can represent an entire physical disk or a partition as well. If you go to /dev you will see that there is an entry for /dev/sdX which represents an entire physical disk as well as entries for /dev/sdXY which represent a partition of that disk

    – akabhirav
    Jan 22 at 5:51











  • It has a driver. Own makes it sound like they all have a different one, and this is not true. All sata devices will share a driver, and all partitions will share a driver.

    – ctrl-alt-delor
    Jan 22 at 9:05











  • Each disk has a block device, each partition has a block device, each LVM logical disk has a block device...

    – AlexP
    Jan 22 at 9:27











  • Do you mean Understanding the Linux Kernel?

    – Jeff Schaller
    Jan 22 at 12:11











  • Right @Schaller

    – asap diablo
    Jan 23 at 1:47







1




1





I am not familiar with the book, but a block device can represent an entire physical disk or a partition as well. If you go to /dev you will see that there is an entry for /dev/sdX which represents an entire physical disk as well as entries for /dev/sdXY which represent a partition of that disk

– akabhirav
Jan 22 at 5:51





I am not familiar with the book, but a block device can represent an entire physical disk or a partition as well. If you go to /dev you will see that there is an entry for /dev/sdX which represents an entire physical disk as well as entries for /dev/sdXY which represent a partition of that disk

– akabhirav
Jan 22 at 5:51













It has a driver. Own makes it sound like they all have a different one, and this is not true. All sata devices will share a driver, and all partitions will share a driver.

– ctrl-alt-delor
Jan 22 at 9:05





It has a driver. Own makes it sound like they all have a different one, and this is not true. All sata devices will share a driver, and all partitions will share a driver.

– ctrl-alt-delor
Jan 22 at 9:05













Each disk has a block device, each partition has a block device, each LVM logical disk has a block device...

– AlexP
Jan 22 at 9:27





Each disk has a block device, each partition has a block device, each LVM logical disk has a block device...

– AlexP
Jan 22 at 9:27













Do you mean Understanding the Linux Kernel?

– Jeff Schaller
Jan 22 at 12:11





Do you mean Understanding the Linux Kernel?

– Jeff Schaller
Jan 22 at 12:11













Right @Schaller

– asap diablo
Jan 23 at 1:47





Right @Schaller

– asap diablo
Jan 23 at 1:47










1 Answer
1






active

oldest

votes


















2














At the fundamental level, a block device represents a set of N blocks of data, with some fixed block size. The blocks are numbered consecutively 0 .. (N-1).



This could be a physical disk, a partition, a RAID array consisting of multiple physical disks, a LVM logical volume consisting of parts of one or more disks, or a virtual view of any of the above through an encryption layer.



A filesystem driver does not generally care about the physical details: it only deals with representing that range of blocks as a functional filesystem. The underlying driver(s) may translate the block numbers any way they deem necessary, as long as each block is uniquely addressable by its number.



  • A partition driver just applies an offset to the block number and refers to the underlying whole-disk device.

  • A LVM logical volume driver has a table of ranges of logical block numbers and corresponding (underlying device + offset) pairs.

  • A RAID driver can have many underlying devices, and a request for a single block can map to several underlying blocks on different devices, for redundancy. A single read request can be split between multiple underlying devices that have identical content for performance, or recovered from other underlying devices if one of them has failed; a write request may need to be repeated on each underlying device (for RAID1) and/or have checksums calculated for it (for RAID5/6).

  • A multipath driver has several underlying (path) devices all connecting to the same storage device at the far end of the paths. It does not change the block number, but may retry the same operation on multiple paths if necessary.

  • A disk encryption driver may or may not map the block numbers (to obfuscate the real disk access patterns), but it will certainly modify the data passing through it: any blocks to be written are encrypted before passing the request on to the underlying device, and any data read from the underlying device is decrypted.

Since a block device has basically the same interface whether it's a physical disk, a partition, a LVM LV, a RAID device, or something else, all these mapping drivers are stackable: you can freely place these mapping layers on top of each other. Of course, not all combinations are guaranteed to be sensible, or even useful.






share|improve this answer























  • What you mentioned is quite right in the physical disk management.

    – asap diablo
    Jan 23 at 2:09


















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














At the fundamental level, a block device represents a set of N blocks of data, with some fixed block size. The blocks are numbered consecutively 0 .. (N-1).



This could be a physical disk, a partition, a RAID array consisting of multiple physical disks, a LVM logical volume consisting of parts of one or more disks, or a virtual view of any of the above through an encryption layer.



A filesystem driver does not generally care about the physical details: it only deals with representing that range of blocks as a functional filesystem. The underlying driver(s) may translate the block numbers any way they deem necessary, as long as each block is uniquely addressable by its number.



  • A partition driver just applies an offset to the block number and refers to the underlying whole-disk device.

  • A LVM logical volume driver has a table of ranges of logical block numbers and corresponding (underlying device + offset) pairs.

  • A RAID driver can have many underlying devices, and a request for a single block can map to several underlying blocks on different devices, for redundancy. A single read request can be split between multiple underlying devices that have identical content for performance, or recovered from other underlying devices if one of them has failed; a write request may need to be repeated on each underlying device (for RAID1) and/or have checksums calculated for it (for RAID5/6).

  • A multipath driver has several underlying (path) devices all connecting to the same storage device at the far end of the paths. It does not change the block number, but may retry the same operation on multiple paths if necessary.

  • A disk encryption driver may or may not map the block numbers (to obfuscate the real disk access patterns), but it will certainly modify the data passing through it: any blocks to be written are encrypted before passing the request on to the underlying device, and any data read from the underlying device is decrypted.

Since a block device has basically the same interface whether it's a physical disk, a partition, a LVM LV, a RAID device, or something else, all these mapping drivers are stackable: you can freely place these mapping layers on top of each other. Of course, not all combinations are guaranteed to be sensible, or even useful.






share|improve this answer























  • What you mentioned is quite right in the physical disk management.

    – asap diablo
    Jan 23 at 2:09
















2














At the fundamental level, a block device represents a set of N blocks of data, with some fixed block size. The blocks are numbered consecutively 0 .. (N-1).



This could be a physical disk, a partition, a RAID array consisting of multiple physical disks, a LVM logical volume consisting of parts of one or more disks, or a virtual view of any of the above through an encryption layer.



A filesystem driver does not generally care about the physical details: it only deals with representing that range of blocks as a functional filesystem. The underlying driver(s) may translate the block numbers any way they deem necessary, as long as each block is uniquely addressable by its number.



  • A partition driver just applies an offset to the block number and refers to the underlying whole-disk device.

  • A LVM logical volume driver has a table of ranges of logical block numbers and corresponding (underlying device + offset) pairs.

  • A RAID driver can have many underlying devices, and a request for a single block can map to several underlying blocks on different devices, for redundancy. A single read request can be split between multiple underlying devices that have identical content for performance, or recovered from other underlying devices if one of them has failed; a write request may need to be repeated on each underlying device (for RAID1) and/or have checksums calculated for it (for RAID5/6).

  • A multipath driver has several underlying (path) devices all connecting to the same storage device at the far end of the paths. It does not change the block number, but may retry the same operation on multiple paths if necessary.

  • A disk encryption driver may or may not map the block numbers (to obfuscate the real disk access patterns), but it will certainly modify the data passing through it: any blocks to be written are encrypted before passing the request on to the underlying device, and any data read from the underlying device is decrypted.

Since a block device has basically the same interface whether it's a physical disk, a partition, a LVM LV, a RAID device, or something else, all these mapping drivers are stackable: you can freely place these mapping layers on top of each other. Of course, not all combinations are guaranteed to be sensible, or even useful.






share|improve this answer























  • What you mentioned is quite right in the physical disk management.

    – asap diablo
    Jan 23 at 2:09














2












2








2







At the fundamental level, a block device represents a set of N blocks of data, with some fixed block size. The blocks are numbered consecutively 0 .. (N-1).



This could be a physical disk, a partition, a RAID array consisting of multiple physical disks, a LVM logical volume consisting of parts of one or more disks, or a virtual view of any of the above through an encryption layer.



A filesystem driver does not generally care about the physical details: it only deals with representing that range of blocks as a functional filesystem. The underlying driver(s) may translate the block numbers any way they deem necessary, as long as each block is uniquely addressable by its number.



  • A partition driver just applies an offset to the block number and refers to the underlying whole-disk device.

  • A LVM logical volume driver has a table of ranges of logical block numbers and corresponding (underlying device + offset) pairs.

  • A RAID driver can have many underlying devices, and a request for a single block can map to several underlying blocks on different devices, for redundancy. A single read request can be split between multiple underlying devices that have identical content for performance, or recovered from other underlying devices if one of them has failed; a write request may need to be repeated on each underlying device (for RAID1) and/or have checksums calculated for it (for RAID5/6).

  • A multipath driver has several underlying (path) devices all connecting to the same storage device at the far end of the paths. It does not change the block number, but may retry the same operation on multiple paths if necessary.

  • A disk encryption driver may or may not map the block numbers (to obfuscate the real disk access patterns), but it will certainly modify the data passing through it: any blocks to be written are encrypted before passing the request on to the underlying device, and any data read from the underlying device is decrypted.

Since a block device has basically the same interface whether it's a physical disk, a partition, a LVM LV, a RAID device, or something else, all these mapping drivers are stackable: you can freely place these mapping layers on top of each other. Of course, not all combinations are guaranteed to be sensible, or even useful.






share|improve this answer













At the fundamental level, a block device represents a set of N blocks of data, with some fixed block size. The blocks are numbered consecutively 0 .. (N-1).



This could be a physical disk, a partition, a RAID array consisting of multiple physical disks, a LVM logical volume consisting of parts of one or more disks, or a virtual view of any of the above through an encryption layer.



A filesystem driver does not generally care about the physical details: it only deals with representing that range of blocks as a functional filesystem. The underlying driver(s) may translate the block numbers any way they deem necessary, as long as each block is uniquely addressable by its number.



  • A partition driver just applies an offset to the block number and refers to the underlying whole-disk device.

  • A LVM logical volume driver has a table of ranges of logical block numbers and corresponding (underlying device + offset) pairs.

  • A RAID driver can have many underlying devices, and a request for a single block can map to several underlying blocks on different devices, for redundancy. A single read request can be split between multiple underlying devices that have identical content for performance, or recovered from other underlying devices if one of them has failed; a write request may need to be repeated on each underlying device (for RAID1) and/or have checksums calculated for it (for RAID5/6).

  • A multipath driver has several underlying (path) devices all connecting to the same storage device at the far end of the paths. It does not change the block number, but may retry the same operation on multiple paths if necessary.

  • A disk encryption driver may or may not map the block numbers (to obfuscate the real disk access patterns), but it will certainly modify the data passing through it: any blocks to be written are encrypted before passing the request on to the underlying device, and any data read from the underlying device is decrypted.

Since a block device has basically the same interface whether it's a physical disk, a partition, a LVM LV, a RAID device, or something else, all these mapping drivers are stackable: you can freely place these mapping layers on top of each other. Of course, not all combinations are guaranteed to be sensible, or even useful.







share|improve this answer












share|improve this answer



share|improve this answer










answered Jan 22 at 10:10









telcoMtelcoM

17.2k12347




17.2k12347












  • What you mentioned is quite right in the physical disk management.

    – asap diablo
    Jan 23 at 2:09


















  • What you mentioned is quite right in the physical disk management.

    – asap diablo
    Jan 23 at 2:09

















What you mentioned is quite right in the physical disk management.

– asap diablo
Jan 23 at 2:09






What you mentioned is quite right in the physical disk management.

– asap diablo
Jan 23 at 2:09



Popular posts from this blog

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay