Archive for the ‘FreeBSD’ Category.

How to restart FreeBSD?

FreeBSD can be restarted in a few ways:

As root run the following:

# reboot

You can also run this command.

# init 6

If you are not logged in as root but you have access to the console, you can initiate a reboot by pressing the common Ctrl + Alt + Delete key sequence.

How to update all your installed ports on FreeBSD using portupgrade?

Ok, this week there is a simple tool that we are going to talk about. It is called portupgrade. This is a handy software that allows you to manage your ports more efficiently.

I use portupgrade when I want to do things the easy way.

Lets give you a use case. You want to install a new piece of software that requires a library that you already have installed, for example, openssl, however the port fails because the dependency is too old of a version. Well, now you have find the updated port for openssl and uninstall and reinstall it. That might seem easy with one port. But now imaging you have a very new piece of software and you have to update a dozen or more ports. That is going to be time consuming. That is where portupgrade comes in. It does the hard work for you.

Step 1 – Make sure you have ports installed and updated
I already have a post on this. It is pretty short. Check it out here.
How to install ports on FreeBSD?

Make sure that even if you have installed ports that you update ports again so you have the latest.

Step 2 – Install portupgrade

  1. Log on as root.
    $ su
    Password:
    #
  2. Change to the ports directory and
    #
    #
    cd /usr/ports/ports-mgmt/portupgrade
    make BATCH=yes install

Step 3 – See which ports are outdated
The following command will show you which packages are up to date and which are not. Ok, you don’t really need portupgrade for this, because you can also run pkg_version which is part of base, but portupgrade seems to make a database and do this faster.

# portversion

Now, if you want to only see ports that are not up to date, do this:

# portversion |grep \<

Step 4 – Upgrade a port
Ok, now that portupgrade is installed, it is easy to upgrade a port.

# portupgrade portname

You can just copy and past the portname from the output of the portversion command.

Step 5 – Upgrade all ports
Ok, maybe you want to upgrade all your ports, and I am not saying you should, but maybe you want to. Here is a nice command that will do that for you.

# portupgrade -a -m BATCH=yes

Now that is not exactly complete, because we need to update the ports tree first. So do this:

# portsnap fetch update && portupgrade -a -m BATCH=yes

Now, on my FreeBSD box with an Xorg and KDE4 install, this has been going for over a day and isn’t done yet. I takes a long time to recompile all the Xorg, GTK, KDE4, and other miscellaneous ports.

Have fun with portupgrade.


Copyright ® Rhyous.com – Linking to this article is allowed without permission and as many as ten lines of this article can be used along with this link. Any other use of this article is allowed only by permission of Rhyous.com.

BSD Mag is now a free online publication: Download the first issue

Hello everyone,

Many of you may know this, but I didn’t. BSD Mag is now a free online publication.

There is a January and February issue, as well as a few issues from last year and other past years. You can see the issues available for download here:

http://bsdmag.org/pdf-articles

The February issue is titled: BSDs AS SERVERS

The January issue is titled: Infinity. Freedom. FreeBSD

BSD Mag goes right along with my FreeBSD Friday idea of becoming a little more of an export slowly over time. The magazine comes once a month and reading it for a few months probably won’t change your skills much, but over five or ten or more years, the knowledge you gain will help you become an expert.

How to install VMWare-tools on FreeBSD 8 or PC-BSD 8?

I have documentation on how to create a FreeBSD 8 Desktop environment here:
How to install and configure a FreeBSD 8 Desktop with Xorg and KDE?

However, if you install FreeBSD or PC-BSD as a VMWare guest, you will want to install two additional pieces of software when you are finished:

  1. You need to install the VMWare X11 driver (no, it will not be installed when you install the VMWare tools)
  2. You need to install VMWare-tools

This guide is to walk you through resolving the second of these two issues. I assume you followed my article for building the FreeBSD desktop, and if you did, these steps will work for you. But if you didn’t, I can’t guarantee that there won’t be some steps that are slightly different for you.

In order for me to consider the VMWare-Tools installed and working, the following features must work:

  • Clipboard Synchonization
  • Grab/Release Mouse Input when mouse enters/leaves the guests screen
  • Autofit Guest (automatically making the guests screen resolution take all available space)
  • Time Synchronization (the time in the VMWare guest will match the hosts time).

In this document, I successfully get these features working.

I have VMWare Workstation 6.5.3 build 185404 and the host is Windows 7.

Part 1 – Installing and Configuring the VMWare X11 Driver

Already posted on this here:
How to install the vmware video card driver on a FreeBSD 8 guest virtual machine?

Part 2 – Installing and Configuring VMWare Tools

Step 1 – Mount the VMware Tools virtual cd

  1. On the VMWare hosts make sure that your FreeBSD guest is selected and that you are not full screen so you have the VMWare Workstation application surrounding the FreeBSD guest.
  2. From the VMWare Workstation application, choose VM | Install VMWare tools…You will see a pop-up inside FreeBSD on the bottom left.
  3. Click on the popup where it says VMWare Tools. This will open Dolphin file browser.
  4. In the Dolphin file browser on the bottom left, you should see the VMWare Tools media. Click on it.

Step 2 – Extract the vmware-freebsd-tools.tar.gz

  1. Right click on vmware-freebsd-tools.tar.gz and choose Extract Archive to… Now you can extract to where you want, as long as you have the folder permission to write to, but the next steps describe where I extracted it to.
  2. Click on Home at the left. There is no need to create a folder as the extacted files will all be in one folder called vmwware-tools-distrib when extracted.
  3. Click OK. The vmware-freebsd-tools.tar.gz is extracted.

Step 3 – Open a shell as root

  1. Cick K | Applications | System | Konsole to open the shell.
  2. Type in su$ su
    Password:
    #

Step 4 – Install the freebsd6 compatibility package.

  1. Determine your architecture or processor type. If you are 64 bit, it will be amd64 even it is intel 64 bit. If you are 32 bit, it is likely x86. Type uname -a to determine what your architecture is and look at the last piece of information provided.

    # uname -a
    FreeBSD FBSD8.hsd1.ut.comcast.net. 8.0-RELEASE-p2 FreeBSD 8.0-RELEASE-p2 #0: Tue Jan 5 21:11:58 UTC 2010 root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC amd64
    #

  2. Install the compat6x-[arch].tgz package, where you replace [arch] with your architecture.  This is already installed on PC-BSD.
    # pkg_add -r compat6x-amd64

Step 5 – Compile and Install the vmware-freebsd-tools

  1. Change to the directory where you extracted the vmware-freebsd-tools.tar.gz.

    # cd /home/jared/vmware-tools-distrib

  2. Run vmware-install.pl.# ./vmware-install.pl

    Just keep hitting enter and accepting the defaults until the vmware-tools are installed.

Step 6 – Start vmware tools

  1. As root run the following:

    # /usr/local/etc/rc.d/vmware-tools.sh start

    Or you could just reboot.

    Note: Since vmware-tools doesn’t exactly integrate with rcNG, you don’t need to add anything to /etc/rc.conf. The just dump a script into /usr/local/etc/rc.d and it is just a shell script and isn’t formatted to require it to be enabled by /etc/rc.conf.

Step 7 – Enabling VMWare user features
The vmware-user process must be launched to enable vmware-user features.

  • Clipboard Synchonization
  • Grab/Release Mouse Input when mouse enters/leaves the guests screen
  • Autofit Guest (automatically making the guests screen resolution take all available space)
  1. Configure vmware-user to run at KDE login by copying the /usr/local/bin/vmware-user shell script to the ~/.kde4/Autostart directory.  You could also create a symlink.
    $ cp /usr/local/bin/vmware-user ~/.kde4/Autostart

    Note: You don’t have to use the command.  In the System Settings under Advanced |Autostart there is an option to Add Script that you can use.

  2. Logout of KDE and log back in.

Step 8 – Running the VMWare-Toolbox
There may be some vmware settings you want to change on the VMWare guest. Not many are configurable through the vmware-toolbox on FreeBSD but at least one is configurable here called Time Synchronization. This feature will synchronize your vmware guest’s time with the hosts time.

  1. Run vmware-toolbox

    $ vmware-toolbox

  2. Check the box to enable time synchronization
  3. Feel free to explore and become familiar with the other settings, there aren’t many and two of the settings can only run as root.

Tuning Recommendations
I found a lot of tuning recommendations. However, if you chose Other | FreeBSD or Other FreeBSD 64 when creating your vm, these first two are set by default.

  1. It is recommended to have kern.hz set to 100 and it is by default so nothing to do here.
  2. It was recommended that on the host, in the vmx config file for the guest, that the following be configured:
    • ethernet0.virtualDev = “e1000”

    Again, if you chose Other | FreeBSD or Other FreeBSD 64 when creating your vm, this is set by default.

  3. Some people will recommend this setting in the vmx config file as well:
    • tools.syncTime = “TRUE”

    However, this is the same as the time synchronization setting we configured with the vmware-toolbox. It is safer to make the configuration in the vmware-toolbox tool.

If you know of any further tuning options, please comment them to me.


Copyright ® Rhyous.com – Linking to this article is allowed without permission and as many as ten lines of this article can be used along with this link. Any other use of this article is allowed only by permission of Rhyous.com.

How to install the vmware video card driver on a FreeBSD 8 guest virtual machine?

Well, I have documentation on how to create a FreeBSD 8 Desktop environment here:
How to install and configure a FreeBSD 8 Desktop with Xorg and KDE?

However, if you install FreeBSD as a VMWare guest, you will want to install two additional pieces of software when you are finished:

  1. You need to install the VMWare X11 driver (no, it will not be installed when you install the VMWare tools)
  2. You need to install VMWare-tools

This guide is to walk you through resolving the first of these two issues. I assume you followed my article for building the FreeBSD desktop, and if you did, these steps will work for you. But if you didn’t, I can’t guarantee that there won’t be some steps that are slightly different for you.

Part 1 – Installing and Configuring the VMWare X11 Driver

Step 1 – Install the VMWare X11 driver

  1. Change to the appropriate ports directory.

    # cd /usr/ports/x11-drivers/xf86-video-vmware

  2. Make (compile) and install the VMWare X11 driver

    # make install

The VMWare X11 driver is now installed.

Step 2 – Modify the /etc/X11/xorg.conf
Note: If you didn’t create an xorg.conf file, then you don’t need to do this step, so skip it.

  1. If you auto-created your xorg.conf, auto create it again.
    # Xorg -configure
  2. Move the auto created /root/xorg.conf.new to /etc/X11/xorg.conf.

    # mv /root/xorg.conf.new /etc/X11/xorg.conf

If you have a custom xorg.conf, then it may be easier to edit it manually.

  1. Edit the /etc/x11/xorg.conf as root.

    # ee /etc/x11/xorg.conf

  2. Change the “Device” section to look as follows.
    Section "Device"
            ### Available Driver options are:-
            ### Values: <i>: integer, <f>: float, <bool>: "True"/"False",
            ### <string>: "String", <freq>: "<f> Hz/kHz/MHz"
            ### [arg]: arg optional
            #Option     "HWcursor"                  # [<bool>]
            #Option     "Xinerama"                  # [<bool>]
            #Option     "StaticXinerama"            # <str>
            Identifier  "Card0"
            Driver      "vmware"
            VendorName  "VMware"
            BoardName   "SVGA II Adapter"
            BusID       "PCI:0:15:0"
    EndSection
    

Step 3 – Restart Xorg
If you are still in KDE, you must logout and log back in. You can probably do this without instructions, but if this is your first time using FreeBSD and KDE 4, a quick screen shot of how to do this won’t hurt. I do like my walk-thru’s to be newbie proof.

  1. At the bottom left of your window, click on the K icon, then Leave, then Logout.

  2. After clicking the Leave option, KDE will exit, and xorg will restart and you should be returned to the login screen. Now log back in.

Note: If you aren’t using KDM, then you will be returned to your logged in shell and you will have to launch Xorg and KDE yourself using the startx command.
Step 4 – Configure your screen resolution

  1. Click the K icon, then Applications | System.
  2. When the menu shifts, the system options appears. Select Screen Resize & Rotate.

  3. Now don’t be confused when this doesn’t open a window. It does launch the program, but for some reason it starts up minimized and is an icon at the bottom right of the panel. It looks like a little monitor (the red arrow is pointing to it).
  4. Click on the monitor icon to get the Configure Display window.
  5. Click the Size drop down menu and choose your new resolution.
  6. Click Apply.
  7. If the resolution fails, it should return to the previous resolution after about ten or fifteen seconds. If the resolution works, click the option to accept the resolution.

You should now have the VMWare Driver installed.

Part 2 – Installing and Configuring VMWare Tools

This is in a separate post here:
How to install VMWare-tools on FreeBSD 8?


Copyright ® Rhyous.com – Linking to this article is allowed without permission and as many as ten lines of this article can be used along with this link. Any other use of this article is allowed only by permission of Rhyous.com.

How to compile and install K-3D 0.7.12 on FreeBSD 8? (Update K-3D 0.8.0.0)

Ok, so I found a port that is need of updating. K-3D. FreeBSD has K-3D version 6.7 in ports but K-3D is on release 7.11 and approaching their version 8 release. So lets see what we need to do to get this port updated.

To start out, I have informed both FreeBSD and K-3D that I am going to help with this using their forums.
http://forums.freebsd.org/showthread.php?t=10647
http://www.k-3d.org/forums/topic/updated-port-for-freebsd-8

Step 1 – Build a FreeBSD 8 Desktop Environment
Build yourself a desktop as described here (or however you want if you know what you are doing):
How to install and configure a FreeBSD 8 Desktop with Xorg and KDE?

Step 2 – Install dependencies
The following are dependencies that are required to build K-3D on FreeBSD 8.

  1. Install mercurial
    K-3D uses Mercurial as its version managed system for its code (it used to use subversion but now uses mercurial). So to download the code you need to install Mercurial.

    As root do this:

    # cd /usr/ports/devel/mercurial
    # make install

  2. Install cmake 2.8 or later.
    K-3D now uses cmake as its build management system as opposed to make or gmake. Since cmake is not installed on FreeBSD by default, lets install it.

    # cd /usr/ports/devel/cmake
    # make install

  3. Install cairomm.

    # cd /usr/ports/graphics/cairomm
    # make install

    Note: This will also install glibmm and sigc++.

  4. Install gnome-vfs.

    # cd /usr/ports/devel/gnome-vfs
    # make install

  5. Install gtkglex.

    # cd /usr/ports/x11-toolkits/gtkglext
    # make install

  6. Install gtkmm24.

    # cd /usr/ports/x11-toolkits/gtkmm24
    # make install

  7. Install gtksourceview2.

    # cd /usr/ports/x11-toolkits/gtksourceview2
    # make install

  8. Install gts.

    # cd /usr/ports/graphics/gts
    # make install

  9. Install ImageMagick.

    # cd /usr/ports/graphics/ImageMagick
    # make install

  10. Install e2fsprogs-libuuid.

    # cd /usr/ports/misc/e2fsprogs-libuuid
    # make install

  11. Install Doxygen.

    # cd /usr/ports/devel/doxygen
    # make install

    Note: This took quite a long time to compile because it also had a lot of large depencies.

  12. Install libexecinfo.

    # cd /usr/ports/devel/libexecinfo
    # make install

