Welcome to the Linux Foundation Forum!

Loop devices and filesystems

Hi all,

I still don't really understand the concept of loop devices, especially why were they needed when creating and using the partition table on a file, that was in chapter 17 if I recall correctly?
Only after using losetup and asking it to scan the partition table do we get separate loop devices for all partitions, but is that the only way to get a device file for every partition? Why couldn't the file containing the filesystem simply have device files for all it's partitions like i. e. /dev/sda has?

Comments

  • Hi @vbeljan ,

    I still don't really understand the concept of loop devices, especially why were they
    needed when creating and using the partition table on a file, that was in chapter 17 if I recall correctly?

    The idea of using loop devices is to be able to play with the partitioning tools like parted, fdisk, gparted, without the need of having real partitions. Now that we have virtual machines, we can easily create virtual disks to play with partitions.

    Only after using losetup and asking it to scan the partition table do we get separate loop devices
    for all partitions, but is that the only way to get a device file for every partition? Why couldn't the file
    containing the filesystem simply have device files for all it's partitions like i. e. /dev/sda has?

    I don't understand this question. Did you take a look to Lab 17.3? Is that what you were asking?

    Regards,
    Luis.

  • coop
    coop Posts: 915

    On one point, even the nodes for real physical devices (like /dev/sda and particitions /dev/sda1, sda2, etc) exist only when the partitions exist and are discovered by the system. So it makes no sense to predefine loop devices, it is all dynamic.

  • vbeljan
    vbeljan Posts: 5

    I don't understand this question. Did you take a look to Lab 17.3? Is that what you were asking?

    Regards,
    Luis.

    Hi, sorry if it was a bit unclear. What I wanted to know is this: If we made a partition table in a file like in lab 17.3 and we wanted to have files in /dev that represent specific partitions on it (like /dev/loop0p1, /dev/loop0p2, etc when using losetup), would it be possible to create such files/nodes for the partitions in some other way without using losetup and loop devices?

  • Hi @vbeljan ,

    I'm not aware of a different way to make partitions from a file than using loop devices and losetup. When I'm confused about a tool, I use to look for additional documentation and examples, so I try and test until I understand it.

    Many regards,
    Luis.

  • coop
    coop Posts: 915

    you could make the nodes in /dev by using "mknod". However, this is the ancient way of doing things which has been obsolete for many years since dynamical allocation by the udev system (discussed later) has been the norm. ANd if you make them manually I cannot promise they will work as expected

Categories

Upcoming Training