Solved Installing PKGs in a Diskless environment

balanga

Son of Beastie

Reaction score: 153
Messages: 3,344

Booting FreeBSD in a Diskless environment is useful for numerous reasons, but it is quite limiting when only using the base operating system. It would be much more useful to be able to install pkgs, but I haven't found a straightforward way to do this.

Can anyone suggest how to do this?

If I chroot() to ${NFSROOTDIR} and run pkg install I get:-
The package management tool is not yet installed on your system.
Do you want to fetch and install it now? [y/N]: y
Bootstrapping pkg from pkg+http://pkg.FreeBSD.org/FreeBSD:12:amd64/quarterly, please wait...
pkg: Error fetching http://pkg.FreeBSD.org/FreeBSD:12:amd64/quarterly/Latest/pkg.txz: No address record
A pre-built version of pkg could not be found for your system.
Consider changing PACKAGESITE or installing it from ports: 'ports-mgmt/pkg'.
Not sure what to make of this....
 

genneko

Member

Reaction score: 6
Messages: 32

Hi. I'd also like to know what options are available. I have a working PXE booting environment with some packages installed so I'm sure I did it before but forgot how...
BTW, "No address record" seems to suggest a name resolution failure.
${NFSROOTDIR}/etc/resolv.conf?
 

Bobi B.

Well-Known Member

Reaction score: 155
Messages: 371

You might try pkg -c $NFSROOTDIR install foo; -c stands for chroot.

Other than that, pkg(8) most likely doesn't work in your chroot environment, because of lacking /etc/resolv.conf.
 

sol289

Member

Reaction score: 10
Messages: 33

As Bobi B. already mentioned, you have make your $NFSROOTDIR/etc/resolv.conf point to your DNS server. You can do cp /etc/resolv.conf $NFSROOTDIR/etc/ before chroot $NFSROOTDIR.
 
OP
OP
B

balanga

Son of Beastie

Reaction score: 153
Messages: 3,344

Hi. I'd also like to know what options are available. I have a working PXE booting environment with some packages installed so I'm sure I did it before but forgot how...
BTW, "No address record" seems to suggest a name resolution failure.
${NFSROOTDIR}/etc/resolv.conf?
I tried ping 8.8.8.8 from within a chroot() environment and get:-
ping: Unable to open /dev/null
ping: unable to limit access to system.dns service: Socket is not connected
so don't think it is related to host name resolution.
 
OP
OP
B

balanga

Son of Beastie

Reaction score: 153
Messages: 3,344

You might try pkg -c $NFSROOTDIR install foo; -c stands for chroot.

Other than that, pkg(8) most likely doesn't work in your chroot environment, because of lacking /etc/resolv.conf.
Many thanks for this.

Just to confirm what worked...

cp /etc/resolv.conf $NFSROOTDIR/etc/
pkg -c $NFSROOTDIR install foo
 
Top