linux-lvm.redhat.com archive mirror
 help / color / mirror / Atom feed
* [linux-lvm] lvmcreate_initrd with SuSE 6.3?
@ 2000-04-09 23:34 Shaw, Marco
  0 siblings, 0 replies; 2+ messages in thread
From: Shaw, Marco @ 2000-04-09 23:34 UTC (permalink / raw)
  To: linux-lvm

Trying to setup my root fs as a LVM.  Was reading up on lvmcreate_initrd,
and my SuSE 6.3 system has the man page, but I searched my entire system,
and the command itself cannot be found.

I imagine I could create it myself with the appropriate libraries...

Any ideas?
Marco

^ permalink raw reply	[flat|nested] 2+ messages in thread

* RE: [linux-lvm] lvmcreate_initrd with SuSE 6.3?
@ 2000-04-10 10:54 Shaw, Marco
  0 siblings, 0 replies; 2+ messages in thread
From: Shaw, Marco @ 2000-04-10 10:54 UTC (permalink / raw)
  To: linux-lvm

[-- Attachment #1: Type: text/plain, Size: 682 bytes --]

Can someone provide me with this script?  Or tell me if this is the latest
one (don't know if attachment will work since I'm using Outlook...)?

 <<lvmcreate_initrd-19991114.txt>> 

Thanks,
Marco

> -----Original Message-----
> From:	Shaw, Marco [SMTP:marco.shaw@nbtel.nb.ca]
> Sent:	April 9, 2000 8:35 PM
> To:	linux-lvm@msede.com
> Subject:	[linux-lvm] lvmcreate_initrd with SuSE 6.3?
> 
> Trying to setup my root fs as a LVM.  Was reading up on lvmcreate_initrd,
> and my SuSE 6.3 system has the man page, but I searched my entire system,
> and the command itself cannot be found.
> 
> I imagine I could create it myself with the appropriate libraries...
> 
> Any ideas?
> Marco

[-- Attachment #2: lvmcreate_initrd-19991114.txt --]
[-- Type: text/plain, Size: 8001 bytes --]

#!/bin/sh
#=============================================================================
#
# Warning! This is definitely NOT the original version!!!
#
# DONTCHA USE THIS SCRIPT EXCEPT ON OWN RISK!!!
#
# Read the following sentence 10 times:
#
#     I have been warned.
#
#                                                       1999-11-12/Ulf Bartelt
#                                                                   ulf@twc.de
#=============================================================================
#
#  Copyright (C) 1997 - 1999  Heinz Mauelshagen, Germany
# 
#  June 1999
# 
#  LVM 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, or (at your option)
#  any later version.
#  
#  LVM 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 LVM; see the file COPYING.  If not, write to
#  the Free Software Foundation, 59 Temple Place - Suite 330,
#  Boston, MA 02111-1307, USA. 
# 

#
# make it devfs clean
#

cmd=`basename $0`

#
# 19991112/UBa:
#	I decided to generate the image using a loop mount instead of a
#	ramdisk device and not to put initrd into /boot automagically, so
#	this has to be done manually now not forgetting to rerun lilo or
#	whatever bootloader you're using...
#
DEVRAM=/tmp/initrd
INITRD=/tmp/initrd.gz
INITRDSIZE=8192
#
# 19991113/UBa:
#	added grep
# 19991112/UBa:
#	added mount and umount
#	question: what for did Heinz include rm in this list?
#
INITRDFILES="/bin/grep /bin/mount /bin/umount /sbin/modprobe /sbin/vgchange /sbin/vgscan /bin/bash /bin/sh /bin/rm /sbin/insmod /dev/* /lib/modules/`uname -r`/modules.dep /lib/modules/`uname -r`/block/lvm.o"
TMP=/tmp/mnt.$$

trap "
  cd /
  umount $DEVRAM
  rm -rf $TMP
  echo -e 'Bye bye...\n'
" 1 2 3 15


function create_fstab {
   echo "
/dev/ram        /                         ext2            defaults   1   0
none            /proc                     proc            defaults   0   0
   " > etc/fstab
   chmod 644 etc/fstab
}

#
# 19991113/UBa:
#	added scanning /proc/partitions for vg00/root to get major and minor
#	of root device
# 19991112/UBa:
#	added mounting/umounting proc to echo a hardcoded value of
#	major*256+minor of root device into /proc/sys/kernel/real-root-dev
#
function create_linuxrc {
   echo "\
#!/bin/sh
/bin/mount /proc
/sbin/insmod lvm

/sbin/vgscan
/sbin/vgchange -a y

/bin/grep vg00/root /proc/partitions | (
   read major minor blocks name
   if [ \$name == vg00/root ] ; then
      echo found vg00/root with major/minor = \$major/\$minor
      echo \$((\$major*256+\$minor)) > /proc/sys/kernel/real-root-dev
   else
      echo error, cannot find vg00/root in /proc/partitions
   fi
)

/bin/umount /proc
" > linuxrc
   chmod 555 linuxrc
}

#
# Main
#
# 19991112/UBa:
#	Heinz shall not be blamed if THIS script fails, so it has to be
#	echoed that this IS NOT the original version
#
echo -e "\nLogical Volume Manager 0.7 by Heinz Mauelshagen  01/07/1999\n"
echo -e "$cmd -- (hack warning: this script is modified by ulf@twc.de)\n"
echo -e "$cmd -- this script creates a LVM initial ram disk in $INITRD\n"

#
# 19991112/UBa:
#	I wanted not to use a ramdisk to create initrd, so I changed this
#	stuff to do it on a file.
#	Additionally the original script used -N 4096 option of mke2fs to set
#	the number of inodes. This option is not understood by mke2fs of
#	Debian-2.1, so using -i 2048 on a 8192 blocks filesystem should do
#	the same...
#
echo "$cmd -- making a file of $INITRDSIZE blocks in $DEVRAM"
dd if=/dev/zero of=$DEVRAM bs=1024 count=$INITRDSIZE >/dev/null 2>&1
if [ $? -ne 0 ]; then
   echo -e "$cmd -- ERROR making file for initrd image\n"
   exit 1
fi
echo "$cmd -- making filesystem on $DEVRAM"
echo y | mke2fs -m 0 -i 2048 $DEVRAM $INITRDSIZE >/dev/null 2>&1
if [ $? -ne 0 ]; then
   echo -e "$cmd -- ERROR making filesystem on $DEVRAM\n"
   exit 1
fi

mkdir -p $TMP/ram >/dev/null 2>&1
if [ $? -ne 0 ]; then
   echo -e "$cmd -- ERROR making $TMP/ram\n"
   exit 1
fi

#
# 19991112/UBa:
#	changed to mount the image via loop
#
echo "$cmd -- mounting ram filesystem"
mount -o loop -t ext2 $DEVRAM $TMP/ram >/dev/null 2>&1
if [ $? -ne 0 ]; then
   echo -e "$cmd -- ERROR mounting $DEVRAM on $TMP/ram\n"
   exit 1
fi

#
# 19991112/UBa:
#	added mkdir proc, as I need proc to be mounted for scanning for
#	vg00/root in /proc/partitions, calculate major*256+minor of it and
#	echo this value to /proc/sys/kernel/ral-root-dev.
#
cd $TMP/ram
[ ! -d etc ] && mkdir etc
[ ! -d proc ] && mkdir proc

#
# create new conf.modules to avoid kmod complaining about nonexsisting modules.
#
echo "$cmd -- creating etc/conf.modules"
i=0
while [ $i -lt 256 ]; do
   echo "alias	block-major-$i	off"
   echo "alias	char-major-$i	off"
   let i=i+1
done > etc/conf.modules

#
# 19991113/UBa:
#	I got this one as module but not in this initrd...
#	aliasing ide-cd to off suppresses the lines complaining a missing
#	ide-cd module. The lines complaining no driver being present still
#	remain.
#
echo "alias  ide-cd          off" >> etc/conf.modules

# to ensure, that modprobe doesn complain about timestamps
echo "$cmd -- creating new modules.dep"
depmod -a >/dev/null 2>&1
if [ $? -ne 0 ]; then
   echo -e "$cmd -- ERROR depmod\n"
   exit 1
fi

# copy necessary files to ram disk
echo "$cmd -- copying files to ram disk"
find $INITRDFILES|cpio -pdm $TMP/ram >/dev/null 2>&1
if [ $? -ne 0 ]; then
   echo -e "$cmd -- ERROR cpio to ram disk\n"
   exit 1
fi

# figure out which actual shared libraries we need in our initrd
#
# 19991112/UBa:
#	@@@TODO:
#		this is incomplete now, as I added some binaries.
#		...but it still generates a working initrd, so I put my
#		hands on this stuff later.
#		Plan: ldd on bin/* sbin/* or file on all files and ldd on
#		those which could need libraries (execs and(?) libs)...
#
echo "$cmd -- figuring out shared libraries"
SHLIBS=`ldd sbin/vg* bin/sh|awk '{if(/=>/){print $3}}'|sort -u 2>/dev/null`
if [ $? -ne 0 ]; then
   echo -e "$cmd -- ERROR figuring out needed shared libraries\n"
   exit 1
fi

echo "$cmd -- copying shared libraries to ram disk"
find $SHLIBS|cpio -Lpdm $TMP/ram >/dev/null 2>&1
if [ $? -ne 0 ]; then
   echo -e "$cmd -- ERROR copying needed shared libraries to ram disk\n"
   exit 1
fi

echo "$cmd -- creating linuxrc"
create_linuxrc >/dev/null 2>&1
if [ $? -ne 0 ]; then
   echo -e "$cmd -- ERROR creating linuxrc\n"
   exit 1
fi

echo "$cmd -- creating etc/fstab"
create_fstab >/dev/null 2>&1
if [ $? -ne 0 ]; then
   echo -e "$cmd -- ERROR creating etc/fstab\n"
   exit 1
fi

cd /
echo "$cmd -- ummounting ram disk"
umount $DEVRAM
if [ $? -ne 0 ]; then
   echo -e "$cmd -- ERROR umounting $DEVRAM\n"
   exit 1
fi

#
# 19991114/UBa:
#	cleanup
#
echo "$cmd -- removing temporary mount point"
rm -rf $TMP
if [ $? -ne 0 ]; then
   echo -e "$cmd -- ERROR removing temporary mount point $TMP\n"
   exit 1
fi

#
# 19991114/UBa:
#	added reminder to manually put the crated initrd to where it is needed.
#
echo "$cmd -- creating compressed initrd in $INITRD"
echo "$cmd -- uncompressed $DEVRAM will NOT automagically be removed"
gzip -9 < $DEVRAM > $INITRD 2>/dev/null
if [ $? -ne 0 ]; then
   echo -e "$cmd -- ERROR creating $INITRD\n"
   exit 1
else
   echo "$cmd -- sucessfully created $INITRD"
   echo "$cmd -- this image is NOT automagically activated."
   echo "$cmd -- $INITRD sure is not the path where your bootloader"
   echo "$cmd -- expects it."
fi

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2000-04-10 10:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-04-09 23:34 [linux-lvm] lvmcreate_initrd with SuSE 6.3? Shaw, Marco
2000-04-10 10:54 Shaw, Marco

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).