Step 3 – Download the code and build it

  1. As a regular user, run these commands:

    $ cd ~
    $ hg clone http://k3d.hg.sf.net/hgweb/k3d/k3d

    The code will take a minute or two (or more if you have a slow connection) to download.

  2. – Make a build directory
    K-3D cannot be built in the same directory where the code resides. So lets create a build directory and change to that directory.

    $ mkdir ~/k3d-build
    $ cd k3d-build

  3. Run cmake against k3d

    $ cmake ~/k3d

    Note: If you forget to install the dependencies, you will get errors. Here is the output of my attempt to compile before I installed the dependencies.

    $ cd k3d-build
    $ cmake ~/k3d
    -- checking the width of std::vector<>::size_type for this platform
    --   std::vector<>::size_type is 64 bits
    -- checking for module 'cairomm-1.0'
    gnome-config: not found
    --   package 'cairomm-1.0' not found
    -- checking for module 'dbus-glib-1'
    --   found dbus-glib-1, version 0.82
    -- checking for module 'freetype2'
    --   found freetype2, version 9.20.3
    -- checking for module 'glibmm-2.4'
    gnome-config: not found
    --   package 'glibmm-2.4' not found
    -- checking for module 'gnome-vfs-2.0'
    gnome-config: not found
    --   package 'gnome-vfs-2.0' not found
    -- checking for module 'gtkglext-1.0'
    gnome-config: not found
    --   package 'gtkglext-1.0' not found
    -- checking for module 'gtkmm-2.4'
    gnome-config: not found
    --   package 'gtkmm-2.4' not found
    -- checking for module 'gtksourceview-2.0'
    gnome-config: not found
    --   package 'gtksourceview-2.0' not found
    -- checking for module 'gts'
    gnome-config: not found
    --   package 'gts' not found
    -- checking for module 'ImageMagick++'
    gnome-config: not found
    --   package 'ImageMagick++' not found
    -- checking for module 'OpenEXR'
    --   found OpenEXR, version 1.6.1
    -- checking for module 'libpng12'
    --   found libpng12, version 1.2.40
    -- checking for module 'sigc++-2.0'
    gnome-config: not found
    --   package 'sigc++-2.0' not found
    CMake Error at cmake/modules/K3DDependencies.cmake:18 (MESSAGE):
      Couldn't find glibmm, which is required to build K-3D.  You can obtain
      glibmm from http://gtkmm.org.
    Call Stack (most recent call first):
      CMakeLists.txt:248 (K3D_CHECK_REQUIRED_DEPENDENCY)
    
    
    CMake Error at cmake/modules/K3DDependencies.cmake:18 (MESSAGE):
      Couldn't find libsigc++, which is required to build K-3D.  You can obtain
      libsigc++ from http://libsigc.sourceforge.net.
    Call Stack (most recent call first):
      CMakeLists.txt:251 (K3D_CHECK_REQUIRED_DEPENDENCY)
    
    
    -- checking for module 'uuid'
    gnome-config: not found
    --   package 'uuid' not found
    CMake Error at cmake/modules/K3DDependencies.cmake:18 (MESSAGE):
      Couldn't find uuid, which is required to build K-3D.  You can obtain uuid
      from http://www.ossp.org/pkg/lib/uuid.
    Call Stack (most recent call first):
      CMakeLists.txt:257 (K3D_CHECK_REQUIRED_DEPENDENCY)
    
    
    CMake Error at cmake/modules/K3DDependencies.cmake:28 (MESSAGE):
      Couldn't find the gtkglext library, which is required by
      K3D_BUILD_NGUI_MODULE.
    Call Stack (most recent call first):
      CMakeLists.txt:272 (K3D_CHECK_OPTIONAL_DEPENDENCY)
    
    
    CMake Error at cmake/modules/K3DDependencies.cmake:28 (MESSAGE):
      Couldn't find the gtkmm library, which is required by
      K3D_BUILD_NGUI_MODULE.
    Call Stack (most recent call first):
      CMakeLists.txt:273 (K3D_CHECK_OPTIONAL_DEPENDENCY)
    
    
    CMake Error at cmake/modules/K3DDependencies.cmake:28 (MESSAGE):
      Couldn't find the cairomm library, which is required by
      K3D_BUILD_NGUI_PIPELINE_PANEL_MODULE.
    Call Stack (most recent call first):
      CMakeLists.txt:274 (K3D_CHECK_OPTIONAL_DEPENDENCY)
    
    
    -- checking for module 'gthread-2.0'
    --   found gthread-2.0, version 2.20.5
    -- generating i18n catalog
    --   done
    -- Could NOT find Doxygen  (missing:  DOXYGEN_EXECUTABLE)
    -- Configuring incomplete, errors occurred!
    $
    

    Hopefully you installed the dependencies and didn’t see any of the above errors.

Step 4 – Test Running the application
We can test running this from the build directory before installing, so lets do that.

  1. From the k3d-build directory, type make run:

    $ make run

  2. Ok, so now that it is compiling it is failing to run…hopefully we can get that fixed. Stay tuned.

UPDATE: 2/2/2010

Ok, so I am back. Here is the what I have done.

