Solved Adding pkgs to the memstick img

Hey there, I'd like to get a live system (meaning all just temporary and nothing installed to disk) on a memory stick.
But with pkgs.
In fact, I only need ntfs-3g support (the sysutils/fusefs-ntfs port) on an amd64 system.
Networking is available and the precompiled pkg could be loaded from the internet.

But pkg bootstrapping fails as the system is read-only.

How would you do it?
 
But pkg bootstrapping fails as the system is read-only.
Did you use the memstick or the ISO image to write to the memory stick? The ISO image is indeed read-only because it's meant to be written to read-only media.

Another solution is to just create your own image, it's not that difficult to do. Or you can have a look at mfsBSD and customize that to your liking.
 
Did you use the memstick or the ISO image to write to the memory stick? The ISO image is indeed read-only because it's meant to be written to read-only media.

Another solution is to just create your own image, it's not that difficult to do. Or you can have a look at mfsBSD and customize that to your liking.
I did use the memstick image on a usb pen drive.
 
NOTE: Deleted my previous posts #5, #7, #8 to improve and to consolidate in one post.

Steps to create a Live system from a official installer *-memstick.img image on USB:

Option 1: The easy and fast way:

Take two USB sticks, install from the FreeBSD installer USB stick on the target USB stick, add packages to the system.

Option 2: In case there is no second USB stick at hand:

1 - Increase the size of FreeBSD's file system partition on the installer USB to allow the installation of addition files. Assuming the USB sticks capacity is larger than the *-memstick.img copied over, boot into single user mode, execute:
Code:
# gpart resize -i 2 da0
# gpart resize -i 1 da0s2
# service growfs onestart
Eventually adapt da0.

2 - Mount file system read/write
Code:
# mount -uw /
3 - To set the systems file system from read only to read/write edit the mount option in /etc/fstab
Code:
/dev/ufs/FreeBSD_Install   /    ufs   rw,noatime    1   1
4 - Continue boot into multi user mode
Code:
# exit
5 - At the FreeBSD Installer "Welcome" dialog drop to "Shell"
6 - Configure a DNS name server
Code:
# echo "nameserver 8.8.8.8" > /tmp/bsdinstall_etc/resolv.conf
7 - Acquire IP address
Code:
# dhclient em0
(replace em0 with what interface name the network card was assigned to)

7 - Bootstrap ports-mgmt/pkg
Code:
# pkg
8 - Install sysutils/fusefs-ntfs
Code:
# pkg install sysutils/fusefs-ntfs
9 - Optional install additional packages
10 - Optional disable FreeBSD installer dialog
Code:
# mv /etc/rc.local /etc/rc.local.0
11 - Edit /etc/rc.conf
Code:
hostname=LiveSystem.stick
ifconfig_DEFAULT="DHCP"
keymap="uk"
kld_list="fusefs"
Add additional needed kernel modules or services, i.e. sshd, zfs, change keymap, etc.

12 - Optional change file system back to read only in /etc/fstab

Live system ready. Login name is "root" if /etc/rc.local is disabled, no password. Optional set "root" password, add users.

Option 3+: One of the other suggested methods in the thread.
 
Last edited:
Hey there, I'd like to get a live system (meaning all just temporary and nothing installed to disk) on a memory stick.
But with pkgs.
In fact, I only need ntfs-3g support (the sysutils/fusefs-ntfs port) on an amd64 system.
Networking is available and the precompiled pkg could be loaded from the internet.

But pkg bootstrapping fails as the system is read-only.

How would you do it?
What is different when installing FreeBSD on a USB drive? As far as I know, the installer does not care what kind of storage you put your boot partition and system root on.

You don't need to create a live media or an installer, right? Then simply install FreeBSD on the USB drive and boot from it.
In FreeBSD installer and select the USB drive as your target device. Then do automatic partitioning and when you boot you can install whatever packages you need.
I have used this with a NAS, it works exactly as if it were installed on a HDD.
 
… a live system (meaning all just temporary and nothing installed to disk) … with pkgs. …

Airyx™ might be of future interest. A live desktop environment that can be OK with 1 GB memory (probably less). Unfortunately not yet using a FreeBSD repo for packages; I'm in discussion.

