Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 12 Oct 2004 23:15:12 -0400
From:      Matt Juszczak <matt@atopia.net>
To:        freebsd-questions@freebsd.org, Matt Juszczak <matt@atopia.net>
Subject:   m0n0wall not booting after switch to mdconfig
Message-ID:  <416C9DC0.9030800@atopia.net>

next in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------050104080109040805090209
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

Hello,

As of yesterday I stopped using m0n0image by Michael I and took most of the commands from m0n0image and the hackers guide, along with the FreeBSD handbook, and tried to write a new shell script that worked with mdconfig.

The shell script works great.  It can successfully "decompress" an image and "recompress" an image without any errors.  However, whenever I boot from an image that the shell script creates, it doesn't load.  The boot up process stops at the kernel loading and it says it can't find kernel or kernel.old.

I'm pretty sure I'm doing everything right.  Maybe there's one mistake I'm completely missing.  Could someone please look at it and let me know?

Shell script is attached.

Thanks,

Matt


--------------050104080109040805090209
Content-Type: text/plain;
 name="label.proto"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="label.proto"

# /dev/md0c:
type: unknown
disk: amnesiac
label:
flags:
bytes/sector: 512
sectors/track: 32
tracks/cylinder: 64
sectors/cylinder: 2048
cylinders: 5
sectors/unit: 12288
rpm: 3600
interleave: 1
trackskew: 0
cylinderskew: 0
headswitch: 0           # milliseconds
track-to-track seek: 0  # milliseconds
drivedata: 0

8 partitions:
#        size   offset    fstype   [fsize bsize bps/cpg]
  a:    12288        0    4.2BSD     1024  8192    26   # (Cyl.    0 - 4)
  c:    12288        0    unused        0     0         # (Cyl.    0 - 4)

--------------050104080109040805090209
Content-Type: text/plain;
 name="script.sh"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="script.sh"

#!/usr/local/bin/bash

printf "Image Generator/Decompressor\n\n"
ls -al | grep "\.img" | grep -v " \."
ls -al | grep "drwx" | grep -v " \."
printf "\n(G)enerate an image or (D)ecompress one?: "
read REQUEST

if [ "$REQUEST" = "d" ]
then
	printf "Source Name (without extension): "
	read image
	printf "Output Directory: "
	read image_dir
	if [ \( -f $image.img -a $image_dir \) ]
	then
		printf "Decompressing $image ... 0%%\b\b"
		mkdir $image_dir
    		mkdir $image_dir/fs
		mkdir $image_dir/kern
		printf "10%%\b\b\b"
		mv $image.img $image.bin.gz
		gzip -d $image.bin.gz
		printf "20%%\b\b\b"
		mdconfig -a -t vnode -f $image.bin -u 0
		mount /dev/md0a /mnt
		printf "30%%\b\b\b"
		cp -p /mnt/kernel.gz $image_dir/kern/
		printf "35%%\b\b\b"
		cp -p /mnt/mfsroot.gz $image_dir
		printf "40%%\b\b\b"
		cp -Rp /mnt/boot $image_dir/boot
		printf "45%%\b\b\b"
		cp -Rp /mnt/conf $image_dir/conf
		printf "50%%\b\b\b"
		umount /mnt
		mdconfig -d -u 0
		printf "60%%\b\b\b"
		gzip -9 $image.bin
		mv $image.bin.gz $image.img
		printf "70%%\b\b\b"
		gzip -d $image_dir/mfsroot.gz
		printf "80%%\b\b\b"
		mdconfig -a -t vnode -f $image_dir/mfsroot -u 0
		mount /dev/md0c /mnt
		cp -Rp /mnt/* $image_dir/fs
		printf "90%%\b\b\b"
		umount /mnt
		mdconfig -d -u 0
		rm $image_dir/mfsroot
		printf "100%%"
	fi
elif [ "$REQUEST" = "g" ]
then
	printf "Output Name (without extension): "
	read outfile
	printf "Source Directory: "
	read directory
	if [ \( -d $directory -a -n $outfile \) ]
	then
		printf "Compressing $directory ... 0%%\b\b"
		mkdir tmp
		dd if=/dev/zero of=tmp/mfsroot.bin bs=1k count=12288 > /dev/null 2>&1
		printf "10%%\b\b\b"
		mdconfig -a -t vnode -f tmp/mfsroot.bin -u 0
		disklabel -r -w md0 auto
		newfs -b 8192 -f 1024 /dev/md0c > /dev/null 2>&1
		printf "20%%\b\b\b"
		mount /dev/md0c /mnt
		cp -Rp $directory/fs/* /mnt
		umount /mnt
		printf "30%%\b\b\b"
		mdconfig -d -u 0
		gzip -9 tmp/mfsroot.bin
		printf "40%%\b\b\b"
		mv tmp/mfsroot.bin.gz tmp/mfsroot.gz
		dd if=/dev/zero of=tmp/$directory.bin bs=1k count=6144 > /dev/null 2>&1
		mdconfig -a -t vnode -f tmp/$directory.bin -u 0
		printf "50%%\b\b\b"
		disklabel -BR md0 label.proto
		newfs -b 8192 -f 1024 /dev/md0a > /dev/null 2>&1
		mount /dev/md0a /mnt
		printf "60%%\b\b\b"
		cp -Rp $directory/boot /mnt
		cp -Rp $directory/conf /mnt
		printf "70%%\b\b\b"
		cp -p tmp/mfsroot.gz $directory/kern/kernel.gz /mnt
		umount /mnt
		printf "80%%\b\b\b"
		mdconfig -d -u 0
		gzip -9 tmp/$directory.bin
		printf "90%%\b\b\b"
		mv tmp/$directory.bin.gz $outfile.img
		rm -rf tmp
		printf "100%%";
	fi
else
	printf "You must choose G or D"
	printf
fi

echo

--------------050104080109040805090209--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?416C9DC0.9030800>