Last active
February 10, 2017 15:44
-
-
Save bactisme/6960a007f68c29af0f96ac9e3330ac24 to your computer and use it in GitHub Desktop.
On a proxmox 4.x environnement, this script look for vm and mount their disk on a host mount point
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# On proxmox 4.x, with a thinlvm setup, mount all running vm disk | |
BASE=/mnt | |
LVM_BASE=/dev/pve | |
#VMS=$(pct list|grep "running"|cut -d' ' -f1) | |
VMS=$(pct list|grep -v "VMID"|cut -d' ' -f1) | |
for VMID in $VMS | |
do | |
disk=$(pct config $VMID|grep "rootfs") | |
d=$(echo \"$disk\"|sed -e 's/.*\(vm-.*\),.*/\1/') | |
if [ ! -d $BASE/$d ]; then | |
mkdir $BASE/$d | |
fi | |
if mount | grep $BASE/$d > /dev/null; then | |
echo "!! $BASE/$d already mounted" | |
else | |
mount $LVM_BASE/$d $BASE/$d | |
echo "OK Mount $LVM_BASE/$d on $BASE/$d" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment