Nerdier

Adjective: Comparative form of nerdy: more nerdy.

Failed to activate new LV. Limit for the maximum number of semaphores reached.

Came across this error when attempting to create a logical volume for a VM;

I’ve run into this before, when a VM failed to start on Xen. You can try to increase the number of semaphores by adding something like the following to /etc/sysctl.conf

kernel.sem = 300 307200 32 4092

and then running sysctl to import, and ipcs to check

# sysctl -p
# ipcs -ls

------ Semaphore Limits --------
max number of arrays = 4092
max semaphores per array = 300
max semaphores system wide = 307200
max ops per semop call = 32
semaphore max value = 32767

Though I found this didn’t actually help with my issue. So what I did was to free up semaphores for pids that don’t exist anymore using a script.

#!/bin/bash
for semid in $(ipcs -s | awk '/[0-9]/ {print $2}'); do
    pid=$(ipcs -s -i ${semid} | grep -A1 pid | awk '/[0-9]/ {print $5}')
    if ! $(test -d /proc/${pid}); then
        echo "Freeing ${semid} ${pid}"
        ipcrm -s ${semid}
    fi
done

Once that had finished running, I had to manually remove the logical volume I had tried to create, as the namespace of it still existed even though it failed to create.

lvremove /dev/vg/lukstesting

Then I could recreate the LV and finish provisioning the VM I was setting up to test NDBE!

Leave a Reply

Your email address will not be published. Required fields are marked *