PC-BSD only installing off a memory stick or off a DVD these days. I opted to go the DVD route because this computer didn't support booting off USB media as far as I could tell (I tried it on two machines: an old HP eVectra 933MHz box, and a slightly newer Dell Optiplex GX270).
The summary of this hack is 'Copy all the files from /boot on the ISO image onto a hard disk that has been made bootable and use a USB expansion box to store the real DVD'.
First, I needed to create a bootable hard disk. I put the hard disk that was going to be installed into the system info a USB expansion box and plugged it into my FreeBSD system. This gave me a disk as 'da0'. This disk had an old Windows installation on it. All commands are run as root. You are advised to triple check your typing, as transposed letters and such might have adverse effects.
Relabeling the Disk
Since I had an old windows install on the disk, I just needed to delete the old windows partition and create a FreeBSD one.
- gpart delete -i 1 da0
- gpart add -t \!165 da0
- gpart create -s bsd da0s1
- gpart add -t \!7 da0s1
Making the disk bootable
Next we need to make the disk bootable. This is a lot easier than it used to be in days of yore:
- gpart bootcode -b /boot/boot0 da0
- gpart bootcode -b /boot/boot da0s1
Copying The Files
The pc-bsd installer for the DVD just loads a ram disk, and then runs off that. All the early stages of the boot loader need are contained in /boot. This includes the kernel, the third stage boot loader and various config files and scripts. So the next steps are to copy these files from the cd onto the bootable hard disk we just made. This assumes that the mdconfig command below prints "md0" for unit 0. If it prints anything else, you'll need to adjust accordingly. Also, if you are reading this in the future, you may need to change the PCBSD iso name.
- newfs /dev/da0s1a
- mount /dev/da0s1a /mnt
- mdconfig -f PCBSD8.1-x86-DVD.iso
- mount -t cd9660 /dev/md0 /cdrom
- mkdir /mnt/boot
- cd /cdrom/boot
- tar cf - . | (cd /mnt/boot; tar xvf -)
- cd /
- umount /mnt
- umount /cdrom
- mdconfig -d -u 0
Moving the disk
At this point, I had to unplug the USB expander from the first system, remove the hard drive and install it into my target box. I also grabbed my UBS DVD player and connected it to the box with a copy of the DVD I burned from the above file. I selected hard disk as the boot media in the bios and let the system boot. It booted off the hard disk, but then started looking for the proper cd device. Luckily for me, it found the DVD on cd1 instead of cd0 (which is what was built-in to the Dell I was booting off of). It then became a 'normal' PC-BSD installation, which is described in detail elsewhere.
Hopefully, people find these instructions useful. Since I only had one of these systems, I didn't create any kind of script to make it easier. Sorry.
[[ Updated to fix problem noted in the comments ]]
5 comments:
Alain B. from Paris.
Very usefull !
gpart tool was frightened me...
I learn with you, simply by example, essentials about using gpart.
Bye Bye fdisk and disklabel :-)
you have a little typo that's everyone had noticed:
gpart create -s bsd da0
gpart add -t \!7 da0
should be read as:
gpart create -s bsd da0s1
gpart add -t \!7 da0s1
Some others funny things can be done for the old or embedded world:
Nothing new there but it just can save your life :-)
Here, we can always use 'glabel create' on da0,
and adjust fstab in order to always
boot on everything that look like of a disk,
no matters if it's da0, ad4 or ada0.
Same CF can be booted either from USB adapter or SATA to CF converter.
Even if it's an hd image an iSCSI lun booted via gpxe and isboot
(see istgt project).
Yet another idea taken from the BSDRP projet:
in order to properly boot on cheap USB key you should increase the probe delay.
echo 'kern.cam.boot.delay=10000' >> ${IMGROOT}/boot/loader.conf
And the last one...
If you create a customised ISOLIVE CD or read only CF but you still want to alter
the configuration "write on it" at run time:
echo 'mkdir -p /var/fs/etc' >> $CDROOT/etc/rc.local
echo 'mount_unionfs -o noatime /var/fs/etc /etc ' >> $CDROOT/etc/rc.local
with /var as mdmfs(8) will do the trick.
FreeBSD: No limits !
Thank's again for your blog !
alain AT bsdgate.org
Thanks for the tips Alain...
I use ufs labels now in FreeNAS (and added it to nanobsd in the base) so that /dev/ufs/mumble will find the right file system to boot off of. I got the idea from bsdrp. I know that PC-BSD uses glabel to actually label the partitions, but I guess I'm a sucker for booting the filesystem that I tagged as Blah, rather than the partition tagged as Blah. A subtle difference, to be sure.
I have the usb kludge from bsdrp in freenas right now. I hate it. It is just so wrong. IMHO, we should poll for new devices once we drop into the prompt for devices. So it would say 'oh, the specified thing turned up after all, continuing with it' if you didn't type anything...
I think we're using similar tricks for the forth-coming FreeNAS installer...
Now, I wonder, is it worth it to teach nanobsd how to make GPT partitioned devices...
Alain B.
Ok.
I just switched some custom scripts to use UFS label instead of whole disk label.
This make it now more easy to have 2 freebsd partition on a single CF to have a rescue partition.
No more need to tweak loader.conf.
And with gpart, i no more need to create fdisk template for each kind of CF in order to always boot.
It just work's, and i don't know why :-)
Since i know nearly nothing about GPT,
i cannot pronounce me.
Thank's again.
Alain.
At www.plop.at there is free software that will let you boot off of usb even though you hardware doesn't support it directly.
/J
Warner,
I think teaching nanobsd how to make GPT partitioned devices would be worth while. (if you haven't already that is) I've been using GPT exclusively for a while now and would rather not switch back.
-Phil.
Post a Comment