DaemonForums  

Go Back   DaemonForums > Miscellaneous > Guides

Guides All Guides and HOWTO's.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 31st January 2013
bsdnotbdsm bsdnotbdsm is offline
Port Guard
 
Join Date: Jan 2013
Posts: 30
Default NetBSD 6 installation on Thinkpad T420 laptop

Hello,
This is my first post on Daemon Forums, I hope it'll be useful for some of you.


Hardware:
Lenovo Thinkpad T420
CPU: Intel(R) Core(TM) i5-2520M CPU @ 2.50GHz
RAM: 8 GB DDR3 1333MHz
HDD: Western Digital 320GB, 7200 rpm

Software:
NetBSD 6.0.1 amd64
Note on software: because of the graphics performance, I had to replace the default kernel (delivered as part of NetBSD 6.0.1) with an experimental one (details
on this, later).


Foreword:
I'm not a NetBSD guru, but I have 10+ years of experience with other *nixes(mainly Linux and FreeBSD). Therefore, this tutorial may give a bit more NetBSD-specific details than needed. I'm doing this primarily for myself, for documenting steps I might easily forget in the future. However, this aspect can be useful, especially for someone new to NetBSD

On the other hand, I think Daemon Forums is kind of a select club ... so I'm not going into that “step-by-step installation tutorial with screenshots” (for newbies). I'll not insist on (the order of) steps during installation procedure, or on how to add a non-root user. I assume the reader have installed at least … 10 Linux/Unix-based different operating systems and is familiar with disk partitioning, useradd, editors, /etc, etc

Last point, this tutorial is describing my experience with this particular laptop, Thinkpad T420. Anyway, some details will apply to other hardware configurations too...


Installation:
I decided on NetBSD 6.0.1 amd64 because it is the latest stable release. Why amd64? Because the T420 is a powerful monster with i5 64-bit CPU and I want to get the best out of it.

Informations on how to get the installation ISO are found at netbsd.org/releases/
I've chosen to get the ISO by FTP from the master site, so I downloaded the file: iso.netbsd.org/pub/NetBSD/iso/6.0.1/NetBSD-6.0.1-amd64.iso

On the laptop, I prepared 20 GB of unformatted free space: 18GB for the / partition and 2 GB for swap space.
A note about swap: although some tutorials recommend to choose 2 X RAM size for the swap partition, from my experience I concluded that a system with 8 GB RAM can and will perfom OK even with no swap space (for the common “classical desktop” use case: X + web browser + media player + office ). Anyway, choosing 1-2 GB of swap space is wise, because you'll most likely experiment with the new system, compiling large programs for example.

During installation, I chose these options:
- Formatted / partition as FFS, it was the default choice;
- Allocated all 18GB to / (so, no separate partitions for /home, /usr, /var, /tmp)
- Full installation ( it required around 2.5 - 3 GB, I don't remember exactly how much);
- Skipped the boot loader installation on Master Boot Record (which is, I left the MBR untouched);
Explanation for skipping the bootloader: the T420 is a triple-boot system. There are two Linux installations and now the NetBSD, and I didn't want to overwrite the GRUB install. The NetBSD can be added to Grub boot menu very easy. Just add these lines in grub config file (usually /boot/grub/menu.lst):

Code:
title MyNetBSD
root hd(0,6)
chainloader +1
boot
Of course this is my own grub entry, you'll adapt the “title” and “root” entries for your taste and configuration, respectively.

NOTE: Obviously, the skipping of NetBSD boot loader instalation is my special case, because of the multi-boot laptop. If performing the install with NetBSD as the only OS, just skip the grub hacking and install the boot loader on MBR.


Now back to setup of NetBSD: in the install process, all went fine. In the post install configuration phase, I tried to configure the network, but I couldn't figure out how to configure my wireless adapter to connect to my WAP configured with WPA2 encryption. Therefore, I just postponed this step for the first boot.


Post-installation impressions and configs:
So, here I am after the first boot, with my new NetBSD system. First checkings look OK ..
A first pleasant surprise was to see that both my network adapters - wired and wireless - are recognised (ifconfig -a displayed them both).

I strongly recommend taking the time to read:
Code:
bash-4.2# man 8 afterboot
It contains various informations like: how to check hostname, network interfaces, how to enable ssh root logins, how to set date/time, even how to compile your custom NetBSD kernel. It also provides references to other useful manual pages.

In the rest of the tutorial, I'll explain the setup procedures for the three elements I consider crucial for a desktop environment:
- networking
- sound
- graphics


Wired networking: works perfectly, with not much setup. My router has its integrated DHCP server enabled, so all I had to do is to add “dhcp” in /etc/ifconfig.wm0 (wm0 is the Intel i8254x Gigabit Ethernet card in my T420), then plug-in the UTP cable and restart the network:

Code:
bash-4.2# cat /etc/ifconfig.wm0
dhcp 

bash-4.2# /etc/rc.d/network restart
Wireless networking: Works OK, with some setup. The adapter is an Intel Wireless 6205 AGN, identified by NetBSD as iwn0.
As I said above, I need to connect my laptop to an encrypted WAP (WPA2 encryption), so I'll use the wpa_supplicant and dhclient (both are part of the NetBSD default installation).

For wpa_supplicant, first I enabled it to start at boot (as with most BSD's, the /etc/rc.conf is the file that controls the start-up services). So, I added these two lines in /etc/rc.conf:
Code:
wpa_supplicant=YES
wpa_supplicant_flags="-B -i iwn0 -c/etc/wpa_supplicant.conf"
The configuration file for wpa_supplicant is /etc/wpa_supplicant.conf:

Code:
bash-4.2# cat /etc/wpa_supplicant.conf 
network={ 
ssid="home1234"
key_mgmt=WPA-PSK 
psk="yours3cretkeygoesh3re” 
}

For dhclient, the setup is easy. Enable it in /etc/rc.conf and specify the interface in /etc/dhclient.conf:
Code:
bash-4.2# cat /etc/rc.conf |grep dhclient 
dhclient=YES 
bash-4.2# cat /etc/dhclient.conf 
lease { 
interface "iwn0"; 
}
At this point, I unplugged the UTP cable from the wired net adapter, rebooted the laptop, and … hooray! The wireless interface started, successfully connected to the WAP. I can surf the Net wirelessly from NetBSD!

Some final notes about wireless interface: it works OK with my D-Link DIR-615 WAP, connection is stable in time. The download/upload speeds are not impressive for a Wireless-N card, when compared to the same wifi card on Linux:
- download speed: ~ 1.6 MB/s (compared with ~ 1.9 MB/s in Linux)
- upload speed: ~ 1 MB/s (compared with ~ 1.5 MB/s in Linux)
However, it is very usable. As long as I am able to watch a movie on an FS mounted over the network, I am fully satisfied with the performance.


Sound:
My Intel HD audio card has been recognised and configured by the NetBSD 6.0.1. I didn't do any manual configuration. Actually, I just installed aumix program, to control the volume.
The driver used by the soundcard: hdaudio
That's it. For more infos:
man 4 hdaudio
man 8 hdaudioctl



Graphics, Xorg, graphics acceleration:
T420 comes with an Intel HD 3000 display adapter.
And for me, right after finishing installation and setting up networking, the first unpleasant surprise came: the display resolution was stucked at 1024x768, but the native resolution for the T420 is ... 1600x900(works out-of-the-box in some Linuxes).
More than this, no graphic acceleration for this default configuration.
NOTE: I created my own “xorg.conf” file using “Xorg -configure” command, I explicity placed “Driver intel” entry there, but no success. X refused to start like that. The only X display driver that seemed to be accepted was “vesa”.

After extended googling, I've found that NetBSD does not have proper support for more modern graphics cards, with DRM(Direct Rendering Manager). Here's one of the first google results:

Quote:
i3-500 sounds like something with the new on-CPU-die GPU.
Everything that new needs a xf86-video-intel that's currently
incompatible with NetBSD. Well, at least until we port/implement
GEM and KMS in our kernel ...
However, I haven't lost the hope.
After more extended googling, I've found this link: groups.google.com/forum/#!topic/muc.lists.netbsd.current-users/-L8qo-kyiS8

So this guy has ported DRM/GEM kernel driver from OpenBSD to NetBSD, and also ported the Xorg intel driver from Linux to NetBSD. Why not giving a try ?

His precompiled kernel + Xorg files are at: ftp.netbsd.org/pub/NetBSD/misc/gsutre/

Here's what I did:
1) I got the most recent version of the precompiled kernel, from the “drmgem-NetBSD-6.99.14-201210251710Z-amd64” folder.
So, I went to
Quote:
ftp.netbsd.org/pub/NetBSD/misc/gsutre/drmgem-NetBSD-6.99.14-201210251710Z-amd64
and downloaded the two files:
- netbsd-GENERIC-drmgem (the kernel itself)
- usr-X11R7-drmgem.tgz (modified /usr/X11R7)

Now, exit the X session if it's the case, and from the command line:
2) Make a backup of the current /usr/X11R7 and copy the modified X11R7 to /usr.
Code:
bash-4.2# cp -R /usr/X11R7 /usr/X11R7_initial
bash-4.2# cd /root/NetBSD-6.99.14-201210251710Z-amd64/ # replace with the path where usr-X11R7-drmgem.tgz is downloaded
bash-4.2# tar -xzvf usr-X11R7-drmgem.tgz
bash-4.2# cp -R usr/X11R7 /usr/
3) Copied the kernel image to /:
Code:
bash-4.2# cp netbsd-GENERIC-drmgem /netbsd-drmgen
After these steps, the system is modified with all the requirements for enabling DRM/GEM features.

