Skip to contentSkip to conversation

losetup: support for physical devices

BUG Lucio Crusca 4 participants 5 messages Jan 14, 2015 – Jan 26, 2015 Util-Linux package

lore
Share & tools
lore
#0 lore raw

During a disaster recovery I found that losetup either

1. does not support creating loop devices that target physical devices. In this case I think there exists a compelling reason to support them
(http://serverfault.com/questions/659484) and this bug report is a wishlist bug

or

2. it does support physical devices, but it is an undocumented feature (at least in the manpage) and the warning it issues is misleading beacuse it makes you think it doesn't support them ("losetup: /dev/sdc2: warning: file smaller than 512 bytes, the loop device maybe be useless or invisible for system tools"). In this case this could be a documentation bug.

I haven't tested which of the two possibilities is the real situation, but I'm pretty sure you already know.

Thanks for your attention,
Lucio.

maintainer
#1 lore raw
Quoted 7 lines · Lucio Crusca

During a disaster recovery I found that losetup either

1. does not support creating loop devices that target physical devices. In this case I think there exists a compelling reason to support them
(http://serverfault.com/questions/659484) and this bug report is a wishlist bug

Quoted 7 lines

or

2. it does support physical devices, but it is an undocumented feature (at least in the manpage) and the warning it issues is misleading beacuse it makes you think it doesn't support them ("losetup: /dev/sdc2: warning: file smaller than 512 bytes, the loop device maybe be useless or invisible for system tools"). In this case this could be a documentation bug.

commit b048b8af3a5568c90f6e0c2d56f6cb399dedb0d1

Author: Karel Zak <[email protected]>
Date:   Mon May 13 11:00:47 2013 +0200

losetup: use warn_size() for regular files only

Karel

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com
#3 lore raw
In reply to Lucio Crusca
Quoted 9 lines · Lucio Crusca

During a disaster recovery I found that losetup either

1. does not support creating loop devices that target physical devices. In this case I think there exists a compelling reason to support them
(http://serverfault.com/questions/659484) and this bug report is a wishlist bug

or

Quoted 8 lines

2. it does support physical devices, but it is an undocumented feature (at least in the manpage) and the warning it issues is misleading beacuse it makes you think it doesn't support them ("losetup: /dev/sdc2: warning: file smaller than 512 bytes, the loop device maybe be useless or invisible for system tools"). In this case this could be a documentation bug.

I haven't tested which of the two possibilities is the real situation, but I'm pretty sure you already know.

I don't recall what I've done that convinced me, but I'm *sure* that you can do

    losetup -o [offset] {-f[--show]|loopdev} /dev/sdXXX

This is implicit throughout Linux, because any block device is also a "file", and can be read/written as such. (You just can't change its size.)

What command are you executing? What error are you seeing?

Dale

#4 lore raw
Quoted 16 lines · Dale R. Worley
Quoted 15 lines · Lucio Crusca

During a disaster recovery I found that losetup either

1. does not support creating loop devices that target physical devices. In this case I think there exists a compelling reason to support them
(http://serverfault.com/questions/659484) and this bug report is a wishlist bug

or

2. it does support physical devices, but it is an undocumented feature (at least in the manpage) and the warning it issues is misleading beacuse it makes you think it doesn't support them ("losetup: /dev/sdc2: warning: file smaller than 512 bytes, the loop device maybe be useless or invisible for system tools"). In this case this could be a documentation bug.

Quoted 7 lines
Quoted 2 lines

I haven't tested which of the two possibilities is the real situation, but I'm pretty sure you already know.

I don't recall what I've done that convinced me, but I'm *sure* that you can do

    losetup -o [offset] {-f[--show]|loopdev} /dev/sdXXX

Yup, it works for me. I posted an answer on
http://serverfault.com/questions/659484, gist of it is that

sudo losetup -o 32256 -f /dev/sdb3
sets up a loopback dev. Test with:
sudo tail -c 32257 /dev/sdb3 | sudo cmp - /dev/loop5

If you leave out -f or a specific arg like /dev/loop0, then the
command fails because losetup /dev/sdb3 means you're asking losetup to print info on a loopback device called /dev/sdb3.

loop: can't get info on device /dev/sdb3: Inappropriate ioctl for device

IDK how you got it to print

losetup: /dev/sdc2: warning: file smaller than 512 bytes, the loop device maybe be useless or invisible for system tools

Signature · 6 lines
#define X(x,y) x##y
Peter Cordes ;  e-mail: X(peter@cor , des.ca)

"The gods confound the man who first found out how to distinguish the hours!
 Confound him, too, who in this place set up a sundial, to cut and hack
 my day so wretchedly into small pieces!" -- Plautus, 200 BC