Baselayout and OpenRC Migration Guide This guide shows you how to migrate from baselayout-1 to baselayout-2 and OpenRC. 1.1 2008-04-14 Background
What's baselayout?

Baselayout provides a basic set of files that are necessary for all systems to function properly, such as /etc/hosts. It also provides the basic filesystem layout used by Gentoo (i.e. /etc, /var, /usr, /home directories).

What's OpenRC?

OpenRC is a dependency-based rc system that works with whatever init is provided by the system, normally /sbin/init. However, it is not a replacement for /sbin/init. The default init used by Gentoo Linux is sys-apps/sysvinit, while Gentoo/FreeBSD uses the FreeBSD init provided by sys-freebsd/freebsd-sbin.

So why migrate?

Originally Gentoo's rc system was built into baselayout 1 and written entirely in bash. This led to several limitations. For example, certain system calls need to be accessed during boot and this required C-based callouts to be added. These callouts were each statically linked, causing the rc system to bloat over time.

Additionally, as Gentoo expanded to other platforms like Gentoo/FreeBSD and Gentoo Embedded, it became impossible to require a bash-based rc system. This led to a development of baselayout 2, which is written in C and only requires a POSIX-compliant shell. During the development of baselayout 2, it was determined that it was a better fit if baselayout merely provided the base files and filesystem layout for Gentoo and the rc system was broken off into its own package. Thus we have OpenRC.

OpenRC is primarily developed by Roy Marples and supports all current Gentoo variations (i.e. Gentoo Linux, Gentoo/FreeBSD, Gentoo Embedded, and Gentoo Vserver) and other platforms such as FreeBSD and NetBSD.

Migration to OpenRC

Migration to OpenRC is fairly straightforward; it will be pulled in as part of your regular upgrade process by your package manager. The most important step actually comes after you install the new >=sys-apps/baselayout-2 and sys-apps/openrc packages. It is critical that you run dispatch-conf and ensure your /etc is up to date before rebooting. Failure to do so will result in an unbootable system and will require the use of the Gentoo LiveCD to perform the steps below to repair your system.

Once you've finished updating your config files, there are a few things to verify prior to rebooting.

/etc/conf.d/rc

/etc/conf.d/rc has been deprecated and any settings you have in there will need to be migrated to the appropriate settings in /etc/rc.conf. Please read through /etc/rc.conf and /etc/conf.d/rc and migrate the settings. Once you are complete, delete /etc/conf.d/rc.

Kernel modules

Normally, when you want certain kernel modules automatically loaded at boot, you place them into /etc/modules.autoload.d/kernel-2.6 along with any parameters you wanted to pass to them. In baselayout-2, this file is not used anymore. Instead, autoloaded modules and module parameters are placed in one file, /etc/conf.d/modules, no matter the kernel version.

An example old style configuration would be:

ivtv
cx88_dvb video_br=2

Converting the above example would result in the following:

# Modules autoloaded at boot
modules_2_6="ivtv cx88_dvb"
# Module parameters
module_cx88_dvb_args_2_6="video_br=2"

In the above examples, the modules and their parameters would only be passed to 2.6.x series kernels. The new configuration allows for fine grained control over the modules and parameters based on kernel version.

An in-depth example would be:

# Always load ochi1394 and ieee1394, no matter the kernel version
modules="ohci1394 ieee1394"
# Only load tun and usbserial for 2.6.x series kernels
modules_2_6="tun usbserial"
# Only load cx88_dvb for 2.6.23 kernels
modules_2_6_23="cx88_dvb"
# Only load ivtv for 2.6.23-gentoo-r5
modules_2_6_23_gentoo_r5="ivtv"

# For 2.6.23-gentoo-r5, pass video_br=2 to cx88_dvb
module_cx88_dvb_args_2_6_23_gentoo_r5="video_br=2"
# For 2.6.x series kernels, always pass vendor and product
module_usbserial_args_2_6="vendor=0x1410 product=0x2110"
# Always pass debug to ieee1394
module_ieee1394_args="debug" 
Please note the difference between module_ and modules_.
Volume management

Volume management services for your block storage devices should be automatically migrated for you when you switch to OpenRC and baselayout-2. However, in case they aren't, you'll need to follow the instructions below.

Volume management services for your block storage devices are no longer run by default. This means that lvm, raid, swap, device-mapper (dm), dm-crypt, evms, and the like will not be run automatically. If you use these addons, you will have to add the proper initscript to the boot runlevel. Otherwise, it's possible your system will not boot. When you install the various volume management services, they will install an appropriate initscript in /etc/init.d. You must ensure the appropriate initscript is in the boot runlevel.

While the OpenRC ebuild will attempt to do this migration for you, you should verify that it migrated all the volume management services properly.

# ls -l /etc/runlevels/boot/

If you know you use mdraid, lvm, and swap but do not see them above, you would run the following to add initscripts to the boot runlevel.

# rc-update add raid boot
# rc-update add lvm boot
# rc-update add swap boot

Also, make sure your root filesystem is mounted read/write, that your filesystems are checked for errors, that your mountpoints are available, and that the /proc pseudo-filesystem is started at boot. Here's a handy shell script to make it happen:

# for x in root fsck mtab procfs ; do rc-update add $x boot ; done
Clock

Clock settings have been renamed from /etc/conf.d/clock to your system's native tool for adjusting the clock. This means on Linux it will be /etc/conf.d/hwclock and on FreeBSD it will be /etc/conf.d/adjkerntz. The initscript in /etc/init.d/ has also been renamed accordingly, so make sure it's in the appropriate runlevel.

Additionally, the TIMEZONE variable is no longer in this file. Its contents are instead found in the /etc/timezone file. Please review both of these files to ensure their correctness.

XSESSION

The XSESSION variable is no longer found in /etc/rc.conf. The x11-apps/xinit package now provides /etc/env.d/90xsession, which can be used to set the XSESSION variable.

This variable will NOT be migrated for you by default, so you will need to edit /etc/env.d/90xsession.

You must run env-update after creating a file in /etc/env.d, and then logout and login for it to take effect.
EDITOR

The EDITOR variable is no longer found in /etc/rc.conf, and at this time is not provided by any other package. Users are encouraged to set it as needed in their ~/.bashrc file or create /etc/env.d/99editor and set it there.

You must run env-update after creating a file in /etc/env.d, and then logout and login for it to take effect. If you set the variable in ~/.bashrc, you can re-source the file with source ~/.bashrc.
Finishing up

Once you've finished updating your config files and initscripts, the last thing to do is reboot. This is necessary because system state information is not preserved during the upgrade, so you'll need to provide it with a fresh boot.