Migration from 0.9.1betaX to 0.9.1beta8
---------------------------------------

Unfortunately this process requires updating the on-disk metadata
using a supplied tool. If you follow these instructions carefully
there should be no problems but please read them at least once before
attempting an upgrade.  If your system has its root filesystem on LVM
then please also read the relevant notes below.

During the upgrade process it is strictly necessary not to run any LVM
commands, which change the LVM configuration.

The upgrade procedure requires you to run the upgrade tool, and then
upgrade the kernel and user-land tools to beta8. If your kernel has
LVM compiled into it (ie. not as a module) this will require a system
reboot.

It will be helpful if you have the new LVM source tree and kernel
built (but not installed) before you start the upgrade procedure.

We strongly recommend that you take a full system backup and check
your recovery strategies before attempting this upgrade.

In the examples below it is assumed that your LVM sources are in
/root/LVM/<version> and your Linux kernel sources are in
/usr/src/linux. If these locations differ on your system then change
the instructions accordingly.


The pvversion tool
------------------

The pvversion tool provided in the package makes a minor change to the
on-disk metadata on PVs and changes the version number. Prior to beta8
the version number of the metadata was 1, it is now 2. The change is
small and will not affect data stored on the volumes. pvversion is a
perl script and expects to find the perl interpreter in /usr/bin/perl
(no additional modules are required), if your perl interpreter is in a
different directory, eg /usr/local/bin/perl, then edit the first line
of the file accordingly.

The "old" LVM userland tools will only recognise PVs with version 1
metadata, and the new (beta8+) tools will only recognise PVs with
version 2 metadata.

The pvversion tool can also revert the version number back to 1 should
you encounter difficulties. Note that the pvversion tool needs to have
the "right" userland tools in the PATH to work correctly so if you are
upgrading from beta7 to beta8 with the command "pvversion -2" then you
should have the beta7 tools on your PATH. If you are downgrading from
beta8 to beta7 then you should have the beta8 tools on your
PATH. Remember that by default the tools are dynamically liked against
liblvm so just changing PATH may not be enough, you should also change
LD_LIBRARY_PATH or use make install to actually move the binaries into
place on your system.

The command line for pvversion is a simple -1 or -2 switch followed by
a list of all the PVs on your system. eg. If you have 8 SCSI disks
with a single partition on each as PVs, then the following command
could be used to upgrade to version 2:

# pvversion -2 /dev/sd[a-h]1

or, to downgrade a small IDE-based system:

# pvversion -1 /dev/hda2 /dev/hdb1 /dev/hdb2

Upgrade with LVM as a module
----------------------------
1. Close all LVs. eg umount all LVM filesystems.
   Do *NOT* vgchange -an or unload the LVM module
   If this is not possible don't worry - it just means you will have to reboot
   at step 7.
2. cd to the new LVM build directory
   # cd /root/LVM/0.9.1_beta8/tools
3. Run the conversion tool
   #./pvversion -2 <PVs>
4. If that command gave any errors then stop now and read the "troubleshooting"
   section.
5. Now unload LVM
   # vgchange -an
   # rmmod lvm-mod
6. Now install the new tools
   # make install
7. Install the new lvm-mod.o in your modules directory
   # cd /usr/src/linux
   # make modules_install
   # depmod -a            (only needed for Linux 2.2)   
8. Install the new LVM module or reboot
   # modprobe lvm-mod
   # vgscan
   (ignore any errors that say "ERROR: different structure size stored in /etc/lvmtab.d" )
   # vgchange -ay
10.You may now re-mount your logical volumes.


Upgrade with LVM compiled into the kernel
-----------------------------------------
1. Patch the kernel following INSTALL and PATCHES/README instructions.
2. cd to the new LVM build directory
   # cd /root/LVM/0.9.1_beta8/tools
3. Run the conversion tool
   #./pvversion -2 <PVs>
4. If that command gave any errors then stop now and read the "troubleshooting"
   section.
5. Now install the new tools
   # make install
6. Reboot with the new LVM kernel
   Make sure that your bootup sequence includes the vgscan command.


Upgrade from 0.8
----------------

To upgrade from LVM 0.8 to LVM 0.9.1beta8, follow exactly the same
procedures outlined above with the following additional step once the
upgrade has been completed:

- For each Volume Group (VG) you have it is necessary to create a
  small LV and remove it again. This step will add UUIDs to the physical
  volumes that LVM 0.9 uses to identify them. eg: for a VG called
  "homevg" issue the following commands:
  
  # lvcreate -l1 -An -ntempvol homevg
  # lvremove -f -An /dev/homevg/tempvol


Root on LVM
-----------

