NetAdminTools.com
 
SignalQ Sites:
NetAdminTools - Coprolite - NoNIC - SpotBridge - NAW
RoboCoop - AreWeDown - SolarPower - SysAdminTools
Xfig - Gold Loaf - GeekPapa - FixGMC - MCJ - FixRambler
Categories:
GNU/Linux | Homebrew designs | Perl | Administration | Backup/Recovery | Bugs/Fixes | Certification | Database | Email | File/Print | Hardware | Information Grab Bag | Interoperability | GNU/Linux ABCs | Monitoring | Name Resolution | Network Services | Networking | Remote Control | Security | Desktop | Web | BSD | Solaris | GIAGD | REALbasic

Last 30 Days | Last 60 Days | Last 90 Days | All Articles | RSS | Hail Support


Categories:
·GNU/Linux
·Homebrew designs
·Perl
·Administration
·Backup/Recovery
·Bugs/Fixes
·Certification
·Database
·Email
·File/Print
·Hardware
·Information Grab Bag
·Interoperability
·GNU/Linux ABCs
·Monitoring
·Name Resolution
·Network Services
·Networking
·Remote Control
·Security
·Desktop
·Web
·BSD
·Solaris
·GIAGD
·REALbasic
·All Categories


Upgrading LVM To Version 2 and Patching The Linux Kernel
Topic: GNU/Linux   Posted:2004-10-03
Printer Friendly: Print

spacerspacer
So far, we have been using a generic 2.4.24 Linux kernel with LVM enabled. We had to compile this ourselves because the stock Red Hat / Fedora kernels don't support our hard disks. See this article for more details. [Note: Before you do anything involving your partitions or volumes, make a complete backup. Make sure to set up a test system with the same kernel and distribution to see how this stuff works. This article was written using our lab box. Read our terms of use.] It turns out that the necessary drivers to do all we want to do with LVM are not even included in version 2.4.27. We aren't ready to make the jump to 2.6 in our lab, so we had to patch our kernel. While we were at it, we also decided to replace the LVM RPMs. The problem with the kernel shows up when we try and use pvmove to get data off of /dev/sde and /dev/sdf:

