[linux-lvm] snapshots can't be deactivated

Falko Zurell falko.zurell at idmedia.com
Tue Jul 17 14:33:17 UTC 2007

Hello list,

I have a strange behaviour on my snapshots.
I got a Ubuntu Server 7.04 with LVM2 setup:

lvm> version
   LVM version:     2.02.06 (2006-05-12)
   Library version: 1.02.08 (2006-07-17)
   Driver version:  4.11.0

I have two logical volumes I want to make snapshots of every night:

/dev/vg0/home with XFS
/dev/vg0/opt with XFS

These snapshots will be mounted read-only under /backup

So in principle the steps to achieve this should be:

  - unmount the snapshot from yesterday (umount /backup/home)
  - discard the snapshot from yesterday (lvremove -f
  - freeze the filesystem (xfs_freeze -f /dev/vg0/home)
  - create the snapshot (lvcreate --snapshot --size 20G --name 
daily-snap-home -v /dev/vg0/home)
  - unfreeze the filesystem (xfs_freeze -u /dev/vg0/home)
  - mount the new snapshot ro (mount -oro,nouuid 
/dev/vg0/daily-snap-home /backup/home)

I wrote a script for that with some error checking too. But sometimes 
this doesn't work. The problem seems to be that the snapshot isn't 
removed even if "lvremove -f " sais it is removed. I got the following 
error message when I then recreate the snapshot:

root at konrad:~# ./create-snapshot-home.sh
+ /sbin/lvs
   LV              VG   Attr   LSize   Origin Snap%  Move Log Copy%
   daily-snap-home vg0  swi-ao  20.00G home     0.00
   daily-snap-opt  vg0  swi-ao  20.00G opt      0.08
   home            vg0  owi-ao 100.00G
   opt             vg0  owi-ao 100.00G
   root            vg0  -wi-ao  10.00G
   video           vg0  -wi-ao 800.00G
+ /bin/umount -f /backup/home
+ /sbin/lvdisplay
+ grep /dev/vg0/daily-snap-home
                          /dev/vg0/daily-snap-home [active]
   LV Name                /dev/vg0/daily-snap-home
+ [ 0 -eq 0 ]
+ [ -b /dev/mapper/vg0-daily--snap--home ]
+ /sbin/lvremove -f /dev/vg0/daily-snap-home
   Logical volume "daily-snap-home" successfully removed
+ sleep 5
+ [ -b /dev/mapper/vg0-daily--snap--home ]
+ [ 0 -eq 0 ]
+ /usr/sbin/xfs_freeze -f /home
+ [ 0 -eq 0 ]
+ /sbin/lvcreate --snapshot --size 20G --name daily-snap-home -v 
     Setting chunksize to 16 sectors.
     Finding volume group "vg0"
     Archiving volume group "vg0" metadata (seqno 116).
     Creating logical volume daily-snap-home
     Creating volume group backup "/etc/lvm/backup/vg0" (seqno 117).
     Found volume group "vg0"
     Creating vg0-daily--snap--home
     Loading vg0-daily--snap--home table
     Resuming vg0-daily--snap--home (254:5)
     Clearing start of logical volume "daily-snap-home"
     Found volume group "vg0"
   LV vg0/daily-snap-home in use: not deactivating
   Couldn't deactivate new snapshot.
+ /usr/sbin/xfs_freeze -u /home
+ /bin/mount -oro,nouuid /dev/vg0/daily-snap-home /backup/home
mount: you must specify the filesystem type

I don't know why this happens. The script will work perfectly 3 out of 5 
times. But sometimes it comes up with the error above.

Are my steps right in principle? Did I forget to do something before or 
after removing?

Thanks and kind regards


Falko Zurell
Head of Application Management

/i-d media AG
Ohlauer Straße 43
D-10999 Berlin

Tel +49 (0)30 - 2 59 47 - 357
Fax +49 (0)30 - 2 59 47 - 471


Board: Regine Haschka-Helmer (CEO), Franz Klose (CFO)
Chairman of the Supervisory Board: Christian A. Hufnagl
Headquarters: Berlin, Place of Jurisdiction: Berlin HRB 76342
UST-Id. DE812698340

This message may contain confidential information and must not be 
copied, disclosed or used by anybody other than the intended recipient. 
If you have received this message in error, please notify us immediately 
by reply e-mail and delete all records of the message from your 
computer. The views represented in this message are solely those of the 
author. Neither the author nor I-D Media AG accepts any liability for 
the contents of this message.

More information about the linux-lvm mailing list