# Question re: dual-boot with Linux, partitioning



## mefizto (Jul 2, 2016)

Greetings all,

I have acquired an older 32 bit 2GB laptop with two MBR partitions; the first having Linux installed.  I would like to use the second partition for FreeBSD.

Since I have never done dual-boot installation,  from  my reading I understand that I simply install the FreeBSD on the second partition and use the Grub 2 loader to switch between the two OSs.  Is it that simple, or have I missed something?

Also, since I will use UFS, and would like to have a lightweight GUI, e.g., Fluxbox, Lumina, XFCE, and the basic tools like: browser, mail client, Libre Office, and the like, could someone suggest partitioning scheme with sizes for the 100 GB partition?

Kindest regards,

M


----------



## ASX (Jul 2, 2016)

mefizto said:


> Since I have never done dual-boot installation, from my reading I understand that I simply install the FreeBSD on the second partition and use the Grub 2 loader to switch between the two OSs. Is it that simple, or have I missed something?



yes and no, depending on your level of knowledge of Linux / FreeBSD and Grub2.

Assuming (I may be wrong, of course) you are proficient with Linux and Grub2 and a little less with FreeBSD, I would suggest to use the Linux Grub2 to *chainload* a FreeBSD boot loader, and avoid for example to load the FreeBSD kernel directly.

I say that because I have seen how grub automatically detect and install a FreeBSD menuentry, by loading the kernel directly, and that way conflict with the FreeBSD documentation:

Many/most docs will direct you to place "this or that setting" in /boot/loader.conf, when booting from grub->kernel in practice will ignore that file.

Also I'm not sure about how well supported are "extended partitions", and I don't know if your second partition is a primary or an extended/logical one.

Additionally, what a Linux user known as "MBR partition", In BSD world assume the name of "slice", and a slice will be further divided into partitions, this can be quite confusing if you are not familiar with BSD partitioning.

https://www.freebsd.org/doc/handbook/disk-organization.html#basics-disk-slice-part


----------



## kpa (Jul 2, 2016)

I wouldn't do multiple partitions on this type of installation, there's very little gain in doing so on a laptop system. Multiple partitions and multiple filesystem are most useful on a true multiuser environment where some of the users can not be fully trusted not to do something unexpected like filling up the disk that hosts the /home filesystem.


----------



## Maxnix (Jul 2, 2016)

ASX said:


> I would suggest to use the Linux Grub2 to *chainload* a FreeBSD boot loader, and avoid for example to load the FreeBSD kernel directly.


Agree. When I tried loading the kernel directly had problems with the system console (vt(4))
switching from and to X (and perhaps even between virtual consoles, don't remember).

IMHO chainloading is the best thing with non-Linux OSes.


----------



## mefizto (Jul 2, 2016)

Hi ASX,

it is just the opposite, I am more familiar with FreeBSD than Linux, hence my question regarding Grub2.  O.K., I will look up chainloading.  The second partition is unformated.

Hi kpa,

can you please elaborate?  In the past, I have always created partitions for at least /root, /var, /tmp, /usr; the reasoning being easier recovery when one partition is damaged, preventing /root overfill, etc.  Additionally, I cannot be trusted as a user. ;-)

Kindest regards,

M


----------



## ASX (Jul 2, 2016)

mefizto said:


> It is just the opposite, I am more familiar with FreeBSD than Linux, hence my question regarding Grub2. O.K., I will look up chainloading. The second partition is unformated.




You can use something like described below, in grub.cfg both will work:


```
insmod part_bsd
insmod ufs2

menuentry "FreeBSD hd0 2a Loader" {
  set root="(hd0,2a)"
  kfreebsd /boot/loader
}


menuentry "FreeBSD hd0 2a Chainloading" {
  set root=(hd0,msdos2a)
  chainloader +1
}
```

About the layout, guess *kpa* was suggesting to make a single partition, considering the relatively low amount of free space and considering that it will be mostly a single-user machine, and I agree with his view.

So, the root partition and the swap one should suffice.

Of course, you should know better what use you will make of that, therefore the final word is yours!


----------



## scottro (Jul 2, 2016)

Old article of mine, but still works for me.


```
menuentry "FreeBSD" {
set root='(hd0,3)'
kfreebsd /boot/loader
}
```
If it was on the 3rd partition.

NOTE:  This was originally incorrect, ASX caught the error.

If that doesn't work, I'd go with the more sophisticated one that ASX posted, but I like to start as simply as possible.    The method above works for me with Fedora's grub2, and, if I remember correctly, Arch's grub2.

If you're using a RedHat based system, e.g, CentOS or Fedora, it will be in /boot/grub2, if using anything else, I think it's in /boot/grub.  Create a file /boot/grub (or grub2) custom.cfg with the lines I give above (or with the lines in the post above.)

There's a 40_custom.cfg or 41_custom.cfg or something similar, but you can just create your own separate custom.cfg.

My original article is here.  https://srobb.net/grub2.html


----------



## ASX (Jul 3, 2016)

scottro said:


> If it was on the 3 partition.


Hmm ... no, disks are numbered starting from 0, partitions are numbered starting from 1.
Just to not confuse the OP.


----------



## mefizto (Jul 3, 2016)

Hi ASX, scottro,

thank you for the continued help, I will need to read about Grub2 because from your posts, _cf._, scottro's link, it seems that different Linuxes do things differently.



ASX said:


> Just to not confuse the OP.


Nice try, but I am already confused.  And I though it would be easy. ;-(

Kindest regards,

M


----------



## ASX (Jul 3, 2016)

If you need help, please post your specific code from grub.cfg and the current partition layout:
from Linux: `fdisk -l`
from FreeBSD: `gpart show -p`


----------



## scottro (Jul 3, 2016)

Different Linux distributions do things differently. It might be useful to post which Linux distribution.    If, for example, it was CentOS-6.x, it would be using the old grub, and that has a different syntax.

Otherwise, the only difference that should show is that RedHat and its offshoots, CentOS, Fedora, Scientific Linux, Oracle Linux and a few others, use /boot/grub2 instead of /boot/grub. 

The other thing was that ASX caught a typo of mine--I had put in 0,2 for the third partition, and it is 0,3.  (I've corrected it)  Disk starts at 0, partition starts at 1, so 0,3 means the 3rd partition of the first disk.


----------

