# Minimal FreeBSD based system, or how can I manually install FreeBSD... minimally... without internet connectivity



## decuser (Sep 3, 2020)

I realize that I have asked a question that isn't artful. I'm trying to learn a bit more about how things work, so I may not have asked this correctly. Help me out. What I think I want to do is something along the lines of:

1. In a VM running 12.1 w/root on ZFS (or alternatively w/UFS)
2. Add a drive to the system and put a filesystem on it
3. Install just enough FreeBSD to the new drive to boot off it

How I'm thinking this might work is that no installer is involved and 1 is already running and 2 is straightforward, but 3 is where the work comes in. I have two scenarios in mind, one is to copy a bootloader file onto the bootsector of the drive and unpack the kernel and userland onto it (how do I boot it?), and the second is to put the bootloader where it belongs and then cross-compile basic programs (bash, cc, and so on) in some mysterious order so that the system is useable when I boot into it. Option two, seems uber-challenging, but option one seems challenging but doable.

What do y'all think? Has manual installs using the tarballs and bootloader stuff been written up somewhere?


----------



## mark_j (Sep 3, 2020)

What host is running the VM?

Adding a drive is simple. You connect the disk to the host machine and look in the appropriate sections of the manual. If you're using ZFS you don't have to worry about partitions because it's best to use an entire disk.

Your option 3 is a bit confusing. What defines enough? The OS is the OS is the OS, you can't pick and choose what to install (in reality you can pick options like installing compat layers or games). Install the OS gets you the kernel, the init system and the userland utilities like ls, cat, find etc. That's it. 

Is there a manual for all your proposals? Not that I'm aware of, because frankly, what you're proposing is ... silly. In simplistic terms, how are you going to determine what programs are needed? What libraries to include? What parts of the init system are you going to remove, how this will work etc etc. You could do it, but I'm willing to bet a lot of money it will be unusable.

So it all begs the question, what are you trying to achieve?


----------



## hruodr (Sep 3, 2020)

decuser said:


> What do y'all think? Has manual installs using the tarballs and bootloader stuff been written up somewhere?



Perhaps here:









						What is the best form to Install FreeBSD in an USB Stick and keep in Read Only?
					

That is my question: What is the best form to Install FreeBSD in an USB Stick and keep in Read Only?  But I want from time to time to use memory in the stick: to dd an image is sure not the best.  If I do a normal installation in an USB stick: how I can avoid that it be written? What should be a...




					forums.freebsd.org


----------



## getopt (Sep 3, 2020)

decuser said:


> Has manual installs using the tarballs and bootloader stuff been written up somewhere?


Get some hints there:








						Introduction to NanoBSD
					

This document provides information about the NanoBSD tools, which can be used to create FreeBSD system images for embedded applications, suitable for use on a USB key, memory card or other mass storage media.




					www.freebsd.org


----------



## drhowarddrfine (Sep 3, 2020)

hruodr said:


> Perhaps here:


That looks about how I do it.


----------



## decuser (Sep 3, 2020)

mark_j said:


> What host is running the VM?
> 
> snip...
> 
> ...



What host is running the VM? That's an interesting question. Not that it matters, but FreeBSD 8+... or Mac OS El Capitan+... or Windows 8+... or Linux Mint 18+..., Debian 8+, and so on I have used all of these and more and they all run any VM I ask them to. Honestly, I've never seen any significant difference in the 20 or so OSes I've run them on for the 20 or mor OSes I've run on them. Perhaps your experience is different?

I take it you are commenting about the second option... Contrary to your belief, it's definitely not silly, and for exactly the reasons you have given: how am I going to determine what programs are needed? What libraries to include? What parts of the init system am I going to remove, how this will work etc etc. As I stated in the original question, it's a learning exercise. Difficult?, perhaps. Unattainable?, unlikely.


----------



## decuser (Sep 3, 2020)

hruodr said:


> Perhaps here:
> 
> 
> 
> ...



This looks like a great start on what I'm shooting for. getopt's NanoBSD referenced Howto looks promising too. I'll give it a shot this weekend and let you know how it goes.


----------



## T-Daemon (Sep 3, 2020)

hruodr said:


> Perhaps here:
> 
> 
> 
> ...



You can skip the following steps from the linked posting:

```
fetch ftp.freebsd.org/pub/FreeBSD/releases/ISO-IMAGES/11.2/FreeBSD-11.2-RELEASE-amd64-disc1.iso

mkdir mnt
mdconfig -u md0 FreeBSD-11.2-RELEASE-amd64-disc1.iso
mount_cd9660 -o noatime /dev/md0 mnt
cp -R mnt/usr/freebsd-dist/ freebsd-dist
umount mnt/
mdconfig -du md0
```

Just download from https://download.freebsd.org/ftp/releases/amd64/12.1-RELEASE/ base.txz and kernel.txz. No need to download a whole installation image to extract some dist files.


----------



## decuser (Sep 3, 2020)

T-Daemon said:


> You can skip the following steps from the linked posting:
> 
> ```
> fetch ftp.freebsd.org/pub/FreeBSD/releases/ISO-IMAGES/11.2/FreeBSD-11.2-RELEASE-amd64-disc1.iso
> ...



Yup. I figured. Thanks for the clarification.


----------



## mark_j (Sep 3, 2020)

decuser said:


> What host is running the VM? That's an interesting question. Not that it matters, but FreeBSD 8+... or Mac OS El Capitan+... or Windows 8+... or Linux Mint 18+..., Debian 8+, and so on I have used all of these and more and they all run any VM I ask them to. Honestly, I've never seen any significant difference in the 20 or so OSes I've run them on for the 20 or mor OSes I've run on them. Perhaps your experience is different?
> 
> I take it you are commenting about the second option... Contrary to your belief, it's definitely not silly, and for exactly the reasons you have given: how am I going to determine what programs are needed? What libraries to include? What parts of the init system am I going to remove, how this will work etc etc. As I stated in the original question, it's a learning exercise. Difficult?, perhaps. Unattainable?, unlikely.


No I was commenting about the 3rd point but then again,  I think you're as confused as I am. 
I have nothing more to contribute.


----------



## decuser (Sep 3, 2020)

mark_j said:


> No I was commenting about the 3rd point but then again,  I think you're as confused as I am.
> I have nothing more to contribute.



No worries. The other responses were on point. Thanks for trying.


----------



## ekvz (Sep 3, 2020)

sysutils/busybox - https://busybox.net/downloads/BusyBox.html (or maybe https://github.com/landley/toybox if you feel a little more adventurous or strictly require BSD licensed code)

At least in theory (i am not all that much into the internals of FreeBSD yet) this should be all you need beyond a bootloader and a kernel. I am not sure how up to date / complete the port is but https://git.busybox.net/busybox/tree/init/init.c#n1237 could be a good start and since busybox is a static executable you don't need any libraries. Well, at least until you add other binaries. Busybox on it's own already supplies a whole lot while taking very little space though. If that suits your requirements i would very much recommend building your own busybox executable customized for your actual needs to trim down even more.


----------

