Solved Pre-installed packages in FreeBSD

fbsd_

Member

Reaction score: 2
Messages: 38

So I want to build an FreeBSD iso with hexedit preinstalled. I'm doing that to understand how to build custom iso's. I don't have so much idea about custom kernel build. I mean I don't know how can I do that. I take a look to GhostBSD-src and FreeBSD-src over github and see some tutorials to build them but still don't know how to make preinstalled packages on system. That would be awesome if I can get a terminal over iso and use pkg command or ports. So what I have to do?
 

Phishfry

Beastie's Twin

Reaction score: 2,371
Messages: 5,278

I dont have so much idea about custom kernel build.
Than you probably don't need a custom kernel. You will know when you need it.

As for pre-installed packages there are many ways to go. None of them easy.

I think that you should check out the release scripts for building the FreeBSD installer. It will enlighten you.
/usr/src/release/
Also NanoBSD is a good learning tool. It has the ability to build an image with packages.
 

Phishfry

Beastie's Twin

Reaction score: 2,371
Messages: 5,278

I'm doing that to understand how to build custom iso's.
My question is why did you choose ISO format? It is typically an optical disk image. Optical disks are dead.
I build custom image files.
 

Phishfry

Beastie's Twin

Reaction score: 2,371
Messages: 5,278

With what I know now bsdinstall into a jail (with custom bsdinstall config) until you get it the way you want it.
Then author/write it out however you want.
 

Phishfry

Beastie's Twin

Reaction score: 2,371
Messages: 5,278

I do think the Linux ISO thing is very much different than how we do it. They use those hybrid ISO's with squash.
FreeBSD is different. In a good way. But it could take some getting used to.

When I found out I could pad a image file with zeros then enlarge the filesystem I was amazed.
How much simpler could it get.
 
OP
F

fbsd_

Member

Reaction score: 2
Messages: 38

My question is why did you choose ISO format? It is typically an optical disk image. Optical disks are dead.
I build custom image files.
Thats because more softwares supporting iso files to installation mediums. Img files like iso
 
OP
F

fbsd_

Member

Reaction score: 2
Messages: 38

So I checked bsdinstall(8). I think I can do it by:
1)Running a script while system installing that installs packages
2)Loading in single user mode and customizing system then creating an img or iso file over it
3)Mounting iso or img to linux and running shell over it then modifying.

Is one of that methods I thought can work maybe?
 

Phishfry

Beastie's Twin

Reaction score: 2,371
Messages: 5,278

Step 3) should not be needed. You author the image with needed mods.
Step 3 is valid for checking your work and seeing how the modifications worked.
mdconfig(8) load the image and mount partitions allows you to check the filesystem

Here is somebodies FreeBSD install script. I dunno what Sourcehut or sr.ht is but this is a good example.
The red minus entries are code removed and green plus signs are new code.
So as you can see they changed styles from one way to another. Both styles still work.

There is also an older build system named Crochet. It has an i386 example that can be modified for use.
That was my first image building routine. I am unsure if it still works as some have discouraged its use.
It is a series of scripts that can be studied.

Here is another example of bsdinstall scripting
 

datasmurf

New Member

Reaction score: 12
Messages: 18

Just sharing how i do it.

Bash:
truncade -s 2G vmdisk.img
mdconfig -a -f vmdisk.img -t vnode


Bash:
export BSDINSTALL_LOG="/tmp/bsdinstall.log"
export PARTITIONS="$1"
export BSDINSTALL_DISTDIR="/tmp/freebsd-dist"
export DISTRIBUTIONS="kernel.txz base.txz"
export BSDINSTALL_DISTSITE="https://download.freebsd.org/ftp/releases/amd64/12.2-RELEASE/"
export nonInteractive="YES"

#Can be uncommented if $DISTRIBUTIONS are locally available
bsdinstall distfetch

#!/bin/sh

echo "
# Device        Mountpoint      FStype  Options Dump    Pass#
/dev/gpt/rootfs /               ufs     rw      1       1
/dev/gpt/swapfs none            swap    sw      0       0" > /etc/fstab

gpart modify -i 1 -l bootfs $1
gpart modify -i 2 -l rootfs $1
gpart modify -i 3 -l swapfs $1

glabel create bootfs $1p1
glabel create rootfs $1p2
glabel create swapfs $1p3

#This is just how i do the vm naming 

sysrc hostname="freebsd-vm-$(dd if=/dev/random count=10 | \
                                egrep -aoE '[a-z0-9]' | \
                                head -5 | \
                                tr -d '\n' | \
                                tr '[:lower:]' '[:upper:]')"


sysrc ifconfig_DEFAULT="inet6 accept_rtadv auto_linklocal"
sysrc ipv6_activate_all_interfaces="YES"
sysrc growfs_enable="YES"

pkg install -y hexedit

If you save the code above to vmcreate.sh

Bash:
#Replace mdX with the correct md device 
bsdinstall script vmcreate.sh mdX
 
OP
F

fbsd_

Member

Reaction score: 2
Messages: 38

Step 3) should not be needed. You author the image with needed mods.
Step 3 is valid for checking your work and seeing how the modifications worked.
mdconfig(8) load the image and mount partitions allows you to check the filesystem

Here is somebodies FreeBSD install script. I dunno what Sourcehut or sr.ht is but this is a good example.
The red minus entries are code removed and green plus signs are new code.
So as you can see they changed styles from one way to another. Both styles still work.

There is also an older build system named Crochet. It has an i386 example that can be modified for use.
That was my first image building routine. I am unsure if it still works as some have discouraged its use.
It is a series of scripts that can be studied.

Here is another example of bsdinstall scripting
Yea that's right. I don't need to mount it to do modify. Last day, I finally extracted ISO file, created chroot, tried to run pkg command and as normally got internet error(DHCP and network was not configured yet heh) :) I tried GhostBSD today too. It's a very nice system to use BSD as daily system. So now I'm going to search to install hexedit over it. Maybe creating a temporary account on BSD and then installing requirement system components can be a solution. I think I can create a normal setup with a temporary account and then pack it in to a iso file then let other users to setup custom system over their install it then setup to main driver(hdd,ssd etc.) by creating an other software. I think that's how GhostBSD works? maybe. And yea mount lets us to test right.
 
OP
F

fbsd_

Member

Reaction score: 2
Messages: 38

GBI
"GBI is a graphical interface for pc-sysinstall and it is the installer for GhostBSD." There is some examples to do that with python too.
 
OP
F

fbsd_

Member

Reaction score: 2
Messages: 38

Ok so at the end it's about how much creative solution can it be I think. I'm going to do it like GhostBSD's way. I mean trying to installing system then creating iso over it. So problem solved. We can do it by installing system then installing packages over it. I couldn't find and solution like installing packages before system setup to driver but I think that's an solution too.
 
Top