Loop Mounting in Parallel

loop-device

I am doing a project in which I need to mount 100+ loop devices and merge it into AUFS mountpoint
As an observation, for sequentially mounting 90 loop devices, it takes 25 seconds.

I am looking for a solution which will minimize time by mounting loop devices in parallel

Best Answer

I think this is obvious, but

typeset -i M=1
while [ $M -le 102 ]
  do
    mount mysourcedevice$M targetdir$M &
    let M++
done
wait

Should do the job. The wait will wait until all sub-processess are finished, before executing the next command.

Related Question