How many loopback devices can Linux support?
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.
Solution 1:
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
.
Solution 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.