Introduction to Freebsd Additional Topics
Total Page:16
File Type:pdf, Size:1020Kb
Introduction to FreeBSD Topics Additional Topics How FreeBSD boots (more detail) - devfs filesytem ccTLD Workshop Nairobi Recompiling the FreeBSD kernel - Accessing devices Kernel loadable modules - crontab and hardware support September, 2005 Nairobi, Kenya Firewalls X Window vs. Gnome vs. KDE cvs in detail FreeBSD file system: UFS Hervey Allen Logs Use of su Lots more commands How FreeBSD Boots How FreeBSD Boots cont. Initial boot items are in /boot (this resides Stage 3 or /boot/loader: under “/”, or in it's own partition). ¡ Probes for consoles and disk boot0: ¡ Reads in this order: Copy of MBR is in /boot/boot0. MBR is at start of ¢ /boot/loader.rc the boot disk and is 512 bytes in size. If you use ¢ lilo, grub, or other MBR then this is not relevant. /boot/defaults/loader.conf ¢ boot1/boot2 or Stage 1 and 2: /boot/loader.conf to override previous ¡ Kernel and modules are loaded after a 10 /boot/boot1 is 512 bytes in size and runs second wait for key press. Interactive prompt /boot/boot2. available. /boot/boot2 is more complex and runs / For more discussion and examples see: boot/loader. http://www.freebsd.org/doc/en_US.ISO8859- 1/books/handbook/boot-blocks.html How FreeBSD Boots cont. How FreeBSD Boots cont. The init process: The init process cont.: ¡ After the kernel boots it hands over control to ¡ Once file systems are mounted then the the user process /sbin/init. following starts: ¢ ¡ If filesystems look good then init begins reading Networking services the resource configuration of the system. These ¢ System daemons files are read in this order: ¢ Locally installed package daemons ¢ /etc/defaults/rc.conf (/usr/local/etc/rc.d scripts) ¢ /etc/rc.conf (overrides previous) Init process and shutdown: ¢ /etc/rc.conf.local (overrides previous) ¡ When shutdown is called then init runs the ¡ Mounts file systems in /etc/fstab scripts /etc/rc.shutdown. The FreeBSD Kernel Recompiling the FreeBSD Kernel You might rebuild a kernel to add hardware See FreeBSD Handbook section 8.3 support, additional filesystem support, etc. /usr/src/sys/ /conf Config file in arch Or, to remove extraneous drivers. Kernel source, if installed, is in /usr/src/sys Example (old style): cp GENERIC /root/kernel/MYNEWKERNEL “If there is not a /usr/src/sys directory on your system, then the kernel source has not been installed. The ln -s /root/kernel/MYNEWKERNEL easiest way to do this is by running /stand/sysinstall as root, choosing Configure, then Distributions, then src, Edit MYNEWKERNEL file to set options then sys.” (FreeBSD Handbook 9.3) see /usr/src/sys/arch/conf/NOTES To rebuild your kernel you use the default /usr/sbin/config MYNEWKERNEL configuration file, update settings as cd ../compile/MYNEWKERNEL needed, then recompile the kernel, installing it in /boot. make depend, make, make install Recompiling the FreeBSD Kernel cont. Recompiling the FreeBSD Kernel cont. Example (new style): The kernel config file has many options. For a After you've edited MYKERNEL for options more complete explanation of the various cd /usr/src options see (e.g. on a PC with Intel CPU): make buildkernel kernconf=MYNEWKERNEL ¡ /usr/src/sys/i386/conf/NOTES make installkernel kernconf=MYNEWKERNEL And, for non-architecture specific notes see: Kernel installed as /boot/kernel/kernel ¡ /usr/src/sys/conf/NOTES Old kernel is in /boot/kernel.old/kernel Or look at the FreeBSD Handbook section 8.4 If new kernel does not boot, go to boot for some more examples. loader prompt and type: unload boot /boot/kernel.old/kernel Kernel and Hardware Support Kernel Loadable & Static Modules FreeBSD is moving towards “modularizing” Static (in conf) – built-in during recompile hardware support. That is “drivers” (kernel vs. loadable modules) are loaded at boot time Kernel loadable (kld) /boot/kernel modules. to support your systems' hardware. Autoloading using /etc/rc.conf directives Some hardware is still supported by statically and/or using /boot/loader.conf, which loaded software directly in the kernel. overrides /boot/defaults/loader.conf Some hardware use is optimized by setting Address security in FreeBSD vs. Linux and kernel state using the sysctl facility. modules. ¢ Commands kldload, kldstat, kldunload Firewalls Installing a Binary File Building an appropriate firewall ruleset for This is much less common, but you can precompile your situation requires thought: a program for a specific version of FreeBSD. See FreeBSD Handbook section 10.8 to get started. Clearly this would be something that might be done Enable IP FireWall support (IPFW) by adding one, or with commercial applications that have restrictive more options to kernel configuration file. licensing agreements. ipfw was updated to “ipfw2” in July 2002. Normally installation is done using a shell script that Starting and stopping in /etc/rc.conf and /etc/rc.firewall. copies compressed files to the appropriate ipfw rules and firewall set are in /etc/rc.firewall. locations and updates configurations as needed. You can dynamically control ipfw as well: Adobe's Acrobat Reader, Macromedia Flash plugin, ipfw flush, ipfw enable, ipfw disable, etc. are examples (/usr/local/bin/acroread). ipfw flush, etc. Installing with CVS Install cvsup CVS: Concurrent Versions System If you are using KDE or Gnome, then check: Somewhat detailed FreeBSD Handbook entry: pkg_info | grep cvs http://www.freebsd.org/doc/en_US.ISO8859- If CVS is installed you can skip this. Otherwise: 1/books/handbook/cvsup.html ¢ cd /usr/ports/net/cvsup-without-gui Typical use for CVS and FreeBSD (other than software projects) is to keep your Ports collection or up-to-date. cd /usr/ports/net/cvsup ¢ To do this be sure you have installed the Ports collection at initial installation. make ¢ Now install cvsup-without-gui from source if make install necessary: make clean Install cvsup cont. Install and Use cvsup Now copy the cvsup configuration file needed At this point you are ready to update your to tell CVS to upgrade your ports collection. A entire Ports collection with one simple sample is located in /usr/share/examples: command: cp /usr/share/examples/cvsup/ports-supfile /root/. Edit this file to look like this (line 50): cvsup -g -L 2 /root/ports-supfile # IMPORTANT: Change the next line to use one of the CVSup mirror sites # listed at http://www.freebsd.org/doc/handbook/mirrors.html. *default host=cvsupNAME.FreeBSD.org *default base=/usr “-g” : don't use graphical interface. *default prefix=/usr -L 2 *default release=cvs tag=. “ ” : verbosity level. Level 2 is verbose. *default delete use-rel-suffix CVS Summary X Windows – Gnome – KDE CVS is a powerful and complex tool. For some The first thing to understand is that Gnome more hints and information see: and KDE use the X graphical subsystem. man cvsup Generally KDE programs run in Gnome and vice-versa. info cvs For a server you do not need to run, or install, FreeBSD Handbook: any of these. http://www.freebsd.org/doc/en_US.ISO8859- 1/books/handbook/ports-using.html You can run one, both, or other window managers like fwvm, windowmaker, etc. X – Gnome – KDE cont. X – Gnome – KDE cont. ¢ Which desktop environment is better? There's no ¢ You can install Gnome and/or KDE by choosing the correct answer to this. gnome or kde “base” packages in under Packages ¢ using the /stand/sysinstall utility. To configure how X runs you specify this in the file /etc/X11/xorg.conf. ¢ Under FreeBSD 5.4 (July 2005) just install these to ¢ pull in the entire desktop installations: You general configure using the command: ¡ gnome2-2.10.0 Xorg -config ¡ kde-3.4.1 ¢ To exit X you can press ALT-CTRL-Backspace. ¢ Once installed you can generally just run either gdm ¢ You can, also, go directly to a terminal using alt- or kdm to start the Gnome or KDE Display Managers. ctrl-f1 through f8. alt-ctrl-f9 returns to X. ¢ kdm supports multiple desktop choices. ¢ For details on setting up your desktop environment read: http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/x11-wm.html The FreeBSD Unix File System FreeBSD UFS cont. Taken from Wikipedia: UFS2 and Soft Updates make for a powerful UNIX file system (UFS) is a file system used by many unix combination: operating systems. It is derived from the Berkeley Fast File Data is clustered on cylinders to reduce fragmentation. System (FFS), which itself was originally developed from FS Block level fragmentation to avoid wasting disk space in the first versions of UNIX developed at Bell Labs. when large block sizes are used. Nearly all BSD unix derivatives including FreeBSD, NetBSD, Extended attribute support. OpenBSD, NeXTStep, and Solaris use a variant of UFS. In Support for 1TB file systems. Mac OS X it is available as an alternative to HFS. In Linux, Fast file system creation using “lazy” inode partial UFS support is available and the native linux ext2 initizializtion. filesystem is derived from UFS. Soft updates to dramatically improve metadata operations. UFS is journaled so no need for fsck on large drives. FreeBSD UFS cont. Installing FreeBSD (5.2.1) To learn more about UFS and Soft Updates: Sample install session... Boot from CD-ROM Click Exit twice to get to media dialogue - Configure Gnome Choose to install from CD/DVD UFS Definition from Wikipedia: Say "Yes" to last chance to set options - Get from CD/DVD Pick default FreeBSD install - set root password - add users - Add package bash - configure addtion network interfaces - install packages Choose Express install option - configure dc0 http://en.wikipedia.org/wiki/UFS - shells - no dhcp Delete any slices laying around - Add package