Skip to contentSkip to conversation

Problem to remove LVM snaphots

linux-lvm François Valenduc 4 participants 5 messages Apr 18, 2010 – Apr 26, 2010

lore
Share & tools
lore
#0 lore raw

Hello everybody,

I am using gentoo and I use LVM snapshots to make backups of my system. Unfortunately, I always have a problem to remove these. LVM always complains that it can't remove an open logical volume. However, the snapshot is unmounted when I try to remove it. It seems it's only possible to remove the snapshot if the corresponding volume is deactivated. So, I am forced to boot on a live cd to remove the snapshot of my root partition. Is this really normal ?
I already had that problem a long time ago and I thought it was solved if a do a sync before removing the snapshot. It seems it's no more sufficient. I am using LVM 2.02.56-r2, udev 149 and kernel 2.6.33.2

What is even more strange is that I can't even remove snapshot of logical volumes which I have never mount. In fact, I do the following steps:
lvcreate -L5G -n test gentoo
lvcreate -n test1 -L1G -s /dev/gentoo/test
lvremove gentoo/test1
And, I always get this error: Can't remove open logical volume "test1"

Am I forgetting something ? Until 2 month agos, this worked without any error. Does anybody have an idea about this problem ?

Thanks in advance for your help,

Fran�ois Valenduc

#1 lore raw
Quoted 9 lines · Fran�ois Valenduc

Hello everybody,

I am using gentoo and I use LVM snapshots to make backups of my system. Unfortunately, I always have a problem to remove these. LVM always complains that it can't remove an open logical volume. However, the snapshot is unmounted when I try to remove it. It seems it's only possible to remove the snapshot if the corresponding volume is deactivated. So, I am forced to boot on a live cd to remove the snapshot of my root partition. Is this really normal ?

No, it is not normal. Obviously something on your system has the snapshot open. Perhaps it is being auto mounted?

#2 lore raw

Le 19/04/10 01:04, Phillip Susi a �crit :

Quoted 11 lines · Fran�ois Valenduc
Quoted 9 lines

Hello everybody,

I am using gentoo and I use LVM snapshots to make backups of my system. Unfortunately, I always have a problem to remove these. LVM always complains that it can't remove an open logical volume. However, the snapshot is unmounted when I try to remove it. It seems it's only possible to remove the snapshot if the corresponding volume is deactivated. So, I am forced to boot on a live cd to remove the snapshot of my root partition. Is this really normal ?

Quoted 9 lines

No, it is not normal. Obviously something on your system has the snapshot open. Perhaps it is being auto mounted?

_______________________________________________
linux-lvm mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/linux-lvm
read the LVM HOW-TO at http://tldp.org/HOWTO/LVM-HOWTO/

I would really like to know the process which has the snapshot open.The script I use to backup my system is the following:

#!/bin/sh
logrotate -v -f /etc/logrotate.conf
vgcfgbackup
lvcreate -L1G -n backup -s /dev/gentoo/root
if [ $? = 0 ]; then
if [ ! -e /mnt/backup ]; then
mkdir /mnt/backup
fi
mount -o ro /dev/gentoo/backup /mnt/backup
cd /mnt/backup NAME="/home/francois/Backup/gentoo_64_$(date +%F).tar.bz2" tar cvfpj ${NAME} --exclude=tmp/* *
cd /
umount /mnt/backup
if [ $? = 0 ]; then
sync
lvremove -f gentoo/backup
fi
fi

So, the snaphot is clearly unmounted before I try to remove it. But I can almost never remove the snaphot. In fact, I have noticed that if I don't use the "-f" option, I can remove the snapshot but it always fails if I use it. But, I would like to use my script without any confirmation message.

Fran�ois

#3 lore raw
Quoted 1 line · Fran�ois Valenduc

I would really like to know the process which has the snapshot open.The

did you try checking with fuser or /sys/block/dm-*/holders?

Quoted 1 line

script I use to backup my system is the following:

unrelated to problem but:

Quoted 9 lines

#!/bin/sh
logrotate -v -f /etc/logrotate.conf
vgcfgbackup
lvcreate -L1G -n backup -s /dev/gentoo/root
if [ $? = 0 ]; then
if [ ! -e /mnt/backup ]; then
mkdir /mnt/backup
fi
mount -o ro /dev/gentoo/backup /mnt/backup

add error checking here

Quoted 3 lines
       cd /mnt/backup
       NAME="/home/francois/Backup/gentoo_64_$(date +%F).tar.bz2"
       tar cvfpj ${NAME} --exclude=tmp/* *

ugly wildcards, quote the first and consider using . instead of second

Quoted 22 lines

cd /
umount /mnt/backup
if [ $? = 0 ]; then
sync
lvremove -f gentoo/backup
fi
fi

So, the snaphot is clearly unmounted before I try to remove it. But I can almost never remove the snaphot. In fact, I have noticed that if I don't use the "-f" option, I can remove the snapshot but it always fails if I use it. But, I would like to use my script without any confirmation message.

Fran�ois

_______________________________________________
linux-lvm mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/linux-lvm
read the LVM HOW-TO at http://tldp.org/HOWTO/LVM-HOWTO/

Signature · 6 lines
Luca Berra -- [email protected]
        Communication Media & Services S.r.l.
 /"\
 \ /     ASCII RIBBON CAMPAIGN
  X        AGAINST HTML MAIL
 / \
#4 lore raw
In reply to François Valenduc

Dne 19.4.2010 18:47, Fran�ois Valenduc napsal(a):

Quoted 45 lines

Le 19/04/10 01:04, Phillip Susi a �crit :

Quoted 11 lines · Fran�ois Valenduc
Quoted 9 lines

Hello everybody,

I am using gentoo and I use LVM snapshots to make backups of my system. Unfortunately, I always have a problem to remove these. LVM always complains that it can't remove an open logical volume. However, the snapshot is unmounted when I try to remove it. It seems it's only possible to remove the snapshot if the corresponding volume is deactivated. So, I am forced to boot on a live cd to remove the snapshot of my root partition. Is this really normal ?

Quoted 9 lines

No, it is not normal. Obviously something on your system has the snapshot open. Perhaps it is being auto mounted?

_______________________________________________
linux-lvm mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/linux-lvm
read the LVM HOW-TO at http://tldp.org/HOWTO/LVM-HOWTO/

I would really like to know the process which has the snapshot open.The script I use to backup my system is the following:

#!/bin/sh
logrotate -v -f /etc/logrotate.conf
vgcfgbackup
lvcreate -L1G -n backup -s /dev/gentoo/root
if [ $? = 0 ]; then
if [ ! -e /mnt/backup ]; then
mkdir /mnt/backup
fi
mount -o ro /dev/gentoo/backup /mnt/backup
cd /mnt/backup NAME="/home/francois/Backup/gentoo_64_$(date +%F).tar.bz2" tar cvfpj ${NAME} --exclude=tmp/* *
cd /
umount /mnt/backup
if [ $? = 0 ]; then
sync
lvremove -f gentoo/backup
fi
fi

Quoted 5 lines

So, the snaphot is clearly unmounted before I try to remove it. But I can almost never remove the snaphot. In fact, I have noticed that if I don't use the "-f" option, I can remove the snapshot but it always fails if I use it. But, I would like to use my script without any confirmation message.

Sounds like udev problem. Most probably gentoo stepped into the udev mine-field. It's hard to give a good advice - udev currently has its problems.

You may try to experiment - try to disable udev to see whether it helps in this script case and renable after the script...

Zdenek