How to install pkg offline?

Hello! This is my first time trying out FreeBSD on bare metal, as I want to use it as my main system (My second Hard Drive has Windows on it, for Games) and I do not have internet after the installation as I need to install this handy little software to get my phone to connect to my computer. I remember trying to do this once, but I had trouble since I don't know how to install pkg.txz offline. I have downloaded the file from here but I don't know how to install it as you need to use the pkg command to install things, correct? Thank you so much if you can help me out with this!
 
Welcome on board!

Yes, ports-mgmt/pkg needs to be bootstrapped. You'll have to do so manually. You can find the instructions on the wiki. It's near the end of the primer.

Once that is done, all packages can be installed locally using # pkg add ./package.txz.

Of course, for packages that actually have dependencies, you'll need the packages as well as all their dependencies in the same directory.
 
i'm new to FreeBSD. i have laptop and there is no internet after installing OS. but any command wants download software instead of local install

so... >"."<
first boot after instalation OS (dvd 13.0beta3 in my case, there are some packages on dvd). mount my usb:
# mount -t cd9660 /dev/da0s1 /mnt

copy our instalation pkg(8) file:
# cp /mnt/packages/FreeBSD:13:amd64/Latest/pkg.txz ~/

disable signature checking and install full pkg (using preinstalled pkg(7)):
#ee /etc/pkg/FreeBSD.conf
signature_type: "fingerprints"
=>
signature_type: "none"

#cd ~
#pkg add -f -y pkg.txz

bootstrap pkg(8):
# /usr/sbin/pkg

and enable signature checking in /etc/pkg/FreeBSD.conf:
=> signature_type: "fingerprints"
now we can install all other packages from dvd:
pkg add /mnt/packages/FreeBSD:13:amd64/All/bash-5.1.4.txz

also you can download any packages on other PC and bring them to your PC without internet:
#pkg fetch -o ~/folder/ -d sudo
 
Try this:
env PACKAGESITE=file:///mnt/packages/FreeBSD:13:amd64/ pkg bootstrap
 
I've been looking to this too, there are some issues with using pkg add instead of pkg install in general but currently pkg install doesn't resolve local dependencies. It's being looked at but I have no idea when it's going to be resolved.
 
I tend to do a mass fetch of the entire package repo every 6 months or so. You can either scrape the packages off http://pkg.freebsd.org/ (used to be easier with FTP) or you can use pkg fetch -a to grab everything.

https://www.freebsd.org/cgi/man.cgi?query=pkg-fetch

Once you have a big directory with everything in it, when you want to install something, just cd into the directory and run:

Code:
# pkg add <package>.txz

Dependencies will be resolved automatically and offline. I don't think so many people use it like this (kind of like pre-pkgng), but it works well offline and I dislike being tied to the internet (worst part about UNIX and Linux in my opinion).
 
The directories are not browsable anymore, that's correct.
 
The directories are not browsable anymore, that's correct.
I have wondered about that myself, too.
Is there a way to download packages with an operating system other than FreeBSD (i.e. you can’t use pkg fetch)?
 
If you know the exact filename the downloads still work (or else pkg(8) would stop working too). But directory browsing has been turned off on the directory that has the files. Apparently this put too much of a load on the servers.

I've been thinking about a solution, the first is to generate a static HTML page with links to the package files, those can be generated at the same time pkg-repo(8) runs, then you can still "browse" the file list but it won't be dynamically generated any more, which should alleviate the load on the server.

The second solution is more a client side tool, to make a local copy of the repository. You can fetch the meta data and download each file individually based on the information in the meta data. Something like a "repocopy".
 
Incidentally, any recent iPhone or Android phone can act as a WiFi hotspot and you can connect your FreeBSD machine to your phone when you install FreeBSD. So there shouldn’t be any need for all this offline witchcraft!
 
