LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 09-10-2006, 05:48 AM   #1
Zmyrgel
Senior Member
 
Registered: Dec 2005
Location: Finland
Distribution: Slackware, CentOS, RHEL, OpenBSD
Posts: 1,006

Rep: Reputation: 37
Encrypted LVM needs a initrd


Hi,

Just finished installing slackware-current to encrypted LVM partition. Only thing is that I can't get this to boot

I need some aid with the initrd image creation. I found this nice thing called yaird in the web but as it was designed to Debian it won't work for Slack straight for box. Only which needs to change for it to work for Slack is the configuration file below otherwise it should work but after compiling the program and running it, it gave the following:


Code:
root@livecd:/# yaird -f=cramfs -c=/usr/etc/yaird/Slackware.cfg -o=/boot/oma.img kernel_version=2.6.13
Can't locate HTML/Template.pm in @INC (@INC contains: /usr/lib/yaird/perl /usr/lib/perl5/5.8.8/i486-linux /usr/lib/perl5/5.8.8 /usr/lib/perl5/site_perl/5.8.8/i486-linux /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl .) at /usr/lib/yaird/perl/ActionList.pm line 40.
BEGIN failed--compilation aborted at /usr/lib/yaird/perl/ActionList.pm line 40.
Compilation failed in require at /usr/lib/yaird/perl/ModProbe.pm line 90.
BEGIN failed--compilation aborted at /usr/lib/yaird/perl/ModProbe.pm line 90.
Compilation failed in require at /usr/lib/yaird/perl/Plan.pm line 29.
BEGIN failed--compilation aborted at /usr/lib/yaird/perl/Plan.pm line 29.
Compilation failed in require at /usr/sbin/yaird line 27.
BEGIN failed--compilation aborted at /usr/sbin/yaird line 27.
root@livecd:/#
Some forum in the net suggested to add the kernel_version option but that didn't change anything in the above. I have some suspicion that the above might be related to perl but I don't know how.

Also, could someone more knowledgeble check the following configuration file if it would work with slackware:

Code:
#
# Template -- for translation general intentions to exact initrd layout
#   Copyright (C) 2005  Erik van Konijnenburg, Marco Amadori
#
#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
#
# These templates define the translation from general intentions in the
# plan to exact lists of files and script fragments to be included 
# on the initrd image.  Templates are indexed by an action name, and include:
# 	- files to be copied from current system to initrd;
# 	  often executables.
# 	- directories to be created
# 	- fragments to be appended to scripts on the image,
# 	  these are in a hash from script name to script content.
#
# Everything is processed by HTML::Template before being added to the
# image: script fragments, but also file names and script names.
# Leading spaces are dropped from template lines.
#
# If you want to implement busybox support, this is the place to do it.
#
# Obviously, the template names and the attributes used in the template
# should match what is provided by the planner.
#
#