[root@srv-1 root]# pvmove -v /dev/sde
pvmove -- checking name of source physical volume "/dev/sde"
pvmove -- locking logical volume manager
pvmove -- reading data of source physical volume from "/dev/sde"
pvmove -- checking volume group existence
pvmove -- reading data of volume group "volgroup" from lvmtab
pvmove -- checking volume group consistency of "volgroup"
pvmove -- searching for source physical volume "/dev/sde" in volume
group "volgroup"
pvmove -- building list of possible destination physical volumes
pvmove -- checking volume group activity
pvmove -- moving physical extents in active volume group "volgroup"
pvmove -- WARNING: if you lose power during the move you may need
to restore your LVM metadata from backup!
pvmove -- do you want to continue? [y/n] y
pvmove -- starting to move extents away from physical volume "/dev/sde"
pvmove -- checking for enough free physical extents in "volgroup"
pvmove -- /dev/sde [PE 0 [logicalvol [LE 0]] -> /dev/sdf [PE 0] [1/768]
/dev/volgroup/group::/dev/volgroup/logicalvol: 0840 8576, 0850 8576
pvmove -- ERROR "Inappropriate ioctl for device" copying extent from 
"/dev/sde"
pvmove -- ERROR "Inappropriate ioctl for device" moving physical extents

We really wanted to recompile from source, so we didn't have to rely on particular RPMs or stock kernel versions. Device mapper is available from ftp://sources.redhat.com/pub/dm/, and LVM2 is available from ftp://sources.redhat.com/pub/lvm2/. Let's find out what LVM package we are using and get rid of it:

[root@srv-1 root]# rpm -qa | grep lvm
lvm-1.0.3-13
[root@srv-1 root]# 
[root@srv-1 root]# rpm -e lvm-1.0.3-13
error: Failed dependencies:
lvm is needed by (installed) mkinitrd-3.5.14-1
[root@srv-1 root]# rpm -e lvm-1.0.3-13 --nodeps

Note that we ignored the mkinitrd dependency. We aren't using any modules at all, let alone at boot time. But, do be careful here. Now, let's compile device-mapper, and point it at our Linux source tree, per the INSTALL file directions:

[root@srv-1 device-mapper.1.00.19]# ls
autoconf      contrib      dmsetup  INTRO   Makefile.in   patches  scripts
configure     COPYING      include  kernel  make.tmpl.in  po       VERSION
configure.in  COPYING.LIB  INSTALL  lib     man           README   WHATS_NEW
[root@srv-1 device-mapper.1.00.19]# ./configure
--with-kernel-dir=/usr/src/linux-2.4.27
checking build system type... 
.
.
.
config.status: creating man/Makefile
config.status: creating po/Makefile
configure: WARNING: Your kernel source in /usr/src/linux-2.4.27 needs patching
configure: WARNING: For supported kernels, try 'make apply-patches' 
next to do this, or apply the device-mapper patches by hand.
[root@srv-1 device-mapper.1.00.19]#

Well, we'll have to patch the kernel later. For now, let's compile and install the device-mapper files:

[root@srv-1 device-mapper.1.00.19]# make
make -C include
.
.
.
gcc -o dmsetup dmsetup.o  -L../lib/ioctl \
-L../lib/ioctl -L/lib -ldevmapper 
make[1]: Leaving directory `/usr/src/device-mapper.1.00.19/dmsetup'
[root@srv-1 device-mapper.1.00.19]# 
[root@srv-1 device-mapper.1.00.19]# make install
make -C include
make[1]: Entering directory `/usr/src/device-mapper.1.00.19/include'
make[1]: Nothing to be done for `all
.
.
.
/usr/bin/install -c -D -o root -g root -m 555  dmsetup /sbin/dmsetup
make[1]: Leaving directory `/usr/src/device-mapper.1.00.19/dmsetup'
[root@srv-1 device-mapper.1.00.19]# 

Now, let's compile and install the LVM files:

[root@srv-1 src]# tar -xzf LVM*.tgz
[root@srv-1 src]# ls
conf                 linux-2.4.27         lost+found    LVM2.2.00.25.tgz
linux-2.4.24.tar.gz  linux-2.4.27.tar.gz  LVM2.2.00.25
[root@srv-1 src]# cd LVM*
[root@srv-1 LVM2.2.00.25]# 
[root@srv-1 LVM2.2.00.25]# ./configure
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking target system type... i686-pc-linux-gnu
checking for gawk... gawk
.
.
.
checking libdevmapper.h usability... yes
checking libdevmapper.h presence... yes
.
.
.
config.status: creating test/device/Makefile
config.status: creating test/format1/Makefile
config.status: creating test/regex/Makefile
config.status: creating test/filters/Makefile
[root@srv-1 LVM2.2.00.25]# 
[root@srv-1 LVM2.2.00.25]# make
.
.
.
-Wl,--export-dynamic -L../lib -L/lib -llvm -ldevmapper -ldl  -rdynamic
make[1]: Leaving directory `/usr/src/LVM2.2.00.25/tools'
[root@srv-1 LVM2.2.00.25]# 
[root@srv-1 LVM2.2.00.25]# make install
make[1]: Nothing to be done for `install'.
make[1]: Leaving directory `/usr/src/LVM2.2.00.25/daemons'
[root@srv-1 LVM2.2.00.25]# 

If we run pvmove --version, we will see that our kernel still needs the device-mapper driver:

[root@srv-1 LVM2.2.00.25]# pvmove --version
LVM version:     2.00.25 (2004-09-29)
Library version: 1.00.19-ioctl (2004-07-03)
/dev/mapper/control: open failed: No such file or directory
Is device-mapper driver missing from kernel?
[root@srv-1 LVM2.2.00.25]# 

Let's go in to our Linux source tree and patch:

[root@srv-1 linux-2.4.27]# patch -p1 < /usr/src/device-mapper.1.00.19/
patches/linux-2.4.26-rc1-devmapper-ioctl.patch
patching file Documentation/Configure.help
Hunk #1 succeeded at 1953 (offset 30 lines).
patching file MAINTAINERS
Hunk #1 succeeded at 589 (offset 2 lines).
patching file arch/mips64/kernel/ioctl32.c
patching file arch/parisc/kernel/ioctl32.c
patching file arch/ppc64/kernel/ioctl32.c
.
.
.
patching file mm/Makefile
patching file mm/filemap.c
patching file mm/mempool.c
patching file mm/vmalloc.c
[root@srv-1 linux-2.4.27]# 

The patch appears to work OK with 2.4.27, but notice that we are being a bit adventurous. Notice that another option for device-mapper support shows up in the kernel configuration menu:

[root@srv-1 linux-2.4.27]# make menuconfig
Linux Kernel v2.4.27 Configuration
Multi-device support (RAID and LVM) 
[*] Multiple devices driver support (RAID and LVM)
[*]  RAID support                    
[ ]   Linear (append) mode          
[ ]   RAID-0 (striping) mode       
[*]   RAID-1 (mirroring) mode     
[ ]   RAID-4/RAID-5 mode         
[ ]   Multipath I/O support     
[*]  Logical volume manager (LVM) support  
[*]  Device-mapper support (NEW)          
[*]   Mirror (RAID-1) support            

We just need to recompile our kernel, now, to enable the device-mapper support:

[root@srv-1 linux-2.4.27]# make dep clean bzImage

After we install and boot from this kernel, we should be able to remove /dev/sde from our volume group, which we do in this article.

There are six articles in this series:
Setting Up Logical Volume Manager
Extending a Logical Volume
Shrinking a Logical Volume With LVM
Adding a RAID1 Device to a Volume With LVM
Upgrading LVM To Version 2 and Patching The Linux Kernel
Finish Conversion And Expansion to Two RAID1 Devices With LVM




Please read our Terms of Use
Microsoft, Windows, Windows XP, Windows 2003, Windows 2000, and NT are either trademarks or registered trademarks of Microsoft Corporation. NetAdminTools.com is not affiliated with Microsoft Corporation. Linux is a registered trademark of Linus Torvalds, and refers to the Linux kernel. The operating system of most distributions that contain the Linux kernel is GNU/Linux. All logos and trademarks in this site are property of their respective owner. Copyright 1997-2008 NetAdminTools.com

Created by:
MCJ
MCJ CMS