Gentoo Wiki ArchivesGentoo Wiki

HOWTO_Install_Gentoo_with_NVRAID_using_dmraid/dmraidinitrd

Updated dmraidinitrd mentioned in HOWTO Install Gentoo with NVRAID using dmraid:
busybox updated to 1.2.1 (this is major change because busybox changed configuration scheme)
device-mapper is now 1.02.09
dmraid is now 1.0.0.rc10

#!/bin/sh
# Gerte Hoogewerf <gerte at nieuwenborg.nl>
# Released under the GNU General Public License version 2
# http://tienstra4.flatnet.tudelft.nl/~gerte/gen2dmraid/
# Gentoo-ers: use Genkernel!

#changing this values might involve editing make_busybox()
BUSYBOX_URI_PREFIX="http://www.busybox.net/downloads/"
BUSYBOX_TARBALL="busybox-1.2.2.tar.bz2"
BUSYBOX_DIR="busybox-1.2.2"

#changing this values might involve editing make_devicemapper()
DEVICEMAPPER_URI_PREFIX="ftp://sources.redhat.com/pub/dm/"
DEVICEMAPPER_TARBALL="device-mapper.1.02.12.tgz"
DEVICEMAPPER_DIR="device-mapper.1.02.12"

#changing this values might involve editing make_dmraid()
#please, don't use older versions of dmraid with this version of dmraidinitrd
DMRAID_URI_PREFIX="http://people.redhat.com/~heinzm/sw/dmraid/src/"
DMRAID_TARBALL="dmraid-1.0.0.rc13.tar.bz2"
DMRAID_DIR="dmraid/1.0.0.rc13"

#Download directory (an existing one is allowed)
#DISTFILES_DIR="/tmp/download"
DISTFILES_DIR="/usr/portage/distfiles"

#Temporary directory (must not already exist)
TMPDIR="/tmp/initrd"

#Tweak this one when having "no space left on device" errors
BLOCKS="2048"

#Dmraid depends on the device-mapper userspace library
#Leave this setting to "0" if you want this script to compile it.
DEVICEMAPPER_INSTALLED="0"

trap "die" SIGINT SIGQUIT

usage() {
	cat <<EOF
dmraidinitrd creates a compressed initial ramdisk containing a static dmraid binary.
Syntax: dmraidinitrd <linuxrcscript> <targetfilename>

EOF
}

die() {
	#echo 'Cleaning up...'
	umount ${TMPDIR}/tmp 2> /dev/null || true
	#rm -rf ${TMPDIR}
	echo $1
	exit 1
}

fetch_busybox() {
	if [ ! -e ${DISTFILES_DIR}/${BUSYBOX_TARBALL} ]
	then
		( cd ${DISTFILES_DIR}; wget ${BUSYBOX_URI_PREFIX}${BUSYBOX_TARBALL} )
	fi
}

fetch_dmraid() {
	if [ ! -e ${DISTFILES_DIR}/${DMRAID_TARBALL} ]
	then
		( cd ${DISTFILES_DIR}; wget ${DMRAID_URI_PREFIX}${DMRAID_TARBALL} )
	fi
}

fetch_devicemapper() {
	if [ ! -e ${DISTFILES_DIR}/${DEVICEMAPPER_TARBALL} ]
	then
		( cd ${DISTFILES_DIR}; wget ${DEVICEMAPPER_URI_PREFIX}${DEVICEMAPPER_TARBALL} )
	fi
}

