====== FreeBSD Experience ====== This page is about my experience using [[https://www.freebsd.org/|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// ====== FreeBSD Installation ====== 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 m(// ===== Getting FreeBSD ===== The official way to do this is, of course, to [[https://www.freebsd.org/where.html|get it]] from [[https://www.freebsd.org/|freebsd.org]]. ===== Standard Installation ===== Latest: Installing FreeBSD-12.0-RELEASE-amd64 on VirtualBox ==== Base System ==== * fresh install using memstick image file * install kernel and base only * added my main user account to {//wheel//,//operator//} group * for desktop use, all users need to be in //video// or //wheel// * so normal users should be in //video// group * normal users should also be in //operator// group to be able to shutdown from mate desktop * enable sshd, enable ntpdate(on-boot), disable sendmail ==== Desktop (GUI) ==== * use binary package management tool ''pkg'' * by default, even that is not installed... ^_^ * install x server pkg install -y xorg * install desktop environment pkg install -y gnome3 * enable stuffs in ''/etc/rc.conf'': hald_enable="YES" dbus_enable="YES" gdm_enable="YES" gnome_enable="YES" * desktop environment requires procfs - insert into ''/etc/fstab'': proc /proc procfs rw 0 0 * enable sound in ''/boot/loader.conf'': snd_driver_load="YES" * enable switching virtual consoles during X session, edit ''/boot/loader.conf'':kern.vty=vt * reduce auto-boot delay, edit ''/boot/loader.conf'':autoboot_delay="3" * **VBOX** install virtualbox additions pkg install -y virtualbox-ose-additions * **VBOX** enable virtualbox start script, edit ''/etc/rc.conf'': vboxguest_enable="YES" vboxservice_enable="YES" * **VBOX** disable host time synchronization, edit ''/etc/rc.conf'': vboxservice_flags="--disable-timesync" ==== Utility ==== - install useful stuffs * avahi & multicast dns pkg install -y avahi-app nss_mdns * enable avahi daemon in ''/etc/rc.conf'': avahi_daemon_enable="YES" * modify the ''hosts:'' line in ''/etc/nsswitch.conf'': hosts: files dns mdns * network manager pkg install -y networkmgr * configure doas - create ''/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 ==== Application ==== * development pkg install -y git geany * console multitasking pkg install -y screen * office & browser pkg install -y libreoffice firefox ==== User Account ==== * by default root shell is csh and user is sh - edit .shrc to get prettier prompt PS1="`whoami`@\H:\w\$ " * (IF using slim) to enable x environment after slim login, create ''~/.xinitrc'' for each user: exec /usr/local/bin/mate-session ===== Custom Installation ===== ==== Network Configuration ==== //**Note** DHCP client is dhclient - simply run ''dhclient '' when booting to console and using something like USB tethering.// Configure (wireless) network interface (in case was not done during installation) * FreeBSD has network interface name - based on the driver name (e.g. sis, re) * to find this, use ''pciconf -lv'' * for normal wired connection (e.g. re0), add to '/etc/rc.conf' ifconfig_re0="DHCP" * for a wireless connection (e.g. ath0), add in wlan_ath0="wlan0" ifconfig_wlan0="DHCP" * for a secured wireless connection (e.g. WPA protected), add in wlan_ath0="wlan0" ifconfig_wlan0="WPA SYNCDHCP" also, append '/etc/wpa_supplicant.conf' network={ ssid="the_ssid" psk="the_psk" } * not sure why but ''wlan0'' was not auto-created? * from official handbook, do ''ifconfig wlan0 create wlandev ath0'' * to start up and scan, do ''ifconfig wlan0 up scan'' * or just scan, do ''ifconfig wlan0 list scan'' ==== Graphics ==== Driver for ASUS E5450 Graphics Card (based on Radeon 5450?) * install driver pkg install -y xf86-video-ati * to load on startup, edit ''/etc/rc.conf'':kld_list="radeonkms" For Intel Graphics (Asus H81M-K Motherboard) * install driver pkg install -y xf86-video-intel * to load on startup, edit ''/etc/rc.conf'':kld_list="i915kms" * install something? (for kernel?) pkg install -y drm-kmod * some older ones require ''drm-fake-kmod'' instead ==== Server ==== Web Server (Apache) * find apache package(s) pkg search apache2 | grep -e "^apache2" * install apache package(s) pkg install -y php56 mod_php56 php56-mbstring php56-mcrypt php56-zlib php56-curl php56-gd php56-json * to load on startup, edit ''/etc/rc.conf'':apache24_enable="YES" * default document path is ''/usr/local/www/apache24/data/'' Server Script (PHP) * find php package(s) pkg search php5 | grep -e "^php5" * install php package(s) pkg install -y apache24 * configure ''/usr/local/etc/apache24/Includes/php.conf'': DirectoryIndex index.php index.html SetHandler application/x-httpd-php SetHandler application/x-httpd-php-source * copy template configuration file ''//# cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini//'' Database (mysql/mariadb) * install package(s) pkg install mariadb103-server mariadb103-client php56-mysqli * to load on startup, edit ''/etc/rc.conf'':mysql_enable="YES" * by default, it listens to remote request at port 3306. to check: # lsof -i4 -i6 # sockstat -4 -6 * to allow local access only, edit ''/etc/rc.conf'':mysql_args="--bind-address=127.0.0.1" * now, to make sure all is okay: # lsof -i4 -i6 | grep mysql # netstat -an | grep 3306 # sockstat -4 -6 | grep 3306 ===== Offline Installation ===== //**Note**: Need to test this... :-P// * Get the desired packages on a FreeBSD machine with internet connection # mkdir /root/offline # pkg fetch -d -o /root/offline xorg mate slim firefox * ''-d'' for dependencies * ''-o'' specifies destination path for the fetched packages * Copy those files to a portable USB drive * On the target machine, copy everything to /var/cache/pkg * Then, do a # pkg -U install xorg mate slim firefox git geany networkmgr * ''-U'' is the short form for ''--no-repo-update'' ===== USB Thumb-Drive Installation ===== 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 [[freebsd:create_usbdisk_layout|here]]. I'm going to prepare for UEFI boot on a GPT formatted disk. - plug in usb drive * find device name (i.e. /dev/???) * usually da0 is the first usb drive? - refer to [[https://gist.github.com/johnko/fa763b97f0a4671a3c60|this]]... //to be continued...// ===== Dual-Boot on UEFI Systems ===== 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''. ====== FreeBSD Maintenance ====== Maintaining the system... ===== System Upgrade/Update ===== For example, upgrading 10.1-RELEASE to 10.2-RELEASEfreebsd-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 ===== Package Upgrade/Update ===== Install package pkg install [...]//Note: include '-y' to override prompts// Delete package pkg delete [...] 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 ===== Using ports system ===== Will most probably need these at some point... To get it, portsnap fetch extract To update, portsnap fetch update To manage, use ''[[freebsd#using_portmaster|portmaster]]'' ===== Using 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= -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 ===== Minor Tweaks ===== - 'git log' output does not show colorized output * can see the escape sequence * so, as user, type git config --global core.pager "ls -r" ====== Useful Stuffs ====== ===== Creating Disk Layout for Bootable USB ===== {{page>freebsd:create_usbdisk_layout&noheader}} ===== Label for Partitions/Slices ===== 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 To check if assigned,# ls /dev/ufs For swap,# glabel label To check if assigned,# ls /dev/label Then, /etc/fstab entry can be like, /dev/label/ ===== Disk Utility ''gpart'' ===== 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 ===== Access to Linux ExtFS ===== At the moment, full R/W access for Ext2, Journal-less for Ext3 and R/O for Ext4. # kldload ext2fs # mount -t ext2fs /dev/ ===== Install on SSD ===== //**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: http://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 ====== FreeBSD on RasPi400 ====== * got FreeBSD13 arm64 aarch64 image * write to microsd card * boot issue * ok if boot from usb (note: starting pi4, usb boot is possible!) * need to update u-boot binary (look for that in forum) * console display is not ok when using on tv (high res?) * edit config.txt and comment out hdmi_safe=1 going for dwm * pkg install libX11 libXft libXinerama * pkg install git //work in progress...//