Page 1 of 1

Mounting LVM Snapshots (FC5)

Posted: Sun May 13, 2007 10:21 pm
by shambler
I have Scalix 11.0.4 installed on Fedora Core 5. The following volumes are mounted::

Code: Select all

[root@merlin ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda2             5.7G  1.6G  3.9G  30% /
/dev/sda1              76M  9.1M   63M  13% /boot
tmpfs                1011M     0 1011M   0% /dev/shm
/dev/mapper/vgscalix-lvscalix
                      197G  604M  187G   1% /var/opt/scalix
/dev/sdb               67G   55M   64G   1% /var/opt/scalix/mn/s/temp


The device sda is a RAID 1+0 array and device sdb is a separate disk to which I have mounted the temp directory in order to improve performance. The LVM volume group is setup on sda.

My system is not live yet (no users except myself) and I have been experimenting with LVM snapshots. I'm having trouble mounting my snapshots after creating them. I have arbitrarily chosen a volume size of 40GB based on suggestions that it should be around 15-20% of the original volume. During snapshot creation I receive the following error message:

Code: Select all

[root@merlin ~]# omsuspend -s 60 &
[root@merlin ~]# sync
[root@merlin ~]# lvcreate -L 40G -s -n sxbackup /dev/vgscalix/lvscalix
  LV vgscalix/sxbackup in use: not deactivating
  Couldn't deactivate new snapshot.
[root@merlin ~]# omsuspend -r


I'm not sure if this is a warning or an error. In any case, I can confirm the creation of the snapshot with the lvdisplay command:

Code: Select all

[root@merlin ~]# lvdisplay
  --- Logical volume ---
  LV Name                /dev/vgscalix/lvscalix
  VG Name                vgscalix
  LV UUID                Ix12TP-6PLr-Q91z-rq71-4cJR-6dql-3i70cV
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                200.00 GB
  Current LE             51200
  Segments               1
  Allocation             inherit
  Read ahead sectors     0
  Block device           253:0

  --- Logical volume ---
  LV Name                /dev/vgscalix/sxbackup
  VG Name                vgscalix
  LV UUID                HLckYJ-nQ5D-6Zs9-YU87-x65D-tprw-oClE2i
  LV Write Access        read/write
  LV Status              available
  # open                 0
  LV Size                40.00 GB
  Current LE             10240
  Segments               1
  Allocation             inherit
  Read ahead sectors     0
  Block device           253:1


However, when I try to mount the snapshot, I run into problems:

Code: Select all

[root@merlin ~]# mount /dev/vgscalix/sxbackup /mnt/sxbackup
mount: you must specify the filesystem type
[root@merlin ~]# mount -t ext3 /dev/vgscalix/sxbackup /mnt/sxbackup
mount: wrong fs type, bad option, bad superblock on /dev/vgscalix/sxbackup,
       missing codepage or other error
       In some cases useful info is found in syslog - try
       dmesg | tail  or so


I saw a thread (http://www.scalix.com/forums/viewtopic.php?t=6627&highlight=mount+snapshot ) describing a similar problem with SLES10. Has anybody else experienced similar problems under FC5? Am I going to have to patch the kernel to get this working? Any advice would be much appreciated.

Posted: Mon May 14, 2007 1:58 am
by brockz
modprobe dm_snapshot

Posted: Mon May 14, 2007 3:36 am
by shambler
Thanks for the hint, brockz. This actually worked straight away, but then I tried adding the module to /etc/modules.conf and rebooting to make sure it would autoload, and now it doesn't work again. I have since removed the entry from /etc/modules.conf and tried manually loading the module with modprobe but the same error comes up:

Code: Select all

[root@merlin ~]# modprobe dm_snapshot
[root@merlin ~]# lsmod | grep snapshot
dm_snapshot            20205  0
dm_mod                 54745  4 dm_snapshot,dm_mirror
[root@merlin ~]# lvcreate -L 40G -s -n sxbackup /dev/vgscalix/lvscalix
  LV vgscalix/sxbackup in use: not deactivating
  Couldn't deactivate new snapshot.
[root@merlin ~]# lvscan
  ACTIVE            '/dev/vgscalix/lvscalix' [200.00 GB] inherit
  ACTIVE            '/dev/vgscalix/sxbackup' [40.00 GB] inherit
[root@merlin ~]# mount /dev/vgscalix/sxbackup /mnt/sxbackup
mount: you must specify the filesystem type


Why did it work the first time and then revert after a reboot? I feel like I'm missing one small but important step... :?

Posted: Tue May 15, 2007 5:40 am
by friedmar
There seems to be a clitch in udev handling. Try /etc/init.d/boot.udev stop before the snapshot and start udev with /etc/init.d/boot.udev start!

This workaround solved the problem for me.

Friedmar

Posted: Thu May 17, 2007 11:14 pm
by obrodkin
This is a known bug in SUSE or RH latest kernel. Solution is to add one line to udev conf file exlude snapshot volumes from triggering udev.

Oleg

Posted: Mon May 21, 2007 2:07 am
by shambler
Yes, it does look like udevd is causing the problem. If I create a snapshot while udevd is running then I can't mount it. The script /etc/init.d/boot.udev doesn't exist on my system, so I just killed udevd instead. Does anyone know the proper way to start/stop the udev daemon on Fedora Core 5? There doesn't seem to be any udev-related services registered on my system:

Code: Select all

[root@merlin ~]# chkconfig --list | grep udev
[root@merlin ~]#


Oleg, are you referring to a udev rule that I could add? Would you be able to give an explicit example of such a rule? I'm not sure how to prevent snapshot volumes from triggering udev. Thanks to everyone for your help so far.

Posted: Mon May 21, 2007 12:48 pm
by obrodkin
this is what has to be done on SLES 10, I remember seeing instructions for RH as well, so google away

in /etc/udev/rule.d/, I've added file :55-lvm.rules":

Code: Select all

#
# 05-01-07 Recommended fix for the bug with lvcreate snapshot
#
KERNEL=="dm-[0-9]*", OPTIONS+="ignore_device"


OIeg

Posted: Mon May 21, 2007 8:39 pm
by shambler
That worked a treat. I rebooted after writing a similar rule file and I can now create LVM snapshots without any extra fiddling. I think I also discovered the correct place for loading modules at boot time. I created a simple script in /etc/sysconfig/modules:

Code: Select all

#!/bin/sh

modprobe dm_snapshot >/dev/null 2>&1


This seems a bit crude but there was already a script in this directory that used the same method so I guess it's the way things are done in FC5. Thanks to everybody who contributed. Problem solved! :D