Updated FreeBSD 11.2 manual

2018-11-20-160101_1920x975_scrot.png

I updated the manual at

https://gitlab.com/jacekkowalczyk82/freebsd/blob/master/README.md

I added more comments and updated example of .xinitrc file.

 

Advertisements

How to install and configure FreeBSD 11.2

A few months ago I started using FreeBSD. First it was only virtual machine but later on I bought a Lenovo ThinkPad x240  to install there Freebsd 11.2.

This is a story of my setup and customization.

The most up to date manual and backup config files are here at https://gitlab.com/jacekkowalczyk82/freebsd

 

2018-11-20-160101_1920x975_scrot.png

2018-11-20-160942_1920x975_scrot.png

Installation FreeBSD 11.2

Auto ZFS
created user added to group wheel

FreeBSD 11.2 in Virtualbox VM – Post installer configurations and steps

#as root
freebsd-update fetch 
freebsd-update install

portsnap fetch 
portsnap extract

pkg update
pkg upgrade

pkg install bash nano sudo 
bash 
nano /usr/local/utc/sudoers
uncomment line: %wheel ALL = (ALL) ALL

pkg install xorg 
pkg install mate-desktop mate slim vim htop git screenfetch

nano /etc/fstab
#I added this line
proc /proc procfs rw 0 0

nano /etc/rc.conf
#I added these 3 lines
dbus_enable="YES"
hald_enable="YES"
slim_enable="YES"

cd ~/
nano .xinitrc
# set this line
exec /usr/local/bin/mate-session


ln -s .xinitrc .xsession
cp .xinitrc /home/kowalczy/
ln -s /home/kowalczy/.xinitrc /home/kowalczy/.xsession

chown kowalczy:kowalczy /home/kowalczy/.xinitrc
chown kowalczy:kowalczy /home/kowalczy/.xsession

pkg install virtualbox-ose-additions

nano /etc/rc.conf
# I added these 2 lines
vboxguest_enable="YES"
vboxservice_enable="YES"

reboot

FreeBSD 11.2 at thinkpad x240 – Post installer configurations and steps

# as root

freebsd-update fetch 
freebsd-update install

portsnap fetch 
portsnap extract

pkg update
pkg upgrade

pkg install bash nano sudo 
bash 
nano /usr/local/utc/sudoers
uncomment line: %wheel ALL = (ALL) ALL

pkg install xorg 
pkg install mate-desktop mate slim vim htop git screenfetch

nano /etc/fstab
# I added this line
proc /proc procfs rw 0 0

nano /etc/rc.conf
#I added these 3 lines

dbus_enable="YES"
hald_enable="YES"
slim_enable="YES"

cd ~/
nano .xinitrc
#I added this 1 line
exec /usr/local/bin/mate-session

ln -s .xinitrc .xsession
cp .xinitrc /home/jacek/
ln -s /home/kowalczy/.xinitrc /home/jacek/.xsession

chown kowalczy:kowalczy /home/jacek/.xinitrc
chown kowalczy:kowalczy /home/jacek/.xsession

reboot

Install Virtualbox at host

  • First of all in BIOS settings enable Kernel Virtualization of the CPU
  • Install desired software
freebsd-version -k
sudo pkg install subversion
sudo svn co svn://svn.freebsd.org/base/releng/11.2/ /usr/src

cd /usr/ports/emulators/virtualbox-ose-kmod/
sudo make install clean

sudo pkg install gcc

cd /usr/ports/emulators/virtualbox-ose
sudo make install clean
  • Configure User for running Virtualbox
sudo pw groupmod vboxusers -m jacek
sudo pw groupmod operator -m jacek

sudo pluma /etc/rc.conf
# add this to file
#for virtualbox
vboxnet_enable="YES"
devfs_system_ruleset="system"
#

sudo pluma /etc/devfs.conf 
#add this to file 
#for virtualbox 
own vboxnetctl root:vboxusers
perm vboxnetctl 0660
#

sudo /etc/rc.d/devfs restart
  1. Enable Virtualbox kernel modules
sudo kldload vboxdrv
sudo chown root:vboxusers /dev/vboxnetctl

sudo pluma /boot/loader.conf 
#add this to file 
#for virtualbox
vboxdrv_load="YES"
##

Setup Wifi

  1. Create file /etc/wpa_supplicant.conf
network={
ssid="WORK_OFFICE_WIFI_SSID"
psk="PIN_OR_PASSWORD"
id_str="work"
}

network={
ssid="HOME_WIFI_SSID"
psk="PIN_OR_PASSWORD"
id_str="home"
}
  • Restart networking by command
sudo service netif restart

More responsive GUI

  • Edit file /etc/sysctl.conf and set
kern.sched.preempt_thresh=224
  • reboot machine

 

Install Graphics drivers

cd /usr/ports/graphics/drm-next-kmod/ 
sudo make install clean

sudo echo "# for graphics" >> /etc/rc.conf
sudo echo "kld_list=\"/boot/modules/i915kms.ko\"" >> /etc/rc.conf

 

Connecting external display by the miniDP -> HDMI cable

  • Run xrandr without connected cable, and check available resolution modes and device names
  • Connect cable and run xrandr command again. Examples:
xrandr --output HDMI-1 --mode 1600x900 --above eDP-1 
# or 
xrandr --output HDMI-1 --mode 1600x900 --same-as eDP-1
# or just 
xrandr

Byobu

sudo pkg install byobu
sudo mkdir -p /compat/linux/proc
sudo mount -t linprocfs linproc /compat/linux/proc
To make it permanent, you need the following line in /etc/fstab:
linproc /compat/linux/proc linprocfs rw,late 0 0

FreeBSD 11.2 – install i3wm
# as root

 

pkg update
pkg upgrade

pkg install i3 i3lock i3status 
pkg install dmenu nitrogen

cp /usr/local/etc/i3/config ~/.config/i3/config 
edit the file ~/.config/i3/config and add at the beginning 
#use Windows key as mod key
set $mod Mod4 
# replace all default Mod1 with $mod 
# default Mod1 is left Alt key

nano ~/.xinitrc
#I set this only one line 
/usr/local/bin/i3

Slim themes

sudo pkg install slim-themes
sudo nano /usr/local/etc/slim.conf
set current_theme fbsd

The names of all themes can be found in /usr/local/share/slim/themes/
archlinux-simple
debian-moreblue
fbsd
flat
gentoo-simple
lake
mindlock
rainbow
scotland-road
wave
capernoited
default
fingerprint
flower2
gnewsense
lunar
parallel-dimensions
rear-window
subway
zenwalk

 

Update system and applications

freebsd-update fetch
freebsd-update install

pkg update
pkg upgrade

Tweak system for Desktop use plus some usefull light GUI application

  • Install packages:
sudo pkg install xedit geany ted scribus diffuse
sudo pkg install bsdstats
  • Edit /boot/loader.conf and add entries:
##### from desktop-installer investigation
kern.hz="100"
kern.maxfiles="25000"
kern.timecounter.hardware=i8254
uplcom_load="YES"
firewire_load="YES"
ng_ubt_load="YES"
kern.vty=vt
cuse4bsd_load="YES"
  • Edit /etc/fstab and add lines:
# from desktop installer investigation , for automounting USB, cdrom devices
fdesc /dev/fd fdescfs rw 0 0

/dev/cd0 /removable/cdrom0 cd9660 ro,noauto 0 0
/dev/cd1 /removable/cdrom1 cd9660 ro,noauto 0 0
/dev/cd2 /removable/cdrom2 cd9660 ro,noauto 0 0
/dev/da0s1 /removable/flash0 msdosfs rw,noauto 0 0
/dev/da1s1 /removable/flash1 msdosfs rw,noauto 0 0
/dev/da2s1 /removable/flash2 msdosfs rw,noauto 0 0

  • Edit /etc/devfs.conf and add lines:
# Added by desktop-installer:
perm cuad0 0660
own cuad0 root:operator

