Wednesday, March 21, 2012

FreeBSD Post install config

So here it is, the promised post about FreeBSD post install configuration.  This guide assumes that you are already familiar with Unix like operating systems in general.  If you are completely new to FreeBSD, and find yourself getting lost through this guide, see The FreeBSD Handbook to get started.  This was a base install, meaning that I did not install any other applications aside from base, doc, and the system sources.  I did this to have more options when it came to installing software later.  I also did it this way because it is easier to get DRM/DRI configured correctly if you don't install Xorg first.  Which brings us to our first point:

- DRM/DRI configuration for ATI with the goal of 3D acceleration:
Okay, this works, but it doesn't work perfectly.  I have still not been able to get compiz-fusion to work, and I have compositing only with XFCE4, but as that is all I wanted in the first place, this solution works great for me.  Cairo-Dock still does not work correctly, and I don't know why.  For some reason, it is not picking up on the fact that the compositor for XFCE is running.  Also some of the features for the ATI cards will not work because of KMS, and the fact that FreeBSD does not have KMS yet.  There is a project under way to get KMS and GEM, but I have a feeling that inclusion into the kernel is still a long way off.  So what is KMS?
Mode-setting can be done in kernel space (Kernel Mode Setting, KMS) or in user space (User-space Mode Setting, UMS). Doing mode-setting in kernel-space is more flexible and allows displaying of an error in the case of a fatal error in the kernel, even when using a user-space display server. User-space mode-setting would have needed superuser privileges for direct hardware access, so kernel-based mode-setting increases security because the user-space graphics server does not need superuser privileges.
All of the newer cards have dropped support for mode setting in user space, and have switched to KMS.  There is nothing that can be done about this, and if you have to be able to access this functionality, I would highly recommend using Arch Linux as your distribution of choice.  So, moving along.  
The first thing that needs to be done before you install anything is a quick edit to /etc/make.conf
Add the following:
WITHOUT_NOUVEAU=yes
Now, save the file, and navigate to /usr/ports/graphics/dri  
# make && make install clean
Once this command completes, you can then navigate to /usr/ports/graphics/mesa-demos  
# make && make install clean 
This should have installed the 7.6.1 mesa libraries on your machine.  This is crucial to having compositing and 3D acceleration.  You can now navigate to /usr/ports/x11/xorg 
# make && make install clean
All of this is going to take quite some time to complete, so have a snack and watch some TV, or catch up on your reading.  You will have to interact with the process selecting build options, so don't wander too far off.
And the final item, navigate to /usr/ports/x11-drivers/xf86-video-ati.  
# make && make install clean
Once this completes, run the command
# Xorg -configure 
and copy the resulting config to /etc/X11/xorg.confOnce this process is complete, proceed with installing your WM of choice, XFCE4 for me, and basic software like browsers, etc.  I chose to use pre-compiled packages for most of these, and compiled most of them later once I got the Graphical environment up and running.  After completion run  
% glxinfo | grep render 
if all went well you should see:
direct rendering: Yes
OpenGL renderer string: Mesa DRI R600 (RS880 9712) 20090101 TCL
Or some similar variation.  If you see any information about a software rasterizer, then there are some issues with the install of dri or mesa.  I have run into this error and just re-built mesa and dri.  

Suspend/Resume:
And this brings us to our next issue.  Suspend/Resume.  I had a devil of a time getting this to work correctly, and after a large amount of reading, I was able to come to a solution.  FreeBSD uses sysctl to manage various aspects of ACPI management, and these settings can be configured at boot time by adding them to /etc/sysctl.conf, so the first thing to do is see what settings are available.  Run the command  
# sysctl hw.acpi | grep state 
if you see S3 listed in hw.acpi.supported_sleep_state, then you are in luck, you can suspend.  I chose to suspend on lid close, because that is the most useful to me so edit the file /etc/sysctl.conf and add:
hw.acpi.lid_switch_state=s3
hw.acpi.reset_video=1
Resetting the video fixes a nasty issue that arises when resuming, wherein the monitor does not seem to want to work correctly, or sometimes at all.  Resetting the video via sysctl fixes this, at least for me, as with all things mileage may vary.
The final step is editing /boot/device.hints and adding:
hint.psm.0.flags="0x2000"
This flag sets the bit that triggers HOOKRESUME which sends data to the mouse to wake it up.  Other values are "0x6000" which triggers both HOOKRESUME and INITAFTERSUSPEND,(this will wake up the mouse and re-initialize it), and "0x4000" which triggers INITAFTERSUSPEND, which will re-initialize the mouse. 
Getting Flash Player and Linux Compatibility up and running
Getting Flash Player to work is mostly painless.  The first thing to do is load the linux compatibility module into the kernel.
# kldload linux 
Once you have done this navigate to /usr/ports/emulators/linux_base-f10/
# make && make install clean
Next navigate to /usr/ports/www/nsplugin-wrapper/
# make && make install clean
Then navigate to /usr/ports/www/linux-f10-flashplugin11
# make && make install clean
Set up a symbolic link to libflashplayer.so in /usr/local/lib/browser_plugins: 
# ln -s /usr/local/lib/npapi/linux-f10-flashplugin/libflashplayer.so /usr/local/lib/browser_plugins
You may have to create the browser_plugins directory.
Finally you have to install the plugin for every user INDIVIDUALLY as that user by running:
% nspluginwrapper -v -a -i
Once you have completed this step, restart your browser, and you should be in business.

Controlling Wireless:
This is the easy one.  If you are using wpa_supplicant, and you set up your wireless adapter during the install, all you have to do is add your networks to /etc/wpa_supplicant.conf and it will switch for you when you are in range.

I hope that this helps someone to avoid some of the issues that I ran into during my most recent post install.  Here is a screen shot of the finished system.

No comments:

Post a Comment