[[FreeBSD]]
 

Freebsd
freebsd.jpg
founder: Maxfx
depends on:
interested: ruza
malanius
rainbof
ray
foonix
software license: -
hardware license: -

FreeBSD

FreeBSD is a freely available and open source implementation of the Berkeley version of the UNIX operating system.This system is in the same family of operating systems as Solaris, AIX, HP-UX, and Digital UNIX. The original UNIX operating system can trace its roots back to the 1960s. The designers of UNIX created a design so flexible and powerful that even 30 years later, UNIX (and thus FreeBSD as well) remains one of the most versatile, well-respected operating systems available. It runs on the following platforms: AMD64, ARM, ARM64, I386, MIPS, PC98, PPC, SPARC, XBOX, RPI, PICO. FreeBSD is an operating system for a variety of platforms which focuses on features, speed, and stability. It is derived from BSD, the version of UNIX® developed at the University of California, Berkeley. It is developed and maintained by a large community. FreeBSD offers advanced networking, performance, security and compatibility features today which are still missing in other operating systems, even some of the best commercial ones.

Distribution FreeBSD OS

Features FreeBSD

FreeBSD Myth (For linux (RedHat) users)

Avoiding Linuxisms

For Linux users

http://www.freebsd.cz/doc/en/articles/linux-users/article.html

---------------------------------------------------------------------------------------------------------------------------
|| Linux® command (Red Hat/Debian)                 ||   FreeBSD equivalent       Purpose                                 ||
---------------------------------------------------------------------------------------------------------------------------
|| yum install package  / apt-get install package  ||   pkg install package      Install package from remote repository  ||
|| rpm -ivh package     / dpkg -i package          ||   pkg add package          Install local package                   ||
|| rpm -qa              / dpkg -l                  ||   pkg info                 List installed packages                 ||
|| lspci                                           ||   pciconf                  List PCI devices                        ||
|| lsmod                                           ||   kldstat                  List loaded kernel modules              ||
|| modprobe                                        ||   kldload / kldunload      Load/Unload kernel modules              || 
|| strace                                          ||   truss                    Trace system calls                      ||
---------------------------------------------------------------------------------------------------------------------------

FreeBSD handbook

FreeBSD Video

Support Laptops

First step after installation FreeBSD

FreeBSD update, upgrade

freebsd-update fetch
freebsd-update upgrade -r 11.0-RELEASE or other version
freebsd-update install

PortSnap

Portsnap tool is used to fetch and update compressed snapshots of the FreeBSD ports tree.

portsnap fetch
portsnap extract

Update ports is east command

portsnap fetch update

If you need audit package for vulnerable.

pkg audit -F

How install programs

pkg install nano sudo
...

Desktop Environments Xfce4, Mate, Gnome3, Cinnamon, KDE, Lumina

pkg install xfce

pkg install mate

pkg install gnome3

pkg install cinnamon

pkg install kde

pkg install lumina

How install Desktop Xfce

pkg install xfce xorg slim

Enable component for kernel in etc/rc.conf

You need for run desktop

zfs_enable="YES"  - if you use ZFS file system
hald_enable="YES"
dbus_enable="YES"
slim_enable="YES"

if you want enable crash dump, if no write “NO”

dumpdev="AUTO"

Next step is create file .xinitrc in /root/ and /home/user/ with command

exec startxfce4
and reboot.

How to set slim theme

# pkg install slim-themes
# cd /usr/local/share/slim/themes
# fetch http://daemon-notes.com/downloads/assets/themes/slim-freebsd.tar.bz2
# tar jxvf slim-freebsd.tar.bz2
# rm slim-freebsd.tar.bz2

Edit and set /usr/local/etc/slim.conf
#current_theme       default
current_theme       freebsd

NTPD synchronize

ntpdate_enable="YES"
ntpdate_hosts="in.pool.ntp.org"

Or manualy update time and date

If you will set securelevel on 2 then you cannot set time only about second.

ntpdate -b pool.ntp.org
sudo service ntpd start

Portmaster

portmaster -L - Check all update for ports
portmaster -a - Upgrade ports

How to setup MYSQL Database

First step is installation

sudo pkg install mysql56-server

next step is enable in /etc/rc.conf

sudo sysrc mysql_enable=yes

Remember to run mysql_upgrade the first time you start the MySQL server after an upgrade from an earlier version.

Now start MYSQL Server

sudo service mysql-server start

then set database

sudo mysql_secure_installation

Source code FreeBSD kernel

sudo pkg install subversion  
sudo svn checkout https://svn0.us-east.FreeBSD.org/base/stable/you_version_system /usr/src
svn up /usr/src

How setup WIFI card

pciconf -l - look for if see wifi hardware
sudo ifconfig wlan0 create wlandev wpi0
sudo wpa_supplicant -i wlan0 -c /etc/wpa_supplicant.conf

Mount ZFS

zpool import

For control command mount.

Mount USB Mass

# ls /dev/da*
# mount_msdosfs /dev/da0 /media/usb

Automounting Removable Media

Uncomment in config file in /etc/auto_master

/media		-media		-nosuid

Add lines to /etc/devd.conf

notify 100 {
	match "system" "GEOM";
	match "subsystem" "DEV";
	action "/usr/sbin/automount -c";
};

Reload service

service automount reload
service devd restart

and added configuration /etc/rc.conf

autofs_enable="YES"

ACPI

IBM ACPI

If you use notebooks, is better enable acpi driver in /boot/loader.conf For IBM notebooks is command:

acpi_ibm_load="YES"

HP ACPI

If you use notebooks, is better enable acpi driver in /boot/loader.conf For HP notebooks is command:

