This page is about my experience using FreeBSD.
Note: Since I have decided to stick with Linux for now, I will be gearing my FreeBSD usage towards GUI-centric experience.
Update20200428: I want to get back to FreeBSD (FuryBSD?) after I am done with my current project (may take a while, but I am certain of trying FreeBSD again). Just some notes: (1) try lumina desktop [BSD licensed, written for TrueOS], (2) port all my software to BSD :p, (3) try mingw32-gcc to cross-compile windows program
My installation notes…
Note: When using VirtualBox on a Linux host, make sure the virtual machine is NOT using Intel HD Audio! It creates an 'interrupt storm' (irq21 - whatever that is…) and makes the system unusable
The official way to do this is, of course, to get it from freebsd.org.
Latest: Installing FreeBSD-12.0-RELEASE-amd64 on VirtualBox
pkg
pkg install -y xorg
pkg install -y gnome3
/etc/rc.conf
:hald_enable="YES" dbus_enable="YES" gdm_enable="YES" gnome_enable="YES"
/etc/fstab
:proc /proc procfs rw 0 0
/boot/loader.conf
:snd_driver_load="YES"
/boot/loader.conf
:kern.vty=vt
/boot/loader.conf
:autoboot_delay="3"
pkg install -y virtualbox-ose-additions
/etc/rc.conf
:vboxguest_enable="YES" vboxservice_enable="YES"
/etc/rc.conf
:vboxservice_flags="--disable-timesync"
pkg install -y avahi-app nss_mdns
/etc/rc.conf
:avahi_daemon_enable="YES"
hosts:
line in /etc/nsswitch.conf
:hosts: files dns mdns
pkg install -y networkmgr
/usr/local/etc/doas.conf
:permit nopass keepenv :wheel cmd netcardmgr permit nopass keepenv :wheel cmd detect-nics permit nopass keepenv :wheel cmd detect-wifi permit nopass keepenv :wheel cmd ifconfig permit nopass keepenv :wheel cmd service permit nopass keepenv :wheel cmd wpa_supplicant
pkg install -y git geany
pkg install -y screen
pkg install -y libreoffice firefox
PS1="`whoami`@\H:\w\$ "
~/.xinitrc
for each user:exec /usr/local/bin/mate-session
Note DHCP client is dhclient - simply run dhclient <interface>
when booting to console and using something like USB tethering.
Configure (wireless) network interface (in case was not done during installation)
pciconf -lv
ifconfig_re0="DHCP"
wlan_ath0="wlan0" ifconfig_wlan0="DHCP"
wlan_ath0="wlan0" ifconfig_wlan0="WPA SYNCDHCP"
also, append '/etc/wpa_supplicant.conf'
network={ ssid="the_ssid" psk="the_psk" }
wlan0
was not auto-created?ifconfig wlan0 create wlandev ath0
ifconfig wlan0 up scan
ifconfig wlan0 list scan
Driver for ASUS E5450 Graphics Card (based on Radeon 5450?)
pkg install -y xf86-video-ati
/etc/rc.conf
:kld_list="radeonkms"
For Intel Graphics (Asus H81M-K Motherboard)
pkg install -y xf86-video-intel
/etc/rc.conf
:kld_list="i915kms"
pkg install -y drm-kmod
drm-fake-kmod
insteadWeb Server (Apache)
pkg search apache2 | grep -e "^apache2"
pkg install -y php56 mod_php56 php56-mbstring php56-mcrypt php56-zlib php56-curl php56-gd php56-json
/etc/rc.conf
:apache24_enable="YES"
/usr/local/www/apache24/data/
Server Script (PHP)
pkg search php5 | grep -e "^php5"
pkg install -y apache24
/usr/local/etc/apache24/Includes/php.conf
:<IfModule dir_module> DirectoryIndex index.php index.html <FilesMatch "\.php$"> SetHandler application/x-httpd-php </FilesMatch> <FilesMatch "\.phps$"> SetHandler application/x-httpd-php-source </FilesMatch> </IfModule>
# cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini
Database (mysql/mariadb)
pkg install mariadb103-server mariadb103-client php56-mysqli
/etc/rc.conf
:mysql_enable="YES"
# lsof -i4 -i6 # sockstat -4 -6
/etc/rc.conf
:mysql_args="--bind-address=127.0.0.1"
# lsof -i4 -i6 | grep mysql # netstat -an | grep 3306 # sockstat -4 -6 | grep 3306
Note: Need to test this…
# mkdir /root/offline # pkg fetch -d -o /root/offline xorg mate slim firefox
-d
for dependencies-o
specifies destination path for the fetched packages# pkg -U install xorg mate slim firefox git geany networkmgr
-U
is the short form for –no-repo-update
I want to try to install to a USB thumb-drive… from my FreeBSD virtual machine (VirtualBox). I have a 16GB USB3 Kingston Data Traveller drive, and already installed FreeBSD 12 on a virtual machine.
To prepare the drive layout, checkout here. I'm going to prepare for UEFI boot on a GPT formatted disk.
- plug in usb drive
- refer to this…
to be continued…
Find boot1.efi
as place it in EFI System Partition. It will look for first partition with type freebsd-ufs (which can even be on another disk) and load loader.efi
.
Maintaining the system…
For example, upgrading 10.1-RELEASE to 10.2-RELEASE
freebsd-update -r 10.2-RELEASE upgrade
Then run
freebsd-update install
To update within a release, do a
freebsd-update fetch
before running 'install'.
Hint hit 'q' when prompted
Install package
pkg install <pkg_name> [...]
Note: include '-y' to override prompts
Delete package
pkg delete <pkg_name> [...]
Update catalogue
pkg update
Upgrade software
pkg upgrade
List installed packages
pkg info
Remove all packages and start over
pkg delete --all --force
Clean all package cache
pkg clean
Remove orphaned package(s)?
pkg autoremove
If pkg installation quits due to size mismatch or something,
pkg clean rm -rf /var/cache/pkg/* pkg update -f
Will most probably need these at some point…
To get it,
portsnap fetch extract
To update,
portsnap fetch update
To manage, use portmaster
To build portmaster,
cd /usr/ports/ports-mgmt/portmaster/ && make install clean
To setup portmaster,
# cp /usr/local/etc/portmaster.rc.sample /usr/local/etc/portmaster.rc # ee /usr/local/etc/portmaster.rc
To update all ports
portmaster -a
To search updates
portmaster -L | grep "New version available:"
To cleanup
portmaster --clean-distfiles{-all}
To remove port
portmaster -e target_port
To rebuild port
portmaster -r target_port
Dumping ground - from portmaster man page…
Build a port locally but use packages for build dependencies, then delete the build dependencies when finished: portmaster --packages-build --delete-build-only fooport-1.23 Update a system using only packages that are available locally: portmaster -PP --local-packagedir=<path> -a Update all ports that need updating: portmaster -a Update all ports that need updating, and delete stale distfiles after the update is done: 1. portmaster -aD 2. portmaster --clean-distfiles
git config --global core.pager "ls -r"
Using GPT
creating disk layout (gpt) for freebsd - assuming disk is da0 (change accordingly for other designation) 0- clean existing partitions/slices # gpart destroy -F da0 (manual op) find total sector count using diskinfo # diskinfo -v da0 backup/secondary gpt table is at the last 34 sector # echo '<total> - 34' | bc <offset> # dd if=/dev/zero of=/dev/da0 bs=512 seek=<offset> 1- create gpt and bios boot scheme # gpart create -s gpt da0 da0 created # gpart add -t freebsd-boot -l gpboot -b 40 -s 1004K da0 da0p1 added # gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 da0 partcode written to da0p1 bootcode written to da0 2- create efi partition # gpart add -t efi -l gpefiboot -s 127M da0 da0p2 added # newfs_msdos /dev/da0p2 ... 3- copy efi binary # mount -t msdosfs /dev/da0p2 /mnt # mkdir -p /mnt/EFI/BOOT # cp /boot/boot1.efi /mnt/EFI/BOOT/ # umount /mnt 4- create partition/slice for root and swap # gpart add -t freebsd-ufs -l gprootfs -s 14G da0 da0p3 added # gpart add -t freebsd-swap -l gpswap da0 da0p4 added 5- format/prepare fs for root # newfs -U /dev/da0p3
Using MBR (just in case… :p)
# gpart create -s mbr da0 # gpart bootcode -b /boot/mbr da0 # gpart add -t freebsd da0 # gpart set -a active -i 1 da0 # gpart create -s bsd da0s1 # gpart bootcode -b /boot/boot da0s1
This is nice to have in /etc/fstab when device assignment may change (e.g. usb drive on different machine may be assigned differently)
For ufs,
# tunefs -L <label> /dev/da0p?
To check if assigned,
# ls /dev/ufs
For swap,
# glabel label <label> /dev/da0p?
To check if assigned,
# ls /dev/label
Then, /etc/fstab entry can be like,
/dev/label/<label> none swap sw 0 0 /dev/ufs/<label> / ufs rw 1 1
Show partition
# gpart show
Resize partition
# gpart resize -i 3 da0
Not really gpart stuff, but don't forget to grow FS to fit new size
# growfs /dev/da0p3
At the moment, full R/W access for Ext2, Journal-less for Ext3 and R/O for Ext4.
# kldload ext2fs # mount -t ext2fs /dev/<slice> <mount-path>
Note: Generally, it seems that this is no longer an issue - some just did a normal install and have no problems at all. But, I want to put this here anyways.
Creating partitions (from: https://www.wonkity.com/~wblock/docs/html/ssd.html)
# gpart create -s gpt ada0 # gpart add -t freebsd-boot -s 1m -a 4k -l ssdboot ada0 # gpart bootcode -b /boot/pmbr -p /boot/gptboot -i1 ada0 # gpart add -t freebsd-ufs -l ssdroot -b 1m -s 4g ada0 # gpart add -t freebsd-ufs -l ssdvarfs -a 1m -s 2g ada0 # gpart add -t freebsd-ufs -l ssdusrfs -a 1m ada0 # newfs -U -t /dev/gpt/ssdrootfs # newfs -U -t /dev/gpt/ssdvarfs # newfs -U -t /dev/gpt/ssdusrfs
create fstab (save as /tmp/bsdinstall_etc/fstab)
# Device Mountpoint FStype Options Dump Pass# /dev/gpt/ssdroot / ufs rw 1 1 /dev/gpt/ssdvarfs /var ufs rw 2 2 /dev/gpt/ssdusrfs /usr ufs rw 2 2 tmpfs /tmp tmpfs rw,mode=01777 0 0
going for dwm
work in progress…