Hi AlexanderProphet,
I've been struggling with the network drivers on an old laptop TP T400, both wired and wireless, since yesterday. No luck. I suspect the hardware is already broken or in bad shape. For example, the wired network card even failed DHCP lease aquisition during installation.
I've seen several posts mentioning the iphone tethering, also in the handbook. From the description it seems easy work but i could not succeed. You mind sharing your experience to help me out?
 
Hi bxbzq,
I’ve not ever had a WiFi card fail on me. Are you sure you’re setting the “regdomain” correctly for your country when installing FreeBSD? I had to experiment a bit. Even though I’m in the UK, I believe it was the USA setting that eventually worked for me. Sorry I can’t be more exact as I don’t have the installer in front of me - there are only about ten regdomains to choose from though.
This is how I turn my iPhone 11 into a wireless access point: tap settings (the grey cog) then tap “Personal hotspot”. Then switch on “Allow others to join”. It should say underneath what is your WiFi password.
The most important thing that I discovered is that you can’t really use the phone as a phone at the same time because when you navigate away from the “Personal hotspot” page the connection will usually be dropped. I think this is to save power/data but it’s very annoying. The connection also cuts out when the iPhone’s screen switches off, so you’ll probably also want to choose Settings -> Display and Brightness -> Auto-lock -> Never.
On Android it’s better because you can carry on using the phone as normal whilst it’s being a WiFi hotspot.
 
Hi bxbzq,
I’ve not ever had a WiFi card fail on me. Are you sure you’re setting the “regdomain” correctly for your country when installing FreeBSD? I had to experiment a bit. Even though I’m in the UK, I believe it was the USA setting that eventually worked for me. Sorry I can’t be more exact as I don’t have the installer in front of me - there are only about ten regdomains to choose from though.
This is how I turn my iPhone 11 into a wireless access point: tap settings (the grey cog) then tap “Personal hotspot”. Then switch on “Allow others to join”. It should say underneath what is your WiFi password.
The most important thing that I discovered is that you can’t really use the phone as a phone at the same time because when you navigate away from the “Personal hotspot” page the connection will usually be dropped. I think this is to save power/data but it’s very annoying. The connection also cuts out when the iPhone’s screen switches off, so you’ll probably also want to choose Settings -> Display and Brightness -> Auto-lock -> Never.
On Android it’s better because you can carry on using the phone as normal whilst it’s being a WiFi hotspot.
Looks we are not on the same page.
By tethering, I’m referring to section 32.4 in the handbook, “Many cellphones provide the option to share their data connection overUSB (often called "tethering"). Thisfeature
uses one of RNDIS, CDC, or a custom Apple® iPhone®/iPad® protocol.
• Android™ devices generally use the urndis(4) driver.
• Apple® devices use the ipheth(4) driver.
• Older devices will often use the cdce(4) driver.
Before attaching a device, load the appropriate driver into the kernel:”
 
I've seen several posts mentioning the iphone tethering, also in the handbook. From the description it seems easy work but i could not succeed. You mind sharing your experience to help me out?
Add those 3 modules to /boot/loader.conf, than reboot.
Code:
if_urndis_load="YES"
if_cdce_load="YES"
if_ipheth_load="YES"

Connect your phone to your wifi.
Connect your phone via usb cable to your laptop.
Open phone's Settings > Network & Internet > Hotspot & Tethering > USB tethering [enable it]
Check your new network interface:
# ifconfig
You might see at least two interfaces > lo0 and ue0.
Add DHCP client on your new interface:
# dhclient ue0
Check connection:
# ping -c 4 1.1.1.1

I have two android phones: Freetel (v5 android) and OnePlus6 (v11 android). I didn't get internet through OnePlus, but the old phone gave me successful connect.
 
Add those 3 modules to /boot/loader.conf, than reboot.
Code:
if_urndis_load="YES"
if_cdce_load="YES"
if_ipheth_load="YES"

Connect your phone to your wifi.
Connect your phone via usb cable to your laptop.
Open phone's Settings > Network & Internet > Hotspot & Tethering > USB tethering [enable it]
Check your new network interface:
# ifconfig
You might see at least two interfaces > lo0 and ue0.
Add DHCP client on your new interface:
# dhclient ue0
Check connection:
# ping -c 4 1.1.1.1

