Why does `losetup` need to associate loop devices with block devices?
man losetup
says
losetup is used to associate loop devices with regular files or block devices, to detach loop
devices, and to query the status of a loop device.
https://en.wikipedia.org/wiki/Loop_device says
In Unix-like operating systems, a loop device, vnd (vnode disk), or lofi (loop file interface) is a pseudo-device that makes a file accessible as a block device.
Since a loop file makes a file accessible as a block device, why does losetup
need to associate loop devices with block devices? Isn't that unnecessary? Thanks.
loop-device losetup
add a comment |
man losetup
says
losetup is used to associate loop devices with regular files or block devices, to detach loop
devices, and to query the status of a loop device.
https://en.wikipedia.org/wiki/Loop_device says
In Unix-like operating systems, a loop device, vnd (vnode disk), or lofi (loop file interface) is a pseudo-device that makes a file accessible as a block device.
Since a loop file makes a file accessible as a block device, why does losetup
need to associate loop devices with block devices? Isn't that unnecessary? Thanks.
loop-device losetup
1
I actually thinked about that, I think it's just linux can implement this functionality easily, although it's unlikely to be used. After all, for linux, there's not much difference between block device and regular files…
– 炸鱼薯条德里克
3 hours ago
2
Possible duplicate of Why does one need a loop device at all?
– Stephen Harris
3 hours ago
add a comment |
man losetup
says
losetup is used to associate loop devices with regular files or block devices, to detach loop
devices, and to query the status of a loop device.
https://en.wikipedia.org/wiki/Loop_device says
In Unix-like operating systems, a loop device, vnd (vnode disk), or lofi (loop file interface) is a pseudo-device that makes a file accessible as a block device.
Since a loop file makes a file accessible as a block device, why does losetup
need to associate loop devices with block devices? Isn't that unnecessary? Thanks.
loop-device losetup
man losetup
says
losetup is used to associate loop devices with regular files or block devices, to detach loop
devices, and to query the status of a loop device.
https://en.wikipedia.org/wiki/Loop_device says
In Unix-like operating systems, a loop device, vnd (vnode disk), or lofi (loop file interface) is a pseudo-device that makes a file accessible as a block device.
Since a loop file makes a file accessible as a block device, why does losetup
need to associate loop devices with block devices? Isn't that unnecessary? Thanks.
loop-device losetup
loop-device losetup
asked 3 hours ago
TimTim
27.3k78264473
27.3k78264473
1
I actually thinked about that, I think it's just linux can implement this functionality easily, although it's unlikely to be used. After all, for linux, there's not much difference between block device and regular files…
– 炸鱼薯条德里克
3 hours ago
2
Possible duplicate of Why does one need a loop device at all?
– Stephen Harris
3 hours ago
add a comment |
1
I actually thinked about that, I think it's just linux can implement this functionality easily, although it's unlikely to be used. After all, for linux, there's not much difference between block device and regular files…
– 炸鱼薯条德里克
3 hours ago
2
Possible duplicate of Why does one need a loop device at all?
– Stephen Harris
3 hours ago
1
1
I actually thinked about that, I think it's just linux can implement this functionality easily, although it's unlikely to be used. After all, for linux, there's not much difference between block device and regular files…
– 炸鱼薯条德里克
3 hours ago
I actually thinked about that, I think it's just linux can implement this functionality easily, although it's unlikely to be used. After all, for linux, there's not much difference between block device and regular files…
– 炸鱼薯条德里克
3 hours ago
2
2
Possible duplicate of Why does one need a loop device at all?
– Stephen Harris
3 hours ago
Possible duplicate of Why does one need a loop device at all?
– Stephen Harris
3 hours ago
add a comment |
1 Answer
1
active
oldest
votes
The ability of configuring a loop device on top of another block device can be useful in cases where the loop device is being used to access only parts of the block device, to change its properties or to apply a transfer function on its contents.
For example, losetup
can take a --offset offset and a --sizelimit limit arguments, allowing it to only map part of the underlying block device. (Similar to how partitions work, but not necessarily where you have a partition table.)
It also can take a -r or --read-only option to make the loop device block writes, which can be useful to prevent unwanted writes from applications that take a block device and are not expected to write to them.
Finally, losetup
can take a -e, -E or --encryption encryption_type argument to use a transfer function that implements encryption on top of the underlying block device.
These three use cases are potentially useful on top of other block devices (as well as files), since their result is not just an identical translation of the underlying device.
Arguably, the devicemapper is a more modern API to accomplish this kind of transformations (and modern features for managing them, such as LVM and cryptsetup, are based on devicemapper.) The original losetup
features are still present though, since users may still depend on them.
See the man page of losetup(8) for more details on the options discussed above.
1
Yeah...more like an old simple device mapper functionality, but does device mapper support regular file as block device? It seems not, so for disk image, loop device may still be needed
– 炸鱼薯条德里克
2 hours ago
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f503028%2fwhy-does-losetup-need-to-associate-loop-devices-with-block-devices%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The ability of configuring a loop device on top of another block device can be useful in cases where the loop device is being used to access only parts of the block device, to change its properties or to apply a transfer function on its contents.
For example, losetup
can take a --offset offset and a --sizelimit limit arguments, allowing it to only map part of the underlying block device. (Similar to how partitions work, but not necessarily where you have a partition table.)
It also can take a -r or --read-only option to make the loop device block writes, which can be useful to prevent unwanted writes from applications that take a block device and are not expected to write to them.
Finally, losetup
can take a -e, -E or --encryption encryption_type argument to use a transfer function that implements encryption on top of the underlying block device.
These three use cases are potentially useful on top of other block devices (as well as files), since their result is not just an identical translation of the underlying device.
Arguably, the devicemapper is a more modern API to accomplish this kind of transformations (and modern features for managing them, such as LVM and cryptsetup, are based on devicemapper.) The original losetup
features are still present though, since users may still depend on them.
See the man page of losetup(8) for more details on the options discussed above.
1
Yeah...more like an old simple device mapper functionality, but does device mapper support regular file as block device? It seems not, so for disk image, loop device may still be needed
– 炸鱼薯条德里克
2 hours ago
add a comment |
The ability of configuring a loop device on top of another block device can be useful in cases where the loop device is being used to access only parts of the block device, to change its properties or to apply a transfer function on its contents.
For example, losetup
can take a --offset offset and a --sizelimit limit arguments, allowing it to only map part of the underlying block device. (Similar to how partitions work, but not necessarily where you have a partition table.)
It also can take a -r or --read-only option to make the loop device block writes, which can be useful to prevent unwanted writes from applications that take a block device and are not expected to write to them.
Finally, losetup
can take a -e, -E or --encryption encryption_type argument to use a transfer function that implements encryption on top of the underlying block device.
These three use cases are potentially useful on top of other block devices (as well as files), since their result is not just an identical translation of the underlying device.
Arguably, the devicemapper is a more modern API to accomplish this kind of transformations (and modern features for managing them, such as LVM and cryptsetup, are based on devicemapper.) The original losetup
features are still present though, since users may still depend on them.
See the man page of losetup(8) for more details on the options discussed above.
1
Yeah...more like an old simple device mapper functionality, but does device mapper support regular file as block device? It seems not, so for disk image, loop device may still be needed
– 炸鱼薯条德里克
2 hours ago
add a comment |
The ability of configuring a loop device on top of another block device can be useful in cases where the loop device is being used to access only parts of the block device, to change its properties or to apply a transfer function on its contents.
For example, losetup
can take a --offset offset and a --sizelimit limit arguments, allowing it to only map part of the underlying block device. (Similar to how partitions work, but not necessarily where you have a partition table.)
It also can take a -r or --read-only option to make the loop device block writes, which can be useful to prevent unwanted writes from applications that take a block device and are not expected to write to them.
Finally, losetup
can take a -e, -E or --encryption encryption_type argument to use a transfer function that implements encryption on top of the underlying block device.
These three use cases are potentially useful on top of other block devices (as well as files), since their result is not just an identical translation of the underlying device.
Arguably, the devicemapper is a more modern API to accomplish this kind of transformations (and modern features for managing them, such as LVM and cryptsetup, are based on devicemapper.) The original losetup
features are still present though, since users may still depend on them.
See the man page of losetup(8) for more details on the options discussed above.
The ability of configuring a loop device on top of another block device can be useful in cases where the loop device is being used to access only parts of the block device, to change its properties or to apply a transfer function on its contents.
For example, losetup
can take a --offset offset and a --sizelimit limit arguments, allowing it to only map part of the underlying block device. (Similar to how partitions work, but not necessarily where you have a partition table.)
It also can take a -r or --read-only option to make the loop device block writes, which can be useful to prevent unwanted writes from applications that take a block device and are not expected to write to them.
Finally, losetup
can take a -e, -E or --encryption encryption_type argument to use a transfer function that implements encryption on top of the underlying block device.
These three use cases are potentially useful on top of other block devices (as well as files), since their result is not just an identical translation of the underlying device.
Arguably, the devicemapper is a more modern API to accomplish this kind of transformations (and modern features for managing them, such as LVM and cryptsetup, are based on devicemapper.) The original losetup
features are still present though, since users may still depend on them.
See the man page of losetup(8) for more details on the options discussed above.
answered 2 hours ago
filbrandenfilbranden
9,30621342
9,30621342
1
Yeah...more like an old simple device mapper functionality, but does device mapper support regular file as block device? It seems not, so for disk image, loop device may still be needed
– 炸鱼薯条德里克
2 hours ago
add a comment |
1
Yeah...more like an old simple device mapper functionality, but does device mapper support regular file as block device? It seems not, so for disk image, loop device may still be needed
– 炸鱼薯条德里克
2 hours ago
1
1
Yeah...more like an old simple device mapper functionality, but does device mapper support regular file as block device? It seems not, so for disk image, loop device may still be needed
– 炸鱼薯条德里克
2 hours ago
Yeah...more like an old simple device mapper functionality, but does device mapper support regular file as block device? It seems not, so for disk image, loop device may still be needed
– 炸鱼薯条德里克
2 hours ago
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f503028%2fwhy-does-losetup-need-to-associate-loop-devices-with-block-devices%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
I actually thinked about that, I think it's just linux can implement this functionality easily, although it's unlikely to be used. After all, for linux, there's not much difference between block device and regular files…
– 炸鱼薯条德里克
3 hours ago
2
Possible duplicate of Why does one need a loop device at all?
– Stephen Harris
3 hours ago