Groups | Search | Server Info | Keyboard shortcuts | Login | Register


Groups > comp.os.linux.misc > #898

Re: HOW does 'loop' work ?

From Tauno Voipio <tauno.voipio@notused.fi.invalid>
Newsgroups alt.os.linux.slackware, comp.os.linux.misc
Subject Re: HOW does 'loop' work ?
Date 2011-04-24 18:09 +0300
Organization A noiseless patient Spider
Message-ID <ip1eff$9ar$1@dont-email.me> (permalink)
References <ip11gp$imq$1@dont-email.me>

Cross-posted to 2 groups.

Show all headers | View raw


On 24.4.11 2:28 , no.top.post@gmail.com wrote:
> References:<iohio5$rs4$1@dont-email.me>
>
> In article<iohio5$rs4$1@dont-email.me>, Tauno Voipio<tauno.voipio@notused.fi.invalid>  wrote:
>
>> On 17.4.11 5:17 , Tauno Voipio wrote:
>>> no.top.post@gmail.com wrote:
>>
>> Let's analyze your procedure:
>>
>>>> An extract of `man losetup`, with my embedded queries, is:-
>>>>> The following commands can be used as an example of using the loop
>>>>> device. dd if=/dev/zero of=/file bs=1k count=100
> -- snip--
>> To create an unencrypted loop, use:
>>
>>     losetup /dev/loop0 /file
> -- snip--
>
>> The files and directories are still in the disk/partition image
>> in /file, until you delete the file or mount the file system again
>> and delete them on the mounted node.
>
> That's a complex concept; which is why not many people seem to
> really know it. Lets:
>
> ->  losetup /dev/loop0 /tmp/LFile  == no such: /tmp/LFile  ?!
> So losetup does not 'create' any file.

Is is written somewhere that losetup should create the file?

> ->  dd if=/dev/zero of=/tmp/LFile bs=1 count=88
> ->  losetup /dev/loop0 /tmp/LFile  == see all zero bytes
> ->  mkfs -t ext2 /dev/loop0 88 == see:
> 00001BF0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
> 00001C00 02 00 00 00 0C 00 01 02 2E 00 00 00 02 00 00 00 ................
> 00001C10 0C 00 02 02 2E 2E 00 00 0B 00 00 00 E8 03 0A 02 ................
> 00001C20 6C 6F 73 74 2B 66 6F 75 6E 64 00 00 00 00 00 00 lost+found......
> == see 'partition structure'

This is actually an ext2 file system, which can, but does not
need to, reside on a partition.

Please be careful with the concepts to avoid mix-ups.

> ->  mount  /dev/loop0 /mnt/tmp
> ->  man losetup>  /mnt/tmp/ml
> ->  ls -l /mnt/tmp/ ==  ..
> drwx------ 2 root root 12288 2011-04-21 22:47 lost+found
> -rw-r--r-- 1 root root 5740 2011-04-21 23:06 ml
> == see: man losetup in the partition: /mnt/tmp/ !!
>
> IMO the reason why this is little understood, is because of NOT
> using a goal-directed explanation: "what is the purpose?".

Where should it then be? You wrote the file to the mounted
file system, wherever the file system then resides. The
only proper way to access the file system is via the
mount point.

> "The loop mechanism allows building and populating a 'partition',
> in a file, which could be in RAM. So that ... ? "
>
>   I'm trying to understand the 'create a bootable sys
> on eg. a USBstik' mechanism.

You did not ask how to create a bootable USB, but you
did ask what the loop interface does. I think that I
responded to the expilicit question.

>> /mnt resides in the main file system, and you do not see it when
>> the other filesystem is mounted on it. The mounted file system
>> you see on /mnt between mount and umount is the file system
>> inside the loop target /file.
>> You should re-read manuals of mount and losetup.
>
> They don't [need to] explain why:
> if you haven't got a device to give you a partition,
> and you can only use RAM,
> you should bother to simulate a physical device via 'loop'.

Do you mean that you do not have the necessary space
for the image of the USB stick on the system root
disk device?

For RAM use, a ramdisk (e.g. tmpfs) would be a better
chioce.

> For making a bootable-USBstik, why do they need to go via loop,
> instead of just directly writing [cp&  edit] to the USBstik.

The main reason seems to limit the count of writes on the
Flash chips in the USB stick. Building the file system
needs plenty of writes and re-writes on the base file
device. It loads the stick much less when a ready-made
image is just transferred to the stick.

> A confusing fact, confirmed experimentally,
> which may be relevant,
> is that a 'new' `mount<device>  /mnt`,
> masks only PART of the previous '/mnt-tree'.

I do not quite grab you - the mount masks the
whole file tree under the mount point, and only it.
Just read any textbook on Unix file systems.

-- 

Tauno Voipio

Back to comp.os.linux.misc | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Re: HOW does 'loop' work ? no.top.post@gmail.com - 2011-04-24 11:28 +0000
  Re: HOW does 'loop' work ? Tauno Voipio <tauno.voipio@notused.fi.invalid> - 2011-04-24 18:09 +0300
    Re (2): HOW does 'loop' work ? no.top.post@gmail.com - 2011-04-25 18:43 +0000
      Re: Re (2): HOW does 'loop' work ? Tauno Voipio <tauno.voipio@notused.fi.invalid> - 2011-04-25 22:36 +0300
      Re: Re (2): HOW does 'loop' work ? Kevin Snodgrass <kdsnodgrass@yahoo.com> - 2011-04-26 00:02 +0000
        Re (3): HOW does 'loop' work ? no.top.post@gmail.com - 2011-04-27 13:16 +0000
      Re: Re (2): HOW does 'loop' work ? Robert Nichols <SEE_SIGNATURE@localhost.localdomain.invalid> - 2011-04-25 22:16 -0500

csiph-web