All posts by vezhlys

NetBSD 6, GPT disc and grub2

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 -s -t ffs /dev/wd0. and was taken from gpt show information. ffs creates BSD4.2 partition.
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 -s /dev/wd0). Look for gpt man page if you need more information.

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 :).

NetBSD 6.0.1 released

I waited for 6 release for so long that rapid pace of current releases is even tiresome :D. Nevertheless 6.0.1 is released. This is the first security/bugfix update of the NetBSD 6.0 release branch. Release notes can be found here.

In meantime I just donated some money for the project and encourage you to do the same. Project targets to get 60,000 USD by the end of 2012 to continue current or start new funded development in various areas (go to donations page for more information) .

What is more I am trying to install NetBSD on gpt partitioned disk and boot it from grub2 bootloader but I have some issues currently. If I will solve them I will try to write small article on that.

Jibbed 6.0 released

I have never tried Jibbed myself but I noticed the release in distrowatch. Jibbed 6.0 is a bootable live CD based on NetBSD 6.0. It includes a complete NetBSD environment, automatic hardware detection, compiler sets, provides features like tmpfs to simulate read-write access on read-only media and more. You can read release announcement here. Jibbed is amd64 (x86_64) only from this release. It also runs in VirtualBox, VMware or QEMU so you can try NetBSD without installing it or even rebooting (but you can’t install system to hard drive using this live CD, you need to download official system images).

NetBSD 5.2 released

The NetBSD Project released NetBSD 5.2 which is the second feature update of the NetBSD 5.0 release branch. It contains selected subset of fixes to improve security and stability and some new features and enhancements. You can read release announcement here and release notes here for more information. Look at http://www.netbsd.org/mirrors/ to download all necessary files or at http://www.netbsd.org/mirrors/torrents/ for torrent files. If you are a new user I would recommend 6.0 release. Upgrade on your setup requirements otherwise.

NetBSD 6 and Folding@home v7 client

It is already some time when you can download folding@home v7 client for Windows, Linux and MAC OS X. Besides, it has two additional applications FAHControl – graphical application for configuration and progress monitoring and FAHViewer – 3D work unit viewer. This time I was able to run FAHClient in NetBSD only (but not like service). It is possible that FAHViewer didn’t work because client wasn’t running like service. FAHControl might be another story. It is python application and it tries to run after some modifications but no UI appears and it loads forever (taking one core fully). I suspect you can launch service easily if you put all files in correct places and modify init script a little bit (it is included in Linux version). Nevertheless you can run folding@home v7 on NetBSD 6 and onwards though some work is needed. Of course, you need Linux emulation enabled and suse121 packages installed for that and download rpm or deb FAHClient package and extract it manually. What is more, you need to find libbz2.so* file which doesn’t come in those packages. The easiest way for me was to copy them from my Fedora 17 installation (they reside in /usr/lib64 folder. I just took all libbz2* files, two of them were simlinks) and put them in the same directory in NetBSD system. Ubuntu has different folder structure but you should be able to find them in /usr/lib or /usr/lib64 folders. Be careful, don’t replace Linux library files with your NetBSD ones. Otherwise google should help you. It is enough to run FAHClient but I still had problems because it couldn’t connect to stanford servers to download core files. Because of this you have two options. First one is to download them manually (you can see download link in folding log file) and put them in quite puzzling folder structure (cores/www.stanford.edu/~pande/Linux/AMD64/Core_[coreversion].fah/ where [coreversion] should be changed to a3 or a4 or any other you downloaded) . Second option is to get them from your other OS installation if you have been already using folding@home (files from other folding@home versions suits well). One other option is to use much older 6.02 Linux client version which downloads cores without any problems in NetBSD (but this version download only one core at time that is needed for current folding project). Finally, if you run folding client manually from terminal (not as service), your current path should be the same to the FAHClient application. Otherwise it creates working folders in the same place from which you have started the application and it can cause additional problems (it is common problem in Linux too). So if all this information didn’t scare you and you want put your NetBSD system to this project with the newest client version you can do it with some effort (older versions runs more easily but 6.23 can’t download core files too you need to get them manually as well). Good luck.

