losetuping files in tmpfs fails?
Whilst trying to figure out why my dang stripes won't persist (a separate but worrisome issue), I wrote a dittie which creates a couple junk files in /tmp (tmpfs), associates loop devices with them, whoops, losetup craps out.
/home/root# losetup -d /dev/loop/5 2>/dev/null # Free /dev/loop/5
/home/root# cd /home/root # Go home
/home/root# mount | grep /home # Filesystem is ...
/dev/md/8 on /home type reiserfs (rw) # reiserfs
/home/root# echo foo > foo # Create file foo /home/root# losetup /dev/loop/5 foo # Give foo to /dev/loop/5 /home/root# losetup -d /dev/loop/5 # Free /dev/loop/5 /home/root# rm foo # Remove foo
/home/root# cd /tmp # Go to /tmp /tmp# mount | grep tmp # Filesystem is ... tmpfs on /tmp type tmpfs (rw) # tmpfs /tmp# echo foo > foo # Create file foo /tmp# losetup /dev/loop/5 foo # Give foo to /dev/loop/5 ioctl: LOOP_SET_FD: Invalid argument # DISCO!!! <o > <o > /tmp# rm foo # Remove foo
Version information:
Distribution: Debian Woody, up-to-date as of a week ago
Kernel: Linux 2.4.17
I don't subscribe to [email protected]. If you want me to
see a message, please mail it to me. If my site is down, send to [email protected]. And bonk my administrator with a wiffle bat.
Regards, [Ag] Andy Gaynor [email protected]
Quoted 11 lines · Andy Gaynor
Whilst trying to figure out why my dang stripes won't persist (a separate but worrisome issue), I wrote a dittie which creates a couple junk files in /tmp (tmpfs), associates loop devices with them, whoops, losetup craps out.
...
/tmp# mount | grep tmp # Filesystem is ... tmpfs on /tmp type tmpfs (rw) # tmpfs /tmp# echo foo > foo # Create file foo /tmp# losetup /dev/loop/5 foo # Give foo to /dev/loop/5 ioctl: LOOP_SET_FD: Invalid argument # DISCO!!! <o > <o >
Yup, tmpfs doesn't provide some of the facilities which the
loop driver requires. Specifically, prepare_write() andcommit_write().
Probably it's not too hard to change loop to use generic_file_write(), and it will then permit tmpfs file-backed loop mounts.
It's not obvious that there's a burning need to support loop-on-tmpfs though, is there?
-
Quoted 3 lines · Andrew Morton
It's not obvious that there's a burning need to support loop-on-tmpfs though, is there?
/sbin/mkinitrd and /sbin/mkinitd_helper in major distros tend to loop back on files called /tmp/initird.blah to make the images.
Quoted 16 lines · Andrew Morton
Quoted 10 lines · Andy Gaynor
Whilst trying to figure out why my dang stripes won't persist (a separate but worrisome issue), I wrote a dittie which creates a couple junk files in /tmp (tmpfs), associates loop devices with them, whoops, losetup craps out.
...
/tmp# mount | grep tmp # Filesystem is ... tmpfs on /tmp type tmpfs (rw) # tmpfs /tmp# echo foo > foo # Create file foo /tmp# losetup /dev/loop/5 foo # Give foo to /dev/loop/5 ioctl: LOOP_SET_FD: Invalid argument # DISCO!!! <o > <o >Yup, tmpfs doesn't provide some of the facilities which the
loop driver requires. Specifically,prepare_write()andcommit_write().
Quoted 5 lines
Probably it's not too hard to change loop to use
generic_file_write(), and it will then permit tmpfs file-backed loop mounts.It's not obvious that there's a burning need to support loop-on-tmpfs though, is there?
Well, if you are using tmpfs as your /tmp filesystem (presumably not such a strange situation given the name ;-), then any tool which creates a loopback in /tmp will break. Good examples would be mkinitrd, or anything that is generating a floppy image (e.g. Linux Router Project floppy, boot floppy tools, etc).
Cheers, Andreas
--
Andreas Dilger
http://sourceforge.net/projects/ext2resize/
http://www-mddsp.enel.ucalgary.ca/People/adilger/
Thanks all for your responses to ...
Quoted 1 line · [email protected] (Yers truly) wrote:
[Lookey, I can't loop to files in tmpfs!]
Before trying out a new kernel feature, I give the docs at least a quick look for bugs and warnings. The higher the signal-to-noise ratio, the closer I look. tmpfs.txt is conversational, so I only gave it a cursory scan. The notes on the loop restriction are kind of obscured. The first is the second line of "usage" 3. Having read the first line, completely innocuous and unrelated to the restriction, I moved on. The second was "todo" 2 at the very bottom, and todos aren't usually very interesting to first-time users. This is an important restriction with no obvious justification (the cynical might even call such a bug), and should be prominently advertised.
Quoted 2 lines · [email protected] (Andrew Morton) wrote:
It's not obvious that there's a burning need to support loop-on-tmpfs though, is there?
Completeness is enough. /tmp is a general purpose area and should generally work. Given /tmp's transient nature, it's quite reasonable to trade away persistence for other features, including speed and flexibility. However, there is no obvious justification for trading away other features, like the ability to contain the objects of loops.
As for specific need, it's common practice to create temporary filesystems
in a file before sending them to removable volumes. The activity on such filesystems is usually intensive and short-lived, making them ideal candidates for tmpfs's features. It pleases me to get better mileage from my generous swap partitions, which occupy prime prime real estate on my hard drives: fast low-order fast locations strategically placed between system and data areas.
Regards, [Ag] Andy Gaynor [email protected]