perm cuad1 0660
own cuad1 root:operator

perm cuau0 0660
own cuau0 root:operator

perm cuau1 0660
own cuau1 root:operator

perm acd0 0660
own acd0 root:operator

perm acd1 0660
own acd1 root:operator

perm cd1 0660
own cd1 root:operator

perm fd0 0660
own fd0 root:operator

perm fd1 0660
own fd1 root:operator
  • Edit /etc/devfs.rules and add lines:
[system=10]
# Added by desktop-installer.
add path 'ugen*' mode 0660 group operator
# Added by desktop-installer.
add path 'cuaU*' mode 0660 group operator
# Added by desktop-installer.
add path 'uhid*' mode 0660 group operator
# Added by desktop-installer.
add path 'usbctl*' mode 0660 group operator
# Added by desktop-installer.
add path 'usb/*' mode 0660 group operator
# Added by desktop-installer.
add path 'video*' mode 0660 group operator
# Added by desktop-installer.
add path 'ng_ubt*' mode 0660 group operator
# Added by desktop-installer.
add path 'acd*' mode 0660 group operator
# Added by desktop-installer.
add path 'cd*' mode 0660 group operator
# Added by desktop-installer.
add path 'da*' mode 0660 group operator
# Added by desktop-installer.
add path 'pass*' mode 0660 group operator
# Added by desktop-installer.
add path 'xpt*' mode 0660 group operator
# Added by desktop-installer.
add path 'unlpt*' mode 0660 group cups
# Added by desktop-installer.
add path 'ulpt*' mode 0660 group cups
# Added by desktop-installer.
add path 'lpt*' mode 0660 group cups
  • Edit ‘/etc/rc.conf’ and add lines
# from desktop installer investigation
nfs_client_enable="YES"
#rpc_statd_enable="YES"
#rpc_lockd_enable="YES"
devd_enable="YES"
devfs_system_ruleset="system"

#vboxguest_enable="YES"
#vboxservice_enable="YES"
cupsd_enable="YES"
#webcamd_enable="YES"
bsdstats_enable="YES"


# from Robo Nuggie
#automount NFS
autofs_enable="YES"
  • Edit /etc/sysctl.conf and add lines:
#more power for GUI
kern.sched.preempt_thresh=224

# From desktop-installer investigation
vfs.usermount=1
kern.ipc.shm_allow_removed=1

  • Reboot the system

Install DWM from suckless.org as a desktop

  • Install required packages
sudo pkg install dwm sterm dmenu

sudo pkg install surf-browser

sudo pkg install gcc libX11 libXft libXinerama 
cd ~/git/
git clone git://git.suckless.org/dwm
  • make changes in config.mk
diff --git a/config.mk b/config.mk
index 25e2685..b81970e 100644
--- a/config.mk
+++ b/config.mk
@@ -7,8 +7,8 @@ VERSION = 6.1
PREFIX = /usr/local
MANPREFIX = ${PREFIX}/share/man

-X11INC = /usr/X11R6/include
-X11LIB = /usr/X11R6/lib
+X11INC = /usr/local/include
+X11LIB = /usr/local/lib

# Xinerama, comment if you don't want it
XINERAMALIBS = -lXinerama
@@ -16,7 +16,7 @@ XINERAMAFLAGS = -DXINERAMA

# freetype
FREETYPELIBS = -lfontconfig -lXft
-FREETYPEINC = /usr/include/freetype2
+FREETYPEINC = /usr/local/include/freetype2
# OpenBSD (uncomment)
#FREETYPEINC = ${X11INC}/freetype2
  • make changes in config.def.h
diff --git a/config.def.h b/config.def.h
index 1c0b587..0bf6c2a 100644
--- a/config.def.h
+++ b/config.def.h
@@ -44,7 +44,7 @@ static const Layout layouts[] = {
};

