Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 34714 Details for
Bug 55973
modifications to baselayout to add vserver-support
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
gentoo-vserver-baselayout.html
gentoo-vserver-baselayout.html (text/html), 7.63 KB, created by
Thomas Eckert
on 2004-07-03 08:41:10 UTC
(
hide
)
Description:
gentoo-vserver-baselayout.html
Filename:
MIME Type:
Creator:
Thomas Eckert
Created:
2004-07-03 08:41:10 UTC
Size:
7.63 KB
patch
obsolete
><HTML> ><HEAD> > <TITLE>GentooVserverBaselayout</TITLE> > <STYLE TYPE="text/css"><!-- > >/***********************************************************************/ >/* general */ > >body { > background: #FF8500; > font-family: tahoma, verdana, sans-serif; > font-size: 13pt; > margin: 0; > margin-top: 3em; > } > >textarea.edit { width: 70em; height: 40em; font-family: courier; } > >div.content { > background: #FF8500; > font-family: tahoma, verdana, sans-serif; > margin-left: 2cm; > width: 24cm; > } > >h1,h2,h3 { > margin-left: -1cm; > } > >h4,h5 { > margin-left: 0cm; > } > >a:link, a:visited { > color:#FFFF00; > font-family:sans-serif; > text-decoration: none; > } >a:active { > text-decoration: none; > } > >a:focus, a:hover { > color:#FFFFF0; > //text-decoration: blink; > } > >P.nav, P.tnav { > height: 1.4em; > width: 100%; > font-size: 100%; > position: fixed; > x-position: fixed; > > padding-right: 0px; > padding-left: 0px; > padding-top: -2px; > padding-bottom: 3px; > margin: 0px; > > background: #FFA000; > border-bottom: 1px solid red; > text-align: right; > } > >TABLE.nav { > height: 1.0em; > width: 100%; > font-size: 80%; > font-weight: bold; > > padding-bottom: 20px; > padding-top: 0px; > margin: 0px; > margin-top: -1px; > > text-align: right; > } > >P.bnav { > height: 1.4em; > width: 100%; > font-size: 100%; > padding-left: -5cm; > position: relative; > > padding-top: 0px; > padding-bottom: 0px; > > background: #FFA000; > border-top: 1px solid red; > border-bottom: 1px solid red; > text-align: right; > } > > >TR.r { background: rgb(204, 155, 204); } >TR.s { background: rgb(155, 155, 155); } > > >TR.p { background: rgb(204, 255, 204); } >TR.q { background: rgb(255, 255, 255); } >TD.data { vertical-align: top; } > >pre.code { > background: #CCCCCC; > font-family: courier; > font-size: 90%; > margin: 1em; > padding: 0.5em; > } > > --></STYLE> ></HEAD> ><BODY> ><div class="content"> >Attempt to modify Gentoo-baselayout to make vserver-deployment easier without >breaking the current behaviour and without needing to split the baselayout. ><P> >The modifications outlined below were tested with sys-apps/baselayout-1.9.4-r2 >on a vserver-enabled system without trouble; further testing is needed as >failures in baselayout may render the system unbootable. ><P> >sources of information: ><UL CLASS="square"> ><LI><A HREF="http://vserver.strahlungsfrei.de/tiki-index.php?page=VServerGentooNew">http://vserver.strahlungsfrei.de/tiki-index.php?page=VServerGentooNew</A> ><LI><A HREF="http://www.linux-vserver.org">http://www.linux-vserver.org</A> ></UL CLASS="square"> > ><P> >related Gentoo-packages: ><UL CLASS="square"> ><LI>sys-kernel/vserver-sources ><LI>sys-cluster/util-vserver ></UL CLASS="square"> > ><P> ><H4>helper-functions and modification of /sbin/rc and /etc/inittab</H4> ><P> ><UL CLASS="square"> ><LI>helper-functions we use: ><PRE CLASS="code">instserv sbin # cat /sbin/vserver-functions.sh >#!/bin/bash >## >## basic function-set for integration in gentoo-baselayout -- this >## should allow save (re-)booting of vservers and root-servers without >## maintaining 2 completely different baselayouts. >## Idea: we simply check if we are on a root- or v-server and react accordingly. >## If there is no "s_context:" at all we have a vanilla (i.e. non-vserver) system >## that is treated like a root-server. > >check_context() { > ## TODO: error-handling? what to do if /proc/$$/status does not exist? > awk '/^s_context:/ { print $2; }' /proc/$$/status >} > >on_rootserver() { > local ctx=$(check_context) > > if [ "x${ctx}" = "x0" -o "x${ctx}" = "x" ]; then > ## we are on the root-server or a non-vserver-system: > return 0 > else > return 1 > fi >} > >on_vserver() { > on_rootserver && return 1 || return 0 >} ></PRE> ><P> ><LI>modify /sbin/rc to perform a depscan (the "fake-init"-stuff prevents > /sbin/rc to do it as the runlevel is never "S"!?): ><PRE CLASS="code">instserv sbin # diff -u rc.org rc >--- rc.org 2004-06-13 13:32:17.000000000 +0200 >+++ rc 2004-07-03 15:40:42.000000000 +0200 >@@ -10,6 +10,10 @@ > [ -f /sbin/livecd-functions.sh ] && source /sbin/livecd-functions.sh > umask 022 > >+## vserver-support: >+[ -f /sbin/vserver-functions.sh ] && source /sbin/vserver-functions.sh >+on_vserver && /sbin/depscan.sh >+ > try() { > local errstr > local retval=0 ></PRE> ><P> ><LI>create two new runlevel-directories and adjust /etc/inittab: <BR> > [ "vdefault" may be omitted, see "Plan B" below ] ><PRE CLASS="code">mkdir /etc/runlevels/{vboot,vdefault} >instserv runlevels # diff -u /etc/inittab.org /etc/inittab >--- /etc/inittab.org 2004-06-13 13:32:17.000000000 +0200 >+++ /etc/inittab 2004-07-03 15:49:16.000000000 +0200 >@@ -17,14 +17,14 @@ > si::sysinit:/sbin/rc sysinit > > # Further system initialization, brings up the boot runlevel. >-rc::bootwait:/sbin/rc boot >+rc::bootwait:/sbin/rc vboot > > l0:0:wait:/sbin/rc shutdown > l1:S1:wait:/sbin/rc single > l2:2:wait:/sbin/rc nonetwork >-l3:3:wait:/sbin/rc default >-l4:4:wait:/sbin/rc default >-l5:5:wait:/sbin/rc default >+l3:3:wait:/sbin/rc vdefault >+l4:4:wait:/sbin/rc vdefault >+l5:5:wait:/sbin/rc vdefault > l6:6:wait:/sbin/rc reboot > #z6:6:respawn:/sbin/sulogin > ></PRE> ><P> > => nothing is started up by defaut, to add a service use, e.g. ><PRE CLASS="code">rc-update add sshd vdefault ></PRE> > => this does not work as the values in /etc/inittab are not used; they are > overridden by the "vserver"-tool from "sys-cluster/util-vserver" so that > always "default" is choosen. ><P> > <B>Plan B:</B> ><PRE CLASS="code">cd /etc/runlevels; mv default default.org; ln -s vdefault default ></PRE> > We might as well de-populate the original default-runlevel with "rc-update" > and omitt the whole "vdefault"-stuff above. ><P> ><LI>prepare a configfile for your vserver on your root-server > (/etc/vservers/my_vserver.conf). ></UL CLASS="square"> > ><P> ><H4>modify initscripts</H4> ><P> >We need to <B>modify some initscripts</B> as some operations are not possible >within a vserver and the dependency-tracking of the Gentoo-initsystem is more >than unhappy with failing services (which is the perfectly correct behaviour). ><P> >A vserver "inherits" some of the root-server setup or get's configured from >the root-server. This is the case for, e.g. hardware-clock and >network-configuration. ><P> >List of initscripts that we need to make vserver-aware: ><PRE CLASS="code">hostname >modules >checkfs >localmount >clock >consolefont >serial >net.eth0 >net.lo ></PRE> ><P> >We use the same trick as in <CODE>/sbin/rc</CODE>, each initscript gets the following >lines added at the top (directly after the copyright-header): ><PRE CLASS="code">## vserver-support: >[ -f /sbin/vserver-functions.sh ] && source /sbin/vserver-functions.sh >on_vserver && exit 0 ></PRE> >(if this get's integrated in the offical baselayout the sourcing of >vserver-functions.sh will happen at a more central place and not in every >initscript) ><P> ><H4>reboot and halt</H4> ><P> >In order to enable reboot and halt for a vserver <CODE>rebootmgr</CODE> needs to be >running on the root-server and <CODE>/sbin/halt</CODE> on the vserver needs to be >replaced by <CODE>vreboot</CODE> from sys-cluster/util-vserver. (what about ><CODE>/etc/init.d/shutdown.sh</CODE>?) ><P> >Simply overwriting it is not a good solution as the next baselayout-update >will revert to the "wrong" (non-vserver) version. <BR> >If we only modify <CODE>/etc/init.d/halt.sh</CODE> and <CODE>/etc/init.d/reboot.sh</CODE> like ><PRE CLASS="code">sed -i -e "s@/sbin/halt@/sbin/vhalt@g;" /etc/init.d/halt.sh > : > : ></PRE> ><P> >it is still possible to type <CODE>reboot</CODE> on the shell-prompt and loose contact >with your vserver. ><P> >=> we need to decide what way to go here (maybe a vserver-USE-flag for >baselayout could be introduced?). ></div> ></BODY> ></HTML> >
<HTML> <HEAD> <TITLE>GentooVserverBaselayout</TITLE> <STYLE TYPE="text/css"><!-- /***********************************************************************/ /* general */ body { background: #FF8500; font-family: tahoma, verdana, sans-serif; font-size: 13pt; margin: 0; margin-top: 3em; } textarea.edit { width: 70em; height: 40em; font-family: courier; } div.content { background: #FF8500; font-family: tahoma, verdana, sans-serif; margin-left: 2cm; width: 24cm; } h1,h2,h3 { margin-left: -1cm; } h4,h5 { margin-left: 0cm; } a:link, a:visited { color:#FFFF00; font-family:sans-serif; text-decoration: none; } a:active { text-decoration: none; } a:focus, a:hover { color:#FFFFF0; //text-decoration: blink; } P.nav, P.tnav { height: 1.4em; width: 100%; font-size: 100%; position: fixed; x-position: fixed; padding-right: 0px; padding-left: 0px; padding-top: -2px; padding-bottom: 3px; margin: 0px; background: #FFA000; border-bottom: 1px solid red; text-align: right; } TABLE.nav { height: 1.0em; width: 100%; font-size: 80%; font-weight: bold; padding-bottom: 20px; padding-top: 0px; margin: 0px; margin-top: -1px; text-align: right; } P.bnav { height: 1.4em; width: 100%; font-size: 100%; padding-left: -5cm; position: relative; padding-top: 0px; padding-bottom: 0px; background: #FFA000; border-top: 1px solid red; border-bottom: 1px solid red; text-align: right; } TR.r { background: rgb(204, 155, 204); } TR.s { background: rgb(155, 155, 155); } TR.p { background: rgb(204, 255, 204); } TR.q { background: rgb(255, 255, 255); } TD.data { vertical-align: top; } pre.code { background: #CCCCCC; font-family: courier; font-size: 90%; margin: 1em; padding: 0.5em; } --></STYLE> </HEAD> <BODY> <div class="content"> Attempt to modify Gentoo-baselayout to make vserver-deployment easier without breaking the current behaviour and without needing to split the baselayout. <P> The modifications outlined below were tested with sys-apps/baselayout-1.9.4-r2 on a vserver-enabled system without trouble; further testing is needed as failures in baselayout may render the system unbootable. <P> sources of information: <UL CLASS="square"> <LI><A HREF="http://vserver.strahlungsfrei.de/tiki-index.php?page=VServerGentooNew">http://vserver.strahlungsfrei.de/tiki-index.php?page=VServerGentooNew</A> <LI><A HREF="http://www.linux-vserver.org">http://www.linux-vserver.org</A> </UL CLASS="square"> <P> related Gentoo-packages: <UL CLASS="square"> <LI>sys-kernel/vserver-sources <LI>sys-cluster/util-vserver </UL CLASS="square"> <P> <H4>helper-functions and modification of /sbin/rc and /etc/inittab</H4> <P> <UL CLASS="square"> <LI>helper-functions we use: <PRE CLASS="code">instserv sbin # cat /sbin/vserver-functions.sh #!/bin/bash ## ## basic function-set for integration in gentoo-baselayout -- this ## should allow save (re-)booting of vservers and root-servers without ## maintaining 2 completely different baselayouts. ## Idea: we simply check if we are on a root- or v-server and react accordingly. ## If there is no "s_context:" at all we have a vanilla (i.e. non-vserver) system ## that is treated like a root-server. check_context() { ## TODO: error-handling? what to do if /proc/$$/status does not exist? awk '/^s_context:/ { print $2; }' /proc/$$/status } on_rootserver() { local ctx=$(check_context) if [ "x${ctx}" = "x0" -o "x${ctx}" = "x" ]; then ## we are on the root-server or a non-vserver-system: return 0 else return 1 fi } on_vserver() { on_rootserver && return 1 || return 0 } </PRE> <P> <LI>modify /sbin/rc to perform a depscan (the "fake-init"-stuff prevents /sbin/rc to do it as the runlevel is never "S"!?): <PRE CLASS="code">instserv sbin # diff -u rc.org rc --- rc.org 2004-06-13 13:32:17.000000000 +0200 +++ rc 2004-07-03 15:40:42.000000000 +0200 @@ -10,6 +10,10 @@ [ -f /sbin/livecd-functions.sh ] && source /sbin/livecd-functions.sh umask 022 +## vserver-support: +[ -f /sbin/vserver-functions.sh ] && source /sbin/vserver-functions.sh +on_vserver && /sbin/depscan.sh + try() { local errstr local retval=0 </PRE> <P> <LI>create two new runlevel-directories and adjust /etc/inittab: <BR> [ "vdefault" may be omitted, see "Plan B" below ] <PRE CLASS="code">mkdir /etc/runlevels/{vboot,vdefault} instserv runlevels # diff -u /etc/inittab.org /etc/inittab --- /etc/inittab.org 2004-06-13 13:32:17.000000000 +0200 +++ /etc/inittab 2004-07-03 15:49:16.000000000 +0200 @@ -17,14 +17,14 @@ si::sysinit:/sbin/rc sysinit # Further system initialization, brings up the boot runlevel. -rc::bootwait:/sbin/rc boot +rc::bootwait:/sbin/rc vboot l0:0:wait:/sbin/rc shutdown l1:S1:wait:/sbin/rc single l2:2:wait:/sbin/rc nonetwork -l3:3:wait:/sbin/rc default -l4:4:wait:/sbin/rc default -l5:5:wait:/sbin/rc default +l3:3:wait:/sbin/rc vdefault +l4:4:wait:/sbin/rc vdefault +l5:5:wait:/sbin/rc vdefault l6:6:wait:/sbin/rc reboot #z6:6:respawn:/sbin/sulogin </PRE> <P> => nothing is started up by defaut, to add a service use, e.g. <PRE CLASS="code">rc-update add sshd vdefault </PRE> => this does not work as the values in /etc/inittab are not used; they are overridden by the "vserver"-tool from "sys-cluster/util-vserver" so that always "default" is choosen. <P> <B>Plan B:</B> <PRE CLASS="code">cd /etc/runlevels; mv default default.org; ln -s vdefault default </PRE> We might as well de-populate the original default-runlevel with "rc-update" and omitt the whole "vdefault"-stuff above. <P> <LI>prepare a configfile for your vserver on your root-server (/etc/vservers/my_vserver.conf). </UL CLASS="square"> <P> <H4>modify initscripts</H4> <P> We need to <B>modify some initscripts</B> as some operations are not possible within a vserver and the dependency-tracking of the Gentoo-initsystem is more than unhappy with failing services (which is the perfectly correct behaviour). <P> A vserver "inherits" some of the root-server setup or get's configured from the root-server. This is the case for, e.g. hardware-clock and network-configuration. <P> List of initscripts that we need to make vserver-aware: <PRE CLASS="code">hostname modules checkfs localmount clock consolefont serial net.eth0 net.lo </PRE> <P> We use the same trick as in <CODE>/sbin/rc</CODE>, each initscript gets the following lines added at the top (directly after the copyright-header): <PRE CLASS="code">## vserver-support: [ -f /sbin/vserver-functions.sh ] && source /sbin/vserver-functions.sh on_vserver && exit 0 </PRE> (if this get's integrated in the offical baselayout the sourcing of vserver-functions.sh will happen at a more central place and not in every initscript) <P> <H4>reboot and halt</H4> <P> In order to enable reboot and halt for a vserver <CODE>rebootmgr</CODE> needs to be running on the root-server and <CODE>/sbin/halt</CODE> on the vserver needs to be replaced by <CODE>vreboot</CODE> from sys-cluster/util-vserver. (what about <CODE>/etc/init.d/shutdown.sh</CODE>?) <P> Simply overwriting it is not a good solution as the next baselayout-update will revert to the "wrong" (non-vserver) version. <BR> If we only modify <CODE>/etc/init.d/halt.sh</CODE> and <CODE>/etc/init.d/reboot.sh</CODE> like <PRE CLASS="code">sed -i -e "s@/sbin/halt@/sbin/vhalt@g;" /etc/init.d/halt.sh : : </PRE> <P> it is still possible to type <CODE>reboot</CODE> on the shell-prompt and loose contact with your vserver. <P> => we need to decide what way to go here (maybe a vserver-USE-flag for baselayout could be introduced?). </div> </BODY> </HTML>
View Attachment As Raw
Actions:
View
Attachments on
bug 55973
: 34714 |
50428
|
50516
|
50533
|
50964