The pkg_* commands
| Command |
Option |
Example |
Details |
| pkg_add |
-r |
pkg_add -r package_name |
download and install package_name and fix dependencies |
| pkg_version |
|
pkg_version |
summarize installed version of packages |
|
pkg_version -vl "<" |
list all obsolete packages |
How to install software
There are 2 methods to install software :
| Method |
+ |
- |
| using the ports tree |
- better system stability
- optimized for the hardware
|
- compilation is a LOOONG process
- sometimes leads to the "dependencies hell"
|
| installing pre-compiled packages |
|
- not optimized for the hardware
|
Installing pre-compiled packages is done through the command :
pkg_add -r package_name
kern.maxpipekva exceeded, please see tuning(7)
| Situation |
The system is filling console with kern.maxpipekva exceeded, please see tuning(7), it denies ssh login, and even refuses launching processes once locally logged in. |
| Details |
Kernel memory has "pipes", and "kva pipes".
- The maximum number of "kva pipes" is set in the kern.ipc.maxpipekva sysctl variable.
- The current number of "kva pipes" is set in kern.ipc.pipekva.
It seems this error appears due to a change to the kernel in the FreeBSD 5.2 release. Details : here, and here.
|
| Solution |
Found here, but not sure :
- Edit /etc/login.conf
- browse to the openfiles parameter
- change it from unlimited to 1024
|
When I got this error, the root cause was something tricky : due to a power failure, the machine crashed and HDDs where not properly unmounted. Upon reboot, the system launched an automatic fsck on the disks. It's been fast on the first disk, but it lasted way longer for the other. During that time, the system had rebooted and was trying to run "normally".
In the "normal" operations handled by this machine was a Cron job, run every minute, listing the content of the 2 HDDs. Then, since one of them was still busy being fsck'd, the script never ended, and stayed in memory until it was loaded hundreds of times and running out of "pipe kva".
Switching between single user and multi-user mode
From multi-user, down to single user :
shutdown now
And back to multi-user :
exit
This can also be done through the boot options, but rebooting resets the uptime. And rebooting isn't necessary : we're not running a Windoze machine ;-)
network parameters (IP @, mask, gateway, ...)
Everything is available in /etc/rc.conf
su: Sorry
| Situation |
When logged as any standard user and trying to log as root via su, an error appears : su: Sorry |
| Details |
Investigation shows : -bash-2.05b$ ls -l /usr/bin/su -r-sr-xr-x 1 root wheel 12460 Feb 23 2004 /usr/bin/su The setuid root s bit, together with the group x bit state that su can only be executed by members of the wheel group, and that it'll be run with root privileges. |
| Solution |
Just add the user willing to "su" into the wheel group:
- Open /etc/group in your favorite text editor
- Browse to the line starting with :
wheel:*:0:root
- Append ,user_name at the end of the line. (Don't forget the comma between user names !)
- Save, exit, it should no more say su: Sorry ;-)
|
HDD naming conventions
| Connected on : |
FreeBSD name |
Linux name |
| IDE 1 - Master |
ad0 |
hda |
| IDE 1 - Slave |
ad1 |
hdb |
| IDE 2 - Master |
ad2 |
hdc |
| IDE 2 - Slave |
ad3 |
hdd |
On top of this, FreeBSD partitions also have a s1 added, then a purely conventional suffix :
| Suffix |
Meaning |
| a |
reserved for the / filesystem |
| b |
reserved for swap filesystem |
| c |
wildcard referring to all filesystems (whole disk) |
| d |
reserved for the /var filesystem, which is specially designed for anything varying constantly such as log files |
| e |
reserved for (?) filesystem |
| f |
reserved for (?) filesystem |
| g |
reserved for (?) filesystem |
| h |
reserved for (?) filesystem |
So, on my system, I have :
- /dev/ad0s1a mounted at /
- /dev/ad0s1d mounted at /home
- /dev/ad1s1d mounted at /mnt/Data
... which is not very compliant to the convention :-(
How to create a new partition ?
FreeBSD organizes HDDs in slices then partitions. When installing a new HDD, the procedure is :
- Create a new slice
- Create one or more partitions
- Install (or not) a Boot Manager
- Create a new File System
All of this can be done rather easily with the sysinstall tool :
- As root, just type sysinstall in any tty
- Browse to the Configure | Fdisk option
- Select the physical HDD to be edited (let's consider it's ad1) and enter Fdisk
- Type A to use the entire HDD (or edit manually), then Q to leave this editor
- If required, install a Boot Manager, then leave Fdisk
- Then, enter the partition editor, called Disklabel
- Make sure the disk label is displayed on top of the screen (for the example : ad1) and create partition like in any usual Fdisk
- At this step, you can already specify the mount point (or you'll have to come back to this utility to set it, or manually edit /etc/fstab)
- When finished, press W to write changes, then Q to leave.
- Now, you just have to put tons of mp3's to fill up this new storage space ;-)
The ports tree : installing and keeping it up-to-date with CVSup
FreeBSD ports come as an easy way of installing software (from source !). To take benefits of these :
- install the ports infrastructure during the system setup or with the sysinstall tool
- install CVSup. This utility is designed to upgrade the ports tree only, not the ports themselves. To do so :
cd /usr/ports/net/cvsup-without-gui && make install distclean
- create /root/ports-supfile
- edit it with edit ports-supfile so that it contains :
*default host=cvsup.fr.freebsd.org
*default base=/usr
*default prefix=/usr
*default release=cvs tag=.
*default delete use-rel-suffix
*default compress
ports-all
- and launch the tree upgrade with cvsup -g -L2 ports-supfile. This can take a while.
- to see which ports need to be updated : pkg_version -vl "<"
- install /usr/ports/sysutils/portupgrade
- to upgrade a single port : portupgrade port_name
- to upgrade all the ports that need it : portupgrade -a
- For a massive upgrade of all installed ports : portupgrade -Rraf
- R : upward-Recursive. This will upgrade packages required by the package currently being upgraded
- r : recursive. This will upgrade packages depending on the package currently being upgraded
- a : upgrade all installed packages
- f : force upgrade
The ports tree : installing ports
Once the ports tree is available (make sure it's up-to-date), installing a FreeBSD port is just a matter of few steps :
- find the directory of the port you're going to install : whereis port_name
- launch installation : cd /usr/ports/port_type/port_name && make install distclean
- the latest source of the port will be downloaded and compiled locally. This may take a while.
Or :
portinstall port_name
sysinstall is a utility used for the system initial setup and for post-install operations such as configuration or applications installation. It must be run as root (in tty mode), with /usr/sbin/sysinstall.
To install the ports tree after the system setup, just run sysinstall, then go to the Distribution | Ports menu.
Being a DHCP client, playing with dhclient
Notes:
-
On Linux systems, Ethernet NICs are named ethn. Here, with FreeBSD, they seem to be called :
depending on the NIC manufacturer.
-
dhclient only works with devices that are "UP". ("UP" and "active" is not the same for FreeBSD)
| Action |
Command |
Notes |
| Release a DHCP lease |
dhclient -r rl0 |
Once the lease has been released, the client exits. |
| request a new DHCP lease |
dhclient rl0 |
How to mount floppy, USB key, ...
- mount_msdosfs /dev/fd0 /mnt/floppy
- mount -t msdosfs /dev/da0s1 /mnt/usb
How to enable the graphical login (XDM)
XDM is the X Display Manager. It's a daemon managing X sessions on the local machine. It can be launched at any time with /usr/X11R6/bin/xdm by the root user.
To start it automatically at boot time :
- open /etc/ttys
- seek the line starting with ttyv8
- change the parameter off into on
- run init q to rescan the ttys(5) file and make changes effective. (man init for details)