make_busybox() {
	echo 'Making busybox...'
	(cd $TMPDIR; \
	tar -xjf ${DISTFILES_DIR}/${BUSYBOX_TARBALL}; \
	cd ${BUSYBOX_DIR}; \
	make allnoconfig; \
	cp .config .config.old; \
#	INSMOD not needed in provided linuxrc and causing problems on x86_64
#	GZIP is enabled by default but not compiling with gcc4. It's not
#	needed so I'm disabling it here.
	sed -e "s:^# \\(CONFIG_STATIC\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_BASENAME\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_CAT\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_CHGRP\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_CHMOD\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_CHOWN\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_CHROOT\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_CP\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_CUT\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_DATE\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_DF\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_DIRNAME\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_ECHO\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_ENV\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_EXPR\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_FALSE\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_HEAD\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_ID\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_LN\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_LS\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_FEATURE_LS_COLOR_IS_DEFAULT\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_MKDIR\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_MKFIFO\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_MKNOD\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_PWD\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_RM\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_RMDIR\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_TEST\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_TR\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_TRUE\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_UNAME\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_WC\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_WHO\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_WHOAMI\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_YES\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_CHVT\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_LOADKMAP\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_CLEAR\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_SED\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_FIND\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_GREP\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_XARGS\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_INSMOD\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_FEATURE_INSMOD_VERSION_CHECKING\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_FEATURE_INSMOD_KSYMOOPS_SYMBOLS\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_FEATURE_INSMOD_LOADINKMEM\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_FEATURE_INSMOD_LOAD_MAP\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_FEATURE_INSMOD_LOAD_MAP_FULL\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_RMMOD\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_LSMOD\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_FEATURE_LSMOD_PRETTY_2_6_OUTPUT\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_MODPROBE\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_FEATURE_MODPROBE_MULTIPLE_OPTIONS\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_FEATURE_CHECK_TAINTED_MODULE\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_FEATURE_2_6_MODULES\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_FEATURE_QUERY_MODULE_INTERFACE\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_DMESG\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_LOSETUP\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_MKSWAP\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_MOUNT\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_PIVOT_ROOT\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_CONFIG_SWAPONOFF\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_SWITCH_ROOT\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_UMOUNT\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_FEATURE_UMOUNT_ALL\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_FEATURE_MOUNT_LOOP\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_FEATURE_MTAB_SUPPORT\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_EJECT\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_LESS\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_HDPARM\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_FEATURE_HDPARM_GET_IDENTITY\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_FEATURE_HDPARM_HDIO_GETSET_DMA\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_MOUNTPOINT\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_TIME\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_HOSTNAME\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_IFCONFIG\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_FEATURE_IFCONFIG_STATUS\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_FEATURE_IFCONFIG_SLIP\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_FEATURE_IFCONFIG_HW\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_FEATURE_IFCONFIG_BROADCAST_PLUS\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_NETSTAT\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_NSLOOKUP\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_PING\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_ROUTE\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_TRACEROUTE\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_FEATURE_TRACEROUTE_VERBOSE\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_FEATURE_TRACEROUTE_SOURCE_ROUTE\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_FEATURE_TRACEROUTE_USE_ICMP\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_FREE\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_KILL\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_KILLALL\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_PIDOF\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_PS\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_FEATURE_PS_WIDE\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_BB_SYSCTL\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_TOP\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_UPTIME\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_FEATURE_SH_IS_ASH\\).*\$:\\1=y:" \
	    -e "s:^\\(CONFIG_FEATURE_SH_IS_NONE\\)=y\$:# \\1 is not set:" \
	    -e "s:^# \\(CONFIG_ASH\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_ASH_ALIAS\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_ASH_MATH_SUPPORT\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_ASH_GETOPTS\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_ASH_BUILTIN_ECHO\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_ASH_BUILTIN_TEST\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_FEATURE_COMMAND_EDITING\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_FEATURE_COMMAND_TAB_COMPLETION\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_FEATURE_COMMAND_USERNAME_COMPLETION\\).*\$:\\1=y:" \
	    -e "s:^# \\(CONFIG_FEATURE_SH_FANCY_PROMPT\\).*\$:\\1=y:" .config.old > .config ; \
	make clean > /dev/null 2>&1; \
	make > /dev/null 2>&1 )
}

make_devicemapper() {
	echo 'Making device-mapper lib...'
	(cd $TMPDIR; \
	tar -zxf ${DISTFILES_DIR}/${DEVICEMAPPER_TARBALL}; \
	cd ${DEVICEMAPPER_DIR}; \
	./configure --enable-static_link --prefix=$TMPDIR/opt/device-mapper >/dev/null 2>&1;\
	make >/dev/null 2>&1;\
	echo "  Making fake install in ${TMPDIR}/opt/device-mapper..."
	make install >/dev/null 2>&1 )
}

