Dual booting with freeBSD

Share your own howto's etc. Not for support questions!

Dual booting with freeBSD

Postby sossego » 2008-05-27 10:39

Update: I've added a few updates and will post a beginners note here.
Be sure to look at the last few posts for xorg and HAL tips.
USB works with no trouble. Just be sure to enable it.
If you know the locations of the files in Debian, then you should be able to find the same in FreeBSD.
viewtopic.php?f=16&t=27227&p=262814#p262814 This part of the howto will help you see the similarities.
I've gone and added a third user. To be more secure, I suggest the following accounts: wheel for maintenance, userA in the wheel group, and an unprivileged user for normal activities.

This is my first howto. Comments and additions are welcome.

An unofficial howto for a beginners install of FreeBSD and dual booting with Linux.

Make a list of your hardware that you have on your computer. Be sure that you know the horizontal and vertical rates of your monitor,your monitor vendor and release, your sound card, graphics card, NIC, keyboard layout& type, and mouse If you are using a PPC or SPARC cpu based system, I suggest that you by a separate hard disk and dedicate it to the FreeBSD install. Make a boot only CD of either release of FreeBSD that is on the get page. If you are doing networkless install, burn all discs of the release you chose for your architecture.

The install instructions are easy. Choose your country/language and you will be at the sysinstall menu.
If using DHCP to connect to the internet: select options and enter the submenu. The spacebar changes the values. Change DHCP to YES and exit. For those using IPv6, you may want to enable this option. I don't suggest it. Hit Q when you are done adjusting these values.
Select partition in sysinstall and hit enter.Delete every partition on your disk and create a new primary one with a size of 10 to 25 gigs.
Select the partition with the arrow keys and hit S to make it bootable. Hit Q when you are finished. Choose label in the sysinstall menu and hit enter.
Hit A for automatic allocation of space. Write down the values for all partitions after swap Delete the partitions within the slice and delete the swap space. Now, use this rule for values: If the amount of memory is less than 512M, use the 2x rulw for swap. If the memory is 512M to 1G, use 1G for swap. If the memory is greater than 1G, allocate between 1 and 1.5G of space for swap. Follow the rules for creating by having the disk selected and doing the swap, /var,/tmp, /usr. Choose the FreBSD bootmanager. Hit Q when finished.
Select distributions in sysinstall and choose All. Select yes for the ports collection. Exit.
Select Media. If you are doing a networkless install, choose CD/DVD in the menu. For anyone else, choose FTP. Select a site that is in your country or near you. Select your NIC that is active and hit enter. You can tab through the options and hit OK. If you are prompted for a host name, follow the Linux rule: make one up.
In sysinstall, choose commit now. You may have problems receiving sets, if this happens select another site and hit enter.
When everything is installed, choose yes and go to the post install screen.
Set your root password.
Create a user. In the groups section,enter "wheel," you'll need this to enable the su function. Finish setting up the user and choose prepackaged software. Choose the Gnome or KDE meta or lite packages and firefox. Select yes and let the packages download. Follow the same rule for the install if the connection is reset: choose another server that is close to you.
Set up your mouse.
Select security and disable for now. You're going to need to do a lot from su later.
When you are finished, exit the install and remove any media. Let the system reboot.
Login as user and su to root.

Setting up X: Type "Xorg -configure" and hit enter. Now type "vi /xorg.conf.new" Search the document for Modes. If you don't see any, use ESC +/- i to enter the values. I usually enter "640x480" "800x600" "1024x768" "1280x1024" "1400x1050" "1600x1200" Do this for all depth values. save with the :w! function and exit with :q!
Test by typing startx. Exit the window manager if successful. Left terminal is login and out. Exit from root.

Setting up your environment:
Startx as user. In the right column type "firefox --sync http://www.freebsd.org" and enter. Adjust the size of the window. Go to documentation. Select handbook. Select single html. Remember what window manager you installed. let the page load completely.
From the firefox menu: go to edit, find in this page, and type "startkde" in the prompt box. Scroll this area and follow the instructions for echo "window manager executable" > ~/.xinitrc. Do the command in the left/Login terminal as the user. Exit firefox and close the right terminal. exit from the left terminal.
Adjusting your system for a first time rael run:
Startx as user. Adjust your keyboard rates and resolution now.
Open a terminal, su, and type "vi /boot/defaults/loader.conf"
enable your soundcard here and other services. Set your memory to the physical amount that you have. :w! &:q! and you're done.

Installing software:
As su: type "cd /usr/ports" To search: "make search name=<name of program>" To install: from /usr/ports cd to the section and then cd to the program. Type "make install clean"

Other configurations before rebooting: Follow the handbook for enabling gdm or kdm.
thing that I am not good with and you need to join the mailing list to get help: printing and mounting CD/DVD media as user.
Logout from the manager when done. Place your Linux distro in the tray. Su to root and reboot.

Second system installation.
Alright, install your system as before with grub.
Open /boot/grub/menu.lst for editing. Add these lines
title FreeBSD<architecture and release number>
rootnoverify (hd<disk number>, <partition number. It should be 0>)
chainloader +1.

You are now setup with a FreeBSD system.


Other helpful hints: enable unionfs read in Linux and ext3, reiser, jfs, xfs read in FreeBSD by installing the respective programs. /boot/defaults/loader.conf also has values for Linux emulation and file system support, Set these values here.

You can adjust security and network by typing "/usr/sbin/sysinstall" as su.

Enjoy your new dual setup.

Credits to the handbook and the guys and girls on the mailing list who took time to help me.

Edit: Create a second user with the useradd command; however, do not grant the second user root privilege

Edit: It took me a bit of time to find the information for setting up the cdrom. Here is a link to the post that helped me.

http://daemonforums.org/showthread.php?t=362
Last edited by sossego on 2009-10-18 04:07, edited 1 time in total.
User avatar
sossego
 
Posts: 1072
Joined: 2007-03-20 23:52

dual booting

Postby sossego » 2008-07-20 06:00

There are a few things I will need to add here:
If you want to use a virtual machine, use qemu. You will need to build it first with kqemu support, then build kqemu and enable it in rc.conf. I'll add the web reference howto soon.

Open a terminal and su to root. Cd to each directory as mentioned. Stay in root mode unless the instructions on here say otherwise.

In /boot/defaults, use vi to edit the loader.conf file. You will need to set the following values.

In the section named Kernel tunables:
#hw.physmem="1G" <--reset this value to the next highest gigabyte value from waht you have. E.g., you have 1.5G of RAM then the value will be 2G.
#kern.hz="100" <-- Set this value to the clock rate of your cpu. If you want to be safe, then set it to 1000 for newer chips, and a value of 100 to 500 for older chips.

"In the section named "Filesystems and related modules":
Set the value to YES for #linprocfs_load, #linsysfs_load, and #unionfs_load.

In "Emulation modules":
Set linux_load to a value of "YES".

In "Networking drivers":

Set the value to YES for the card(s) that you are using. Be sure that it is the active card that connects you to the internet or the router.


In "Sound modules"
Set the value of #sound_load to YES.
Set the value of your soundcard to YES. It will be on the list.
Set the value of #snd_driver_load to YES. Do this even if you only have one card.

In "USB modules":

Set #usb_load to YES.
Set any usb devices that you are using and are compatible to the values on the list to YES.

Be sure to :w! and :q! out of there.

If you have trouble installing and you are using a router:

From Choose media on the sysinstall screen, use FTP behind a firewall.

Refer back to the web reference to automounting for gdm. Also refer to the FreeBSD handbook for enabling kdm and gdm.

Now, you will need to be able to mount your linux partition from the FreeBSD one.

Create a directory or directories in your home folder named linux-name-of-mountpoint as the normal user. Now, su to root and type: "mount -t ext2fs -o ro /dev/<name of your mountpoint> /home/<your user name>/ <the linux directory you created for that mountpoint>"
Cd to the new mountpoint and ls. If you have done it right, you will see a listing of your linux filesystem. Cd to / and unmount the partition.

Note: if you don't want to su between root and the user account, just open a new tab and edit the home folder.

Save the changes. Reboot into your Linux system. Debian? Hells yeah!
Add the unionfs module either through apt-get or synaptic. Using module assistant, do the following as root
"module-assistant prepare unionfs && module-assistant build unionfs && module-assistant install unionfs && modprobe unionfs" It should load for you.

Make a directory in mount named freebsd.


Now add these lines to /etc/fstab to enable reading of your FreeBSD system from linux.

<file system> <mount point> <type> <options> <dump> <pass>
"/dev/sda4 /mnt/freebsd ufs ufstype=ufs2,ro 0 2".

Remember this method and do the same in the bsd install on the corresponding /etc/fstab with the values reflecting those of the linux system. use the folder you created in /home/<your user name> as the mount access point.

I, myself, do not know how to build the kernel model for unionfs read&write; however, others do and you should ask them. I don't suggest doing that until you have a good grasp of the bsd install.





I'll add the configuration for printing and networking when I have that equipment again.

Again: Thanks to the bsd and linux communities for helping me with this tutorial.
User avatar
sossego
 
Posts: 1072
Joined: 2007-03-20 23:52

kde4

Postby sossego » 2008-09-10 19:08

I'm adding these build instructions if you decide to install kde and have problems.

Begin by ading ports to the install but do not add any desktop environment.

Option 1: Do a default install listed above and after adding X change to this method.
Su to root and run "portsnap fetch && portsnap update".
Build kde4 with the following commands: "cd /usr/ports/x11/kde4 && make depends".

The build will take time.
Option 2: Install gnome as a package with "pkg_add -r gnome2" then add kde4 as a build process from the normal desktop.You will need to be near your box because a lot of ports will have to be uninstalled and reinstalled. Given that there will be a few packages to be rebuilt no matter what, option one is less time consuming.


More tips: When installing an application, you may need to run "rehash" as root to upgrade commands.

Build packages with "make depends && make config". You will have more control over the install process. You can also edit the Makefile located in the port file for the app..

Search the ports for modules that add Desktop features.

kde4 is taking time to build.

More help: http://unix.derkeiler.com/Mailing-Lists ... 01313.html
Let my desire and hope surpass my expectations;
And give me the strength to persevere through doubt.
Grant me the wisdom to exceed my bounds.
Let my eyes always see through the dream fog of childhood,
so that every moment may be treasured.
User avatar
sossego
 
Posts: 1072
Joined: 2007-03-20 23:52

kdm

Postby sossego » 2008-09-13 09:03

You will need to adjust /etc/ttys
use vi and change: t[yv8 "/usr/local/bin/kdm -nodaemon" xterm on secure]
to [ttyv8 "/usr/local/kde4/bin/kdm -nodaemon" xterm on secure]


This will allow you to use kde4 from the desktop. Sorry about this being late.

If you had trouble then correct with changing "on" to "off" in /etc/ttys at ttyv8.
Add [gdm_enable="YES"] to /etc/rc.conf if you want a working desktop before kde4 is ready. Be sure to comment it out before making the kde4-kdm as the default manager.
Let my desire and hope surpass my expectations;
And give me the strength to persevere through doubt.
Grant me the wisdom to exceed my bounds.
Let my eyes always see through the dream fog of childhood,
so that every moment may be treasured.
User avatar
sossego
 
Posts: 1072
Joined: 2007-03-20 23:52

kde4

Postby sossego » 2008-09-15 08:45

Install oss and arts from the ports.
Gnome screen saver: Disable locking and use graphics, blank screen may lock up. Gnome may give you some trouble. You can use the virtual terminals along with "ps -U <username>" to see what processes can be killed. You may want to use top to view the active processes.
Let my desire and hope surpass my expectations;
And give me the strength to persevere through doubt.
Grant me the wisdom to exceed my bounds.
Let my eyes always see through the dream fog of childhood,
so that every moment may be treasured.
User avatar
sossego
 
Posts: 1072
Joined: 2007-03-20 23:52

Postby sossego » 2008-10-08 08:23

I'm currently working on VirtualBox for FreeBSD AMD64. The vm solution is qemu + kqemu. I have a bit of information on it. If you have questions about this howto or difficulties, feel free to message me.

kde4 binaries will need to be run with "/usr/local/kde4/bin/<name of binary> -possible options" from the command line.

csh is the default shell. you can use bash as the default shell when installing or simply do "bash" from the command line. You may want to do this before building anything.

dev86 on amd64 needs to be patched.

The patch- credit goes to walt:
--- ld/x86_aout.h.orig 2003-01-28 17:17:14.000000000 -0500
+++ ld/x86_aout.h 2005-05-07 22:40:05.000000000 -0400
@@ -13,7 +13,9 @@
typedef long Long;
#define __OUT_OK 1
#else
-typedef char Long[4];
+#define __OUT_OK 1
+#include <sys/types.h>
+typedef int32_t Long;
#endif


Howto patch- I'm going full force blind into developing, the patch is necessary:

#cd /tmp (see the mirror image process already?)
#tar -xvzf /path/to/bin86-0.16.17.tar.gz
#cd bin86-0.16.17
#patch -p0 < /path/to/mynewpatch (there's that -p flag at last!)


Qemu help- I am having difficulty with this but here is what I have:
Create an image with qcow2 where you had used qcow before.
Let my desire and hope surpass my expectations;
And give me the strength to persevere through doubt.
Grant me the wisdom to exceed my bounds.
Let my eyes always see through the dream fog of childhood,
so that every moment may be treasured.
User avatar
sossego
 
Posts: 1072
Joined: 2007-03-20 23:52

Postby sossego » 2008-10-10 14:15

# touch /dev/tap0
touch: /dev/tap0: Operation not supported
# /etc/rc.d/devfs restart && kldload kqemu aio if_tap if_bridge
kldload: can't load kqemu: File exists
kldload: can't load aio: File exists
# sysctl net.link.tap.user_open=1
net.link.tap.user_open: 0 -> 1
# ifconfig bridge0 create
# ifconfig tap0 create
# touch /dev/tap0
# qemu-system-x86_64 -cdrom slax-6.0.7.iso -m 256 -hda slax.img -net nic -net tap -boot d

This is a sample of the qemu setup for amd64. You will get errors. I will post the fixes on here when I recieve them.
Let my desire and hope surpass my expectations;
And give me the strength to persevere through doubt.
Grant me the wisdom to exceed my bounds.
Let my eyes always see through the dream fog of childhood,
so that every moment may be treasured.
User avatar
sossego
 
Posts: 1072
Joined: 2007-03-20 23:52

Postby sossego » 2009-03-02 07:48

This is an update specific for amd64 hosts
If you're having trouble using qemu then do this.
Su to root.

All of the following is to be done in a terminal.

cd /usr/ports/security/sudo && make config && make depends && make clean install clean
cd /usr/ports/emulators/kqemu-kmod && make deinstall clean
cd /usr/ports/emulators/qemu && make deinstall clean
cd /usr/ports/emulators/qemu-develop && make config && make depends && make clean install clean

## Configure sudo and add youself.

makefile should look like this
OPTIONS= KQEMU "Build with (alpha!) accelerator module" Off \
RTL8139_TIMER "allow use of re(4) nic with FreeBSD guests" Off \
SAMBA "samba dependency (for -smb)" Off \
SDL "SDL/X dependency (graphical output)" On \
GNUTLS "gnutls dependency (vnc encryption)" On \
PCAP "pcap dependency (networking with bpf)" On \
CDROM_DMA "IDE CDROM DMA" On \
ALL_TARGETS "Also build dyngen targets (requires gcc34)" On
Turn on kqemu and rtl8139 in the config options. You can do samba if you like.

Create an image with "qemu-img create -f qcow2 <image name>.img <size>"


Follow the qemu documentation. If you are having trouble with lenny or sid due to X then do this.
Create two images. Install etch on the first. Do amodular build and configure xorg. Install lenny or sid on the second. In the sid/lenny install add the etch image but do not mount it. Be sure that lenny/sid is hda and etch is hdb. Do a modular install of lenny/sid with a base system. Apt-get xorg from the command line. Now, you'll need to remember which disk is etch and mount it read only.

Command line within qemu:

mount -t ext3 -o ro /dev/etch/disk /mnt
cd /mnt/etc/X11/
mv /etc/X11/xorg.conf /etc/X11/xorg.conf.old
cp /mnt/etc/X11/xorg.conf /etc/X11/

startx

It should work.
A thing to note: qemu will work on qemu and the kqemu module can be constantly layered but it can cause the image to break.
My apologies for not having added more to this earlier. Again, feel free to contact me.
Let my desire and hope surpass my expectations;
And give me the strength to persevere through doubt.
Grant me the wisdom to exceed my bounds.
Let my eyes always see through the dream fog of childhood,
so that every moment may be treasured.
User avatar
sossego
 
Posts: 1072
Joined: 2007-03-20 23:52

Postby sossego » 2009-03-10 04:31

Update:
Run the portsnap command : http://www.freebsd.org/doc/en_US.ISO885 ... using.html

Remove qemu, reconfigure, and reinstall.
Let my desire and hope surpass my expectations;
And give me the strength to persevere through doubt.
Grant me the wisdom to exceed my bounds.
Let my eyes always see through the dream fog of childhood,
so that every moment may be treasured.
User avatar
sossego
 
Posts: 1072
Joined: 2007-03-20 23:52

Postby sossego » 2009-03-24 16:59

Add this to the FreeBSD virtualbox build instructions:
Set the target CPU to match the host.
Do this with vi to the configure file.

Code: Select all
    TARGET_CPU="amd64"
    TARGET_MACHINE="amd64'


Be sure that the build reflects this.
Long mode flags are not set.
Use the following arguments:

Code: Select all
/path/to/vbox/folder/# ./configure --disable-xpcom --disable-kmods --disable-hardening  --disable-pulse && source env.sh && kmk -k -t -s




Use /usr/sbin/sysinstall to create the vboxusers group. Don't add any users to this until after you have saved it.
Use vi /etc/group to add both root and the initial user account to the new group vboxusers.

The qemu source needs to be searched for long mode flags for the freebsd release and copied to the configure, Config.kmk, and Makefile.kmk files.

You can start and run the testcases with
Code: Select all
 cd out/freebsd.amd64/release/bin/testcase

Use ls to see all of the testcases and run each with
Code: Select all
 ./tstNameOfTestCase
Let my desire and hope surpass my expectations;
And give me the strength to persevere through doubt.
Grant me the wisdom to exceed my bounds.
Let my eyes always see through the dream fog of childhood,
so that every moment may be treasured.
User avatar
sossego
 
Posts: 1072
Joined: 2007-03-20 23:52

Postby sossego » 2009-03-26 08:41

./tstVMStructSize
tstVMStructSize: TESTING
struct VM: 129472 bytes
sizeof(uint128_t): 0x10 (16)
sizeof(int128_t): 0x10 (16)
sizeof(uint64_t): 0x8 (8)
sizeof(int64_t): 0x8 (8)
sizeof(uint32_t): 0x4 (4)
sizeof(int32_t): 0x4 (4)
sizeof(uint16_t): 0x2 (2)
sizeof(int16_t): 0x2 (2)
sizeof(uint8_t): 0x1 (1)
sizeof(int8_t): 0x1 (1)
sizeof(X86DESC): 0x8 (8)
sizeof(X86DESC64): 0x10 (16)
sizeof(VBOXIDTE): 0x8 (8)
sizeof(VBOXIDTR): 0xa (10)
sizeof(VBOXGDTR): 0xa (10)
sizeof(VBOXTSS): 0x88 (136)
sizeof(X86FXSTATE): 0x200 (512)
sizeof(RTUUID): 0x10 (16)
sizeof(X86PTE): 0x4 (4)
sizeof(X86PD): 0x1000 (4096)
sizeof(X86PDE): 0x4 (4)
sizeof(X86PT): 0x1000 (4096)
sizeof(X86PTEPAE): 0x8 (8)
sizeof(X86PTPAE): 0x1000 (4096)
sizeof(X86PDEPAE): 0x8 (8)
sizeof(X86PDPAE): 0x1000 (4096)
sizeof(X86PDPE): 0x8 (8)
sizeof(X86PDPT): 0x1000 (4096)
sizeof(X86PML4E): 0x8 (8)
sizeof(X86PML4): 0x1000 (4096)
VM::selm.s.Tss offset=0xfb88 expected alignment 10, meaning 0x8 off
VM::selm.s.Tss offset 0xfb88 (64392) sizeof 136
VM::selm.s.TssTrap08 offset 0xfc10 (64528) sizeof 136
sizeof(PGMPAGE): 0x10 (16)
tstVMStructSize: Comparing HC and GC...
tstVMStructSize: FAILURE - 1 errors


This is the only failure for the FreeBSD amd64 build.
Let my desire and hope surpass my expectations;
And give me the strength to persevere through doubt.
Grant me the wisdom to exceed my bounds.
Let my eyes always see through the dream fog of childhood,
so that every moment may be treasured.
User avatar
sossego
 