I have two android phones: Freetel (v5 android) and OnePlus6 (v11 android). I didn't get internet through OnePlus, but the old phone gave me successful connect.
I tried iphone 7 and iphone 11, neither of them worked. There was no ue0 interface detected, but usb connection info did show up. Will try to find an android phone and give a try.
 
I tend to do a mass fetch of the entire package repo every 6 months or so. You can either scrape the packages off http://pkg.freebsd.org/ (used to be easier with FTP) or you can use pkg fetch -a to grab everything.

https://www.freebsd.org/cgi/man.cgi?query=pkg-fetch

Once you have a big directory with everything in it, when you want to install something, just cd into the directory and run:

Code:
# pkg add <package>.txz

Dependencies will be resolved automatically and offline. I don't think so many people use it like this (kind of like pre-pkgng), but it works well offline and I dislike being tied to the internet (worst part about UNIX and Linux in my opinion).

I dislike being tied to it too. I just wish the size of the repo was more manageable... 87GiB right now, wow :) How about a 10GiB version?
 
Incidentally, any recent iPhone or Android phone can act as a WiFi hotspot and you can connect your FreeBSD machine to your phone when you install FreeBSD. So there shouldn’t be any need for all this offline witchcraft!
Of course you can do that when you install a random private machine at home.

But you cannot do that when you’re inside an isolated network that has no connection to the internet, and there are only certain ways to transfer data, e.g. by downloading them on a dedicated download server (usually Linux, sometimes Windows). I’ve worked many years as a consultant with a focus on security. During that time I’ve been to several companies that had internal networks with restrictions like that (and of course, using USB sticks was forbidden, and trying to tether with a mobile phone would have brought me into jail). When packages were still distributed via FreeBSD’s FTP servers, you could simply download the tgz/tbz/txz files on the download server, even if that was a Linux or Windows machine, then transfer the files to the internal network.

That doesn’t work anymore today, making it much more difficult to install FreeBSD in such security-sensitive networks. I guess most admins who consider using FreeBSD will just install Linux upon discovering that there is no easy way to download FreeBSD packages separately.
 

But you cannot do that when you’re inside an isolated network that has no connection to the internet, and there are only certain ways to transfer data, e.g. by downloading them on a dedicated download server (usually Linux, sometimes Windows). I’ve worked many years as a consultant with a focus on security. During that time I’ve been to several companies that had internal networks with restrictions like that (and of course, using USB sticks was forbidden, and trying to tether with a mobile phone would have brought me into jail). When packages were still distributed via FreeBSD’s FTP servers, you could simply download the tgz/tbz/txz files on the download server, even if that was a Linux or Windows machine, then transfer the files to the internal network.

That doesn’t work anymore today, making it much more difficult to install FreeBSD in such security-sensitive networks. I guess most admins who consider using FreeBSD will just install Linux upon discovering that there is no easy way to download FreeBSD packages separately.
Or they will arrange to have a FreeBSD build / stage server added to the admin network (approved and verified of course) so they can download and / or build packages on it, for transfer to the isolated network.
 
I tried iphone 7 and iphone 11, neither of them worked. There was no ue0 interface detected, but usb connection info did show up. Will try to find an android phone and give a try.
For Apple Iphones it is the Ipheth device you want to connect to. You have to enable USB Tethering on your Apple iphone for the ipheth device to show up.
https://man.freebsd.org/cgi/man.cgi?query=ipheth&sektion=4&format=html man page for ipheth apple iphone USB tethering
https://forums.freebsd.org/threads/iphone-tethering-broken-since-ios-14.77157/ Iphone USB tethering broken since iOS14 FreeBSD forum post 14.0.1 or .2 has the fix inside.
https://manpages.ubuntu.com/manpages/bionic/man4/if_ipheth.4freebsd.html Ubuntu setup of pheth for freebsd