make_dmraid() {
	echo 'Making dmraid...'
	(cd $TMPDIR; \
	tar -jxf ${DISTFILES_DIR}/${DMRAID_TARBALL}; \
	cd ${DMRAID_DIR}; \
	./configure --enable-static_link >/dev/null 2>&1; \
#	Don't link dmraid against libselinux.
	sed -i tools/Makefile -e "s|DMRAIDLIBS += -lselinux||g"; \
	if [ ${DEVICEMAPPER_INSTALLED} -eq 0 ]
	then 
		make CC="cc -I ${TMPDIR}/opt/device-mapper/include -L ${TMPDIR}/opt/device-mapper/lib" > /dev/null 2>&1
	else 
		make > /dev/null 2>&1
	fi)
}

create_devices() {
	mknod mem c 1 1
	mknod kmem c 1 2
	mknod null c 1 3
	mknod port c 1 4
	mknod zero c 1 5
	mknod full c 1 7
	mknod random c 1 8
	mknod urandom c 1 9
	mknod tty c 5 0
	mknod ram0 b 1 0
	mknod ram1 b 1 1
	mknod ram2 b 1 2
	mknod ram3 b 1 3
	mknod ram4 b 1 4
	mknod ram5 b 1 5
	mknod ram6 b 1 6
	mknod ram7 b 1 7
	mknod ram8 b 1 8
	mknod ram9 b 1 9
	mknod ram10 b 1 10
	mknod ram11 b 1 11
	mknod ram12 b 1 12
	mknod ram13 b 1 13
	mknod ram14 b 1 14
	mknod ram15 b 1 15
	mknod ram16 b 1 16
	mknod loop0 b 7 0
	mknod loop1 b 7 1
	mknod loop2 b 7 2
	mknod loop3 b 7 3
	mknod loop4 b 7 4
	mknod loop5 b 7 5
	mknod loop6 b 7 6
	mknod loop7 b 7 7
	mknod hda b 3 0
	mknod hda1 b 3 1
	mknod hda2 b 3 2
	mknod hda3 b 3 3
	mknod hda4 b 3 4
	mknod hda5 b 3 5
	mknod hda6 b 3 6
	mknod hda7 b 3 7
	mknod hda8 b 3 8
	mknod hda9 b 3 9
	mknod hda10 b 3 10
	mknod hda11 b 3 11
	mknod hda12 b 3 12
	mknod hda13 b 3 13
	mknod hda14 b 3 14
	mknod hda15 b 3 15
	mknod hda16 b 3 16
	mknod hda17 b 3 17
	mknod hda18 b 3 18
	mknod hda19 b 3 19
	mknod hda20 b 3 20
	mknod hdb b 3 64
	mknod hdb1 b 3 65
	mknod hdb2 b 3 66
	mknod hdb3 b 3 67
	mknod hdb4 b 3 68
	mknod hdb5 b 3 69
	mknod hdb6 b 3 70
	mknod hdb7 b 3 71
	mknod hdb8 b 3 72
	mknod hdb9 b 3 73
	mknod hdb10 b 3 74
	mknod hdb11 b 3 75
	mknod hdb12 b 3 76
	mknod hdb13 b 3 77
	mknod hdb14 b 3 78
	mknod hdb15 b 3 79
	mknod hdb16 b 3 80
	mknod hdb17 b 3 81
	mknod hdb18 b 3 82
	mknod hdb19 b 3 83
	mknod hdb20 b 3 84
	mknod hdc b 22 0
	mknod hdc1 b 22 1
	mknod hdc2 b 22 2
	mknod hdc3 b 22 3
	mknod hdc4 b 22 4
	mknod hdc5 b 22 5
	mknod hdc6 b 22 6
	mknod hdc7 b 22 7
	mknod hdc8 b 22 8
	mknod hdc9 b 22 9
	mknod hdc10 b 22 10
	mknod hdc11 b 22 11
	mknod hdc12 b 22 12
	mknod hdc13 b 22 13
	mknod hdc14 b 22 14
	mknod hdc15 b 22 15
	mknod hdc16 b 22 16
	mknod hdc17 b 22 17
	mknod hdc18 b 22 18
	mknod hdc19 b 22 19
	mknod hdc20 b 22 20
	mknod hdd b 22 64
	mknod hdd1 b 22 65
	mknod hdd2 b 22 66
	mknod hdd3 b 22 67
	mknod hdd4 b 22 68
	mknod hdd5 b 22 69
	mknod hdd6 b 22 70
	mknod hdd7 b 22 71
	mknod hdd8 b 22 72
	mknod hdd9 b 22 73
	mknod hdd10 b 22 74
	mknod hdd11 b 22 75
	mknod hdd12 b 22 76
	mknod hdd13 b 22 77
	mknod hdd14 b 22 78
	mknod hdd15 b 22 79
	mknod hdd16 b 22 80
	mknod hdd17 b 22 81
	mknod hdd18 b 22 82
	mknod hdd19 b 22 83
	mknod hdd20 b 22 84
	mknod hde b 33 0
	mknod hde1 b 33 1
	mknod hde2 b 33 2
	mknod hde3 b 33 3
	mknod hde4 b 33 4
	mknod hde5 b 33 5
	mknod hde6 b 33 6
	mknod hde7 b 33 7
	mknod hde8 b 33 8
	mknod hde9 b 33 9
	mknod hde10 b 33 10
	mknod hde11 b 33 11
	mknod hde12 b 33 12
	mknod hde13 b 33 13
	mknod hde14 b 33 14
	mknod hde15 b 33 15
	mknod hde16 b 33 16
	mknod hde17 b 33 17
	mknod hde18 b 33 18
	mknod hde19 b 33 19
	mknod hde20 b 33 20
	mknod hdf b 33 64
	mknod hdf1 b 33 65
	mknod hdf2 b 33 66
	mknod hdf3 b 33 67
	mknod hdf4 b 33 68
	mknod hdf5 b 33 69
	mknod hdf6 b 33 70
	mknod hdf7 b 33 71
	mknod hdf8 b 33 72
	mknod hdf9 b 33 73
	mknod hdf10 b 33 74
	mknod hdf11 b 33 75
	mknod hdf12 b 33 76
	mknod hdf13 b 33 77
	mknod hdf14 b 33 78
	mknod hdf15 b 33 79
	mknod hdf16 b 33 80
	mknod hdf17 b 33 81
	mknod hdf18 b 33 82
	mknod hdf19 b 33 83
	mknod hdf20 b 33 84
	mknod hdg b 34 0
	mknod hdg1 b 34 1
	mknod hdg2 b 34 2
	mknod hdg3 b 34 3
	mknod hdg4 b 34 4
	mknod hdg5 b 34 5
	mknod hdg6 b 34 6
	mknod hdg7 b 34 7
	mknod hdg8 b 34 8
	mknod hdg9 b 34 9
	mknod hdg10 b 34 10
	mknod hdg11 b 34 11
	mknod hdg12 b 34 12
	mknod hdg13 b 34 13
	mknod hdg14 b 34 14
	mknod hdg15 b 34 15
	mknod hdg16 b 34 16
	mknod hdg17 b 34 17
	mknod hdg18 b 34 18
	mknod hdg19 b 34 19
	mknod hdg20 b 34 20
	mknod hdh b 34 64
	mknod hdh1 b 34 65
	mknod hdh2 b 34 66
	mknod hdh3 b 34 67
	mknod hdh4 b 34 68
	mknod hdh5 b 34 69
	mknod hdh6 b 34 70
	mknod hdh7 b 34 71
	mknod hdh8 b 34 72
	mknod hdh9 b 34 73
	mknod hdh10 b 34 74
	mknod hdh11 b 34 75
	mknod hdh12 b 34 76
	mknod hdh13 b 34 77
	mknod hdh14 b 34 78
	mknod hdh15 b 34 79
	mknod hdh16 b 34 80
	mknod hdh17 b 34 81
	mknod hdh18 b 34 82
	mknod hdh19 b 34 83
	mknod hdh20 b 34 84

	mknod hdi b 56 0
	mknod hdj b 56 64
	mknod hdk b 57 0
	mknod hdl b 57 64
	
	mknod sda b 8 0
	mknod sda1 b 8 1
	mknod sda2 b 8 2
	mknod sda3 b 8 3
	mknod sda4 b 8 4
	mknod sda5 b 8 5
	mknod sda6 b 8 6
	mknod sda7 b 8 7
	mknod sda8 b 8 8
	mknod sda9 b 8 9
	mknod sda10 b 8 10
	mknod sda11 b 8 11
	mknod sda12 b 8 12
	mknod sda13 b 8 13
	mknod sda14 b 8 14
	mknod sda15 b 8 15
	mknod sdb b 8 16
	mknod sdb1 b 8 17
	mknod sdb2 b 8 18
	mknod sdb3 b 8 19
	mknod sdb4 b 8 20
	mknod sdb5 b 8 21
	mknod sdb6 b 8 22
	mknod sdb7 b 8 23
	mknod sdb8 b 8 24
	mknod sdb9 b 8 25
	mknod sdb10 b 8 26
	mknod sdb11 b 8 27
	mknod sdb12 b 8 28
	mknod sdb13 b 8 29
	mknod sdb14 b 8 30
	mknod sdb15 b 8 31
	mknod sdc b 8 32
	mknod sdc1 b 8 33
	mknod sdc2 b 8 34
	mknod sdc3 b 8 35
	mknod sdc4 b 8 36
	mknod sdc5 b 8 37
	mknod sdc6 b 8 38
	mknod sdc7 b 8 39
	mknod sdc8 b 8 40
	mknod sdc9 b 8 41
	mknod sdc10 b 8 42
	mknod sdc11 b 8 43
	mknod sdc12 b 8 44
	mknod sdc13 b 8 45
	mknod sdc14 b 8 46
	mknod sdc15 b 8 47
	mknod sdd b 8 48
	mknod sdd1 b 8 49
	mknod sdd2 b 8 50
	mknod sdd3 b 8 51
	mknod sdd4 b 8 52
	mknod sdd5 b 8 53
	mknod sdd6 b 8 54
	mknod sdd7 b 8 55
	mknod sdd8 b 8 56
	mknod sdd9 b 8 57
	mknod sdd10 b 8 58
	mknod sdd11 b 8 59
	mknod sdd12 b 8 60
	mknod sdd13 b 8 61
	mknod sdd14 b 8 62
	mknod sdd15 b 8 63
	mknod tty0 c 4 0
	mknod console c 5 1
	mknod tty1 c 4 1
	mknod tty2 c 4 2
	mknod tty3 c 4 3
	mknod tty4 c 4 4
	mknod tty5 c 4 5
	mknod tty6 c 4 6
	mknod tty7 c 4 7
	mknod tty8 c 4 8
	mknod tty9 c 4 9
	mknod tty10 c 4 10
	mknod tty11 c 4 11
	mknod tty12 c 4 12
	mknod tty13 c 4 13
	mknod tty14 c 4 14
	mknod tty15 c 4 15
	mknod tty16 c 4 16
	mknod tty17 c 4 17
	mknod tty18 c 4 18
	mknod tty19 c 4 19
	mknod tty20 c 4 20
	mknod tty21 c 4 21
	mknod tty22 c 4 22
	mknod tty23 c 4 23
	mknod tty24 c 4 24
	mknod tty25 c 4 25
	mknod tty26 c 4 26
	mknod tty27 c 4 27
	mknod tty28 c 4 28
	mknod tty29 c 4 29
	mknod tty30 c 4 30
	mknod tty31 c 4 31
	mknod tty32 c 4 32
	mknod tty33 c 4 33
	mknod tty34 c 4 34
	mknod tty35 c 4 35
	mknod tty36 c 4 36
	mknod tty37 c 4 37
	mknod tty38 c 4 38
	mknod tty39 c 4 39
	mknod tty40 c 4 40
	mknod tty41 c 4 41
	mknod tty42 c 4 42
	mknod tty43 c 4 43
	mknod tty44 c 4 44
	mknod tty45 c 4 45
	mknod tty46 c 4 46
	mknod tty47 c 4 47
	mknod tty48 c 4 48
	mknod tty49 c 4 49
	mknod tty50 c 4 50
	mknod tty51 c 4 51
	mknod tty52 c 4 52
	mknod tty53 c 4 53
	mknod tty54 c 4 54
	mknod tty55 c 4 55
	mknod tty56 c 4 56
	mknod tty57 c 4 57
	mknod tty58 c 4 58
	mknod tty59 c 4 59
	mknod tty60 c 4 60
	mknod tty61 c 4 61
	mknod tty62 c 4 62
	mknod tty63 c 4 63
}