Posts: 1072
Joined: 2007-03-20 23:52

Postby sossego » 2009-03-26 16:41

In /path/to/vbox/src/VBox/VMM/SELMInternal.h
You can increase the padding value here but it returns the same error.

In Config.kmk look for "port me to freebsd amd64" and copy the values over if you forgot. Add -O2 to the build line. Using -march= or -mtype= should work.

I think it is the trap value and that increasing it from 8 to 10 will work but I am not sure.

Oh, yeah, sorry, cats,let's make this easier.

Code: Select all
 #!/bin/sh /usr/bin/cd /path/to/vbox/folder/ && /bin/bash

Saving this as vb-test.sh should make the build easier.
Let my desire and hope surpass my expectations;
And give me the strength to persevere through doubt.
Grant me the wisdom to exceed my bounds.
Let my eyes always see through the dream fog of childhood,
so that every moment may be treasured.
User avatar
sossego
 
Posts: 1072
Joined: 2007-03-20 23:52

Postby fk » 2009-03-27 22:02

Open /boot/grub/menu.lst for editing. Add these lines
title FreeBSD<architecture and release number>
rootnoverify (hd<disk number>, <partition number. It should be 0>)
chainloader +1.

not really. I use
#For booting FreeBSD
title FreeBSD
root (hd0,0,a)
kernel /boot/loader

and all fine. Some people to:
http://administratosphere.wordpress.com ... n-freebsd/
I think this is more correct way.

Now type "vi /xorg.conf.new"

not sure what vi exist in Freebsd7 by default. BSD people prefer use "ee" - "easy editor" - "freebsd editor". It's more simple - they general reason.

In the groups section,enter "wheel," you'll need this to enable the su function

"wheel" - i hate this one. Thanks for say about it. Not sure that freebsd install-how-to and hand-book have pages about it. I create user what can't use su /sudo and cry :oops:

You can adjust security and network by typing "/usr/sbin/sysinstall" as su.

typing "sysinstall" will enough. I think /usr/sbin in PATH variable already by default

Anyway, Thanks!
Last edited by fk on 2009-03-28 14:37, edited 1 time in total.
User avatar
fk
 
Posts: 105
Joined: 2009-02-28 18:00

Postby sossego » 2009-03-28 08:49

The grub edit is by habit and makes it easier to learn.
Typing /usr/sbin/sysinstall can be avoided, yes;but, I want the path to be known.

Personally, I don't trust sudo. It's a security risk in my eyes. Let them learn how to use su.

You can't edit without wheel just like you can't use visudo without root access.
Also, an account with no root access is good to use for day to day activities.
Vi was the suggestion given to me by the FreeBSD community, that is why I use it. Besides, it's simple.
Let my desire and hope surpass my expectations;
And give me the strength to persevere through doubt.
Grant me the wisdom to exceed my bounds.
Let my eyes always see through the dream fog of childhood,
so that every moment may be treasured.
User avatar
sossego
 
Posts: 1072
Joined: 2007-03-20 23:52

Re: Dual booting with freeBSD

Postby sossego » 2009-09-01 02:01

Update: The install process is the same with a few changes.
When configuring X, edit /root/xorg.conf.new to have the following parameters
Code: Select all
Section "Screen"
   Identifier "Screen0"
   Device     "Card0"
   Monitor    "Monitor0"
   DefaultDepth  24 [or other preferred depth
        Modes "[mode lines]"


Add the original mode options after 1,4,8,15,16,and 24.

In the Monitor section be sure to add the HorizSync and VertRefresh values.

If you want to have a secure system but need to use a kld-file, then you can add the value to / /boot/defaults/loader.conf.
I'll need to boot into my unionfs partition to give the new parameters for cd mounting.
Let my desire and hope surpass my expectations;
And give me the strength to persevere through doubt.
Grant me the wisdom to exceed my bounds.
Let my eyes always see through the dream fog of childhood,
so that every moment may be treasured.
User avatar
sossego
 
Posts: 1072
Joined: 2007-03-20 23:52

Next

Return to Docs, Howtos, Tips & Tricks

Who is online

Users browsing this forum: No registered users and 8 guests

fashionable