TEMPLATE SET
	TEMPLATE prologue
	BEGIN
		# In principle, we don't want device files on the initrd
		# image: device numbers can change between kernels.
		# Instead, create device files at boot time based on info
		# in sysfs.  However, /dev/null and /dev/console are needed
		# to mount sysfs.
		FILE "/dev/null"
		FILE "/dev/console"
		FILE "/bin/dash"
		FILE "/bin/cat"
		FILE "/bin/mkdir"
		FILE "/bin/mount"
		FILE "/bin/umount"
		FILE "/bin/mknod"
		FILE "/bin/sleep"
		FILE "<TMPL_VAR NAME=auxDir>/run_init"

		DIRECTORY "/mnt"
		DIRECTORY "/proc"
		DIRECTORY "/sys"
		DIRECTORY "/dev"
		DIRECTORY "/etc"
		DIRECTORY "/var"

		#
		# We can provide debugging opportunities in the
		# initramfs image; the question is when and how
		# to enable this.  Consider two types of user:
		# - a developer, working on the template
		# - an end user, who has a boot problem with
		#   an image that was generated automatically
		#   after installing a new distribution kernel.
		#
		# The developer can simply add debugging code
		# to the template.
		# For the end user, adding an option to the kernel
		# command line is easier to enable debugging
		# than rebuilding the boot image with special
		# options or a modified configuration file.
		#
		# For this reason, we won't provide a template
		# parameter to control debugging, instead we
		# interpret a new kernel command line parameter:
		# ydebug.
		#
		SCRIPT "/init"
		BEGIN
			!#!/bin/dash
			!#
			!# Generator version: yaird <TMPL_VAR NAME=appVersion>.
			!# Kernel version: <TMPL_VAR NAME=version>.
			!#
			!INIT_DEBUG=
			!if [ "$INIT_DEBUG" != "" ]
			!then
			!	set -x
			!fi
			!
			!#
			!#  Utility functions
			!#
			!mksymdev () {
			!	devfile="$1"
			!	sysfile="$2"
			!	cb="$3"
			!	devpair=$(/bin/cat "$sysfile")
			!	for delay in 1 2 4 8 16
			!	do
			!		if [ "$devpair" = "" ]
			!		then
			!			echo "Waiting $delay seconds for $sysfile to show up"
			!			sleep $delay
			!		fi
			!		devpair=$(/bin/cat "$sysfile")
			!	done
			!
			!	if [ "$devpair" = "" ]
			!	then
			!		echo "Device $sysfile seems to be down."
			!		echo "Debugging opportunity, type ^D to continue."
			!		/bin/dash
			!	fi
			!
			!	maj=${devpair%:*}
			!	min=${devpair#*:}
			!	/bin/mknod "$devfile" $cb $maj $min
			!}
			!mkcdev () {
			!	mksymdev "$1" "/sys/class/$2/dev" c
			!}
			!mkbdev () {
			!	mksymdev "$1" "/sys/block/$2/dev" b
			!}
			!
			!switchroot () {
			!	if [ "$INIT_DEBUG" != "" ]
			!	then
			!		echo "Debugging opportunity, ^D to continue."
			!		/bin/dash
			!	fi
			!
			!	echo "Switching root ..."
			!	/bin/umount -n /sys
			!	/bin/umount -n /proc
			!	exec <TMPL_VAR NAME=auxDir>/run_init \
			!		/mnt $init "$@"
			!}
			!
			!#
			!# Setting up mounts
			!#
			!/bin/mount -nt sysfs sysfs /sys
			!/bin/mount -nt proc proc /proc
			!#
			!# We don't set up a separate /dev file system,
			!# since rootfs is writable without problem.
			!#
			!
			!# /dev/tty is needed for eg cryptsetup.
			!mkcdev /dev/tty tty/tty
			!
			!#
			!# Command line processing
			!# init - first proc to start on next root
			!# root - to be done: how should it relate
			!#	to file system selection?
			!# ro,rw - mount root read-only or read-write.
			!# 	This is like a mount -r; it overrules
			!# 	a -o rw.
			!# noresume, resume - to be done
			!# ide - options for module ide_core.
			!# 	need a way to append these to proper
			!# 	module.  do a check on module name
			!# 	in insmod template?
			!# ip=, nfsaddrs=, nfsroot= - support NFS boot
			!#
			!ro=-r
			!ip=
			!nfsroot=
			!init=/sbin/init
			!for i in $(cat /proc/cmdline)
			!do
			!	case "$i" in
			!	init=*)
			!		init=${i#init=}
			!		;;
			!	ro)
			!		ro=-r
			!		;;
			!	rw)
			!		ro=
			!		;;
			!	ip=*|nfsaddrs=*)
			!		ip="$ip $i"
			!		;;
			!	nfsroot=*)
			!		nfsroot="$i"
			!		;;
			!	ydebug)
			!		INIT_DEBUG=yes
			!	esac
			!done
			!if [ "$INIT_DEBUG" != "" ]
			!then
			!	set -x
			!fi
		END SCRIPT
	END TEMPLATE


	TEMPLATE insmod
	BEGIN
		FILE "<TMPL_VAR NAME=target>"
		FILE "/sbin/insmod"

		# optionList may be undef
		# and already is suitably escaped.
		SCRIPT "/init"
		BEGIN
			!/sbin/insmod '<TMPL_VAR NAME=target>' <TMPL_VAR NAME=optionList>
		END SCRIPT
	END TEMPLATE


	TEMPLATE mkbdev
	BEGIN
		SCRIPT "/init"
		BEGIN
			!mkbdev '<TMPL_VAR NAME=target>' '<TMPL_VAR NAME=sysname>'
		END SCRIPT
	END TEMPLATE



	TEMPLATE evms_activate
	BEGIN
		#
		# Note that evms_active will not do a single device,
		# but everything it encounters.
		#
		TREE "/lib/evms/<TMPL_VAR NAME=evmsVersion>"
		FILE "/sbin/evms_activate"
		FILE "/etc/evms.conf"
		SCRIPT "/init"
		BEGIN
			!# activate for <TMPL_VAR NAME=target>
			!if [ ! -c /dev/evms ]
			!then
			!	/bin/mkdir /dev/evms
			!fi
			!/sbin/evms_activate 
		END SCRIPT
	END TEMPLATE

	#
	# We cannot make mapper/control any earlier,
	# since dm-mod needs to be loaded to be able
	# to determine devno.
	#
	# Hmm. cf debian bug 335315.  The config file is needed
	# on machines where an LVM volume is on an encrypted
	# partition.  However, requiring this might get in
	# the way of machines that do not have a config file.
	#
	TEMPLATE vgchange
	BEGIN
		FILE "/etc/lvm/lvm.conf"
		#FILE "/lib/lvm-200/vgchange"
		FILE "/sbin/vgchange"
		SCRIPT "/init"
		BEGIN
			!if [ ! -c /dev/mapper/control ]
			!then
			!	/bin/mkdir /dev/mapper
			!	mkcdev /dev/mapper/control misc/device-mapper
			!fi
			!/sbin/vgchange -a y '<TMPL_VAR NAME=target>'
		END SCRIPT
	END TEMPLATE

	#
	# NOTE: mdadm can operate without knowledge
	# of device numbers; it will assign an unused
	# one to the new device.  Thus you could have
	# device name /dev/md/boot that is stable,
	# regardless of which other raid devices are
	# operational.  However, debian installer
	# consistently uses device names like /dev/md0,
	# where the name depends on earlier minors
	# that happen to have been assigned.
	# To work around this problem, we forego
	# the --auto option, and mknod the device
	# before putting an md under it.  Better hope
	# the major number is not going to change ...
	#
	TEMPLATE mdadm
	BEGIN
		FILE "/sbin/mdadm"
		SCRIPT "/init"
		BEGIN
			!mknod <TMPL_VAR NAME=target> b <TMPL_VAR NAME=major> <TMPL_VAR NAME=minor>
			!mdadm --assemble <TMPL_VAR NAME=target> --uuid <TMPL_VAR NAME=uuid> \
			!	<TMPL_LOOP NAME=components> <TMPL_VAR NAME=dev></TMPL_LOOP>
		END SCRIPT
	END TEMPLATE


	#
	# cryptsetup arguments:
	# - target
	# - cipher
	# - keySize (always there, 0 for NULL crypto)
	# - hash (hashname or undef)
	# - src
	# - verify (yes or undef)
	#
	# A loop around 'cryptsetup --verify' can help detect
	# and correct typo's in the crypt password.
	#
	TEMPLATE cryptsetup
	BEGIN
		FILE "/sbin/cryptsetup"
		SCRIPT "/init"
		BEGIN
			!DOCRYPT=1
			!while [ "$DOCRYPT" != "0" ]
			!do
			!	/sbin/cryptsetup \
			!		-c <TMPL_VAR NAME=cipher> \
			!		-s <TMPL_VAR NAME=keySize> \
			!		<TMPL_IF NAME=hash> \
			!			-h '<TMPL_VAR NAME=hash>' \
			!		</TMPL_IF> \
			!		<TMPL_IF NAME=verify>-y </TMPL_IF> \
			!		create '<TMPL_VAR NAME=target>' \
			!		'<TMPL_VAR NAME=src>'
			!	DOCRYPT=$?
			!done
		END SCRIPT
	END TEMPLATE


	#
	# cryptsetup arguments:
	# - target
	# - src
	# - verify (yes or undef)
	#
	# A loop around 'cryptsetup --verify' can help detect
	# and correct typo's in the crypt password.
	#
	TEMPLATE cryptsetup_luks
	BEGIN
		FILE "/sbin/cryptsetup"
		SCRIPT "/init"
		BEGIN
			!DOCRYPT=1
			!while [ "$DOCRYPT" != "0" ]
			!do
			!	/sbin/cryptsetup \
			!		<TMPL_IF NAME=verify>-y </TMPL_IF> \
			!		luksOpen '<TMPL_VAR NAME=src>' \
			!		'<TMPL_VAR NAME=target>'
			!	DOCRYPT=$?
			!done
		END SCRIPT
	END TEMPLATE


	#
	# NOTE: honouring the kernel cmdline option ro,rw
	# is very nice, but...  If you have an ext3 in a
	# file loopback-mounted from vfat, it's unlikely
	# that a remount rw of root will also make the
	# underlying vfat read-write.  Underlying filesystems
	# should ignore the kernel ro/rw option; we
	# have an attribute isRoot that's defined iff
	# this is the real root.
	#
	# always -n, since we dont have writable /etc/mtab.
	#
	TEMPLATE mount
	BEGIN
		SCRIPT "/init"
		BEGIN
			!/bin/mount -n \
			!	<TMPL_IF NAME=isRoot>$ro</TMPL_IF> \
			!	-t <TMPL_VAR NAME=fsType> \
			!	<TMPL_VAR NAME=options> \
			!	'<TMPL_VAR NAME=device>' \
			!	'<TMPL_VAR NAME=target>'
		END SCRIPT
	END TEMPLATE

	TEMPLATE nfsstart
	BEGIN
		FILE "<TMPL_VAR NAME=auxDir>/trynfs"
		SCRIPT "/init"
		BEGIN
			!if [ "$ip" != "" ]
			!then
			!	<TMPL_VAR NAME=auxDir>/trynfs $ip $nfsroot /mnt
			!	switchroot "$@"
			!fi
		END SCRIPT
	END TEMPLATE

	TEMPLATE postlude
	BEGIN
		SCRIPT "/init"
		BEGIN
			!switchroot "$@"
		END SCRIPT
	END TEMPLATE
