4

Because everyone wants details on this site:

I am ATTEMPTING to write a P2P powered, Linux OS (LFS). I am going to make it where users can message and walkie-talkie each other. Packages will also be distributed between users. My current thinking is to box executives up into virtual drives and run the executives from those mounted drives. Updates will also be distributed this way. This has nothing to do with Ubuntu, so the project shouldn't be discussed here.

That being said, the question itself has plenty to do with Ubuntu. It has to do with Linux. How many loopback devices can a system support at once? Is there a better way to support a higher number of mounted virtual drives? All I will need is read capabilities.

KI4JGT
  • 1,820

2 Answers2

4

The amount of loopbacks is a setting in modules.conf. It used to be /etc/modules.conf and before that /etc/conf.modules but looks like in 15.04 is is /etc/modules-load.d/modules.conf.

You can add 64 loopbacks with

options loop max_loop=64 

It looks like 256 is a hard coded limit in loop.ko. From a redhat system:

# modinfo loop
...
parm:           max_loop:Maximum number of loop devices (1-256) (int)

If all fails execute this from a root session:

for i in $(seq 0 255); do
  mknod -m0660 /dev/loop$i b 7 $i
  chown root.disk /dev/loop$i
done

That will attempt to create them. If it works add it to /etc/rc.local.

Rinzwind
  • 299,756
  • I tested it, unfortunately number higher than 64 do no effect. I can only mount maximum of 64 files by loop block interface. Probably it is defined by minor:major special file attribute. – Znik Jan 04 '18 at 12:46
  • 1
    Can you try the edit I made? – Rinzwind Jan 04 '18 at 13:44
  • It is good. But my another experience is, 256 is hardcoded in more distros than redhat. When loop is loaded without parameters, it really allocate memory for 64 loopbacks. then without reloading, we can add mknod for next devices, up to 64. It is not important, /dev is physical filesystem, or devfs. Both accepts it. But if we need more than 64 loopbachs, then we must load/reload it with max_loop parameters. Unfortunately I thin likit 256 loopbacks is unbreakable, because minor block device is one byte only. – Znik Mar 06 '18 at 20:47
2

!tested on Ubuntu 18.04 only!

I usually use grub for this, just add the boot parameter max_loop=64 to GRUB_CMDLINE_LINUX_DEFAULT in /etc/default/grub

Example: GRUB_CMDLINE_LINUX_DEFAULT="quiet splash max_loop=64"

Do update-grub after.

The /dev/loopXX should be created automatically.

damianm
  • 21