FreeBSD¶
Upgrade¶
Check the latest FreeBSD release and compare to
uname -a.
Upgrade the system:
sudo pkg upgrade -y
sudo bash -c 'PAGER=cat freebsd-update fetch'
sudo bash -c 'PAGER=cat freebsd-update install'
PAGER=cat is used to ignore messages about added, removed and overriden
configuration files.
Minimum packages to develop on FreeBSD¶
Install:
pkg # first command proposes to install it
pkg install sudo
sudo pkg install vim-console git
Misc¶
Coredump filename:
sudo sysctl -w 'kern.corefile =%N.%P.core'
Configuration¶
Rerun the installer configuration, run::
bsdconfig.Change the keyboard layout: run
kbdmap.
Upgrade to newer FreeBSD¶
Upgrade to FreeBSD 12.0-RC2:
sudo freebsd-update fetch
sudo freebsd-update upgrade -r 12.0
sudo freebsd-update install
sudo reboot
# after reboot
sudo freebsd-update install
Install FreeBSD VM¶
Install VM image¶
https://www.freebsd.org/where.html : Download amd64/qcow2 virtual machine image,
Uncompress the image: unxz file.qcow2.xz
Move the image to /var/lib/libvirt/images/
Create a FreeBSD VM using this disk image
Add “freebsd” hostname to /etc/hosts
Customize FreeBSD:
bsdconfig: Create an userkbdmap: Change the keyboard layout
Run
pkgand follow the wizard to installpkgpkg install sudo
Classic installer (old way)¶
Uncompress: unxz FreeBSD-11.0-RELEASE-amd64-disc1.iso.xz
Create a new VM:
Name: FreeBSD
Boot from an ISO: specify the path to the .iso file
System: select Show all, select UNIX, pick FreeBSD 11
1 cpu, 1 GB of RAM
Disk size: 20 GB
Select network: shared interface, br0
FreeBSD installer:
<install>
Keymap: French ISO-8859-1
Hostname: freebsd
Distribution: only keep [*] ports
Partition: auto, <Entire disk>, MBR, Finish, Commit
(choose a root password)
network: configure IPv4, use DHCP, yes, configure IPv6, auto, yes
Time Zone: 8 Europe, 14 France
Date/Time: Skip
Service started at boot: sshd
(no option)
Add a new user: username vstinner
Exit: Manual config? No
Reboot
Enlarge qcow2 image¶
Shutdown the VM
On the host: sudo qemu-img resize /var/lib/libvirt/images/freebsd.qcow2 40G
Boot the VM, in FreeBSD: sudo /etc/rc.d/growfs onestart
Configure as root¶
Log as root
kbdcontrol -l fr.isopkg install sudo bash tmux vimvisudo: uncomment%whell ALL..without passwordadduser: add user, add it to the wheel group
to add wheel group to an user: pw usermod -n vstinner -G wheel
Enable the SSH server:
Add sshd_enable=”YES” to /etc/rc.conf
service sshd start
Log out
Configure as your user¶
Log in as the your user
chsh -s /usr/local/bin/bash
Log out and log in again to get bash
sudo pkg install git
Commands to develop Python on FreeBSD¶
Install:
sudo pkg install pkgconf
Use ports¶
By default, ports are not installed:
vstinner@freebsd$ ls /usr/ports
ls: /usr/ports: No such file or directory
Install ports:
sudo git clone https://git.FreeBSD.org/ports.git /usr/ports --depth=1
Misc¶
Which package provides a file?
vstinner@freebsd$ pkg which /usr/local/bin/git
/usr/local/bin/git was installed by package git-2.41.0
FreeBSD source code: https://github.com/freebsd/freebsd-src/
DHCP error¶
fix_network.sh:
set -x -e
ifconfig vtnet0 -rxcsum -txcsum
service dhclient restart vtnet0
Repair pkg¶
Repair pkg, if needed:
sudo pkg bootstrap -f
If something goes wrong, reinstall everything installed by pkg:
sudo pkg-static upgrade -f
Resize rootfs¶
On the host (Linux), when the VM is not running, resize the qcow2 file:
cd /var/lib/libvirt/ qemu-img resize freebsd.qcow2 +20G
Boot the VM as single user.
Run
gpart showand identify the main partition and the disk device:root@freebsd# gpart show -l => 34 54592694 ada0 GPT (26G) 34 122 1 bootfs (61K) 156 66584 2 efiboot0 (33M) 66740 2097152 3 swapfs (1.0G) 2163892 10485803 4 rootfs (5.0G) 12649695 41943033 - free - (20G)
Here, the disk device is “ada0” and the rootfs partition is the partition 4.
Resize the partition 4:
gpart resize -i 4 -s 25G ada0Resize the filesystem::
growfs /Reboot (I prefer to restart on a fresh filesystem at boot).