config.xml example
<config>
<user value=’yourusername’/>
<team value=’38099’/>
<passkey value=’yourpasskey’/>
<smp value=’true’/>
<gpu value=’false’/>
</config/>

NetBSD 6.0 final released!

NetBSD 6.0 released. It was quite a long wait but I think it was worth it. amd64, i386 ports has better ACPI, hardware support, updated and much better Linux emulation, userland tools are updated too of course. This is probably features I admired and noticed first but it just a small fraction of all changes. Other changes for NetBSD in general and other ports you can read in release announcement. Or just download it from NetBSD mirrors and give it a try.

My pulseaudio compiling problem

I was having a problem to compile pulseaudio from “current” pkgsrc for a long time in my setup. It prevented me from compiling gnome environment normally (as it had dependencies in various media packages from pkgsrc). Finally I noticed that it had been crashing on dependency checking at the same place:

=> Full dependency libsndfile>=1.0.20: found libsndfile-1.0.25
[1]   Segmentation fault (core dumped) /usr/pkg/sbin/pk…
*** Error code 139

Next dependency was speex in generated work/.depends file. So I tried to figure out what had been wrong.

Firstly I re-installed speex:
/usr/pkgscr/audio/speex

Deleted dependency in pulseaudio:
/work/.depends find line:
full    speex>=1.2rc1   ../../audio/speex

When I needed to set environment variables:
LIBSPEEX_LIBS=”-L/usr/pkg/lib -lspeex -lspeexdsp”
LIBSPEEX_CFLAGS=”-I/usr/pkg/include/speex”
export LIBSPEEX_LIBS
export LIBSPEEX_CFLAGS

After make command I got a new error:

===> Creating toolchain wrappers for pulseaudio-0.9.21nb15
sh: Syntax error: expecting “in”
*** Error code 2

So I edited newly created work/.wrapper_makevars.mk:
I found a line:
BUILDLINK_PREFIX.speex=
and added          /usr/pkg:
BUILDLINK_PREFIX.speex=         /usr/pkg

After make command compilation finally started but I still got warnings that /usr/pkgsrc/audio/pulseaudio/work/.buildlink/include/  hadn’t existed. Because of this I added to work/.buildlink folder these files:
cp -r /usr/pkg/include/speex/ /usr/pkgsrc/audio/pulseaudio/work/.buildlink/include/
cp /usr/pkg/lib/libspeex* /usr/pkgsrc/audio/pulseaudio/work/.buildlink/lib/

I thought that this would be enough but compiling still ended up with errors at some point. However these errors led me to the solution. It appeared that all speex include files (*.h) had been broken. They hadn’t source code, only lots of meaningless text and echo outputs. It is hard to say why this happened but one more speex re-installation fixed them. After that pulseaudio compilation just worked without any issues and upper mentioned actions. I am quite sure that this problem existed in different NetBSD setups for me during last two or three months. I installed speex at least two times this time too. Was it my fault or pkgsrc scripts one or something else it is hard to say currently. Nevertheless, this solved problem probably will help me to look into pkgsrc crashes even more flexibly and save unnecessary spent time.

NetBSD6 BETA2 released

NetBSD6 BETA2 was released on May 26, 2012. According to an interesting bsdtalk215 conversation with David Maxwell, Julio Merino, and Brett Lymn at BSDCan 2012 about upcoming release, it is expected to be last beta release before the first release candidate. Of course, if it is needed we may see other beta releases too. This release is interesting to me because one fix was made by help from myself. It took almost three years to find a problem for me after I submitted it (I investigated the problem lot of times in that period). Nevertheless I was extremely happy to contribute to the project.

Last but not least, you can read an interesting interview at unixmen.com  with another NetBSD member – Martin Husemann. It is especially interesting to new people who wants to understand what NetBSD is and what can you expect from it. Some information about upcoming NetBSD 6 release is mentioned too.