[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Using loop devices in Debian

On 24 January 2014 01:04, Richard Owlett <rowlett@cloud85.net> wrote:
> As I DO NOT have high speed internet available I have purchased a set of
> Squeeze DVD's.
> My impression is that I should be able to copy the set of DVD's to a flash
> drive and access as loop device to save physically handling DVD's when using
> apt-get etc.
> Could I mount it as a loop device and do installs from the flash drive. I've
> already have created several versions of preseed.cfg to address various
> issues.

Disclaimers: I'm not sure exactly what you are asking. I don't know
anything about preseed. Hopefully you find the below assorted tips
useful anyway.

Regarding iso files:

Ordinarily, an iso file is used to prepare a filesystem image that is
then burnt to a dvd. But you want to go in the opposite direction.
Somehow you need to read the entire dvd image into an iso file. And
this is not necessarily simple, see for example:
Years ago I have done this successfully with CDs. I don't know if it
applies to DVDs.

See also:
Section 10.3 and especially 10.3.6 following "you can ... make the
ISO9660 image directly from the CD-ROM device as follows"

Regarding loop mount of file versus device:

wikipedia explains the basic point well thus:
"if the file contains an entire file system, the file may then be
mounted as if it were a disk device."

Note the *file* may be loop-mounted. Not a device. While 'mount' is
commonly used to mount devices, this is different. Loop devices are
files pretending to be devices.

> Could I mount *it* as a loop device (my emphasis on your "it")

You don't loop mount the flash *drive*, you loop mount a *file*.

So where you have several dvd iso files, then ordinarily you would
need several separate loop mounts. Unless you create a filesystem in
one huge file, copy all the iso's into it, and then loop mount that
huge file. That sounds like a very ugly idea to me, but I suppose it's
possible if preseed requires it for some reason. It would be smarter
to create one custom image file based on DVD #1 plus any extra you
need and mount just that. Try it first with just an image of DVD#1
before anything more complex.

Regarding loop filesystems:

Loop filesystems are easy to experiment with. Create a file of zeros
of the required size (dd), create a filesystem inside the file (mkfs),
mount it (mount), copy files into it.

# dd if=/dev/zero of=/tmp/my_file bs=1024 count=1024
# mke2fs /tmp/my_file
# mkdir -p /tmp/my_mountpoint
# mount -v -o loop -t ext2 /tmp/my_file /tmp/my_mountpoint
# echo 'testing' > /tmp/my_mountpoint/testfile
# cat /tmp/my_mountpoint/testfile
# ls -l /tmp/my_mountpoint
# umount -v /tmp/my_mountpoint

That example skips over the utility named 'losetup' which creates the
loop device, because mount calls it for you. For iso images you will
need mount -t iso9660 or whatever 'file' reports for the image file.

Finally, thanks for correctly calling it a "loop" device and not a
"loopback" device (because loopback is a network interface), people
are often careless about this.

Reply to: