Installation of FreeBSD onto a Logical Partition

Right, I'm about halfway through writing the sort-of final version of this, but I've got a practical problem: This computer is connected to the internet by a rather dubious temporary hack, and I just can't get sysinstall to work with FTP. Too many layers of NAT, I suspect, or possibly some problem with WinXP ICS.

I'll have to get back to you when I have bought myself a long TP cable.

For the time being, here's the first half:



Software
FreeBSD, specifically a liveFS CD.
A partitioning program that can create logical partitions (e.g. gPartEd)
GRUB 2
Some way to install GRUB 2, I'm using an Ubuntu install [1].

Outline
  • Create the logical partitions
  • Format, mount, and install FreeBSD to them from the livefs CD
  • Install GRUB2 (from Linux) [2]
  • Configure it to boot FreeBSD.

Step by step
I'll install Ubuntu and do the partitioning from their liveCD, just to cut down on the number of steps. The details of partitioning and installing a linux are beyond the scope here, so I'll just show the partition layout when it was done:
gparted_done.png


The next step is to install FreeBSD. I'm using the amd64 7.1 livefs iso, though the i386 version would also be fine.

When sysinstall starts, chose [font="Courier New"]Fixit -> CDROM/DVD[/font]. This drops you at a shell.
fixit1.png

Note the [font="Courier New"]ad [/font]devices - they correspond to the partitions in the partition editor screenshot above. ad0s1 is the extended partition, and ad0s5+ are the logical partitions inside it.

In this case, we're interested in ad0s7 (which will be our / partition), ad0s8 (which will be /usr), and ad0s9, which will be swap.

First, we need to format it. I'll do UFS2 with softupdates on both:
[font="Courier New"]Fixit# newfs -U /dev/ad0s7[/font]
[font="Courier New"]Fixit# newfs -U /dev/ad0s8[/font]

Next, mount this somewhere. /mnt will do nicely:
[font="Courier New"]Fixit# mount /dev/ad0s7 /mnt[/font]
We also have to mount the other partitions in the appropriate subdirectories:
[font="Courier New"]Fixit# mkdir /mnt/usr[/font]
[font="Courier New"]Fixit# mount /dev/ad0s8 /mnt/usr[/font]


Leave the fixit shell (the exit command, or Ctrl D). Leave the [font="Courier New"]Fixit [/font]menu, and go to [font="Courier New"]Configure[/font]. Select [font="Courier New"]Options[/font], and change Install Root to where you mounted the partition(s), e.g. /mnt.
sysinstall_options.png


Work in progress

Leave the Options menu, and go to [font="Courier New"]Distributions[/font]. Pick Base and Kernels (where you want the GENERIC kernel), and leave the distributions menu: This will take you to the media select screen, where you can pick something suitable - I used FTP, since the liveFS CD doesn't contains the neccesary files.

The details around this are the same as for a normal install,. so I'll just skip to when the installation finishes. There's a few more things we need to do in the fixit shell. I've had some weird problems with starting it again, so I'd suggest leaving sysinstall and rebooting now, starting up from the liveFS CD again, and then starting the fixit shell. If you do, repeat the [font="Courier New"]mount [/font]commands from earlier.

What's left to do is to set the GENERIC kernel as default, and to write a suitable fstab. Assuming the new isntall is mounted at /mnt :
[font="Courier New"]Fixit# cd /mnt/boot
Fixit# mv GENERIC kernel
Fixit# ee /etc/fstab [/font]
With the partitions above, you'd want something like this:

Code:
/dev/ad0s7     /      ufs    rw    0 0
/dev/ad0s8     /usr   ufs    rw    1 1
/dev/ad0s9     none   swap   sw    0 0

Save and exit. Leave the fixit shell, exit sysinstall, reboot.
That's it for the FreeBSD side: What's left is to install grub2 and config it to boot the FreeBSD install (not to mention whatever else you've got installed, but I'll leave that to you.)


GRUB 2
I'll be working in Ubuntu 9.04 from here on, since that's what I happen to have in the VM I'm testing this in. You might be able to install GRUB2 on and from FreeBSD. If so, I might come back to that later.

Support for booting 64-bit FreeBSD was only very recently added, so until it makes it into the packages of assorted linux distros, you probably have to compile it yourself.

To do this, I had to install subversion, autoconf, and bison. It might also be smart to deinstall grub, since we'll be installing to some of the same locations as it (and would risk an update to grub overwriting grub2 files).

# svn co svn://svn.sv.gnu.org/grub/trunk/grub2
# cd grub2
# ./autogen.sh
# ./configure
# make install