At this point, I rebooted the system, and when the NetBSD boot menu appears, I select “Drop to boot prompt” .
From the boot prompt command line:
Code:
boot /netbsd-drmgen
The system boots OK, it recognised my devices. I got the login prompt, logged in as root and did “startx”. And … Great Success! My installation of Xfce4 started with native resolution of 1600x900!
So, the thing ported from OpenBSD really works! Or at least … it's usable. Details a bit later.

Of course, with the modified kernel and modified /usr/X11R7, I can't say I'm running a pure 6.0.1 installation, actually the uname says:
Code:
bash-4.2# uname -a
NetBSD smallnetbsd 6.99.14 NetBSD 6.99.14 (GENERIC) #0: Sat Oct 27 19:27:36 CEST 2012  instsoft@yosemite:/tmp/netbsd-drmgem.usr/src/sys/arch/amd64/compile/GENERIC amd64
So, the kernel is an experimental kernel, and (at least part of ) the base system files are the ones installed from NetBSD 6.0.1 CD. But the system as a whole, it works!

I noticed two bugs during the X usage:
1) When I switch from X to text mode (eg doing Ctrl+Alt+F1) and then switch back to X mode, the desktop is “wrongly” displayed, the mouse pointer is “not in sync” with the desktop surface...
Actually, this bug was reported, I saw it during my searches for X fixing.
However, considering that it's uncommon to switch from X to text mode, I can say that this is not disturbing.