if [ "$1" = "" ] || [ "$2" = "" ]
then
	usage;
	exit 1
fi

if [ "`whoami`" != "root" ]
then
	echo "This script requires root privileges to operate."
	exit 1
fi

if [ ! -e $1 ] 
then
	echo 'linuxrc script '"'$1'"' does not exist.'
	exit 1
fi

if [ -e $2 ]
then
	echo "$2 exists, remove it before running this script (again)."
	exit 1
fi

if [ -e $TMPDIR ]
then
	echo "Directory ${TMPDIR} exists, remove it before running this script."
	exit 1
else
	mkdir $TMPDIR
fi

if [ ! -e ${DISTFILES_DIR} ] 
	then mkdir -p ${DISTFILES_DIR}
fi

fetch_busybox;
make_busybox;

if [ ${DEVICEMAPPER_INSTALLED} -eq 0 ]
then
	fetch_devicemapper;
	make_devicemapper;
fi

fetch_dmraid;
make_dmraid;

echo "Creating initrd image..."

dd if=/dev/zero of=${TMPDIR}/initrd bs=1k count=${BLOCKS}
mke2fs -F -q -N${BLOCKS} ${TMPDIR}/initrd
mkdir "${TMPDIR}/tmp"
mount -t ext2 -o loop ${TMPDIR}/initrd ${TMPDIR}/tmp