Step 5 – Fixing run errors

  1. Compiled with debugging. I ran ccmake ~/k3d again and this time I set the CMAKE_BUILD_TYPE to Debug before choosing to configure. Once configure was done, I ran make again.
  2. Grepped for the error in the code. Specifically, this term:

    $ grep -Rn k3d::iuser_interface ~/k3d/*

    I found the problem code was in this file and line number:
    File: /home/jared/k3d/application/k3d_main.cpp
    line: 460

  3. Went to the problematic code and investigated it. It seems to be a simple check, so I commented that block of code out so it would continue:
    //      if(!dynamic_cast<k3d::iuser_interface*>(g_user_interface))
    //     {
    //              delete g_user_interface;
    //              g_user_interface = 0;
    //              handle_error("UI plugin module [" + module_name + "] does not impleme
    //              return;
    //      }
    
  4. I recompiled (everything remained compiled except the one part with the file I changed so compiling was quick).
  5. I launched make run again:

    # make run

    This time, as I had hoped, it loaded the application completely.

    However, I noticed some errors.

    The first two error lines occurred early in the load process. I am not sure but they seem to be unrelated:

    INFO: Gtk: Failed to load module “atk-bridge”: Shared object “libatk-bridge.so” not found, required by “k3d”
    :1: error: unexpected character `\241′, expected keyword – e.g. `style’

    ERROR: /home/jared/k3d/modules/virtual_opengl_painters/sds_point_painter.cpp line 73: assertion `delegate’ failed
    ERROR: Error creating document plugin: VirtualOpenGLSDSPointPainter
    ERROR: /home/jared/k3d/modules/virtual_opengl_painters/sds_edge_painter.cpp line 73: assertion `delegate’ failed
    ERROR: Error creating document plugin: VirtualOpenGLSDSEdgePainter
    ERROR: /home/jared/k3d/modules/virtual_opengl_painters/sds_face_painter.cpp line 73: assertion `delegate’ failed
    ERROR: Error creating document plugin: VirtualOpenGLSDSFacePainter

  6. I searched the ports tree for the libatk-bridge.so file.

    # /usr/ports
    # grep -R libatk-bridge *

    It looks like there is a at-spi package that provides this library.

  7. Install the at-spi package

    # cd /usr/ports/accessibility/at-spi
    # make install

  8. Tried to make run again.

    # exit
    $ cd ~/k3d-build
    $ make run

    The application loaded and the libatk-bridge error was gone but it was replaced with a warning:

    (k3d:55092): atk-bridge-WARNING **: AT_SPI_REGISTRY was not started at session startup.

    (k3d:55092): atk-bridge-WARNING **: IOR not set.

    (k3d:55092): atk-bridge-WARNING **: Could not locate registry

  9. Ok, so now that it is running, I think it is time to submit bugs to K-3d for the remaining errors.

As of right now, I don’t think it is worth the effort to create a port of version 7.11 as it has bugs for FreeBSD. I feel comfortable that when the next revision of K-3D comes out, version 8.x, the code will work well and we will create a port for it.

UPDATE: February 8, 2010

The main developer has made some changes so that K-3D launches now. The error that prevent the launch is gone (the others that seem somewhat benign are still occurring).

There is now a problem with K-3D on FreeBSD in that the faces cannot be properly selected, so the user-interface is not working perfectly.

Again, I will work on this problem and update this post.

Update: The problem is now resolved. There are couple lingering issues that you can read about at the K-3D forums.
http://www.k-3d.org/forums/topic/updated-port-for-freebsd-8

Hopefully all will be resolved when version 8 releases and we can make a new port.

Update: March 31, 2010

Ok, it looks like we need to move to Mesa 7.6.1 to get the latest versions of K-3D to work. Mesa 7.6.1 is available on FreeBSD.

You just have do make WITHOUT_NOUVEAU in order for the new version to be pulled. Here is what I did.

portsnap fetch update

cd /usr/ports/graphics/libGL/
make deinstall
make WITHOUT_NOUVEAU=yes install

cd /usr/ports/graphics/libGLU/
make deinstall
make WITHOUT_NOUVEAU=yes install

cd /usr/ports/graphics/libGLw/
make deinstall
make WITHOUT_NOUVEAU=yes install

cd /usr/ports/graphics/libglut/
make deinstall
make WITHOUT_NOUVEAU=yes install

cd /usr/ports/graphics/libdrm/
make deinstall
make WITHOUT_NOUVEAU=yes install

cd /usr/ports/graphics/dri/
make deinstall
make WITHOUT_NOUVEAU=yes install

Now things are working rather well, though the rendering with Aqsis is just giving me a black box. Hopefully I will fix that.

I fixed the black box just be restarting K-3D (I had installed Aqsis while K-3D was running).

However, now I am seeing a problem with Rendering the mug example. The handle does not appear to be rendered correctly.

It should look like this:

However, on FreeBSD it looks like this:

How to install the Code::Blocks IDE on FreeBSD 8?

Ok, so some developers are completely happy and content coding without an Integrated Development Environment (IDE), but I really like IDEs and think they provide a lot of ways to improve development speed and efficiency. I never have been able to get into vim or emacs though if you are into it, that’s cool for you, just doesn’t work for me.

So lets install the Code::Blocks IDE on FreeBSD and compile an application or two.

Step 1 – Setup a FreeBSD Desktop
Instructions for doing this are located here
How to install and configure a FreeBSD 8 Desktop with Xorg and KDE?
After following the linked-to guide, you should have FreeBSD with Xorg and KDE installed.

Step 2 – Install CodeBlocks from ports

  1. Login as root.
  2. Change to the ports directory.

    # cd /usr/ports

  3. Find the CodeBlocks port. There are a couple of commands that can help you find the port.

    Run this from anywhere:

    # whereis codeblocks

    Or from /usr/ports run this:

    # make search name=codeblocks

    The port location is /usr/ports/devel/codeblocks.

  4. Change to the directory for the codeblocks port.

    # cd /usr/ports/devel/codeblocks

  5. Type make install to compile and install Code::Blocks.

    # make install

    Note: If you pay attention while CodeBlocks is compiled, you will see that wxWidgets is installed as a dependency.

Step 3 - Launch CodeBlocks for the first time

  1. Click the K icon at the bottom left (similar to the Start icon in windows) and move the cursor over the Applications tab.
  2. Click Development and you will see the list of items. Yes, the Code::Blocks install places an icon to the Development section of the KMenu for you.

  3. Click the Code::Blocks icon.
  4. You will be prompted for a compiler. Select GNU GCC Compiler.

You now are running the Code::Blocks IDE on FreeBSD.

Note: Code::Blocks opens and gives you a "Tip of the day" window. These tips can be valuable, so unless you are a Code::Blocks expert, I recommend leaving them on and taking the short seconds it takes to read them. This goes along with my overall theme of becoming a little more of an expert each day.

Step 4 - Create a new project and compile it

  1. Click File | New | Project.
  2. Select Empty Project.
  3. The next screen is just a welcome screen and you can click a check box to never see it again and then click Next.
  4. Enter a project name. I just typed in hw (short for, yes you guessed it, Hello World).
  5. Enter a directory or click the ... icon to browse to a directory.
    Note: The bottom two fields are filled out for you.

  6. Click Next.
  7. On the next screen you have options, such as switching to a different compiler, but everything is pretty much set to defaults how you probably want. So unless you have a good reason, leave it as is and click Finish.
  8. Click File | New | Empty File.
  9. When prompted to add to the project, choose Yes.
  10. Enter a file name. I used main.cpp and click next.
  11. You will be prompted for the targets this file should be added to, such as debug and release. Click Select All and hit Ok.
  12. On the left, under Projects, expand Workspace, the expand the project Name ("hw" in this example), expand Sources.
  13. Open main.cpp by double-clicking on it.
  14. Enter your code (in this case I am entering in some simple hello world code).

    #include

    int main()
    {
    std::cout << "Hello World" << std::endl; return 0; } [/sourcecode]

  15. Select Build | Build or press Ctrl + F9 to build/compile your program.

Your program should now be compiled.

Step 5 - Run the program

  1. You can run the program in two ways:
    • Select Build | Run or press Ctrl + F10.
    • Open a shell and browse to the directory.

Step 6 - Debug the program
To debug a program you must first create a break point and then start debugging, in that order. So lets do it.

  1. Set a breakpoint by clicking just to the right of the line numbers just to the left of the line of code you want the program to break at. When you set the break point, a red circle is added. I am setting a breakpoint on line 3 of the Hello World code, which is the main() function.
  2. Click Debug | Start or press F8. The program will start and a yellow arrow will show up inside the red circle.
  3. Press F7 to cause the debugging to continue on to the next line. Notice the yellow arrow moves to the next line.

Congratulations you are now using the Code::Blocks IDE on a FreeBSD desktop.


Copyright ® Rhyous.com - Linking to this article is allowed without permission and as many as ten lines of this article can be used along with this link. Any other use of this article is allowed only by permission of Rhyous.com.

How to debug a portion of FreeBSD code using gdb from a shell? (Using Sysinstall code as an example)

Well, in my last FreeBSD Friday post, I talked about How to compile a portion of FreeBSD code with debugging? (Sysinstall for this example). The next step is to learn to step through the code. There is a debugging tool included with FreeBSD called gdb.

A good start for gdb is to read this document from the FreeBSD Developers’ Handbook.
http://www.freebsd.org/doc/en/books/developers-handbook/debugging.html

To really get good at gdb though, you should read the gdb documenation here:
http://sourceware.org/gdb/current/onlinedocs/gdb/

Well, lets get started.

Step 1 – Compile a portion of FreeBSD code with debugging enabled
How to compile a portion of FreeBSD code with debugging? (Sysinstall for this example)

Step 2 – Start gdb
As a user (not root) launch gdb with the name of the executable as the only parameter.

$ gdb sysinstall
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type “show copying” to see the conditions.
There is absolutely no warranty for GDB. Type “show warranty” for details.
This GDB was configured as “amd64-marcel-freebsd”…
(gdb)

Step 3 – Set a break point
At the gdb prompt, type break main.

(gdb) break main
Breakpoint 1 at 0x416b00: file main.c, line 55.
(gdb)

Step 4 – Start the program
To start the program type run and hit enter.

(gdb) run
Starting program: /usr/home/jared/Devel/FreeBSD/head/usr.sbin/sysinstall/sysinstall

Breakpoint 1, main (argc=1, argv=0x7fffffffe998) at main.c:55
55 {
(gdb)

Step 5 – Step through the code
Ok, to step through the code you simply type ‘s’.

(gdb) s
Breakpoint 1 at 0x416b00: file main.c, line 55.
(gdb)

Once you have typed ‘s’ once, you can just hit enter and it will keep stepping through. You could keep typing ‘s’ but you don’t need to.

Step through the code until it terminates because you are not root.

Here is the entire run through in one screen.

$ gdb sysinstall
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type “show copying” to see the conditions.
There is absolutely no warranty for GDB. Type “show warranty” for details.
This GDB was configured as “amd64-marcel-freebsd”…
(gdb) break main
Breakpoint 1 at 0x416b00: file main.c, line 55.
(gdb) run
Starting program: /usr/home/jared/Devel/FreeBSD/head/usr.sbin/sysinstall/sysinstall

Breakpoint 1, main (argc=1, argv=0x7fffffffe998) at main.c:55
55 {
(gdb) s
61 StartName = argv[0];
(gdb)
64 if (getpid() == 1) {
(gdb)
68 signal(SIGPIPE, SIG_IGN);
(gdb)
71 if (geteuid() != 0) {
(gdb)
72 fprintf(stderr, “Error: This utility should only be run as root.\n”);
(gdb)
Error: This utility should only be run as root.
204 }
(gdb)
0x0000000000404d9e in _start ()
(gdb)
Single stepping until exit from function _start,
which has no line number information.

Program exited with code 01.
(gdb)

Ok, you now have done some basic debugging with gdb and you have learned that you cannot run sysinstall as root.

Step 6 – Debug as root
Ok, this shouldn’t be hard for you by now. Sudo to root and repeat the above steps only this time the program will continue past the check for whether it is running as root because it will be. Stop just after you pass the line that checks if you are root.

One you get so far, you will actually get to the sysinstall gui and you can choose to exit.

Step 7 – Set a break point based on line number
Type the following to set a break point based on line number.

(gdb) break main.c:103
Breakpoint 2 at 0x416bd6: file main.c, line 103.
(gdb)

Step 8 – Continuing to the next break point
So now instead of stepping to line 110, we will just continue the program with the command “continue”. By the way, the following three commands will continue and all are really the exact same command. You might ask, “Why are there three ways to do the same thing?” I have to answer, “I don’t know, I didn’t write gdb.” But hey, I am not complaining.

  • continue
  • c
  • fg

So yes to continue you can type any of the three commands at the gdb prompt and your program will continue until the next break point or until the program terminates.

(gdb) c
Continuing.

Breakpoint 2, main (argc=1, argv=0x7fffffffe8c8) at main.c:103
103 systemInitialize(argc, argv);
(gdb)

Note on finding development code or development features
Often while developing, a developer adds code to help them develop. This is development code, development features, debug code, or whatever you want to call it. This code is not really meant to be used in production, but it sure helps the developer write and test and debug the production code. Most large applications have such hidden development features. When stepping through code, you should look for these.

As I was looking through the sysinstall code, I noticed a section of code starting at line 110 (obviously this is subject to change but you should be able to find the line number in the same area) that checks for a parameter called -fake.

    if (argc > 1 && !strcmp(argv[1], "-fake")) {
        variable_set2(VAR_DEBUG, "YES", 0);
        Fake = TRUE;
        msgConfirm("I'll be just faking it from here on out, OK?");
    }

This hidden switch is never mentioned in the man page. It appears to be one of those development only features that we can take advantage of to help us code Sysinstall. It also suggests that you can step through Sysinstall without having anything actually happen, which might be useful in debugging.

Making our first code change
Ok, so if I am going to use the -fake switch, I would assume that I could do so without running as root. Since we are “faking it” anyway, we might as well not be running as root at all.

So here is a code change I have made that will allow me to run as a normal user if I pass the -fake parameter. I am going to change line 73 (again this may not be the exact line for you as this is subject to change) where sysinstall checks if it is running as root and add an additional check to see if a parameter was passed and if so see if the parameter was -fake and if so, continue even though it is not root.

Here is what the code was originally.

    if (geteuid() != 0) {
        fprintf(stderr, "Error: This utility should only be run as root.\n");
        return 1;
    }

Here is what I changed the code to. Notice that I didn’t delete or add to the existing line just yet. Instead, I commented it out and added a new line because that makes it easier to switch back and forth when testing this new code out.

//if (geteuid() != 0) {
if (geteuid() != 0 && (argc < 2 || strcmp(argv[1], "-fake"))) { fprintf(stderr, "Error: This utility should only be run as root.\n"); return 1; } [/sourcecode] Ok, so save and exit. No go ahead and exit your root shell so you are just logged in as your user again. Recompile to apply your changes. In case you forgot, you recompile with this command:

$ make DEBUG_FLAGS=-g

Go ahead and debug again. Repeat the steps above again, however, this time, in the gdb prompt, before you execute the command “run”, go ahead and set the arguments to pass to your application so that the -fake argument is passed.

(gdb) set args -fake
(gdb)

Just to make sure, lets show the arguments to make sure that we properly set them.

(gdb) show args
Argument list to give program being debugged when it is started is “-fake”.
(gdb)

Now you can run your program in gdb and continue debugging sysinstall as a regular user. I think I am going to send this change in because maybe it should be a permanent change. What do you think?


Copyright ® Rhyous.com – Linking to this article is allowed without permission and as many as ten lines of this article can be used along with this link. Any other use of this article is allowed only by permission of Rhyous.com.

Researching the process for integrating FreeBSD with Active Directory

Hello everyone.

So I am not trying to be pro-Microsoft and Anit-open source with this comment. I like both and want that to be clear. However, Active Directory is the single most used authentication source for workstations in a corporation. It is hard to obtain new FreeBSD users if we cannot make it easier for corporate users who must have their machine joined to an Active Directory domain and they must authenticate to active directory. There is both too much effort and not enough effort in the Open Source world to integrate with Windows features such as Active Directory. I think that may be because often the open source community’s computers are probably rarely joined to a domain and just like there are too many Linux distros, there are two many ways to authenticate with Active Directory.

Active Directory is so common in the corporate world, it shouldn’t be so hard to join an Active Directory domain in FreeBSD. I mean, seriously, does it have to be such a pain? FreeBSD really needs a one command script to integrate with Active Directory, or a single port….imagine it. You run one command: joindomain or go to an “activedirectoryintegration” port and type make install. The script/install would prompt you for the domain and then it would look up a server and if it couldn’t find one it would prompt you for a domain controller name or IP, it would prompt your for credentials, etc…, when the script ended, the workstation would be a member of the domain and domain users would be able to login. Maybe also there should be a config file where you can add domain users/groups that can sudo to root.

Alas, it is not so easy. (Google summer of code project idea, anyone…)

You might be thinking to yourself that if I want a feature, I should write and contribute it myself. Which is in part true. However, I am already doing what I can to contribute and have other projects I am working on (for example, writing walk-thrus like the one you are about to read).

So, there are multiple documents and online resources and so here are my sources. However, I found none of them to be 100% correct and the writers words themselves drip with uncertainty about whether they are using the best way.

  • http://satish-linuxbug.blogspot.com/2008/08/freebsd-with-active-directory-single.html
  • http://www.nosam.com/2008/09/making-freebsd-7x-a-windows-server-20032008-active-directory-domain-member
  • http://www.ctdx.net/2008/07/11/freebsd-single-sign-on-with-active-directory-and-access-control/
  • http://web.irtnog.org/doc/how-to/freebsd-winbind
  • www.samba.org/samba/docs/man/Samba-HOWTO-Collection/domain-member.html
  • http://segment7.net/projects/FreeBSD/kerberos.html
  • http://joseph.randomnetworks.com/archives/2005/11/08/freebsd-users-and-groups-with-samba-winbind-and-active-directory/
  • http://technet.microsoft.com/en-au/magazine/2008.12.linux.aspx

It is good to have competition…among competitors in a market place…but not in a product itself. We need one difinitive method for authenticating to Active Directory. I don’t care if multiple methods exist as long as there is one method that the FreeBSD team can rally around, recommend, considers secure, and include in base, or as a single port.

I have never configured FreeBSD to authenticate its users to Active Directory before and I have hardly touched Kerberos 5, I consider myself a newbie in this area. However, the only way to move from being a newbie to being an expert is to learn it and configure it and troubleshoot it, so I can gain experience and then be an expert.

So I have been researching the past week and half (In the evenings outside of work). I had hoped to make it last Friday’s FreeBSD Friday post, but It probably won’t be finished by this Friday.

It will take me a while to research because:

  1. I don’t want to say something is needed when it is not.
  2. I don’t want to leave something out or forget to document a setting that is needed.
  3. I don’t like to change settings that I don’t understand.
  4. When writing a walk-thru, I don’t like telling some one what to do without explaining why when the why is not obvious.

So far it there are articles on integrating with Active Directory using the following:

  1. FreeBSD + Samba 3.x
  2. FreeBSD + Kerberos 5
  3. FreeBSD + Kerberos 5 (built-in) + Samba 3.x
  4. FreeBSD + Kerberos 5 (from ports) + Samba 3.x
  5. FreeBSD + LDAP + Samba 3.x

The ones I have tested so far have not been fully functional, but I have not tested all the articles yet. Maybe I doc on each method is warranted.

So which method is the best for the largest majority of FreeBSD users?

So if you are in a Windows environment, you may want samba anyway so number 1 in the list looks like a good choice. However, some articles say that samba alone won’t work with Active Directory 2003/2008. If that is true, then number 3 in the list may be better. I don’t like number 4 because why install something that is already installed (however, Heimdal is installed not MIT and if there is a reason you need MIT then number 4 makes sense). Number 5 I haven’t even researched but the guy who wrote the doc now says it is not as good of an option as method 1.

Ok, so Active Directory has multiple settings, and the first thing I want to test is a default clean Active Directory install. And then if I increase the security, do any of the above methods break?

No one really seems to have taken this to the next level of research, so anyway…you can see my confusion and frustration. This is definitely an area that needs to be cleaned up documented and probable coded into a long term manageable solution.

Keyboard Shortcuts – To all desktops everywhere, please standardize

Hello world,

I mostly use Windows 7 as a desktop but I often use FreeBSD with KDE, too.

I just submitted this wish to the KDE team.

Bug 221667 – Please make Keyboard shortcuts the same as those used by Microsoft Windows
https://bugs.kde.org/show_bug.cgi?id=221667

If you agree, please Login and vote for this bug. I so want to always use the same keyboard shortcuts no matter which platform I am installed on.

This probably is not just an enhancement request for KDE but for every GUI Operating System everywhere. In fact, let’s make a standard set of Keyboard Shortcuts and have every desktop-like software use the same exact keyboard shortcuts. Maybe someone who is a member could write and RFC and publish it, or does it need to be an IEEE standard?

Anyway…I try not to rant, but today it happened. Sorry.

How to compile a portion of FreeBSD code with debugging? (Sysinstall for this example)

Ok, so maybe you want to work on fixing something in a portion of FreeBSD code, but you lack the knowledge to get started. That is what this document is for, to get you started.

For this example, I am going to use Sysinstall, which is a pretty old installer but still in use and functional. Let’s be honest, when the developers write in the code that Sysinstall needs to be completely rewritten and those notes are almost a decade old, you can guess that the installer is living far past its days. However, I don’t mind Sysinstall and many others don’t mind it either, which is probably why it is not updated yet. So lets at least see if we can inspire some contributors to start working on it. Sysinstall is actually on the Project Ideas page for a couple reasons, though I am surprised that “complete rewrite” is not one of them.

So lets get started.

Step 1 – Install FreeBSD
You need a FreeBSD Environment, so install one. Following one of these documents:
How do I install FreeBSD?
or if you want a FreeBSD install with a desktop as well:
How to install and configure a FreeBSD 8 Desktop with Xorg and KDE?

Step 2 – Download the FreeBSD Source
Follow this guide to make sure you have the source you need.
How to download FreeBSD-Current or FreeBSD-Stable using svn?

Now that you have read that post and have the source, you should understand what I mean when I say for this example I checked out head.

Step 3 – Find the location of the portion of source you wish to compile (Sysinstall in this example)

  1. Change to the directory where your source is stored.
    $ cd /usr/home/jared/Devel/FreeBSD/head
  2. It is probably a good idea to browse the folders and get an understanding of what code is where. But this is a task you should perform over time. For now, lets search for exactly what we want: sysinstall.
    $ find ./ -name sysinstall

    You will see that sysinstall is here: ./usr.sbin/sysinstall

  3. Change to that directory.
    $ cd usr.sbin/sysinstall

Step 4 – Compile with debugging.
FreeBSD uses make to manage the compiling of the code, so it is really easy to compile it all.

  1. Run this command to compile Syinstall with debugging.
    $ make DEBUG_FLAGS=-g

You should now see all the .o libraries and the sysinstall libraries. You have just compiled a portion of FreeBSD.


Copyright ® Rhyous.com – Linking to this article is allowed without permission and as many as ten lines of this article can be used along with this link. Any other use of this article is allowed only by permission of Rhyous.com.

How to download FreeBSD source using svn?

If you want to compile a custom FreeBSD kernel or rebuild world or be a developer for FreeBSD, you may want to download the source.

Download FreeBSD Source as follows.

Step 1 – Install Subversion

Install subversion from ports or as a package.

From ports

# cd /usr/ports/devel/subversion
# make install

From packages

# pkg_add -r subversion

Note: Don’t forget to run ‘rehash’ if after install your current shell cannot find svn.

Step 2 – Check Out FreeBSD Source

To download FreeBSD source, use subversion. You may want to use Release, Stable, or Current. Release doesn’t have any updates, so if you want patches since release, you are likely wanting to do Release Engineering.

Release

svn checkout http://svn.freebsd.org/base/release/9.0.0/ /usr/src

Release Engineering

svn checkout http://svn.freebsd.org/base/releng/9.0/ /usr/src

Stable

# svn checkout http://svn.freebsd.org/base/stable/9 /usr/src

Currrent

# svn checkout http://svn.freebsd.org/base/head /usr/src

You now have FreeBSD source and you should be able to compile the kernel or the FreeBSD world.

How to install and configure a FreeBSD 8 Desktop with Xorg and KDE?

FreeBSD X

I realize that PC-BSD exists, but sometimes, you need only FreeBSD without PBIs and you want it to do it all yourself because that is why you came to FreeBSD in the first place; to be an expert user and be able to set everything up yourself.

Requirements for Success
To consider the desktop a success, the user should be able to do the following after installation:

  1. Have a graphical login screen.
  2. Auto-mount CD/DVD and USB drives.
  3. Connect a USB drive and read and write to it.
  4. Browse the web with Firefox.
  5. Create a document with Open Office.
  6. Play an mp3.
  7. Play a DVD

Step 1 – Download the DVD and burn it

  1. To download the DVD, go here: http://www.freebsd.org/where.html
  2. Click on your platform type. You are probably going to want i386 for a 32 bit computer or amd64 for a 64 bit computer.
  3. Select the DVD and download it.
  4. Extract it as it is compressed into a zip file. Use gunzip on FreeBSD or 7zip on Windows.
  5. Use your favorite burning software to burn the ISO to disk.

Step 2 – Install FreeBSD and include Xorg and KDE4 as additional install packages.

  1. Insert the installation media and boot off it. Wait for it to boot.
  2. First select your Country.
  3. At Sysinstall’s Main Menu, choose Standard.
  4. Read the next screen and hit OK.
  5. Press A to select Use entire disk.
  6. Press Q to Finish.
  7. For the Boot Manager choose Standard and hit OK.
  8. Read the next screen and hit OK.
  9. Press A to select Auto Defaults.
  10. Press Q to Finish.
  11. For Distributions select Custom. (Don’t worry, the Custom is not that hard) and select the following distributions:
    Required – You must have the base system and a kernel. 

    • base
    • kernels | GENERIC

    Optional – You don’t have to select these but I am selecting them.

    • dict
    • doc | en (or you language).
    • games
    • man
    • src | All (Optional, if you plan on having the source so you can work on it an contribute some work back to FreeBSD.)
    • ports
  12. To get back to the Choose Distributions screen, either select Exit or OK.
  13. Hit OK to continue.
  14. At the Choose Installation Media screen choose CD/DVD.
  15. Read the next screen and choose Yes.
  16. Wait for the installations to complete.
  17. Read the Success screen and hit OK.
  18. Choose Yes to configuring an Ethernet network device.
  19. Select you network card type and hit OK. It is usually the top entry. Mine is em0.
  20. (Optional) You may want to say Yes to configure IPv6 these days. All my machines at home support IPv6 now since they are FreeBSD and Windows 7.
    It will try to detect a server, but probably won’t find one, that is just fine.
  21. Choose Yes to try DHCP. Assuming you have a DHCP server (any corporate network or home with an internet connection and router has one).
    The network configuration screen will open with your IP Address.
  22. Enter a computer name in the Host field.
  23. Choose No when prompted if you want the machine to function as a network gateway.
  24. Choose No when prompted if you want the machine to configure inetd.
  25. When prompted to enable SSH, choose Yes if you are going to connect via SSH remotely. Choose No otherwise. I am choosing Yes because I always find a reason to SSH in.
  26. Choose No to have anonymous FTP access to this machine.
  27. Choose No to for configuring this as an NFS server.
  28. Choose No to for configuring this as an NFS client (unless it is going to be and if it is going to be, you would no).
  29. Choose No to customizing the system console settings.
  30. Choose Yes to set the machines time zone now.
  31. Choose No when asked if the CMOS clock is set to UTC (unless you know for sure 100% that it is).
  32. Choose your Region.
  33. Choose your Country.
  34. Choose your Time Zone.
  35. If prompted if your Time Zone looks reasonable, choose Yes.
  36. When prompted if you have a PS/2, serial, or bus Mouse you need to understand that a mouse if almost always only PS2 or USB anymore. If USB choose No, otherwise choose Yes.
    If you choose Yes, then enable your mouse, test it and then exit that screen.
  37. Choose Yes when prompted about the FreeBSD Package collection and if you want to browse it now as this is where we are going to install Xorg and KDE.
  38. On the Package Selection screen, scroll down X11 and hit OK.
  39. On the X11 screen, scroll down and select KDE4. Notice that a lot of other packages are auto-selected as dependencies. This is normal.
  40. Continue scrolling down and select xorg-7.
  41. Now click Ok.
  42. You may want other packages such as bash. Choose them now.
  43. Choose Install and you will see the Package Targets screen. It will only list the packages your selected, not all the dependencies, but don’t worry, all the dependencies will install.
  44. Choose Ok.
  45. Wait for the installation of the packages to complete.
  46. When prompted for adding initial user accounts, choose Yes.
  47. On the User and Group Management Screen choose User and hit OK.
  48. Enter a user name under the Login ID field.
  49. Leave UID and GROUP as is.
  50. Enter a password and confirm the password.
  51. Enter your full name.
  52. In the Member Groups add these groups (without a space, only separated by a comma): wheel,operator
  53. Leave home directory as is.
  54. Leave the login shell as is. (Unless you installed bash and want to use it, then you can change it to /usr/local/bin/bash).
  55. Hit OK.
  56. Back at the User and group management screen choose Exit and hit OK. Feel free to add as many users as you need first, but don’t worry you can add more later.
  57. Read the next screen and hit OK, it is just an informational screen about the fact that you must set a root password.
  58. Enter the root password and hit enter and then enter it again and hit enter to confirm the password.
  59. When prompted to visit the configuration menu for a chance to set any last options, choose No.
  60. You are back at the Sysinstall Main Menu. Select Exit Install.
  61. When asked if you are sure you wish to exit, choose Yes.
  62. Read the next screen, and hit OK.
  63. Whilst rebooting, remove your DVD from the drive so you don’t boot off it (assuming it is first in your boot order otherwise you may not need to do this).

FreeBSD 8 is now installed with all the software needed to make a nice FreeBSD 8 Desktop, Xorg-7 and KDE4. However, there are a few more steps to get Xorg-7 and KDE4 configured.

Step 3 – Patch your new system
Update and patch your system. I already have steps to do this here:
What are the first commands I run after installing FreeBSD
Important: While the ports tree is already installed, don’t skip this step. Updating the ports tree is how you get the latest versions.

Step 4 – Configure Xorg Dependencies

  1. Login to the newly installed system with the username and password you created. Make sure you use the account that you added to the wheel and operators group.
  2. Once logged in, su to root by simply typing this command:
    $ su

  3. After typing su, you will be prompted for a password. Enter the root password.
  4. You now logged in as root. Your prompt should have changed from a $ to a NAME#. For example, I named my system FBSD8 so my prompt looks as follows:
    FBSD#

  5. Add dbus to /etc/rc.conf. Either use easy editor, or use the following shell command to add it without using and editor.
    FBSD# echo ‘dbus_enable=”YES”‘ >> /etc/rc.conf
  6. Enable dbus with this command.
    FBSD# /usr/local/etc/rc.d/dbus start

  7. Add hald to /etc/rc.conf. Either use easy editor, or use the following shell command to add it without using and editor.
    FBSD# echo ‘hald_enable=”YES”‘ >> /etc/rc.conf

  8. Enable hald with this command.
    FBSD# /usr/local/etc/rc.d/hald start

  9. Reboot by running this command:
    FBSD# reboot

    Note: It is also common to reboot using this command: (It doesn’t matter which command you use to reboot.)

    FBSD# init 6

  10. Once rebooted, log back in and su to root again.

Step 5 – Configure Xorg
Note 1: 1 and 2 are optional and you may skip them if you want. An xorg.conf file is not longer required. Usually most configurations work without it.
Note 2: If you are using VMWare, you may want to jump to this article and come back: How to install VMWare-tools on FreeBSD 8?

  1. Have Xorg automatically create an xorg.conf file using this command:
    FBSD# Xorg -configure /root/xorg.conf.new -retro

  2. Copy the xorg.conf.new to /etc/X11/xorg.conf
    FBSD# cp /root/xorg.conf.new /etc/X11/xorg.conf

  3. Type exit to logout as root. You should go back to the $ prompt.
  4. Create a file called .xinitrc in the users home directory. This file will contain one line.
    $ echo exec /usr/local/kde4/bin/startkde4 > ~/.xinitrc

  5. Run startx to launch Xorg-7 and KDE4.
    $ startx

    Note: If something goes wrong here, your xorg.conf may not have been generated correctly. Reboot (you may have to hit the power button or SSH in to reboot as you may not have console access anymore).

Xorg-7 and KDE4 should now be working.

Step 6 – Enable KDM (Optional) on FreeBSD
Instead of having to login in at a command prompt and run startx, you may prefer a GUI login screen. This can be done very easily with KDM. There is an old way and a new way. Just in case the new way isn’t available to you for some reason, I will leave both methods. Do NOT use both of them.

The new way.

  1. Add the following lines to /etc/rc.conf. Either use easy editor, or use the following shell command to add it without using and editor.
    FBSD#
    FBSD#
    echo ‘local_startup=”${local_startup} /usr/local/kde4/etc/rc.d”‘ >> /etc/rc.conf
    echo ‘kdm4_enable=”YES”‘ >> /etc/rc.conf

  2. Start kdm

The old way.

  1. If you are still in KDE, logout. Click the blue K icon at the bottom left of your screen and you can select Leave | Logout to exit KDE.
  2. Use su to login as root as you have done before.
  3. Open the following file with your favorite editor: /etc/ttys. I use Easy Editor or ee.
    FBSD# ee /etc/ttys

  4. Find the following line: (In ee, Page Down three times almost takes me right to this line.)
    ttyv8 “/usr/local/bin/xdm -nodaemon” xterm off secure
  5. Replace that line with this line:
    ttyv8 “/usr/X11R6/kde4/bin/kdm” xterm on secure
  6. Reboot to have the virtual consoles restart. (or make sure Xorg and KDE are not running and run: kill -HUP 1)

KDM should now be working and your system should reboot to a graphic login screen, which is handled by kdm.

Step 7 – Enable CD/DVD/USB mounting
FreeBSD is more secure by default, so something as simple as accessing a CD or DVD or USB drive is not actually allowed by default. You have enable this.

These steps assume that your user is a member of the operator group. Remember above during the installation, I mentioned to make your user a member of both the wheel and operator groups.

  1. Access a shell and su to root.
    Note: The easiest shell to access now that you are in KDE is Konsole. To access Konsole, click the K and go to Applications | System | Terminal. Also you can add the shell icon to your panel by right-clicking on the icon and choosing Add to Panel.
  2. Enable vfs.usermount.
    FBSD# sysctl -w vfs.usermount=1

  3. Configure vfs.usermount to be enabled on boot.
    FBSD# echo vfs.usermount=1 >> /etc/sysctl.conf

  4. Open the following file with an editor: /etc/devfs.conf
    FBSD# ee /etc/devfs.conf
  5. Add the following lines:
    # Commonly used by many ports
    link    acd0    cdrom
    link    acd0    dvd 

    # Allow all users to access CD’s
    perm /dev/acd0 0666
    perm /dev/acd1 0666
    perm /dev/cd0 0666
    perm /dev/cd1 0666

    # Allow all USB Devices to be mounted
    perm /dev/da0 0666
    perm /dev/da1 0666
    perm /dev/da2 0666
    perm /dev/da3 0666
    perm /dev/da4 0666

    # Misc other devices
    perm /dev/pass0 0666
    perm /dev/xpt0 0666
    perm /dev/agpart 0666
    perm /dev/uscanner0 0666

    Note: Yes, I copied these from a PC-BSD install’s version of this file.

    Note: Change to 0660 to only allow users in the operator group to mount drives.

  6. Also you need a devfs.rules file.  Lets create one.
    FBSD# ee /etc/devfs.rules
  7. Add the following lines.
    [Removable_Media]
    add path ‘ad*’ mode 666 group operator
    add path ‘acd*’ mode 666 group operator
    add path ‘cd*’ mode 666 group operator
    add path ‘pass*’ mode 666 group operator
    add path ‘xpt*’ mode 666 group operator
    add path ‘ugen*’ mode 666 group operator
    add path ‘usb*’ mode 666 group operator
    add path ‘lpt*’ mode 666 group cups
    add path ‘ulpt*’ mode 666 group cups
    add path ‘unlpt*’ mode 666 group cups
    add path ‘fd*’ mode 666 group operator

    Note: Again, I copied these from PC-BSD.

  8. Tell /etc/rc.conf about the rules section in /etc/devfs.rules
    FBSD# echo ‘devfs_system_ruleset=”Removable_Media”‘ >> /etc/rc.conf
  9. Edit the following file: /usr/local/etc/PolicyKit/PolicyKit.conf
    FBSD# ee /usr/local/etc/PolicyKit/PolicyKit.conf

  10. Change the xml’s config section from this…
    <config version="0.1">
        <match user="root">
            <return result="yes"/>
        </match>
        <define_admin_auth group="wheel"/>
    </config>
    

    …to this:

    <config version="0.1">
            <define_admin_auth group="operator"/>
            <match action="org.freedesktop.hal.storage.mount-removable">
                    <return result="yes"/>
            </match>
            <match action="org.freedesktop.hal.storage.mount-fixed">
                    <return result="yes"/>
            </match>
            <match action="org.freedesktop.hal.storage.eject">
                    <return result="yes"/>
            </match>
    </config>
    

    Note: Yes, again, I copied this straight from PC-BSD’s PolicyKit.conf.

  11. Edit the following file with ee: ee /etc/fstab
    FBSD# ee /etc/fstab

  12. Comment out or remove the line for your /cdrom. I usually just comment it out by adding a # sign as shown:
    #/dev/acd0 /cdrom cd9660 ro,noauto 0 0
  13. Restart the computer.

You should now be able to mount CD, DVD, and USB drives. You also should be able to both read and write to them, burn disks, write and format USB drives, etc…

Step 8 – Enable your sound card
I already have an article on this here and it is so very simple.
How to enable sound in FreeBSD 8?

Step 9 – Install Software

We are going to install the following software:

  • Firefox
  • Open Office
  • K3b

Binary Packages

  1. To browse the precompiled package lists, open a web browser to here:
    ftp://ftp.freebsd.org/pub/FreeBSD/ports//packages-8.0-release/Latest/ 

    My architecture is amd64 so the URL I use is this:
    ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-8.0-release/Latest/

    Hint: Some time in the future you may be on a different version or architecture. If you run this command, it will fail and the output may show you where to go.

    FBSD# pkg_add -r DoesNotExist

Firefox

  1. Access a shell and su to root as software should be installed as root.
  2. FreeBSD has a binary package for Firefox, so to install it you only have to run one command:
    FBSD# pkg_add -r firefox35

  3. Firefox 3.5 installation notes recommend adding a line to /boot/loader.conf, so use ee and add this line:
    sem_load=”YES”

Firefox is now installed.

Open Office
Note: Here I describe installing using ports, but there may be a package available. Read this post: http://forums.freebsd.org/showthread.php?t=8639

  1. Access a shell and su to root as software should be installed as root.
  2. To install Open Office, run the following commands:
    Note: There is not package as of this moment, so we have to compile from ports and this takes longer. You can check for a package if you want as there may be one sometime after I write this document.) 

    FBSD#
    FBSD#
    cd /usr/ports/editors/openoffice.org
    make install

  3. Wait…and wait…and wait…and wait…
  4. Ok, when it fails because you have to manually download some items for java, read and follow the instructions:
    IMPORTANT: To build the JDK 1.6.0 port, you should have at least
    2.5Gb of free disk space in the build area! 

    Due to licensing restrictions, certain files must be fetched manually.

    Please download the Update 3 Source from http://www.java.net/download/jdk6/6u3/promoted/b05/jdk-6u3-fcs-src-b05-jrl-24_sep_2007.jar and the Source Binaries from http://www.java.net/download/jdk6/6u3/promoted/b05/jdk-6u3-fcs-bin-b05-jrl-24_sep_2007.jar and the Mozilla Headers from http://www.java.net/download/jdk6/6u3/promoted/b05/jdk-6u3-fcs-mozilla_headers-b05-unix-24_sep_2007.jar.

    Please open http://java.sun.com/javase/downloads/index.jsp in a web browser and follow the “Download” link for “JDK US DST Timezone Update Tool – 1_3_21” to obtain the time zone update file, tzupdater-1_3_21-2009p.zip.

    Please download the patchset, bsd-jdk16-patches-4.tar.bz2, from http://www.eyesbeyond.com/freebsddom/java/jdk16.html.

    Please place the downloaded file(s) in /usr/ports/distfiles and restart the build.

  5. While you are at it, get the file from this prompt as well. I am not sure why it is not in the same prompt above, but it isn’t.

    Because of licensing restrictions, you must fetch the distribution manually.

    Please access http://www.FreeBSDFoundation.org/cgi-bin/download?download=diablo-caffe-freebsd7-amd64-1.6.0_07-b02.tar.bz2 with a web browser and “Accept” the End User License Agreement for “Caffe Diablo 1.6.0”.

    Please place the downloaded file(s) in /usr/ports/distfiles.

  6. Make sure you followed the instructions, download the files, and placed them in /usr/ports/distfiles. Restart the build using the same command you ran before. If you didn’t know, you can probably press the up arrow on your keyboard to see command history so you don’t have to type it again.
  7. You will shortly be prompted with a license agreement. Please read ever word, pressing the space bar to scroll until the end, before typing yes.
  8. Now wait some more as Open Office and its dependencies continue compiling.
  9. No you haven’t waited long enough.
  10. Ok…no just kidding, wait a little more.
  11. No really. It takes a long time to compile Open Office so leave it running and skip to the next step.

When it is done, you will be able to write documents that are compatible with MS Office.

K3b

  1. Access a shell and su to root as software should be installed as root.
  2. FreeBSD has a binary package for K3b, so to install it you only have to run one command:
    FBSD# pkg_add -r k3b

  3. There are a lot of notes about postinstallation steps, so burning a CD is going to be for another day and another document.

Playing MP3s
As for paying I can play MP3s with juK the KDE4 Music player that is installed by default with KDE4.

You should now have the idea and can go installing software that you want.

Playing a DVD

Dragon Player didn’t play the a DVD for me. So I installed kmplayer-kde4. It didn’t play the DVD either. I installed Xine and it worked.

Keywords: FreeBSD X


Copyright ® Rhyous.com – Linking to this article is allowed without permission and as many as ten lines of this article can be used along with this link. Any other use of this article is allowed only by permission of Rhyous.com.

How to enable sound in FreeBSD 8?

FreeBSD doesn’t enable the sound by default. However it is simple to detect and enable your sound card.

Step 1 – Detect Your Sound Cound

  1. Install all sound kernel modules by running the following command:

    FBSD# kldload snd_driver

  2. Check which kernel module was able to bind to your sound card by running this command:

    FBSD# cat /dev/sndstat

    The output will be similar to this but of course you may have a different sound card:

    FreeBSD Audio Driver (newpcm: 64bit 2009061500/amd64)
    Installed devices:
    pcm0: at io 0x2040 irq 16 kld snd_es137x [MPSAFE] (2p:1v/1r:1v channels duplex default)
  3. Notice on the last line after kld there is a snd_. This is you sound card kernel module.

Step 2 - Enable the kernel module for your sound card

  1. Configure your the kernel module of your sound card to load at boot by adding it to the /boot/loader.conf as follows.

    FBSD# echo 'snd_es137x_load="YES"' >> /boot/loader.conf

    (Of course when you run the command, replace "es137x_" with the letters you see in the output for your sound card.)
    Note: If you look at the /boot/default/loader.conf you can find information on proper syntax exactly for your module and other modules.

Your sound card should now be working.

From the Fixit environment of a FreeBSD 8 install disk, how do I download a file using ftp?

From the Fixit environment of a FreeBSD 8 install disk, how do I download a file using ftp?

  1. Run ifconfig to find what ethernet controller you have. Mine was em0.
    fixit# ifconfig
  2. Now assign an IP address. Make sure to find an open IP Address that is not already in use.
    fixit# ifconfig em0 inet 192.168.0.25 netmask 255.255.255.0
  3. Run the following commands to enable ssh/sftp capability:

    Fixit#
    Fixit#
    mkdir /usr/bin
    ln -s /mnt2/usr/bin/ssh /usr/bin/ssh

You can now connect to a server on your same subnet using sftp. Feel free to add a default route if you need to connect to a remote server or add a DNS server if you need name resolution.

fixit# sftp user@192.168.0.10

Copyright ® Rhyous.com - Linking to this article is allowed without permission and as many as ten lines of this article can be used along with this link. Any other use of this article is allowed only by permission of Rhyous.com.