/* key definitions */
-#define MODKEY Mod1Mask
+#define MODKEY Mod4Mask
#define TAGKEYS(KEY,TAG) \
{ MODKEY, KEY, view, {.ui = 1 << TAG} }, \
{ MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \

 

  • Execute commands to build DWM
sudo make clean install
  • Prepare .xinitrc file
setxkbmap pl
xrdb ~/.Xresources

exec xrandr --output VGA-0 --mode 1920x975 --rate 60 &
exec nitrogen --restore &

while true ; do xsetroot -name "`date '+%Y-%m-%d %H:%M.%S'` `uptime | sed 's/.*,//'`"; sleep 1; done &

exec /home/kowalczy/git/dwm/dwm

 

  • Edit ~/.Xresources and set/add lines:
uxterm*background: black
uxterm*foreground: lightgray

XTerm.vt100.scrollBar: true
XTerm.vt100.scrollBar.width: 8

How to Setup DWM from suckless.org at Kali Linux / Debian

  • Install packages and get dev libraries
sudo apt install dwm suckless-tools
sudo apt install stterm

mkdir /opt
cd /opt

git clone git://git.suckless.org/dwm
cd dwm

sudo apt install libx11-dev libxft-dev libxinerama-dev
  • Make changes in source files:
diff --git a/config.def.h b/config.def.h
index 1c0b587..fc42d00 100644
--- a/config.def.h
+++ b/config.def.h
@@ -44,7 +44,7 @@ static const Layout layouts[] = {
};

/* key definitions */
-#define MODKEY Mod1Mask
+#define MODKEY Mod4Mask
#define TAGKEYS(KEY,TAG) \
{ MODKEY, KEY, view, {.ui = 1 << TAG} }, \
{ MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \
@@ -57,7 +57,7 @@ static const Layout layouts[] = {
/* commands */
static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
-static const char *termcmd[] = { "st", NULL };
+static const char *termcmd[] = { "stterm", NULL };

static Key keys[] = {
/* modifier key function argument */
diff --git a/config.mk b/config.mk
index 25e2685..b599bf2 100644
--- a/config.mk
+++ b/config.mk
@@ -7,8 +7,8 @@ VERSION = 6.1
PREFIX = /usr/local
MANPREFIX = ${PREFIX}/share/man

-X11INC = /usr/X11R6/include
-X11LIB = /usr/X11R6/lib
+X11INC = /usr/include/X11
+X11LIB = /usr/lib/X11

# Xinerama, comment if you don't want it
XINERAMALIBS = -lXinerama

 

  • Create file ~/.xinitrc
exec nitrogen --restore &
while true ; do xsetroot -name "`date '+%Y-%m-%d %H:%M.%S'` `uptime |sed 's/.*,//'`"; sleep 1 ; done &
exec /opt/dwm/dwm
  • Run commands:
ln -s ~/.xinitrc ~/.xsession
chmod 755 ~/.xinitrc
  • Create file /usr/share/xsessions/custom-dwm.desktop
[Desktop Entry]
Name=Custom-DWM
Exec=/etc/X11/Xsession

How to Install DWM from suckless.org at Fedora 29

dwm-fedora-2018-11-20-152332_1920x975_scrot

sudo dnf install dwm git dmenu st
mkdir ~/git && cd ~/git
git clone git://git.suckless.org/dwm
cd dwm 

sudo dnf install libX11-devel
sudo dnf install libXft-devel
sudo dnf install libXinerama-devel

sudo dnf install nitrogen
sudo dnf install xorg-x11-xinit-session
  • edit config.mk file
commit 7a013dd1af0bb0fb50ea4496910c98c53c7dd840 (HEAD -> kowalczy-dwm-fedora)
Author: Jacek Kowalczyk <jacekkowalczyk82@gmail.com>
Date:   Tue Nov 20 14:25:20 2018 +0100

    compile at fedora

diff --git a/config.mk b/config.mk
index 25e2685..7d6d132 100644
--- a/config.mk
+++ b/config.mk
@@ -7,8 +7,8 @@ VERSION = 6.1
 PREFIX = /usr/local
 MANPREFIX = ${PREFIX}/share/man

-X11INC = /usr/X11R6/include
-X11LIB = /usr/X11R6/lib
+X11INC = /usr/include/X11
+X11LIB = /usr/lib64/X11

 # Xinerama, comment if you don't want it
 XINERAMALIBS  = -lXinerama

  • edit config.def.h file and do the same change in config.h file
commit 3181727ff56be4fd4d9347a5117d68b90301dc1d (HEAD -> kowalczy-dwm-fedora)
Author: Jacek Kowalczyk <jacekkowalczyk82@gmail.com>
Date:   Tue Nov 20 14:30:09 2018 +0100

    Windows Key as ModKey

diff --git a/config.def.h b/config.def.h
index 1c0b587..0bf6c2a 100644
--- a/config.def.h
+++ b/config.def.h
@@ -44,7 +44,7 @@ static const Layout layouts[] = {
 };

 /* key definitions */
-#define MODKEY Mod1Mask
+#define MODKEY Mod4Mask
 #define TAGKEYS(KEY,TAG) \
        { MODKEY,                       KEY,      view,           {.ui = 1 << TAG} }, \
        { MODKEY|ControlMask,           KEY,      toggleview,     {.ui = 1 << TAG} }, \

  • rebuild by sudo make clean install
  • edit ~/.xinitrc file
exec nitrogen --restore &
while true ; do xsetroot -name "`date '+%Y-%m-%d %H:%M.%S'` `uptime |sed 's/.*,//'`"; sleep 1 ; done &
exec ~/git/dwm/dwm
  • ln -s ~/.xinitrc ~/.xsession
  • chmod 755 ~/.xsession
  • on next login select User Script session
  • sudo nano /usr/share/xsessions/custom-dwm.desktop
[Desktop Entry]
Name=Custom-DWM
Exec=/usr/libexec/xinit-compat
  • on next login select Custom-DWM session

Msys2 POSIX tools on Windows

How to turn your Windows 10 into unix like environment

 

What is Msys2 [ http://www.msys2.org/ ]

MSYS2 is a software distro and building platform for Windows

At its core is an independent rewrite of MSYS, based on modern Cygwin (POSIX compatibility layer) and MinGW-w64 with the aim of better interoperability with native Windows software. It provides a bash shell, Autotools, revision control systems and the like for building native Windows applications using MinGW-w64 toolchains.

It features a package management system to provide easy installation of packages, Pacman. It brings many powerful features such as dependency resolution and simple complete system upgrades, as well as straight-forward package building.

 

How to install it and add basic tools?

  • Get Msys2 from http://www.msys2.org/
  • Install as described at the msys2 home page
  • Rename the file c:\msys64\usr\bin\ssh.exe to c:\msys64\usr\bin\ssh.exe_old
  • Run commands in Msys2 terminal window
pacman -S net-utils msys/screenfetch
pacman -S msys/vim msys/bc nano msys/tmux wget gzip zip unzip msys/p7zip tar msys/tree

Have fun!!!

 

How to resize VirtualBox virtual drive VDI

Let’s say we want to resize the VDI to 60GB

  • Make a backup of the VDI file you want to resize
  • "c:\Program Files\Oracle\VirtualBox\VBoxManage.exe" modifyhd my-favourite-os.vdi --resize 61440
    
    
  • Download gParted ISO and add it as LiveCD to your virtualbox machine
  • Boot gParted from LiveCD ISO
  • Resize partition.
  • Remove gParted iso
  • Boot the virtual machine
  • Check partitions by ‘df -h’

If you are using Logical Volume Manager then extra steps needs to be done:

  • Run LVM tools: (use slightly less size for LVM then for disk drive and take into account swap size)
    lvs 
    lvresize volume-group-name/logical-volume-name --size 56G
    #example:
    lvresize fedora_fedora-xfce/root --size 56G
    #
    resize2fs /dev/mapper/volume-group-name-logical-volume-name 56G
    #example:
    resize2fs /dev/mapper/fedora_fedora--xfce-root 56G