if [ ! -e ${TMPDIR}/tmp/bin ]
then
	install -d ${TMPDIR}/tmp/{bin,etc,usr,proc,tmp}
	(mkdir ${TMPDIR}/tmp/dev; cd ${TMPDIR}/tmp/dev; create_devices;)

	ln -s bin ${TMPDIR}/tmp/sbin
	ln -s ../bin ${TMPDIR}/tmp/usr/bin
	ln -s ../bin ${TMPDIR}/tmp/usr/sbin

	ln -s /proc/kcore ${TMPDIR}/tmp/dev/core
	ln -s ram1 ${TMPDIR}/tmp/dev/ram
	ln -s /proc/self/fd ${TMPDIR}/tmp/dev/fd
	ln -s fd/0 ${TMPDIR}/tmp/dev/stdin
	ln -s fd/1 ${TMPDIR}/tmp/dev/stdout
	ln -s fd/2 ${TMPDIR}/tmp/dev/stderr

	cat > ${TMPDIR}/tmp/etc/fstab << EOF
	/dev/ram0       /             cramfs defaults
	proc            /proc         proc   defaults  0 0
EOF
fi

cp $TMPDIR/${BUSYBOX_DIR}/busybox ${TMPDIR}/tmp/bin || die 'Fatal error: did busybox fail to compile?'

for i in '[' ash basename cat chroot clear cp cut dirname echo env expr false find \
grep gunzip gzip insmod ln ls loadkmap losetup lsmod mkdir mknod modprobe more mount mv \
pivot_root ps pwd rm rmdir rmmod sed sh sleep tar test touch tr true umount uname \
xargs yes zcat chmod chown vi;
	do ln ${TMPDIR}/tmp/bin/busybox ${TMPDIR}/tmp/bin/$i || die 'Fatal error: did busybox fail to compile?'
done

#The static dmraid binary will be called from /linuxrc
cp $TMPDIR/${DMRAID_DIR}/tools/dmraid ${TMPDIR}/tmp/sbin || die 'Fatal error: did dmraid fail to compile?'

#HACK, you don't want to compile dmraid on your system?:
#cp /sbin/dmraid ${TMPDIR}/tmp/sbin
cp $1 ${TMPDIR}/tmp/linuxrc || die
chmod 755 ${TMPDIR}/tmp/linuxrc

umount ${TMPDIR}/tmp
gzip -f -9 ${TMPDIR}/initrd
mv ${TMPDIR}/initrd.gz $2

echo "compressed image created as: $2"
die;
Retrieved from "http://www.gentoo-wiki.info/HOWTO_Install_Gentoo_with_NVRAID_using_dmraid/dmraidinitrd"

Last modified: Wed, 03 Sep 2008 12:47:00 +1000 Hits: 5,360

Created by NickStallman.net, Luxury Homes Australia
Real estate agents should list their apartments, townhouses and units in Australia.