To be continued (now that I've finally got myself a decent network connection).



[1] As a variation from the SuSE last time.
[2] I think it's possible to compile it on FreeBSD as well - but one experimental thing at the time.
 
Thanks, so that's all involved?

Which should I make bigger, /mnt or /mnt/usr?

Would it be at all possible to have both on the same hard-drive?

Could you please include a tutorial on how to compile the GRUB2 patch for FreeBSD 64-bit?

Thanks in advance,

Panarchy

PS: Once again, thanks a heap for all your help!
 
I'm actually not in the same town as my experimental machine ATM, which is inconvenient. But yes, part 2 would be "how to compile and config grub2".

And yes, that's essentially it: Create partitions first, boot a liveFS cd, format and mount the paritions, and install to them.

As for how you do your partitioning, that's one of those religious things I wouldn't dare say anything final about. Remember that /mnt (or whatever you use) will correspond to / in the installed system, and /mnt/usr to /usr - then dig up the handbook or any of the endless debates here and other places. ;)

As a starter, remember that /usr will hold all installed ports and all home directories (except for root's), not to mention /usr/ports and /usr/src, so it will typically need to be as big as possible. If you're only using those two, / will need to hold e.g. /var, so it should get a few GB as well.

And "same HD"? Yes, that's what I did ...
(If you meant "same partition", it's entirely possible to use just one partition. It's not without downsides, but if you need to make the most out of limited space it can be the best option.)
 
Thanks, so I can install both onto the same partition, great!

Looking forward to Part2 'How to compile and configure GRUB2 for FreeBSD 64-bit'

:p

Panarchy
 
Both what? I'm still not entirely sure I get what you're asking. ;)

If you mean directories: Remember that any directory can be mounted from anywhere, split however you want. If you'd like to spread out over 200 partitions, that should be as doable as using just one. ;)
 
Indeed! Well, almost. Still needs this;