END TEMPLATE SET
 
Old 09-10-2006, 06:44 AM   #2
Zmyrgel
Senior Member
 
Registered: Dec 2005
Location: Finland
Distribution: Slackware, CentOS, RHEL, OpenBSD
Posts: 1,006

Original Poster
Rep: Reputation: 37
I found out that the error is caused by missing perl modules. Here's how to install them if you have similar errors

Code:
perl -MCPAN -e 'install HTML::Template'
perl -MCPAN -e 'install Parse::RecDescent'
Though now when I run the yaird it gives me odd error:

Code:
yaird error: illegal character in output file name (fatal)
I've tried it with /boot/initrd.gz, /boot/init, /boot/0, /boot/baa.img but all give same error.
 
Old 09-10-2006, 07:10 AM   #3
Zmyrgel
Senior Member
 
Registered: Dec 2005
Location: Finland
Distribution: Slackware, CentOS, RHEL, OpenBSD
Posts: 1,006

Original Poster
Rep: Reputation: 37
Ok, now the yaird works to the point it detects my kernel and complains about it.

How can I change kernels? I'm running currently Gentoo 2006.1 livecd and I use 2.6.13 for my slack. I can't boot that kernel as I need the initrd before that. I could boot with test26.s and mount the partitions but would that work?

Is there a easier way to switch kernels? I am chrooted to my slack now.
 
Old 09-10-2006, 09:46 AM   #4
Zmyrgel
Senior Member
 
Registered: Dec 2005
Location: Finland
Distribution: Slackware, CentOS, RHEL, OpenBSD
Posts: 1,006

Original Poster
Rep: Reputation: 37
Okay, me again keeping my monolog here...

The above error vanished after I started to use --output instead of -o, a bug perhaps.

But next dilemma is this. I booted with slackware cd and installed small version of slackware and then opened my crypted drive and chrooted there. After this I tried to run the yaird and after tinkering modules/blacklist got it to point where it says:
Code:
yaird error: block device: "/dev/vg-crypt/root" not available [/etc/fstab(6)]
I don't recall the exact error but something as the above it was.

I was chrooting to that very partition during the yaird creation, should I make it in the original slackware install drive and or what?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Possible to change non-LVM to LVM? darthfoolish Linux - Software 2 08-01-2008 03:47 AM
creating initrd to boot from LVM jcai Linux - General 3 06-12-2006 01:04 PM
Hacking the initrd for encrypted partitions sonicbuddha Linux - Security 2 12-20-2005 08:23 PM
encrypted IM? jbeiter Linux - Software 2 12-01-2004 02:41 PM
Encrypted FS? linuxtesting2 Linux - Security 4 04-05-2004 04:08 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 10:28 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration