Raspberry Pi - is the default image a good fit for using it as a "normal" FreeBSD machine?

tingo

Daemon

Reaction score: 365
Messages: 1,939

The default image for Raspberry Pi's create this disklayout (on a 4 GB sdcard):
Code:
root@rpi-b:~ # df -h
Filesystem  Size  Used  Avail Capacity  Mounted on
/dev/ufs/rootfs  3.6G  392M  2.9G  12%  /
devfs  1.0K  1.0K  0B  100%  /dev
/dev/msdosfs/MSDOSBOOT  17M  3.8M  13M  23%  /boot/msdos
tmpfs  30M  4.0K  30M  0%  /tmp
If you want to use your Pi as a "normal" FreeBSD machine, one of the things you will likely do is install ports on it. The layout above will make that difficult.
1. tmpfs is limited in size to 30M, this will make even installing ports-mgmt/pkg from ports fail.
2. there is no place for a swap partition on the sdcard (because autoexpand runs on first boot)
3. failures are silent; you get an error compilation, but no errors in logs (or dmesg output), and no indication that a filesystem is (has been) full.

Point number 1 is easy to address; you can remove the tmpfs size limit from /etc/fstab as I learned from another thread. Unfortunately, a Raspberry Pi with only 256MB RAM still has a tmpfs filesystem that can run out of space during port compiles.

So, should the default image layout for Pi's be changed?

Details of FreeBSD image used:
Code:
root@rpi-b# uname -a
FreeBSD rpi-b 10.2-STABLE FreeBSD 10.2-STABLE #0 r293802: Wed Jan 13 10:06:04 UTC 2016
  root@releng1.nyi.freebsd.org:/usr/obj/arm.armv6/usr/src/sys/RPI-B  arm
memory size of my Pi:
Code:
root@rpi-b# dmesg | grep memory
real memory  = 234876928 (223 MB)
avail memory = 220667904 (210 MB)
 

Juha Nurmela

Well-Known Member

Reaction score: 121
Messages: 401

When you first write the SD image, on a PC, can you then also add, say, 1GB are at the end ? Maybe it's easier to prestretch the rootfs partition to SD_size - 1GB and then reserve the rest to another partition, swap or var+tmp+swap or whatever you like.

Juha
 
OP
OP
T

tingo

Daemon

Reaction score: 365
Messages: 1,939

Good idea; how do I implement that? If I just use gpart to add another partition I'm guessing it will be added right after the root partition, thus blocking any expansion of the root partition. AFAICT, ' gpart add ...' doesn't have any easy way to say "add this 1G partition from the end of the device, please".
 

Juha Nurmela

Well-Known Member

Reaction score: 121
Messages: 401

I was just hoping that there would be some advantage with a large, swap backed, tmpfs(5).

You could add a filler, say 3g, then add swap to the end and finally delete the filler. Maybe it's better to calculate by hand, by 512 byte blocks to get the swap to align into SD blocks. Then gpart add -b start.
This calls for a script, getting blocknumbers from "1m 3g" input.

gpart list shows Stripesize: 131072 for my 2G SD. I wonder if this information comes from the SD itself.

Juha
 

Juha Nurmela

Well-Known Member

Reaction score: 121
Messages: 401

Just for fun, I tried with a fresh 11.0-CURRENT image, around 1GB uncompressed and a random 2GB SD.
On a PC, before moving the SD to the Pi.

Code:
dd bs=128k < FreeBSD-11.0-CURRENT-arm-armv6-RPI-B-20160127-r294912.img > /dev/mmcsd0
gpart resize -i 2 mmcsd0
gpart resize -i 1 -s 1536M mmcsd0s2
gpart add -t freebsd-swap mmcsd0s2
And it won't boot. Not even when that extra munging is removed. Maybe the card is bad, or the image, or it is now asking something which I don't see without a monitor. Looking on the PC, there is nice 1.5GB root and 0.5GB swap.

Oh well, swapfile then.

Juha
 

Juha Nurmela

Well-Known Member

Reaction score: 121
Messages: 401

Thanks. That might be it.

Another way to prevent Pi from immediately robbing all disk is, ugh, embarrassingly obvious. Just mount the rootfs and edit growfs_enable="YES" out.

Juha

Edit: An older CURRENT worked fine, as did the trickery. Convenient to edit /mnt/etc/rc.conf on the PC (saves from setting up the dhcpd too) and then gpart the SD at will on the Pi.
 
Last edited:
Top