NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: booting from gpt/raid?



On Thu 05 Jul 2018 at 10:52:12 +0300, Andreas Gustafsson wrote:
> MLH wrote:
> > Boot Options are:
> >  Hard Drive, CDROM, USB-FDD, USB-ZIP, USB-CDROM, USB-HDD, Legacy LAN
> 
> A USB memory stick emulates a hard drive, so USB-HDD should work.

A USB stick formatted like a hard drive *should* always work.
Many BIOSes also allow booting from a USB stick formatted as a cdrom,
i.e. filled with an .iso image.

Here is a script I once made to create a bootable dvd from the install
sets. I made it to have a non-standard live and install dvd that also
includes all sources. I had also been trying to include (apart from the
amd64 version) i386 and VAX on the same dvd, but I didn't get far with
that.

This one was working for 7.1.1/amd64.

#!/bin/sh
# Make a bootable cd for amd64.
# If the same method works for VAX, I have to look into.
#

#set -x

arch=amd64
sets="kern-GENERIC modules base comp etc games man misc text"
xsets="xbase xcomp xetc xfont xserver"

work=work.$arch

top=$(pwd)
what=${top##*/}
mkdir $work
cd $work

umask 0000

echo "Creating a ${what} dvd image:"

for set in $sets $xsets
do
    echo "Extracting ${set} (using chroot)..."
    tar --chroot -x -p -z -f $top/$arch/binary/sets/${set}.tgz
done

# Put bootfiles in place:

# For amd64:
cp -p ./usr/mdec/boot .
cp -p ./usr/mdec/bootxx_cd9660 ./bootxx_cd9660.${arch}

cat >boot.cfg <<EOF
banner=Welcome to the ${what} ${arch} installation CD
banner================================================================================
banner=
banner=ACPI (Advanced Configuration and Power Interface) should work on all modern
banner=and legacy hardware.  However if you do encounter a problem while booting,
banner=try disabling it and report a bug at http://www.NetBSD.org/.
menu=Install NetBSD:boot netbsd
menu=Install NetBSD (no ACPI):boot netbsd -2
menu=Install NetBSD (no ACPI, no SMP):boot netbsd -12
menu=Drop to boot prompt:prompt
timeout=30
EOF

cat >etc/rc.d/filltmpfs <<'EOF'
# PROVIDE: filltmpfs
# REQUIRE: root
# BEFORE: mountcritlocal

$_rc_subr_loaded . /etc/rc.subr

name="filltmpfs"
rcvar="filltmpfs"
start_cmd="filltmpfs_start"
stop_cmd=":"

filltmpfs_start()
{
    # hack to get around bugs in kernfs's rootdev/rrootdev lookup.
    ls -l /dev/* > /dev/null 2>&1

    # prepare important directories in the tmpfses, so dhcpcd and vi will work
    echo "Prepare important directories in the tmpfses, so dhcpcd and vi will work."
    mount_critical_filesystems local

    /bin/mkdir -p /var/run /var/db /var/log /var/tmp /var/spool /var/cron
    touch /var/log/messages /var/log/authlog /var/log/cron /var/log/xferlog
    touch /var/log/lpd-errs /var/log/maillog
}

load_rc_config $name
run_rc_command "$1"
EOF
chmod a+x etc/rc.d/filltmpfs

cat >etc/fstab <<EOF
# device	mount		fstype	ro/rw
/dev/cd0a	/		cd9660	ro		0 0
tmpfs		/etc		tmpfs	rw,union	0 0
tmpfs		/tmp		tmpfs	rw		0 0
tmpfs		/var		tmpfs	rw	0 0
kernfs		/kern		kernfs	rw
ptyfs		/dev/pts	ptyfs	rw
procfs		/proc		procfs	rw
EOF

cat >>etc/rc.conf <<'EOF'
critical_filesystems_local="$critical_filesystems_local /tmp"
rc_configured=YES
filltmpfs=YES
mountall=YES
hostname="installer"
postfix=NO
no_swap=YES
wscons=YES
EOF

sed <etc/ttys >etc/ttys.new \
    -e '/^console/s/on /off /' \
    -e '/^ttyE/s/off /on /'
mv etc/ttys.new etc/ttys

mkdir mnt2 targetroot kern proc
ln -s . release

echo "Link in distribution:"

ln ${top}/CHANGES* ${top}/LAST_MINUTE ${top}/README.files .

(cd ${top}; find ${arch} source shared -type d ) |
    while read dir
    do
	echo "    ${dir}"
	mkdir -p ${dir}
	ln ${top}/${dir}/* ${dir}/ 2>/dev/null
    done

cd dev
rm -f console	# force the system to make a tmpfs /dev
# ./MAKEDEV all
cd ..

echo "Creating the iso image..."

makefs	-t cd9660 \
	-o "bootimage=i386;usr/mdec/bootxx_cd9660,no-emul-boot,rockridge,allow-deep-trees,allow-multidot,volumeid=${what}.${arch}" \
	${top}/live-and-install.$arch.iso .

cd $top

echo "Testing the image:"
echo dd if=/dev/zero of=disk.img bs=1m count=1536
echo qemu-system-x86_64 -cdrom boot.amd64.iso -drive file=disk.img,index=0,media=disk,format=raw # -netdev user,id=mynet0 -device e1000,netdev=mynet0


-Olaf.
-- 
___ Olaf 'Rhialto' Seibert  -- Wayland: Those who don't understand X
\X/ rhialto/at/falu.nl      -- are condemned to reinvent it. Poorly.

Attachment: signature.asc
Description: PGP signature



Home | Main Index | Thread Index | Old Index