Here's how to add support to GRUB2 for the 64-bit FreeBSD kernel;
Felix Zielcke said:
Just checkout the source code and then apply the patch with `cd grub2]

Perhaps amalgamate all the tutorials you've given so far (and the above) into your next post?

Then I'll PM staff-members to pin this topic!

Thanks for all your help Djn, PHcoder & Bean,

Panarchy

BTW: In case you were wondering, PHcoder & Bean coded the GRUB2 PATCH.
 
Staff are everywhere, in case you hadn't noticed ;)

Anyway, we don't usually pin/stickify developing threads (would require clean-up and summarising first), but it has the potential to be turned into a HOWTO and posted in the appropriate forum, of course. I suggest waiting for a definitive outcome, though.
 
I know it works - I booted it (32bit) last time I tried.
What's missing is a reasonably clear write up of the parts I've said are missing - and that's waiting for me to get it done (I've got some practical issues that need sorting). I'll contact someone when I feel done. ;)
 
That is, once I've gotten my other OS's to work. Trying to save as many primary as possible, so trying to get ALL my Windows onto logical partitions.

That way I'll have plenty spare for Solaris etc.

So as soon as I can work out how to get this to work, I'll install FreeBSD.

Thanks for all the help.

Panarchy
 
Problem installing

Hi DJN

I try to follow your instruction from your first edit.

Originally Posted by DJN
FreeBSD
I then rebooted into a FreeBSD 7.2-BETA1 livefs CD, and in the fixit shell did this:
Code:
Fixit# newfs /dev/ad0s7
Fixit# newfs -U /dev/ad0s9
Fixit# mkdir /new
Fixit# mount /dev/ad0s7 /new
Fixit# mkdir /new/usr
Fixit# mount /dev/ad0s9 /new/usr
Fixit# exit
In sysinstall, choose Configure.
In the configure menu, first go to Options and change Install Root to /new .
Then go to Distributions, and select base and kernels (picking the GENERIC kernel).
Exiting the Distributions selection will bring up the media selection. Pick whatever works for you, but keep in mind that you can't install off a livefs CD. I used FTP.

When that finishes, exit out to the main menu and start the fixit shell again - it'll complain a bit (about linker cache and mounting /bin, I seem to remember), but that's harmless.
At the shell, do this:
Code:
Fixit# cd /boot
Fixit# mv GENERIC kernel
Fixit# ee /etc/fstab

When itry to do this the mv Generic kernel, it gives me an error message generic kernel cannot be rename.

In the fstab, add something like this:
Code:
/dev/ad0s7 / ufs rw 1 1
/dev/ad0s9 /usr ufs rw 2 2
/dev/ad0s8 none swap sw 0 0
Save, exit, exit the fixit shell, and get ready to mess with grub2 - but first, a small fix.

How will I'm going to do this do I need to press the tab key in the keyboard for spacing?

How will I'm going to boot this if I'm using the easybcd bootmanager?

Hope to hear from you.

Thanks
 
jessa_jr said:
Hi DJN

I try to follow your instruction from your first edit.
When I try to do this the mv Generic kernel, it gives me an error message generic kernel cannot be rename.

Hmm. You're just trying to rename a directory, nothing very complicated. Are you sure you were in the right directory? Check that it exists there, and that you typed it right (remember, it has to be all-uppercase).

How will I'm going to do this do I need to press the tab key in the keyboard for spacing?
It's quite forgiving - use as many spaces or tabs (or both) as you think looks good.

How will I'm going to boot this if I'm using the easybcd bootmanager?

Hope to hear from you.

Thanks

EasyBCD is a tool to make configuring the vista bootmanager easier - and I don't think it can load FreeBSD kernels directly. The easiest might be to configure it to boot grub2 from a file on your windows partition, and then use that to load FreeBSD. It's a bit beyond what I'm doing here, but if I find the time I might look at it.

If you've got a spare primary partition I'd recommend you use that instead, though - it's significantly easier to set up (both the install and the bootloader part).
 
Originally Posted by DJN
Hmm. You're just trying to rename a directory, nothing very complicated. Are you sure you were in the right directory? Check that it exists there, and that you typed it right (remember, it has to be all-uppercase).

I don't actually I do even make it all small letters and all caps. I will try this again this weekend.

EasyBCD is a tool to make configuring the vista bootmanager easier - and I don't think it can load FreeBSD kernels directly. The easiest might be to configure it to boot grub2 from a file on your windows partition, and then use that to load FreeBSD. It's a bit beyond what I'm doing here, but if I find the time I might look at it.

If you've got a spare primary partition I'd recommend you use that instead, though - it's significantly easier to set up (both the install and the bootloader part).

But easybcd boot the freebsd when I install it in the primary partition. But now I don't have a spare primary partition to put the freebsd because I will need to install also the solaris and opensolaris to the primary partition.
 
Grub4dos

jessa_jr said:
I don't actually I do even make it all small letters and all caps. I will try this again this weekend.



But easybcd boot the freebsd when I install it in the primary partition. But now I don't have a spare primary partition to put the freebsd because I will need to install also the solaris and opensolaris to the primary partition.

Grub4DOS should do the trick. (easybcd=neogrub :p)

Okay?

EDIT: (that's right, I can edit now!)
Djn: Any chance of a summarised tutorial, or would you like me to write one based off of what you've written so far?

PS: Once again, thank you Bean for porting GRUB2 to FreeBSD 64-bit.
 
I've still got a section left (the "configuring grub2"-part), and I think I can put something together when that's done.
What would be good is if you could test it when I'm done, though - I might have forgotten to write some step down, or assumed something that'll fail for others.

jessa_jr: The reason EasyBCD can load freebsd when it's on a primary partition is that it just lets the FreeBSD bootloader handle it. That won't work when you're using a logical partition, since the FreeBSD loader doesn't support them. (What I'm doing is essentially to replace the FreeBSD loader with GRUB2)
 
@Panarchy
Originally Posted by Panarchy
Grub4DOS should do the trick. (easybcd=neogrub )

How can I do this? So is this means when you install grub4DOS bootloader to the "root partion"(if im right or where will I install grub4DOS) of the freebsd in the logical drive, I will just call that partition using easybcd manager.

@DJN
I hope you can finished the tutorial so I can also try it. Just wanna ask where you will install the grub bootloader is that in the "root partition" only not all the partition. If you can do that I think I can call the freebsd using the easybcd because it support grub.
 
grub4dos

I have vista and easybcd installed already and I know how to edit the menu.lst. Im just asking how will im going to install grub4dos and in what partition root,usr or swap (I know its in the root partition) but how? Then I will call that partition using easybcd.
 
How will I do it

@Panarchy

I'm very sorry but its not clear for me so did you mean that I dont need to install grub4dos, How will I add freebsd in my menu list, will I "to it to the root partition of the freebsd in the logical partition and use grub instead of freebsd"

Thanks
 
Not so hard

Merely install NeoGRUB from within EasyBCD, then edit the menu.lst to add the partititon containing FreeBSD.

chainload
 
Back
Top