Good luck and comment how it works for you.
Here is my forum post on Android USB Tethering af forums.ghostbsd.org
https://forums.ghostbsd.org/viewtopic.php?p=8141#p8141
 
Hello, I even have to create an account to tell my experience:

Coming from the Linux world, specifically Arch, I decided to try FreeBSD 13.2 on a new (to me) PC. The PC has a Realtek 8125 network card.

After installing FreeBSD, I discovered that it lacks a driver for the card. OK fine I'm familiar with installing OS on PC without network driver.

However, upon reading posts on this forum, I also learned that the package manager "pkg" is not included by default. Furthermore, you cannot find the URL for the driver's package on the web, and downloading from other operating systems is not permitted.

It's not a user-friendly experience for a beginner. Why complicate things like this?
 
I also learned that the package manager "pkg" is not included by default.
pkg can be downloaded from the repo on another PC:

https://pkg.freebsd.org/FreeBSD:13:amd64/quarterly/Latest/
Furthermore, you cannot find the URL for the driver's package on the web, and downloading from other operating systems is not permitted.
The pkg system's web server *is* problematic in that it doesn't support listings in the package directory. Without the pkg metadata, you don't know the URL. Without the URL, getting the driver to download and process the pkg metadata is difficult. Migrate *all* your operating systems to FreeBSD and you won't have this problem ;).

You can grab the packagesite.txz file from i.e here:

https://pkg.freebsd.org/FreeBSD:13:amd64/latest/

Extract it, open in text editor (its just YAML, so fairly human readable) and get the url from there:

https://pkg.freebsd.org/FreeBSD:13:amd64/latest/All/realtek-re-kmod-198.00_3.pkg

But it does feel hacky.

However, in your case, I would recommend just build the port instead. Drivers tend to be low on dependencies, plus it will give the the URL to the source tarball you need to download from another PC:

https://cgit.freebsd.org/ports/tree/net/realtek-re-kmod/Makefile

It's not a user-friendly experience for a beginner. Why complicate things like this?
Its not a particularly great setup for non-beginners either. Package managers in general are very tightly bound to an external server; when you don't have network capability, this is always a PITA.

Once you are done, and online: just do pkg fetch -a to grab everything and store it. Will take some time but then you have everything if you find yourself offline again.
 
However, upon reading posts on this forum, I also learned that the package manager "pkg" is not included by default.
[…]
It's not a user-friendly experience for a beginner. Why complicate things like this?
For offline installations there's the DVD ISO image recommended, as it includes many binary packages (handbook section 2.3.1 Prepare the Installation Media).
This may not sound very elegant today, but if FreeBSD really suits you, you will find this strict separation of the base system and ports/packages great at some point.
BTW: One URL for your package is https://pkg.freebsd.org/FreeBSD:13:amd64/quarterly/All/realtek-re-kmod-198.00_1.pkg - it is possible to get that URL without using pkg or websearches. But you're right, hardly at the beginning.
 
pkg can be downloaded from the repo on another PC:

https://pkg.freebsd.org/FreeBSD:13:amd64/quarterly/Latest/

The pkg system's web server *is* problematic in that it doesn't support listings in the package directory. Without the pkg metadata, you don't know the URL. Without the URL, getting the driver to download and process the pkg metadata is difficult. Migrate *all* your operating systems to FreeBSD and you won't have this problem ;).

You can grab the packagesite.txz file from i.e here:

https://pkg.freebsd.org/FreeBSD:13:amd64/latest/

Extract it, open in text editor (its just YAML, so fairly human readable) and get the url from there:

https://pkg.freebsd.org/FreeBSD:13:amd64/latest/All/realtek-re-kmod-198.00_3.pkg

But it does feel hacky.

However, in your case, I would recommend just build the port instead. Drivers tend to be low on dependencies, plus it will give the the URL to the source tarball you need to download from another PC:

https://cgit.freebsd.org/ports/tree/net/realtek-re-kmod/Makefile

 
Back
Top