I haven’t used NetBSD for some time because not so long ago I had tried to install Fedora 18 Alpha recklessly and I had lost all my partitions in disk drive. After this event I have decided to give a chance for PC-BSD briefly. Unfortunately it haven’t met my expectations so eventually I’ve made a decision to return to my default configuration – Fedora Linux and NetBSD.
Firstly I have installed Fedora 17 which had created GPT partitioned disk by default (I even hadn’t noticed before I tried to install NetBSD). Unfortunately NetBSD sysinst doesn’t support GPT discs right now so I made a little headache for myself. I looked for the information and found that there was GSoC project to create GPT aware booloader for BIOS systems several years ago. My system has UEFI and Fedora uses grub2 bootloader. Because of this I decided to go by a little bit another route but instructions on how to install and use that bootloader were helpful anyway. I also found this page which describes how to configure grub2 to load NetBSD kernel. Generally if you want to boot NetBSD on gpt disc with grub2 (UEFI system) you need configure grub2 bootloader to boot NetBSD kernel from your Linux system and manually create gpt partition, extract NetBSD kernel and binary sets into that partition from NetBSD boot CD (or other media). Then some small configuration of fstab, ttys and rc.conf and you are ready to go. I booted system successfully on the first try, however my mistakes took three more evenings before I could actually use the system (I skip them this time).
Steps I took:
1. Firstly I booted into Fedora and configured my grub2. vi /etc/grub.d/40_custom (of course use su or sudo to get root privileges before) and
added lines:
menuentry “NetBSD” {
insmod ufs2
set root=(hd0,gpt2)
knetbsd /netbsd –root=hd0b
}
hd0b is the second partition. dk1 worked also. Then I ran grub2-mkconfig -o /boot/grub2/grub.cfg to make changes into effect.
2. Rebooted and loaded the system installer (sysinst) from NetbSD boot CD. Chose utility menu and ran /bin/sh.
3. Used gpt show /dev/wd0 to see how my disc was partitioned. I had BIOS boot partition, 1xunused ext4 partition and 1xFedora system partition (ext4 too). Utility also shows a start sector and the size of all partitions and partition indexes.
4. I delete unused ext4 partition (which was dk1) with gpt remove -i1 /dev/wd0, where i was a partition index and created a new one gpt add -i1 -b
5. Formatted the partition: newfs -O2 /dev/rdk1.
6. Mounted it: mount /dev/dk1 /mnt.
7. Went to amd64/binary/sets directory in the installation disc (amd64 directory depends on architecture you install, it can be i386 or other). Extracted the kernel first: tar –gunzip -C /mnt -xpvf netbsd-GENERIC.gz. Later I extracted other sets that I had needed (base, comp, misc and others). Don’t forget to add -p parameter (preserve permissions) as you will run in problems shortly otherwise.
8. chroot /mnt (you can use vi and other system applications).
9. Created /etc/fstab and configured /etc/ttys (examples are below).
10. Changed RC_CONFIGURED to yes in /etc/rc.conf. Also added WSCONS=YES and HOSTNAME value.
11. Rebooted and chose NetBSD. It booted successfully but root didn’t have password, passwd didn’t work and “warning: no /dev/console” message appeared (also some other related errors). To fix that I went to /dev folder and ran ./MAKEDEV all (or at least wscons). I rebooted one more time (though that might be unnecessary).
12. That is all. I created a new user and NetBSD was fully functioning.
I also created one more partition for swap (gpt add -i3 -t swap -b
Examples:
fstab:
/dev/dk1 / ffs rw 1 1
/dev/dk3 none swap sw,dp 0 0
kernfs /kern kernfs rw
ptyfs /dev/pts ptyfs rw
procfs /proc procfs rw
/dev/cd0a /cdrom cd9660 ro,noauto
P.S. you need to create /kern, /proc and /cdrom directories manually before mounting them (chmod 555). Other directory structure was created while I was extracting binary sets. If your manually created user has a problem to access /tmp you can change its permissions to 775 from root (user should be in wheel group).
ttys:
<...>
console “/usr/libexec/getty Pc” vt100 on secure
constty “/usr/libexec/getty Pc” vt100 off secure
ttyE0 “/usr/libexec/getty Pc” vt220 off secure
ttyE1 “/usr/libexec/getty Pc” vt220 on secure
ttyE2 “/usr/libexec/getty Pc” vt220 on secure
ttyE3 “/usr/libexec/getty Pc” vt220 on secure
tty00 “/usr/libexec/getty std.9600” unknown off secure
<...>
There are a lot of text in this article but actually it takes about 15-20 minutes to install the system on Core i7 system if you are doing everything correctly from the start. The most time consuming actions are files extracting and writing fstab file. So you shouldn’t be afraid to try it if you have some space left in your HDD and have enough confidence that you won’t ruin everything :).