In the meantime we have GhostBSD, for example (not the most recent release):

1633676438114.png

The live ISO requires at least 4 GB to boot, which is fair enough for the target audience.
 
NOTE: Deleted my previous posts #5, #7, #8 to improve and to consolidate in one post.

Steps to create a Live system from a official installer *-memstick.img image on USB:

Option 1: The easy and fast way:

Take two USB sticks, install from the FreeBSD installer USB stick on the target USB stick, add packages to the system.

Option 2: In case there is no second USB stick at hand:

1 - Increase the size of FreeBSD's file system partition on the installer USB to allow the installation of addition files. Assuming the USB sticks capacity is larger than the *-memstick.img copied over, boot into single user mode, execute:
Code:
# gpart resize -i 2 da0
# gpart resize -i 1 da0s2
# service growfs onestart
Eventually adapt da0.

2 - Mount file system read/write
Code:
# mount -urw /
3 - To set the systems file system from read only to read/write edit the mount option in /etc/fstab
Code:
/dev/ufs/FreeBSD_Install   /    ufs   rw,noatime    1   1
4 - Continue boot into multi user mode
Code:
# exit
5 - At the FreeBSD Installer "Welcome" dialog drop to "Shell"
6 - Configure a DNS name server
Code:
# echo "nameserver 8.8.8.8" > /tmp/bsdinstall_etc/resolv.conf
7 - Acquire IP address
Code:
# dhclient em0
(replace em0 with what interface name the network card was assigned to)

7 - Bootstrap ports-mgmt/pkg
Code:
# pkg
8 - Install sysutils/fusefs-ntfs
Code:
# pkg install sysutils/fusefs-ntfs
9 - Optional install additional packages
10 - Optional disable FreeBSD installer dialog
Code:
# mv /etc/rc.local /etc/rc.local.0
11 - Edit /etc/rc.conf
Code:
hostname=LiveSystem.stick
ifconfig_DEFAULT="DHCP"
keymap="uk"
kld_list="fusefs"
Add additional needed kernel modules or services, i.e. sshd, zfs, change keymap, etc.

12 - Optional change file system back to read only in /etc/fstab

Live system ready. Login name is "root" if /etc/rc.local is disabled, no password. Optional set "root" password, add users.

Option 3+: One of the other suggested methods in the thread.
Thanks, that was exactly what I was looking for.
 
Option 2: In case there is no second USB stick at hand:

1 - Increase the size of FreeBSD's file system partition on the installer USB to allow the installation of addition files. Assuming the USB sticks capacity is larger than the *-memstick.img copied over, boot into single user mode, execute:
Code:
# gpart resize -i 2 da0
# gpart resize -i 1 da0s2
# service growfs onestart
Eventually adapt da0.

Thanks for the write-up. One observation that might be benign, the c: (raw) partition of the grown slice is now smaller than the a: (root) partition. bsdlabel(8) says

Code:
# bsdlabel da0s2
# /dev/da0s2:
8 partitions:
#          size     offset    fstype   [fsize bsize bps/cpg]
  a:  121634800         16    4.2BSD        0     0     0
  c:    2201360          0    unused        0     0     # "raw" part, don't edit
partition a: partition extends past end of unit

I suspect it's not a problem unless someone really needs the raw partition, but just to have everything tidy and in order, here is a procedure to correct the c: size:

Bash:
DEV=da0

# Save unfixed label.
bsdlabel "${DEV}s2" > s2.label
# Use bc to add and avoid overflow. The TB USB disks are here already.
rawsize="$(bsdlabel ${DEV}s2 | awk '$1 == "a:" {print $2 "+" $3}' | bc)"
# Adjust c: size.
awk -v s="$rawsize" '$1 == "c:" {$2 = s} 1' s2.label  > s2.fixedlabel
# Write result.
bsdlabel -R "${DEV}s2" s2.fixedlabel
# Show result.
bsdlabel "${DEV}"

I'm tempted to say not adjusting the c: partition size is actually a bug in "gpart resize" since I can't seem to resize c: with any index (-i) argument to gpart resize -i N ${DEV}s2. I'm always a little worried if I find lying labels.
 
Back
Top