Right, I have managed to install FreeBSD to a logical partition using only the 7.1 amd64 livefs CD. All of this was done in a virtualbox, but it should be equally doable on real hardware.
I have
not tried to boot it. I can't even guarantee that the existing grub will be happy afterwards, though I don't think it will interfere.
edit: Right, I've messed up some detail in the partition layout. Oops - let me find out what I did wrong before anyone attempts to duplicate this. And *sigh* - 8 AM is no time to be going to bed ...
The starting point
I'm using a 20GB hard disk image.
I installed openSuSE (i386) with a custom partition layout:
One extended partition covering the disk, carved into three logical partitions: 512MB swap, 8GB root file system, and 11.5GB unformatted.
The extended partition is the first (and only) partition on the disk, so it'll be s1 in FreeBSD. If it's on the first ata HD, it's ad0s1 - which is what it was called for me, and what I'll use.
Fun with fixit
I only had an amd64 livefs image at hand and couldn't be bothered downloading an i386 one for this - it shouldn't matter.
At the loader menu, press 6 (
Escape to loader prompt):
Code:
[b]OK[/b] load geom_part_mbr
[b]OK[/b] boot
In sysinstall, choose Fixit, CD/DVD . This will drop you at a shell.
Code:
[b]Fixit#[/b] geom part list ad0s1 | less
This will give you some information on the extended partition and the logical partitions in it. You're interested in the "first" and "last" numbers for the entire partition, and the "length" and "offset" for all the detected logical partitions (which will be under "Providers"). The logical partitions will have names like "ad0s1s1" and "ad0s1s2". (You can read these names as descending into a hierarchy: atadisk0 -> slice 1 -> slice 1 )
If the empty logical partition you want to use is listed here, great. If not, you have to create it; this was the case for me.
The first/last numbers are 512-byte sectors, while the length/offset numbers are in bytes. For me, the numbers looked like this:
ad0s1:
First->last (sectors): 63 -> 41913584
First->last (bytes): 32256 -> 21459755008
Length (calculated) : 21459722752 bytes / 41913521 sectors
ad0s1s1 (linux swap):
Offset: 32256 bytes
Length: 534610944 bytes
Position (bytes): 32256 -> 534643200
ad0s1s2 (linux / ):
Offset: 534643200 bytes
Length: 8587192320 bytes
Position (bytes): 534643200 -> 9121835520
The free space is between the end of the last logical partition and the end of the extended partition:
Offset (bytes): 9121835520 (end of previous logical partition)
Length (bytes): 21459755008 - 9121835520 = 12337919488
To create the partition, I use
gpart add, which wants all number in blocks: Just dividing by 512 will work.
Code:
[B]Fixit# [/B]gpart add -b 17816085 -s 24097499 -t freebsd ad0s1
ad0s1s3 added
With the logical partition in place, the next step is to use bsdlabels to carve it up a bit. My desired layout looks like this:
Code:
a: 2GB /
b: 1GB swap
(c: reserved)
d: the rest /usr
First, create a new disklabel and look at it:
Code:
[B]Fixit# [/B]bsdlabel -w ad0s1s3
If you don't like vi:
[B]Fixit# [/B]export EDITOR="ee"
[B]Fixit# [/B]bsdlabel -e ad0s1s3
The partition called
a covers the entire usable area, so we'll split that up into parts. The length and offset numbers are in 512 byte sectors again. Using the rough numbers from above, we want this:
Code:
a: 4194304 long, starting at 16 : ends before 4194320
b: 2097152 long, starting at 4194320: ends before 6291472
d: 24097421 - (4194304 + 2097152) = 17805965 long , starting at 6291472
Editing the disklabel to fit gives this:
Save and exit - that will write the label.
Now, to format and mount the new partitons, and leave the fixit shell. I'll use softupdates (-S) on /usr but not on / ; it's arguably a conservative choice.
Code:
[B]Fixit# [/B]newfs /dev/ad0s1s3a
[B]Fixit# [/B]newfs -S /dev/ad0s1s3d
[B]Fixit# [/B]mkdir /dest
[B]Fixit# [/B]mount /dev/ad0s1s3a /dest
[B]Fixit# [/B]mkdir /dest/usr
[B]Fixit# [/B]mount /dev/ad0s1s3d /dest/usr
[B]Fixit# [/B]exit
Back in sysinstall, leave the fixit menu, and go to Configure.
Under Options, set
Install Root to /dest .
Under distributions, check the ones you want - for now, just base and kernel (and probably man) will do.
This should take you to the media select screen, if not, select Media.
If your network card works, I'd suggest an FTP install - I didn't get a CD install to work, so I suspect the relevant files aren't on the livefs image.
When that finishes, you have a very sparse FreeBSD install in a logical partition.
Post-install setup
I haven't tried to make this boot yet, that's definitely for another evening (the sun is already up here and I need a few hours of sleep). I'd suggest doing a few things now, though; they seem sensible.
Go back to the Fixit shell, and edit /etc/fstab (with vi or ee, as you prefer); you want something like this:
Code:
/dev/ad0s1s3a / ufs rw 1 1
/dev/ad0s1s3d /usr ufs rw 2 2
/dev/ad0s1s3b none swap sw 0 0
You most likely want to load geom_part_mbr at boot, too. Edit /boot/loader.conf, and add
geom_part_mbr_load="YES".
The next step is to set up grub. I think. Assuming that the above can be made to boot.