Sunday, 25 September 2016

NetBSD for newbies - Develop your own Power PC

So you may have few questions in your mind, indeed you're the one from millions who really knows the power of UNIX(or may be interested) like BSD Unix. Here today I'm trying to brief you about NetBSD. And how you can get stable working desktop on your laptop

YES this is what exactly you gonna achieve what you're looking in picture if you will follow step by step.



Alright.
Install NetBSD if not familiar with installation please go through installation on google or youtube

We used Netbsd 7.0.1 amd64 Image for installation purpose.

and after installation what you might need to do first is below. 

STEPS TO PERFORM FIRST
  • To get internet or WIFI working you need to first check your wireless and Ethernet card names in my case when I entered  ifconfig I get the names like ath0 for wireless and rtk0 for Ethernet. 
  • You need to create three files  /etc/wpa_supplicant.conf , /etc/ifconfig.ath0 and /etc/ifconfig.rtk0
  • Contents of the files are below, you need to adjust as per your environment


/etc/ifconfig.ath0

!wpa_supplicant -B -i ath0 -c/etc/wpa_supplicant.conf
dhcp

/etc/ificonfig.rtk0

up
media autoselect


/etc/wpa_supplicant.conf

ctrl_interface=/var/run/wpa_supplicant
ctrl_interface_group=wheel

network={
ssid="HUAWEI-B310-2D52"
psk="Password"
}

network={
    ssid="YourNetworkName"
    psk="Password"
 }


  • You Need to set pkgsrc link in /root/.profile for direct pkgsrc fetching
Add the following line in your /root/.profile


export PKG_PATH="http://ftp.de.netbsd.org/pub/pkgsrc/packages/NetBSD/amd64/7.0.1/All" 

 Now you will be able to run this command pkg_add -v desiredpackagename without any error.


#####MAKING YOUR NETBSD SYSTEM 7.0.1 RELEASE TO 7_STABLE ######


This is the main part and a bit complicated because we're going to fetch NetBSD stable source and recompiling and installing kernel.

Downloading sources for a NetBSD stable branch


Before you can do an initial (full) checkout of the NetBSD sources via anonymous CVS, you must set the CVSROOT environment variable, which tells cvs(1) where to fetch the files from:
$ export CVSROOT="anoncvs@anoncvs.NetBSD.org:/cvsroot"
Make sure that the environment variable CVS_RSH is set to ssh.
$ export CVS_RSH="ssh"

NetBSD stable branches are a flavor of Maintenance branches. Please consult the Section 30.2, “Terminology”.
If you want to follow a stable branch, just pass the branch name to the cvs(1) -r option.
For example, if you want to fetch the most recent version of netbsd-7, you just need to use that tag:
$ cd /usr
$ cvs checkout -r netbsd-7 -P src
And for the xsrc module:
$ cvs checkout -r netbsd-7 -P xsrc
If you have checked out sources from a stable branch in /usr/src and want to update them to get the latest security and bug fixes, run:
$ cd /usr/src
$ cvs update -dP
The same applies to the xsrc module, but in that case you will have to change your working directory to /usr/xsrc first.

 

 Configuring the kernel manually

When you've finished modifying the kernel configuration file (which we'll call MYKERNEL), you should issue the following command:
$ config MYKERNEL
If MYKERNEL contains no errors, the config(1) program will create the necessary files for the compilation of the kernel, otherwise it will be necessary to correct the errors before running config(1) again.

Dependencies generation and kernel compilation is performed by the following commands:
$ cd ../compile/MYKERNEL
$ make depend
$ make
 
It can happen that the compilation stops with errors; there can be a variety of reasons but the most common cause is an error in the configuration file which didn't get caught by config(1). Sometimes the failure is caused by a hardware problem (often faulty RAM chips): the compilation puts a higher stress on the system than most applications do. Another typical error is the following: option B, active, requires option A which is not active. A full compilation of the kernel can last from some minutes to several hours, depending on the hardware.
The result of a successful make command is the netbsd file in the compile directory, ready to be installed.

 You need to install kernel after compiling it otherwise it wouldn't work.

 Installing the new kernel

Whichever method was used to produce the new kernel file, it must now be installed. The new kernel file should be copied to the root directory, after saving the previous version.
#cd ../compile/MYKERNEL
# mv /netbsd /netbsd.old
# mv netbsd /
Customization can considerably reduce the kernel's size. In the following example netbsd.old is the install kernel and netbsd is the new kernel.
-rwxr-xr-x  3 root  wheel  3523098 Dec 10 00:13 /netbsd
-rwxr-xr-x  3 root  wheel  7566271 Dec 10 00:13 /netbsd.old
The new kernel is activated after rebooting:
# shutdown -r now

If something went wrong

When the computer is restarted it can happen that the new kernel doesn't work as expected or even doesn't boot at all. Don't worry: if this happens, just reboot with the previously saved kernel and remove the new one (it is better to reboot single user):
  • Reboot the machine
  • Press the space bar at the boot prompt duringhttps://www.blogger.com/blogger.g?blogID=8564502499231768514#editor/target=post;postID=4981906295107079464 the 5 seconds countdown
    boot:
  • Type
    > boot netbsd.old -s
  • Now issue the following commands to restore the previous version of the kernel:
    # fsck /
    # mount /
    # mv netbsd.old netbsd
    # reboot
This will give you back the working system you started with, and you can revise your custom kernel config file to resolve the problem. In general, it's wise to start with a GENERIC kernel first, and then make gradual changes.


Alright now all set Now proceed with packages installation. If you will enter uname -a command you will see 7-stable is running now. 


Install the following packages.
$su
#pkg_add -v openbox feh tint2 gnome-terminal firefox vlc lxappearance obconf  pavucontrol


once all done. 

Past the following files in exactly same directory location. Please remember each user will use it's on directory like if you create a user of your own choice you need to login with that user not root user. You can also configure the same GUI for root user but it's not recommended for security reasons. 

ok 
#mkdir /home/username/.themes
# cp -rvf mytheme /home/username/.themes/mytheme
#cp -rvf  openbox /home/username/.config/openbox
# cp -rvf tint2 /home/username/.config/tint2
# cp .conkyrc /home/username/.conkyrc
# cp .conkyrctop /home/username/.conkyrctop
#cp .gtkrc-2.0 /home/username/.gtkrc-2.0
# cp .xinitrc /home/username/.xinitrc

If you missed any of above files you will not get desired look. And if you already done as up mentioned and still icons or theme is not working use obconf and lxappearance tools to adjust setting in GUI mode.

All mentioned files can be downloaded from HERE

That's it.

And if Youtube audio is not working follow this  below.


YouTube with audio!

After posting a link to the aforementioned NetBSD article in Reddit, a reader offered a solution in that forum (/r/NetBSD) on how to get audio working for YouTube. They said "as for audio on Firefox, it Just Works, but the default uses PulseAudio, which requires dbus running". They recommended these steps to get 'er done:


# cp /usr/pkg/share/examples/rc.d/dbus /etc/rc.d/
# echo "dbus=YES" >> /etc/rc.conf
# service dbus start


and control system audio with pavucontrol.

Thanks for reaching here and reading this article please comment below for any question.  

6 comments:

  1. Thanks for the tutorial. I'm trying to get a similar desktop look and feel on FreeBSD. You seem to leave out some important source file locations, i.e., mytheme, openbox, and tint2 config files. They don't exist in your google drive and I don't see them on the filesystem after the packages are installed.

    ReplyDelete
    Replies
    1. mytheme is elegantbrit GTK2 theme can easily be downloaded or you can download and use more cool gtk theme. Tint2 rc file is already there with the name "brit.tint2rc".

      Delete
  2. Unfortunately NetBSD does not support my wifi card (Atheros AR9485) and all my gpus (skylake + nvidia). But congratulations for the tutorial.

    ReplyDelete
    Replies
    1. Check NetBSD hardware support here: http://www.netbsd.org/support/hardware/pci.html . If still not compatible, for the sake of configurations you can use Ethernet Cable or usb wifi card.

      Delete
  3. This comment has been removed by the author.

    ReplyDelete
  4. I’ve been using NetBSD since 5.1.2, says 2012. I’m now on 7_STABLE. I love this OS so much, clean source code, traditional Unix and highest portability. But as I always adhere with Unix, which I don’t think the traditional Unix had any graphical interfaces. By the way, I always use pkgsrc and tcsh.

    ReplyDelete