acpi_hp_load="YES"

More : https://www.freebsd.org/cgi/man.cgi?acpi_ibm

Linux® Binary Compatibility

# kldload linux
# kldload linux64

# kldstat - you can look for modules
 1   72 0xffffffff80200000 1fa7c38  kernel
 2    1 0xffffffff821a9000 30aec0   zfs.ko
 3    2 0xffffffff824b4000 adc0     opensolaris.ko
 4    1 0xffffffff824bf000 231f8    if_urtw.ko
 5    1 0xffffffff82621000 4fac     ng_ubt.ko
 6    5 0xffffffff82626000 befc     netgraph.ko
 7    1 0xffffffff82632000 a58f     ng_hci.ko
 8    3 0xffffffff8263d000 107c     ng_bluetooth.ko
 9    1 0xffffffff8263f000 2a05     uhid.ko
10    1 0xffffffff82642000 3710     ums.ko
11    1 0xffffffff82646000 677b     u3g.ko
12    1 0xffffffff8264d000 53df     ucom.ko
13    1 0xffffffff82653000 d57d     ng_l2cap.ko
14    1 0xffffffff82661000 1b187    ng_btsocket.ko
15    1 0xffffffff8267d000 393d     ng_socket.ko
16    1 0xffffffff82681000 978bd    i915kms.ko
17    1 0xffffffff82719000 55180    drm2.ko
18    4 0xffffffff8276f000 26e8     iicbus.ko
19    1 0xffffffff82772000 1c75     iic.ko
20    1 0xffffffff82774000 1e70     iicbb.ko
21    1 0xffffffff82776000 3de40    linux.ko
22    2 0xffffffff827b4000 7b08     linux_common.ko
23    1 0xffffffff827bc000 389f4    linux64.ko

and add line to /etc/rc.conf:
linux_enable="YES"

Disable Beep

# sysctl hw.syscons.bell=0
# reboot

or if you use XFCE

set bell-style none

Sudo user

visudo
userX ALL=(ALL) ALL

Change standard shell

You must add line in /etc/shells for example fish shell

/usr/local/bin/fish

Change shell and path your favorite shell

chsh -s /usr/local/bin/fish

GELI

Install CD -> Partition -> Shell

gpart create -s gpt vtbd0
gpart add -t freebsd-boot -s 512k -a 4k vtbd0
gpart add -t freebsd-ufs -a 1M vtbd0
gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 vtbd0

geli init -b -g vtbd0p2
geli attach vtbd0p2

newfs -j /dev/vtbd0p2.eli
mount /dev/vtbd0p2.eli /mnt

- /tmp/bsdinstall_etc/fstab
/dev/vtbd0p2.eli / ufs rw,noatime 1 1

- /tmp/bsdinstall_boot/loader.conf
geom_eli_load="YES"

exit (installer will continue)

Change  /dev/vtbd0p2.eli to gptid/rawuuid (gpart list):
/dev/gptid/015ceb9a-90a4-11e6-b8fc-1392a9ed1847 / ufs rw,noatime 1 1

Kernel module

Simple kernel module.
https://github.com/Martinfx/FreeBSD-Kernel-module

Security on FreeBSD

To check the status of the securelevel on a running system: Add to /etc/sysctl.conf

kern.securelevel=2
security.bsd.see_other_uids=0
security.bsd.stack_guard_page=1
net.inet.ip.random_id=1

more : http://www.freebsd.cz/doc/faq/security.html

Troubleshooting with FreeBSD

SSH

Too many authentication failures

If You are not able to authenticate via ssh and mesage “Too many authentication failures” is logged in /var/log/auth.log you probably have more than 2 keys loaded in your ssh agent that are failing to authenticate. To solve this unload keys you are not using from ssh agent (ssh-add -d path/ ssh-add -D), use ssh -i path_to_key or create appropriate section in your ~/.ssh/config with IdentityFile.

BOOT on FreeBSD

Fatal double fault FreeBSD 10.3 - i386

Fatal double fault is problem on FreeBSD with ZFS file system. If you will have i386 OS you must set wm.kmem_size=“512M” and vm.kmem_size_max=“” is minimal value.

vfs.zfs.prefetch_disable=0
vm.kmem_size="512M"
vm.kmem_size_max="768M"
vfs.zfs.arc_max="40M"
vfs.zfs.vdev.cache.size="5M"

More information on page https://www.freebsd.org/releases/10.3R/errata.html As described in /usr/src/UPDATING entry 20121223, rebuilding the kernel with options KSTACK_PAGES=4 has been observed to resolve the boot-time crash. This, however, is not an ideal solution for inclusion in the GENERIC kernel configuration, as increasing KSTACK_PAGES implicitly decreases available usermode threads in an environment that is already resource-starved.

You must do this steps for new kernel:

# mkdir -p /usr/src
# svnlite co svn://svn.freebsd.org/base/releng/10.2 /usr/src
# make -C /usr/src kernel-toolchain
# printf "include GENERIC\noptions KSTACK_PAGES=4\n" > /usr/src/sys/i386/conf/ZFS
# make -C /usr/src buildkernel KERNCONF=ZFS
# make -C /usr/src installkernel KERNCONF=ZFS

How to boot from live CD

If you have problem with boot on freebsd and cannot run system.

Back to FreeBSD menu and choose option 3. ( Escape to loader prompt ) For help in commandline is command help or ? (list of commands ) help set are options for command set

For boot from CD is commnad

set boot_cdrom (for mount filesystem)
boot

Look for mounted filesystem with command mount.If you havent zfs filesystem mounted you must run command and connect zpool :

zpool import -f zroot
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 4.0 International
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki