# Sudden LVM problem in initrd ("not found") [SOLVED]

## Loibisch

I have been running an lvm2 setup from my initrd for quite a while now. Recently I decided to update the initrd using the script I made to originally create it and voila, the Laptop refused to boot.

The error I#m receiving is plain and simple:

```
/init: line 21: vgchange: not found
```

If I drop to a rescue shell and try to execute vgchange (which is a symlink to the lvm binary, statically compiled of course) I get the same error message "not found". If I try to execute any busybox command or even mdadm/cryptsetup it works just fine. It's just lvm2 that's broken. I'm using the latest version available in portage. (2.02.51-r2).

Here is my init script:

```
#!/bin/sh

#mount pseudo filesystems

mount -t proc proc /proc

mount -t sysfs sysfs /sys

CMDLINE=`cat /proc/cmdline`

#sleep 3

#load keyboard map

loadkmap < /etc/kmap-de

#raid

#mdadm --assemble /dev/md2 /dev/sda2 /dev/sdb2

#dm-crypt

#cryptsetup luksOpen /dev/md2 vault

#lvm

vgchange -ay vertex

#try to resume (uswsusp)

resume

#root filesystem

mount -r /dev/mapper/vertex-root /newroot

#restore sanity

umount /proc

umount /sys

#root switch

exec /bin/busybox switch_root /newroot /sbin/init ${CMDLINE}
```

My mkinitrd script:

```
#!/bin/sh

cd /usr/src/initrd

rm -rf image

#create image directory

mkdir -v image

cd image

#create a few directories

mkdir -v bin dev dev/mapper dev/vc etc newroot proc sbin sys

cp -v /bin/busybox /sbin/cryptsetup /sbin/lvm /sbin/mdadm /usr/lib64/suspend/resume bin

#devices

cp -a /dev/console /dev/sda2 /dev/null /dev/urandom /dev/snapshot dev

#cp -a /dev/tty1 /dev/fb0 /dev/dri/card0 dev

cp /etc/suspend.conf etc

#create symlinks

ln -vs busybox bin/cat

ln -vs busybox bin/loadkmap

ln -vs busybox bin/mount

ln -vs busybox bin/sh

ln -vs busybox bin/switch_root

ln -vs busybox bin/umount

ln -vs lvm bin/vgchange

ln -vs ../console dev/vc/0

busybox dumpkmap > etc/kmap-de

cp -v ../init .

echo -n "Generating initrd..."

find . | cpio -o -H newc | gzip -9 > /boot/initramfs.gz
```

Does anybody have any idea where this is coming from? Using the same scripts I used to boot just fine on this machine. Thanks for any help.Last edited by Loibisch on Wed Nov 11, 2009 4:50 pm; edited 1 time in total

----------

## Loibisch

anyone?   :Sad: 

----------

## richard.scott

there's been recent changes to udev, device-mapper and lvm2.

perhaps you need to re-emerge udev, or rebuild your initrd image with the latest lvm2 binarys?

----------

## Loibisch

Ok, I found the problem. I must have missed this post-upgrade lvm2 message:

```
 * Warning, we no longer overwrite /sbin/lvm and /sbin/dmsetup with

 * their static versions. If you need the static binaries,         

 * you must append .static the filename!                           

[...]
```

So basically, previously lvm2 compiled with the "static" useflag would put a static binary at "/sbin/lvm".

Newer versions put a dynamic version at "/sbin/lvm" and the static version at "/sbin/lvm.static".

Slight adaptation of the mkinitrd script to use the ".static" versions instead fixed the problem.

Took me a while to figure out that "small change"...

----------

## stolar

Hello,

Loibisch, could You please describe this 'slight adaptation'? :Smile: 

Cheers!

----------

## Loibisch

Sorry, didn't check this topic in a while. Here is the adapted mkinitrd script with the changed lines highlighted. Essentially all you need to do is copy the ".static" version of lvm instead:

New mkinitrd:

 *Quote:*   

> #!/bin/sh
> 
> cd /usr/src/initrd
> 
> rm -rf image
> ...

 

----------

