| 1 |
<?xml version='1.0' encoding='UTF-8'?>
|
| 2 |
<!DOCTYPE guide SYSTEM "/dtd/guide.dtd">
|
| 3 |
<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/openrc-migration.xml,v 1.15 2009/02/17 07:19:23 nightmorph Exp $ -->
|
| 4 |
|
| 5 |
<guide link="/doc/en/openrc-migration.xml">
|
| 6 |
<title>Baselayout and OpenRC Migration Guide</title>
|
| 7 |
|
| 8 |
<author title="Author">
|
| 9 |
<mail link="cardoe"/>
|
| 10 |
</author>
|
| 11 |
<author title="Author">
|
| 12 |
<mail link="nightmorph"/>
|
| 13 |
</author>
|
| 14 |
<author title="Contributor">
|
| 15 |
<mail link="uberlord"/>
|
| 16 |
</author>
|
| 17 |
|
| 18 |
<abstract>
|
| 19 |
This guide shows you how to migrate from baselayout-1 to baselayout-2 and
|
| 20 |
OpenRC.
|
| 21 |
</abstract>
|
| 22 |
|
| 23 |
<!-- The content of this document is licensed under the CC-BY-SA license -->
|
| 24 |
<!-- See http://creativecommons.org/licenses/by-sa/2.5 -->
|
| 25 |
<license/>
|
| 26 |
|
| 27 |
<version>1.10</version>
|
| 28 |
<date>2009-11-12</date>
|
| 29 |
|
| 30 |
<chapter>
|
| 31 |
<title>Background</title>
|
| 32 |
<section>
|
| 33 |
<title>What's baselayout?</title>
|
| 34 |
<body>
|
| 35 |
|
| 36 |
<p>
|
| 37 |
Baselayout provides a basic set of files that are necessary for all systems to
|
| 38 |
function properly, such as <path>/etc/hosts</path>. It also provides the basic
|
| 39 |
filesystem layout used by Gentoo (i.e. <path>/etc</path>, <path>/var</path>,
|
| 40 |
<path>/usr</path>, <path>/home</path> directories).
|
| 41 |
</p>
|
| 42 |
|
| 43 |
</body>
|
| 44 |
</section>
|
| 45 |
<section>
|
| 46 |
<title>What's OpenRC?</title>
|
| 47 |
<body>
|
| 48 |
|
| 49 |
<p>
|
| 50 |
OpenRC is a dependency-based rc system that works with whatever init is provided
|
| 51 |
by the system, normally <path>/sbin/init</path>. However, it is <e>not</e> a
|
| 52 |
replacement for <path>/sbin/init</path>. The default init used by Gentoo Linux
|
| 53 |
is <c>sys-apps/sysvinit</c>, while Gentoo/FreeBSD uses the FreeBSD init provided
|
| 54 |
by <c>sys-freebsd/freebsd-sbin</c>.
|
| 55 |
</p>
|
| 56 |
|
| 57 |
</body>
|
| 58 |
</section>
|
| 59 |
<section>
|
| 60 |
<title>So why migrate?</title>
|
| 61 |
<body>
|
| 62 |
|
| 63 |
<p>
|
| 64 |
Originally Gentoo's rc system was built into baselayout 1 and written entirely
|
| 65 |
in bash. This led to several limitations. For example, certain system calls need
|
| 66 |
to be accessed during boot and this required C-based callouts to be added. These
|
| 67 |
callouts were each statically linked, causing the rc system to bloat over time.
|
| 68 |
</p>
|
| 69 |
|
| 70 |
<p>
|
| 71 |
Additionally, as Gentoo expanded to other platforms like
|
| 72 |
Gentoo/FreeBSD and Gentoo Embedded, it became impossible to require a bash-based
|
| 73 |
rc system. This led to a development of baselayout 2, which is written in
|
| 74 |
C and only requires a POSIX-compliant shell. During the development of
|
| 75 |
baselayout 2, it was determined that it was a better fit if baselayout merely
|
| 76 |
provided the base files and filesystem layout for Gentoo and the rc system
|
| 77 |
was broken off into its own package. Thus we have OpenRC.
|
| 78 |
</p>
|
| 79 |
|
| 80 |
<p>
|
| 81 |
OpenRC is primarily developed by <uri link="http://roy.marples.name/openrc">Roy
|
| 82 |
Marples</uri> and supports all current Gentoo variations (i.e. Gentoo Linux,
|
| 83 |
Gentoo/FreeBSD, Gentoo Embedded, and Gentoo Vserver) and other platforms such as
|
| 84 |
FreeBSD and NetBSD.
|
| 85 |
</p>
|
| 86 |
|
| 87 |
</body>
|
| 88 |
</section>
|
| 89 |
</chapter>
|
| 90 |
|
| 91 |
<chapter>
|
| 92 |
<title>Migration to OpenRC</title>
|
| 93 |
<section>
|
| 94 |
<body>
|
| 95 |
|
| 96 |
<p>
|
| 97 |
Migration to OpenRC is fairly straightforward; it will be pulled in as part of
|
| 98 |
your regular upgrade process by your package manager. The most important step
|
| 99 |
actually comes after you install the new <c>>=sys-apps/baselayout-2</c> and
|
| 100 |
<c>sys-apps/openrc</c> packages. It is <e>critical</e> that you run
|
| 101 |
<c>dispatch-conf</c> and ensure your <path>/etc</path> is up to date before
|
| 102 |
rebooting. <brite>Failure to do so will result in an unbootable system</brite>
|
| 103 |
and will require the use of the Gentoo LiveCD to perform the steps below to
|
| 104 |
repair your system.
|
| 105 |
</p>
|
| 106 |
|
| 107 |
<p>
|
| 108 |
Once you've finished updating your config files, there are a few things to
|
| 109 |
verify prior to rebooting.
|
| 110 |
</p>
|
| 111 |
|
| 112 |
</body>
|
| 113 |
</section>
|
| 114 |
|
| 115 |
<section id="rc_conf">
|
| 116 |
<title>/etc/conf.d/rc</title>
|
| 117 |
<body>
|
| 118 |
|
| 119 |
<p>
|
| 120 |
<path>/etc/conf.d/rc</path> has been deprecated and any settings you have in
|
| 121 |
there will need to be migrated to the appropriate settings in
|
| 122 |
<path>/etc/rc.conf</path>. Please read through <path>/etc/rc.conf</path> and
|
| 123 |
<path>/etc/conf.d/rc</path> and migrate the settings. Once you are complete,
|
| 124 |
delete <path>/etc/conf.d/rc</path>.
|
| 125 |
</p>
|
| 126 |
|
| 127 |
</body>
|
| 128 |
</section>
|
| 129 |
<section id="modules">
|
| 130 |
<title>Kernel modules</title>
|
| 131 |
<body>
|
| 132 |
|
| 133 |
<p>
|
| 134 |
Normally, when you want certain kernel modules automatically loaded at boot, you
|
| 135 |
place them into <path>/etc/modules.autoload.d/kernel-2.6</path> along with any
|
| 136 |
parameters you wanted to pass to them. In baselayout-2, this file is not used
|
| 137 |
anymore. Instead, autoloaded modules and module parameters are placed in one
|
| 138 |
file, <path>/etc/conf.d/modules</path>, no matter the kernel version.
|
| 139 |
</p>
|
| 140 |
|
| 141 |
<p>
|
| 142 |
An example old style configuration would be:
|
| 143 |
</p>
|
| 144 |
|
| 145 |
<pre caption="/etc/modules.autoload.d/kernel-2.6">
|
| 146 |
ivtv
|
| 147 |
cx88_dvb video_br=2
|
| 148 |
</pre>
|
| 149 |
|
| 150 |
<p>
|
| 151 |
Converting the above example would result in the following:
|
| 152 |
</p>
|
| 153 |
|
| 154 |
<pre caption="/etc/conf.d/modules">
|
| 155 |
<comment># Modules autoloaded at boot</comment>
|
| 156 |
modules_2_6="ivtv cx88_dvb"
|
| 157 |
<comment># Module parameters</comment>
|
| 158 |
module_cx88_dvb_args_2_6="video_br=2"
|
| 159 |
</pre>
|
| 160 |
|
| 161 |
<p>
|
| 162 |
In the above examples, the modules and their parameters would only be passed
|
| 163 |
to 2.6.x series kernels. The new configuration allows for fine grained
|
| 164 |
control over the modules and parameters based on kernel version.
|
| 165 |
</p>
|
| 166 |
|
| 167 |
<p>
|
| 168 |
An in-depth example would be:
|
| 169 |
</p>
|
| 170 |
|
| 171 |
<pre caption="detailed example of /etc/conf.d/modules">
|
| 172 |
<comment># Always load ochi1394 and ieee1394, no matter the kernel version</comment>
|
| 173 |
modules="ohci1394 ieee1394"
|
| 174 |
<comment># Only load tun and usbserial for 2.6.x series kernels</comment>
|
| 175 |
modules_2_6="tun usbserial"
|
| 176 |
<comment># Only load cx88_dvb for 2.6.23 kernels</comment>
|
| 177 |
modules_2_6_23="cx88_dvb"
|
| 178 |
<comment># Only load ivtv for 2.6.23-gentoo-r5</comment>
|
| 179 |
modules_2_6_23_gentoo_r5="ivtv"
|
| 180 |
|
| 181 |
<comment># For 2.6.23-gentoo-r5, pass video_br=2 to cx88_dvb</comment>
|
| 182 |
module_cx88_dvb_args_2_6_23_gentoo_r5="video_br=2"
|
| 183 |
<comment># For 2.6.x series kernels, always pass vendor and product</comment>
|
| 184 |
module_usbserial_args_2_6="vendor=0x1410 product=0x2110"
|
| 185 |
<comment># Always pass debug to ieee1394</comment>
|
| 186 |
module_ieee1394_args="debug"
|
| 187 |
</pre>
|
| 188 |
|
| 189 |
<note>
|
| 190 |
Please note the difference between <b>module_</b> and <b>modules_</b>.
|
| 191 |
</note>
|
| 192 |
|
| 193 |
</body>
|
| 194 |
</section>
|
| 195 |
<section id="boot">
|
| 196 |
<title>Boot runlevel</title>
|
| 197 |
<body>
|
| 198 |
|
| 199 |
<p>
|
| 200 |
The <c>boot</c> runlevel performs several important steps for every machine. For
|
| 201 |
example, making sure your root filesystem is mounted read/write, that your
|
| 202 |
filesystems are checked for errors, that your mountpoints are available, and
|
| 203 |
that the <path>/proc</path> pseudo-filesystem is started at boot.
|
| 204 |
</p>
|
| 205 |
|
| 206 |
<p>
|
| 207 |
With OpenRC, volume management services for your block storage devices are no
|
| 208 |
longer run automatically at boot. This includes lvm, raid, swap, device-mapper
|
| 209 |
(dm), dm-crypt, evms, and the like. You must ensure the appropriate initscript
|
| 210 |
for these services is in the <c>boot</c> runlevel, otherwise it's possible that
|
| 211 |
your system will not boot!
|
| 212 |
</p>
|
| 213 |
|
| 214 |
<p>
|
| 215 |
While the OpenRC ebuild will attempt to do this migration for you, you should
|
| 216 |
verify that it migrated all the volume management services properly:
|
| 217 |
</p>
|
| 218 |
|
| 219 |
<pre caption="Display all services in boot runlevel">
|
| 220 |
# <i>ls -l /etc/runlevels/boot/</i>
|
| 221 |
</pre>
|
| 222 |
|
| 223 |
<p>
|
| 224 |
If you don't see root, procfs, mtab, swap, and fsck in the above listing,
|
| 225 |
perform the following to add them to the <c>boot</c> runlevel:
|
| 226 |
</p>
|
| 227 |
|
| 228 |
<pre caption="Adding critical services to the boot runlevel">
|
| 229 |
# <i>rc-update add root boot</i>
|
| 230 |
# <i>rc-update add procfs boot</i>
|
| 231 |
# <i>rc-update add mtab boot</i>
|
| 232 |
# <i>rc-update add fsck boot</i>
|
| 233 |
# <i>rc-update add swap boot</i>
|
| 234 |
</pre>
|
| 235 |
|
| 236 |
<p>
|
| 237 |
If you know you use mdraid and lvm but do not see them above, you would run
|
| 238 |
the following to add initscripts to the <c>boot</c> runlevel:
|
| 239 |
</p>
|
| 240 |
|
| 241 |
<pre caption="Adding raid and lvm to the boot runlevel">
|
| 242 |
# <i>rc-update add raid boot</i>
|
| 243 |
# <i>rc-update add lvm boot</i>
|
| 244 |
</pre>
|
| 245 |
|
| 246 |
</body>
|
| 247 |
</section>
|
| 248 |
<section>
|
| 249 |
<title>Udev</title>
|
| 250 |
<body>
|
| 251 |
|
| 252 |
<p>
|
| 253 |
OpenRC no longer starts <c>udev</c> by default, but it does need to be present
|
| 254 |
in the <c>sysinit</c> runlevel to be started. The OpenRC ebuild should detect if
|
| 255 |
<c>udev</c> was previously enabled and add it to the <c>sysinit</c> runlevel.
|
| 256 |
However, to be safe, check if <c>udev</c> is present:
|
| 257 |
</p>
|
| 258 |
|
| 259 |
<pre caption="Verifying udev">
|
| 260 |
# <i>ls -l /etc/runlevels/sysinit</i>
|
| 261 |
lrwxrwxrwx 1 root root 14 2009-01-29 08:00 /etc/runlevels/sysinit/udev -> \
|
| 262 |
/etc/init.d/udev
|
| 263 |
</pre>
|
| 264 |
|
| 265 |
<p>
|
| 266 |
If <c>udev</c> is not listed, add it to the correct runlevel:
|
| 267 |
</p>
|
| 268 |
|
| 269 |
<pre caption="Adding udev to the sysinit runlevel">
|
| 270 |
# <i>rc-update add udev sysinit</i>
|
| 271 |
</pre>
|
| 272 |
|
| 273 |
</body>
|
| 274 |
</section>
|
| 275 |
<section>
|
| 276 |
<title>Network</title>
|
| 277 |
<body>
|
| 278 |
|
| 279 |
<p>
|
| 280 |
Due to baselayout and OpenRC being broken into two different packages, your
|
| 281 |
net.eth0 initscript may disappear during the upgrade process. To replace this
|
| 282 |
initscript please perform the following:
|
| 283 |
</p>
|
| 284 |
|
| 285 |
<pre caption="Adding back missing net.eth0 script">
|
| 286 |
# <i>cd /etc/init.d</i>
|
| 287 |
# <i>ln -s net.lo net.eth0</i>
|
| 288 |
</pre>
|
| 289 |
|
| 290 |
<p>
|
| 291 |
If you are missing any other network initscripts, follow the instructions above
|
| 292 |
to re-add them. Simply replace <c>eth0</c> with the name of your network
|
| 293 |
device.
|
| 294 |
</p>
|
| 295 |
|
| 296 |
<p>
|
| 297 |
Also, <path>/etc/conf.d/net</path> no longer uses bash-style arrays for
|
| 298 |
configuration. Please review <path>/usr/share/doc/openrc/net.example</path> for
|
| 299 |
configuration instructions. Conversion should be relatively straight-forward,
|
| 300 |
for example a static IP assignment would change as follows:
|
| 301 |
</p>
|
| 302 |
|
| 303 |
<pre caption="Old /etc/conf.d/net style">
|
| 304 |
config_eth0=( "192.168.1.37 netmask 255.255.255.0 brd 192.168.1.255" )
|
| 305 |
routes_eth0=( "default via 192.168.1.100" )
|
| 306 |
</pre>
|
| 307 |
|
| 308 |
<pre caption="New /etc/conf.d/net style">
|
| 309 |
config_eth0="192.168.1.37 netmask 255.255.255.0 brd 192.168.1.255"
|
| 310 |
routes_eth0="default via 192.168.1.100"
|
| 311 |
</pre>
|
| 312 |
|
| 313 |
</body>
|
| 314 |
</section>
|
| 315 |
<section>
|
| 316 |
<title>Clock</title>
|
| 317 |
<body>
|
| 318 |
|
| 319 |
<p>
|
| 320 |
Clock settings have been renamed from <path>/etc/conf.d/clock</path> to your
|
| 321 |
system's native tool for adjusting the clock. This means on Linux it will be
|
| 322 |
<path>/etc/conf.d/hwclock</path> and on FreeBSD it will be
|
| 323 |
<path>/etc/conf.d/adjkerntz</path>. Systems without a working real time clock
|
| 324 |
(RTC) chip should use <path>/etc/init.d/swclock</path>, which sets the system
|
| 325 |
time based on the mtime of a file which is created at system shutdown. The
|
| 326 |
initscripts in <path>/etc/init.d/</path> have also been renamed accordingly, so
|
| 327 |
make sure the appropriate script for your system has been added to the boot
|
| 328 |
runlevel.
|
| 329 |
</p>
|
| 330 |
|
| 331 |
<p>
|
| 332 |
Additionally, the <c>TIMEZONE</c> variable is no longer in this file. Its
|
| 333 |
contents are instead found in the <path>/etc/timezone</path> file. If it
|
| 334 |
doesn't exist, you will of course have to create it with your timezone. Please
|
| 335 |
review both of these files to ensure their correctness.
|
| 336 |
</p>
|
| 337 |
|
| 338 |
<p>
|
| 339 |
The proper value for this file is the path relative to your timezone from
|
| 340 |
<path>/usr/share/zoneinfo</path>. For example, for someone living on the east
|
| 341 |
coast of the United States, the following would be a correct setting:
|
| 342 |
</p>
|
| 343 |
|
| 344 |
<pre caption="/etc/timezone">
|
| 345 |
America/New_York
|
| 346 |
</pre>
|
| 347 |
|
| 348 |
</body>
|
| 349 |
</section>
|
| 350 |
<section>
|
| 351 |
<title>XSESSION</title>
|
| 352 |
<body>
|
| 353 |
|
| 354 |
<p>
|
| 355 |
The XSESSION variable is no longer found in <path>/etc/rc.conf</path>. Instead,
|
| 356 |
you can set the XSESSION variable per-user in <path>~/.bashrc</path> (or
|
| 357 |
equivalent), or system-wide in <path>/etc/env.d/</path>.
|
| 358 |
</p>
|
| 359 |
|
| 360 |
<p>
|
| 361 |
Here's an example of setting XSESSION for the whole system:
|
| 362 |
</p>
|
| 363 |
|
| 364 |
<pre caption="Setting XSESSION system-wide">
|
| 365 |
# <i>echo 'XSESSION="Xfce4"' > /etc/env.d/90xsession</i>
|
| 366 |
</pre>
|
| 367 |
|
| 368 |
<impo>
|
| 369 |
You must run <c>env-update</c> after creating a file in <path>/etc/env.d</path>,
|
| 370 |
and then logout and login for it to take effect. If you set the variable in
|
| 371 |
<path>~/.bashrc</path>, you can re-source the file with <c>source
|
| 372 |
~/.bashrc</c>.
|
| 373 |
</impo>
|
| 374 |
|
| 375 |
</body>
|
| 376 |
</section>
|
| 377 |
<section>
|
| 378 |
<title>EDITOR and PAGER</title>
|
| 379 |
<body>
|
| 380 |
|
| 381 |
<p>
|
| 382 |
The EDITOR variable is no longer found in <path>/etc/rc.conf</path>. Both
|
| 383 |
EDITOR and PAGER are set by default in <path>/etc/profile</path>. You should
|
| 384 |
change this as needed in your <path>~/.bashrc</path> (or equivalent) file or
|
| 385 |
create <path>/etc/env.d/99editor</path> and set the system default there.
|
| 386 |
</p>
|
| 387 |
|
| 388 |
<impo>
|
| 389 |
You must run <c>env-update</c> after creating a file in <path>/etc/env.d</path>,
|
| 390 |
and then logout and login for it to take effect. If you set the variable in
|
| 391 |
<path>~/.bashrc</path>, you can re-source the file with <c>source
|
| 392 |
~/.bashrc</c>.
|
| 393 |
</impo>
|
| 394 |
|
| 395 |
</body>
|
| 396 |
</section>
|
| 397 |
<section>
|
| 398 |
<title>Boot log</title>
|
| 399 |
<body>
|
| 400 |
|
| 401 |
<p>
|
| 402 |
Previously, you could log the boot process by using
|
| 403 |
<c>app-admin/showconsole</c>. However, OpenRC now handles all logging
|
| 404 |
internally, so there's no need for the hacks that <c>showconsole</c> employed.
|
| 405 |
You can safely unmerge <c>showconsole</c>. To continue logging boot messages,
|
| 406 |
just set the appropriate variable in <path>/etc/rc.conf</path>. Logs will appear
|
| 407 |
in <path>/var/log/rc.log</path>.
|
| 408 |
</p>
|
| 409 |
|
| 410 |
<pre caption="Enabling boot logging in /etc/rc.conf">
|
| 411 |
rc_logger="YES"
|
| 412 |
</pre>
|
| 413 |
|
| 414 |
</body>
|
| 415 |
</section>
|
| 416 |
<section>
|
| 417 |
<title>Finishing up</title>
|
| 418 |
<body>
|
| 419 |
|
| 420 |
<p>
|
| 421 |
Once you've finished updating your config files and initscripts, the last thing
|
| 422 |
to do is <b>reboot</b>. This is necessary because system state information is
|
| 423 |
not preserved during the upgrade, so you'll need to provide it with a fresh
|
| 424 |
boot.
|
| 425 |
</p>
|
| 426 |
|
| 427 |
</body>
|
| 428 |
</section>
|
| 429 |
</chapter>
|
| 430 |
</guide>
|