2) When watching a movie (applies to both DivX avi files and DVD files, I tested them both), sometimes the screen flickers (it's like a less-than-a-second flashy thing). I estimate this happens about 10 times for a 2 hour movie, at random times.
Again, considering the duration of this, I can say that I don't find this disturbing.

As a status of my graphics with the netbsd-drmgen kernel, have a look at my native resolution and FPS statistics:
Code:
bash-4.2# xrandr -q
Screen 0: minimum 320 x 200, current 1600 x 900, maximum 4096 x 4096
VGA disconnected (normal left inverted right x axis y axis)
LVDS connected 1600x900+0+0 (normal left inverted right x axis y axis) 310mm x 174mm
   1600x900       60.0*+
HDMI-3 disconnected (normal left inverted right x axis y axis)
DP-B disconnected (normal left inverted right x axis y axis)
HDMI-4 disconnected (normal left inverted right x axis y axis)
HDMI-5 disconnected (normal left inverted right x axis y axis)
DP-C disconnected (normal left inverted right x axis y axis)
DP-D disconnected (normal left inverted right x axis y axis)
bash-4.2# glxgears 
1180 frames in 5.0 seconds = 235.946 FPS
1326 frames in 5.0 seconds = 265.053 FPS
1343 frames in 5.0 seconds = 268.492 FPS
1405 frames in 5.0 seconds = 280.885 FPS
1401 frames in 5.0 seconds = 280.066 FPS
And that's it about my T420 +NetBSD 6.0.1 configuration!

Of course, I didn't have the time and means to test some other things such as bluetooth, Gigabit ethernet transfer speed, dual-monitor configuration, and many, many others.
But, for getting a working desktop computer, I dare to say I documented the required stuff!


Any comments are welcomed.
Reply With Quote
  #2   (View Single Post)  
Old 31st January 2013
bsdnotbdsm bsdnotbdsm is offline
Port Guard
 
Join Date: Jan 2013
Posts: 30
Default

First comment for me, from myself: :P
My apologies for non-formatted URLs. I'm a new user, so I don't have all the features enabled...
Reply With Quote
  #3   (View Single Post)  
Old 31st January 2013
vermaden's Avatar
vermaden vermaden is offline
Administrator
 
Join Date: Apr 2008
Location: pl_PL.lodz
Posts: 1,056
Default

Looks like quite a lot of work to make all these whistles working, good job and thanks for sharing it
__________________
religions, worst damnation of mankind
"If 386BSD had been available when I started on Linux, Linux would probably never had happened." Linus Torvalds

Linux is not UNIX! Face it! It is not an insult. It is fact: GNU is a recursive acronym for “GNU's Not UNIX”.
vermaden's: links resources deviantart spreadbsd
Reply With Quote
  #4   (View Single Post)  
Old 23rd February 2013
clod clod is offline
New User
 
Join Date: Feb 2013
Posts: 2
Default

How's battery life on the laptop? and what about the fan? On linux you probably know in order to keep it from spinning constantly at 1800rpm you need to use thinkfan.
Reply With Quote
  #5   (View Single Post)  
Old 9th March 2013
daemonfowl daemonfowl is offline
bsdstudent
 
Join Date: Jan 2012
Location: DaemonLand
Posts: 834
Default

bsdnotbdsm, Thank you for sharing !
Reply With Quote
  #6   (View Single Post)  
Old 27th March 2013
bsdnotbdsm bsdnotbdsm is offline
Port Guard
 
Join Date: Jan 2013
Posts: 30
Default

Quote:
Originally Posted by clod View Post
How's battery life on the laptop? and what about the fan? On linux you probably know in order to keep it from spinning constantly at 1800rpm you need to use thinkfan.
In the only experiment I did, the battery lasted for 4 hours and 33 minutes.
The battery is a 9 months old 6-cell one.
Testing conditions: display at maximum brightness all the time, wireless connected continously, doing casual Net surfing activity and compiling software for about 30 minutes(therefore only 30+ minutes of heavy load).
Note: I estimate the system was idle for about 1 hour out of those 4.5 hours(screen saver went on), however the wireless was connected continously.

Regarding the fan, I don't know (yet) how to get informations about its status in NetBSD.
On short: the system is not over-heating when doing casual stuff, it heats when I compile big programs(using pkgsrc) and then I can hear the fan increasing its speed. All in all, heating is not an issue, I assume fan is working OK.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Your NetBSD Laptop vermaden NetBSD General 38 5th October 2023 01:41 PM
Thinkpad nvram in NetBSD bamdad NetBSD Installation and Upgrading 10 19th September 2010 05:49 PM
NetBSD laptop thread Mr-Biscuit Guides 1 10th June 2009 05:51 AM
Installation problems on X24 laptop IIMarckus OpenBSD Installation and Upgrading 6 5th September 2008 07:58 PM
NetBSD + old laptop adventure anomie NetBSD General 4 27th June 2008 01:57 PM


All times are GMT. The time now is 04:16 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick