3

I want to add a few image files with file systems to a LVM volume group. If I make them available as loop devices changes are pretty high that one day the script gets corrupted due to an increasing number of used loop devices. Rather than increasing my number of loop devices, I'd like to make the file available with loop device functionality (like I would have set it up with losetup) under a unique name, like /dev/program/my_unique_name, so that mount -t atype /dev/program/my_unique_name /path/to/mount_point would do the same like mount -t atype /dev/loopX /path/to/mount_point.

Background: I tried to acchieve the thing I want by increasing the number of loop devices to X and started to assgn /dev/loopX, /dev/loopX-1, etc. which looks promising as long as

  • less than X - number of images I want to use loop devices are used on the system[1]
  • kernel performance doesn't suffer from an increased number of loop devices
  • no one needs similar functionality and start to assign loop devices starting with the highest number -> this complicates the script code, increases test necessity and decreases maintainability

It would be no problem to use variable loop devices, i.e. simply query the next free block device with losetup -f, assign the file and make it available under a unique name.


[1] probability to exceed X is low, so it's more a question of elegance to provide a resource under a unique name rather than under a number in inverval [0;X]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.