Running root on LVM is currently a complicated thing to do and only to
be attempted if you really know what you are doing. The upgrade
procedure to beta8 is potentially hazardous so you should make doubly
sure that your backups and recovery strategies are in place. In
particular we recommend you have a bootable linux system (perhaps on
CD or spare disk or partition) available with statically linked
versions of *BOTH* your current LVM tools and the new ones.

The instructions below include vague statements like "edit lilo.conf"
- it is assumed that you know what you are doing here. If not then you
really should not be running root on LVM ! Also if you are using
another boot loader such as grub you should modify the instructions
accordingly.

Running with root on LVM usually requires you to start the system with
an initial RAM disk (initrd), this procedure assumes that you are
using an initrd created with the lvmcreate_initrd script. If this is
not the case you should make sure you understand what the upgrade
process involves and how your installation is affected and modify the
below instructions as appropriate.

The basic procedure is similar to that above for the "normal" root
case with the additional step of creating a new initrd and some extra
steps to try to keep the system recoverable in the case of a
problem. In addition to the new LVM tools you should have a copy of
your existing LVM tools built and ready to install because this
procedure requires you to switch between them.

1. Close all LVs. eg umount all LVM filesystems.
   Do *NOT* vgchange -an or unload the LVM module
2. cd to the new LVM build directory
   # cd /root/LVM/0.9.1_beta8/tools
3. Install the new tools
   # make install

4. Install the new kernel or module into its target directory (do
   *NOT* load the new module into the kernel yet). How you do this
   depends on whether you are using a module, the kernel version you are
   using and where you keep your kernel sources. If you are using modules
   here you should make sure that the lvm-mod.o file is in the correct
   place for it to be collected by lvmcreate_initrd and placed into the
   initial RAM disk. You may also want to make a copy of the old
   lvm-mod.o module at this point so you don't lose it.

5. Create a new initrd. If your new kernel is same version as the old one then
   it is recommended that you rename the old initrd first (as they are named
   by kernel version)
   # lvmcreate_initrd
6. Edit /etc/lilo.conf to add a new entry for the new kernel and initrd and
   also reflect the new name of the old initrd file.
7. Re-run lilo to install the new boot block
   # /sbin/lilo
8. cd to the old LVM build directory
   # cd /root/LVM/0.9.1_beta7/tools
9. Install the old tools again
   # make install
10.cd to the new LVM build directory
   # cd /root/LVM/0.9.1_beta8/tools
11.Run the conversion tool
   # ./pvversion -2 <PVs>
12.If that command gave any errors then stop now and read the "troubleshooting"
   section.
13.Install the new tools
   # make install
14.Reboot with the new LVM kernel and initrd.


Reverting to your old version
-----------------------------

If the upgrade does not succeed then it is possible to downgrade the
metadata version on disk using the pvversion command:

# pvversion -1 <PVs>

Note that you will need to have the beta8 tools installed to be able
to do this.  Once you have downgraded the metadata you must also
install your old userland tools and old LVM kernel module (or static
kernel).

The procedure is essentially the reverse of that outlined above.


Troubleshooting
---------------

If you follow the instructions carefully then the upgrade should go
smoothly, however there are a number of things that can go wrong.

  pvversion -- no physical volumes found/given

  You have not listed any PVs on the command line, or those that were
  listed are not valid LVM physical volumes. This could mean that the
  volumes listed are already at the version number required. Use the 
  command "pvscan" to get a list of valid physical volumes. Note that
  pvscan can only list volumes that have the same version number as the
  rest of the installed tools.
  
  
  pvversion -- created dummy LV "/dev/vg/pvversionsda820" on empty PV "/dev/sda"

  pvversion detected an unused PV in your system. To complete the upgrade
  pversion needed to create an LV on the PV. Under normal circumstances this
  LV will be removed automatically after the upgrade.
  This message is quite normal. If the LV still exists after the upgrade then
  you can safely remove it.

  
  lvcreate -- ERROR "Device not configured" creating VGDA for "/dev/vg/vol" in kernel
  pvscan -- inactive PV "/dev/sda" of VG "vg" [1.95 GB / 1.95 GB free]
  
  I don't know what causes the above errors but I have seen them occur. To get
  around them 
  # vgchange -an
  # rmmod lvm-mod
  # modprobe lvm-mod
  # vgscan
  # vgchange -ay
  
  
  vgscan Sees no VGs, pvscan sees no PVs

  This usually means that the installed tools does not match the on-disk
  metadata version. If your tools are beta8 then downgrade them, if the
  tools are earlier then upgrade them to beta8. The command "pvscan --version"
  will tell you the current version of the tools.