VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/docs/TestBoxImaging.html@ 64529

最後變更 在這個檔案從64529是 64523,由 vboxsync 提交於 8 年 前

TestBoxImaging: Updates & service script.

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 26.4 KB
 
1<?xml version="1.0" encoding="utf-8" ?>
2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6<meta name="generator" content="Docutils 0.12: http://docutils.sourceforge.net/" />
7<title></title>
8<style type="text/css">
9
10/*
11:Author: David Goodger ([email protected])
12:Id: $Id: TestBoxImaging.html 64523 2016-11-02 20:07:37Z vboxsync $
13:Copyright: This stylesheet has been placed in the public domain.
14
15Default cascading style sheet for the HTML output of Docutils.
16
17See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
18customize this style sheet.
19*/
20
21/* used to remove borders from tables and images */
22.borderless, table.borderless td, table.borderless th {
23 border: 0 }
24
25table.borderless td, table.borderless th {
26 /* Override padding for "table.docutils td" with "! important".
27 The right padding separates the table cells. */
28 padding: 0 0.5em 0 0 ! important }
29
30.first {
31 /* Override more specific margin styles with "! important". */
32 margin-top: 0 ! important }
33
34.last, .with-subtitle {
35 margin-bottom: 0 ! important }
36
37.hidden {
38 display: none }
39
40a.toc-backref {
41 text-decoration: none ;
42 color: black }
43
44blockquote.epigraph {
45 margin: 2em 5em ; }
46
47dl.docutils dd {
48 margin-bottom: 0.5em }
49
50object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] {
51 overflow: hidden;
52}
53
54/* Uncomment (and remove this text!) to get bold-faced definition list terms
55dl.docutils dt {
56 font-weight: bold }
57*/
58
59div.abstract {
60 margin: 2em 5em }
61
62div.abstract p.topic-title {
63 font-weight: bold ;
64 text-align: center }
65
66div.admonition, div.attention, div.caution, div.danger, div.error,
67div.hint, div.important, div.note, div.tip, div.warning {
68 margin: 2em ;
69 border: medium outset ;
70 padding: 1em }
71
72div.admonition p.admonition-title, div.hint p.admonition-title,
73div.important p.admonition-title, div.note p.admonition-title,
74div.tip p.admonition-title {
75 font-weight: bold ;
76 font-family: sans-serif }
77
78div.attention p.admonition-title, div.caution p.admonition-title,
79div.danger p.admonition-title, div.error p.admonition-title,
80div.warning p.admonition-title, .code .error {
81 color: red ;
82 font-weight: bold ;
83 font-family: sans-serif }
84
85/* Uncomment (and remove this text!) to get reduced vertical space in
86 compound paragraphs.
87div.compound .compound-first, div.compound .compound-middle {
88 margin-bottom: 0.5em }
89
90div.compound .compound-last, div.compound .compound-middle {
91 margin-top: 0.5em }
92*/
93
94div.dedication {
95 margin: 2em 5em ;
96 text-align: center ;
97 font-style: italic }
98
99div.dedication p.topic-title {
100 font-weight: bold ;
101 font-style: normal }
102
103div.figure {
104 margin-left: 2em ;
105 margin-right: 2em }
106
107div.footer, div.header {
108 clear: both;
109 font-size: smaller }
110
111div.line-block {
112 display: block ;
113 margin-top: 1em ;
114 margin-bottom: 1em }
115
116div.line-block div.line-block {
117 margin-top: 0 ;
118 margin-bottom: 0 ;
119 margin-left: 1.5em }
120
121div.sidebar {
122 margin: 0 0 0.5em 1em ;
123 border: medium outset ;
124 padding: 1em ;
125 background-color: #ffffee ;
126 width: 40% ;
127 float: right ;
128 clear: right }
129
130div.sidebar p.rubric {
131 font-family: sans-serif ;
132 font-size: medium }
133
134div.system-messages {
135 margin: 5em }
136
137div.system-messages h1 {
138 color: red }
139
140div.system-message {
141 border: medium outset ;
142 padding: 1em }
143
144div.system-message p.system-message-title {
145 color: red ;
146 font-weight: bold }
147
148div.topic {
149 margin: 2em }
150
151h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
152h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
153 margin-top: 0.4em }
154
155h1.title {
156 text-align: center }
157
158h2.subtitle {
159 text-align: center }
160
161hr.docutils {
162 width: 75% }
163
164img.align-left, .figure.align-left, object.align-left {
165 clear: left ;
166 float: left ;
167 margin-right: 1em }
168
169img.align-right, .figure.align-right, object.align-right {
170 clear: right ;
171 float: right ;
172 margin-left: 1em }
173
174img.align-center, .figure.align-center, object.align-center {
175 display: block;
176 margin-left: auto;
177 margin-right: auto;
178}
179
180.align-left {
181 text-align: left }
182
183.align-center {
184 clear: both ;
185 text-align: center }
186
187.align-right {
188 text-align: right }
189
190/* reset inner alignment in figures */
191div.align-right {
192 text-align: inherit }
193
194/* div.align-center * { */
195/* text-align: left } */
196
197ol.simple, ul.simple {
198 margin-bottom: 1em }
199
200ol.arabic {
201 list-style: decimal }
202
203ol.loweralpha {
204 list-style: lower-alpha }
205
206ol.upperalpha {
207 list-style: upper-alpha }
208
209ol.lowerroman {
210 list-style: lower-roman }
211
212ol.upperroman {
213 list-style: upper-roman }
214
215p.attribution {
216 text-align: right ;
217 margin-left: 50% }
218
219p.caption {
220 font-style: italic }
221
222p.credits {
223 font-style: italic ;
224 font-size: smaller }
225
226p.label {
227 white-space: nowrap }
228
229p.rubric {
230 font-weight: bold ;
231 font-size: larger ;
232 color: maroon ;
233 text-align: center }
234
235p.sidebar-title {
236 font-family: sans-serif ;
237 font-weight: bold ;
238 font-size: larger }
239
240p.sidebar-subtitle {
241 font-family: sans-serif ;
242 font-weight: bold }
243
244p.topic-title {
245 font-weight: bold }
246
247pre.address {
248 margin-bottom: 0 ;
249 margin-top: 0 ;
250 font: inherit }
251
252pre.literal-block, pre.doctest-block, pre.math, pre.code {
253 margin-left: 2em ;
254 margin-right: 2em }
255
256pre.code .ln { color: grey; } /* line numbers */
257pre.code, code { background-color: #eeeeee }
258pre.code .comment, code .comment { color: #5C6576 }
259pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
260pre.code .literal.string, code .literal.string { color: #0C5404 }
261pre.code .name.builtin, code .name.builtin { color: #352B84 }
262pre.code .deleted, code .deleted { background-color: #DEB0A1}
263pre.code .inserted, code .inserted { background-color: #A3D289}
264
265span.classifier {
266 font-family: sans-serif ;
267 font-style: oblique }
268
269span.classifier-delimiter {
270 font-family: sans-serif ;
271 font-weight: bold }
272
273span.interpreted {
274 font-family: sans-serif }
275
276span.option {
277 white-space: nowrap }
278
279span.pre {
280 white-space: pre }
281
282span.problematic {
283 color: red }
284
285span.section-subtitle {
286 /* font-size relative to parent (h1..h6 element) */
287 font-size: 80% }
288
289table.citation {
290 border-left: solid 1px gray;
291 margin-left: 1px }
292
293table.docinfo {
294 margin: 2em 4em }
295
296table.docutils {
297 margin-top: 0.5em ;
298 margin-bottom: 0.5em }
299
300table.footnote {
301 border-left: solid 1px black;
302 margin-left: 1px }
303
304table.docutils td, table.docutils th,
305table.docinfo td, table.docinfo th {
306 padding-left: 0.5em ;
307 padding-right: 0.5em ;
308 vertical-align: top }
309
310table.docutils th.field-name, table.docinfo th.docinfo-name {
311 font-weight: bold ;
312 text-align: left ;
313 white-space: nowrap ;
314 padding-left: 0 }
315
316/* "booktabs" style (no vertical lines) */
317table.docutils.booktabs {
318 border: 0px;
319 border-top: 2px solid;
320 border-bottom: 2px solid;
321 border-collapse: collapse;
322}
323table.docutils.booktabs * {
324 border: 0px;
325}
326table.docutils.booktabs th {
327 border-bottom: thin solid;
328 text-align: left;
329}
330
331h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
332h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
333 font-size: 100% }
334
335ul.auto-toc {
336 list-style-type: none }
337
338</style>
339</head>
340<body>
341<div class="document">
342
343
344<div class="section" id="testbox-imaging-backup-restore">
345<h1>Testbox Imaging (Backup / Restore)</h1>
346<div class="section" id="introduction">
347<h2>Introduction</h2>
348<p>This document is explores deloying a very simple drive imaging solution to help
349avoid needing to manually reinstall testboxes when a disk goes bust or the OS
350install seems to be corrupted.</p>
351</div>
352</div>
353<div class="section" id="definitions-glossary">
354<h1>Definitions / Glossary</h1>
355<p>See AutomaticTestingRevamp.txt.</p>
356</div>
357<div class="section" id="objectives">
358<h1>Objectives</h1>
359<blockquote>
360<ul class="simple">
361<li>Off site, no admin interaction (no need for ILOM or similar).</li>
362<li>OS independent.</li>
363<li>Space and bandwidth efficient.</li>
364<li>As automatic as possible.</li>
365<li>Logging.</li>
366</ul>
367</blockquote>
368</div>
369<div class="section" id="overview-of-the-solution">
370<h1>Overview of the Solution</h1>
371<p>Here is a brief summary:</p>
372<blockquote>
373<ul class="simple">
374<li>Always boot testboxes via PXE using PXELINUX.</li>
375<li>Default configuration is local boot (hard disk / SSD)</li>
376<li>Restore/backup action triggered by machine specific PXE config.</li>
377<li>Boots special debian maintenance install off NFS.</li>
378<li>A maintenance service (systemd style) does the work.</li>
379<li>The service reads action from TFTP location and performs it.</li>
380<li>When done the service removes the TFTP machine specific config
381and reboots the system.</li>
382</ul>
383</blockquote>
384<dl class="docutils">
385<dt>Maintenance actions are:</dt>
386<dd><ul class="first last simple">
387<li>backup</li>
388<li>backup-again</li>
389<li>restore</li>
390<li>refresh-info</li>
391<li>rescue</li>
392</ul>
393</dd>
394</dl>
395<p>Possible modifier that indicates a subset of disk on testboxes with other OSes
396installed. Support for partition level backup/restore is not explored here.</p>
397<div class="section" id="how-to-use">
398<h2>How to use</h2>
399<p>To perform one of the above maintenance actions on a testbox copy the</p>
400</div>
401</div>
402<div class="section" id="storage-server">
403<h1>Storage Server</h1>
404<p>The storage server will have three areas used here. Using NFS for all three
405avoids extra work getting CIFS sharing right too (NFS is already a pain).</p>
406<blockquote>
407<ol class="arabic simple">
408<li>/export/testbox-tftp - TFTP config area. Read-write.</li>
409<li>/export/testbox-backup - Images and logs. Read-write.</li>
410<li>/export/testbox-nfsroot - Custom debian. Read-only, no root squash.</li>
411</ol>
412</blockquote>
413</div>
414<div class="section" id="tftp-export-testbox-tftp">
415<h1>TFTP (/export/testbox-tftp)</h1>
416<p>The testbox-tftp share needs to be writable, root squashing is okay.</p>
417<p>We need files from both PXELINUX and SYSLINUX to make this work now. On a
418debian system, the <tt class="docutils literal">pxelinux</tt> and <tt class="docutils literal">syslinux</tt> packages needs to be
419installed. We actually do this further down when setting up the nfsroot, so
420it's possible to get them from there by postponing this step a little. On
421debian 8.6.0 the PXELINUX files are found in <tt class="docutils literal">/usr/lib/PXELINUX</tt> and the
422SYSLINUX ones in <tt class="docutils literal">/usr/lib/syslinux</tt>.</p>
423<p>The initial PXE image as well as associated modules comes in three variants,
424BIOS, 32-bit EFI and 64-bit EFI. We'll only need the BIOS one for now.
425Perform the following copy operations:</p>
426<pre class="literal-block">
427cp /usr/lib/PXELINUX/pxelinux.0 /mnt/testbox-tftp/
428cp /usr/lib/syslinux/modules/*/ldlinux.* /mnt/testbox-tftp/
429cp -R /usr/lib/syslinux/modules/bios /mnt/testbox-tftp/
430cp -R /usr/lib/syslinux/modules/efi32 /mnt/testbox-tftp/
431cp -R /usr/lib/syslinux/modules/efi64 /mnt/testbox-tftp/
432</pre>
433<p>For simplicitly, all the testboxes boot using good old fashioned BIOS, no EFI.
434However, it doesn't really hurt to be prepared.</p>
435<p>The PXELINUX related files goes in the root of the testbox-tftp share. (As
436mentioned further down, these can be installed on a debian system by running
437<tt class="docutils literal"><span class="pre">apt-get</span> install pxelinux syslinux</tt>.) We need the <tt class="docutils literal">*pxelinux.0</tt> files
438typically found in <tt class="docutils literal">/usr/lib/PXELINUX/</tt> on debian systems (recent ones
439anyway). It is possible we may need one ore more fo the modules <a class="footnote-reference" href="#id6" id="id1">[1]</a> that
440ships with PXELINUX/SYSLINUX, so do copy <tt class="docutils literal">/usr/lib/syslinux/modules</tt> to
441<tt class="docutils literal"><span class="pre">testbox-tftp/modules</span></tt> as well.</p>
442<p>The directory layout related to the configuration files is dictated by the
443PXELINUX configuration file searching algorithm <a class="footnote-reference" href="#id7" id="id2">[2]</a>. Create a subdirectory
444<tt class="docutils literal">pxelinux.cfg/</tt> under <tt class="docutils literal"><span class="pre">testbox-tftp</span></tt> and create the world readable file
445<tt class="docutils literal">default</tt> with the following content:</p>
446<pre class="literal-block">
447PATH bios
448DEFAULT local-boot
449LABEL local-boot
450LOCALBOOT
451</pre>
452<p>This will make the default behavior to boot the local disk system.</p>
453<p>Create <tt class="docutils literal"><span class="pre">pxelinux.cfg/do-backup</span></tt>, <tt class="docutils literal"><span class="pre">pxelinux.cfg/do-backup-again</span></tt>,
454<tt class="docutils literal"><span class="pre">pxelinux.cfg/do-restore</span></tt>, <tt class="docutils literal"><span class="pre">pxelinux.cfg/do-refresh-info</span></tt>, and
455<tt class="docutils literal"><span class="pre">pxelinux.cfg/do-rescue</span></tt> configuration files on the form:</p>
456<pre class="literal-block">
457PATH bios
458DEFAULT maintenance
459LABEL maintenance
460 MENU LABEL Maintenance (NFS)
461 KERNEL maintenance-boot/vmlinuz-3.16.0-4-amd64
462 APPEND initrd=maintenance-boot/initrd.img-3.16.0-4-amd64 testbox-action-backup ro ip=dhcp aufs=tmpfs boot=nfs root=/dev/nfs nfsroot=10.42.1.1:/export/testbox-nfsroot,ro nfsvers=3 nfsrootdebug
463LABEL local-boot
464LOCALBOOT
465</pre>
466<p>When you want to preform an action on a testbox, copy the <tt class="docutils literal"><span class="pre">do-&lt;action&gt;</span></tt> to
467<tt class="docutils literal"><span class="pre">pxeclient.cfg/&lt;HEX-ip-addr&gt;</span></tt> and trigger a boot of the testbox. The machine
468config will be removed automatically once the action has been successfully
469completed.</p>
470</div>
471<div class="section" id="images-and-logs-export-testbox-backup">
472<h1>Images and logs (/export/testbox-backup)</h1>
473<p>The testbox-backup share needs to be writable, root squashing is okay.</p>
474<p>In the root there must be a file <tt class="docutils literal"><span class="pre">testbox-backup</span></tt> so we can easily tell
475whether we've actually mounted the share or are just staring at an empty mount
476point directory.</p>
477<p>The <tt class="docutils literal"><span class="pre">testbox-maintenance.sh</span></tt> script maintains a global log in the root
478directory that's called <tt class="docutils literal">maintenance.log</tt>. Errors will be logged there as
479well as a ping and the action.</p>
480<p>We use a directory layout based on dotted decimal IP addresses here, so for a
481server with the IP 10.40.41.42 all its file will be under <tt class="docutils literal">10.40.41.42/</tt>:</p>
482<dl class="docutils">
483<dt><tt class="docutils literal">&lt;hostname&gt;</tt></dt>
484<dd>The name of the testbox (empty file). Help finding a testbox by name.</dd>
485<dt><tt class="docutils literal"><span class="pre">testbox-info.txt</span></tt></dt>
486<dd>Information about the testbox. Starting off with the name, decimal IP,
487PXELINUX style hexadecimal IP, and more.</dd>
488<dt><tt class="docutils literal">maintenance.log</tt></dt>
489<dd>Maintenance log file recording what the maintenance service does.</dd>
490<dt><tt class="docutils literal"><span class="pre">disk-devices.lst</span></tt></dt>
491<dd>Optional list of disk devices to consider backuping up or restoring. This is
492intended for testboxes with additional disks that are used for other purposes
493and should touched.</dd>
494<dt><tt class="docutils literal">sda.raw.gz</tt></dt>
495<dd>The gzipped raw copy of the sda device of the testbox.</dd>
496<dt><tt class="docutils literal"><span class="pre">sd[bcdefgh].raw.gz</span></tt></dt>
497<dd>The gzipped raw copy sdb, sdc, sde, sdf, sdg, sdh, etc if any of them exists
498and are disks/SSDs.</dd>
499<dt>Note! If it turns out we can be certain to get a valid host name, we might just</dt>
500<dd>switch to use the hostname as the directory name instead of the IP.</dd>
501</dl>
502</div>
503<div class="section" id="debian-nfs-root-export-testbox-nfsroot">
504<h1>Debian NFS root (/export/testbox-nfsroot)</h1>
505<p>The testbox-nfsroot share should be read-only and must <strong>not</strong> have root
506squashing enabled.</p>
507<p>There are several ways of creating a debian nfsroot, but since we've got a
508tool like VirtualBox around we've just installed it in a VM, prepared it,
509and copied it onto the NFS server share.</p>
510<p>As of writing debian 8.6.0 is current, so a minimal 64-bit install of it was
511done in a VM. After installation the following modifications was done:</p>
512<blockquote>
513<ul>
514<li><p class="first"><tt class="docutils literal"><span class="pre">apt-get</span> install pxelinux syslinux <span class="pre">initramfs-tools</span> zip gddrescue joe</tt>
515and optionally <tt class="docutils literal"><span class="pre">apt-get</span> install smbclient <span class="pre">cifs-utils</span></tt>.</p>
516</li>
517<li><p class="first"><tt class="docutils literal">/etc/default/grub</tt> was modified to set <tt class="docutils literal">GRUB_CMDLINE_LINUX_DEFAULT</tt> to
518<tt class="docutils literal">&quot;&quot;</tt> instead of <tt class="docutils literal">&quot;quiet&quot;</tt>. This allows us to see messages during boot
519and perhaps spot why something doesn't work on a testbox. Regenerate the
520grub configuration file by running <tt class="docutils literal"><span class="pre">update-grub</span></tt> afterwards.</p>
521</li>
522<li><p class="first">Create the directory <tt class="docutils literal">/etc/systemd/system/getty&#64;tty1.service.d</tt> and create
523the file <tt class="docutils literal">noclear.conf</tt> in it with the following content:</p>
524<pre class="literal-block">
525[Service]
526TTYVTDisallocate=no
527</pre>
528<p>This stops getty from clearing VT1 and let us see the tail of the boot up
529messages, which includes messages from the testbox-maintenance service.</p>
530</li>
531<li><p class="first">Mount the testbox-nfsroot under <tt class="docutils literal">/mnt/</tt> with write privileges. (The write
532privileges are temporary - don't forget to remove them later on.):</p>
533<pre class="literal-block">
534mount -t nfs myserver.com:/export/testbox-nfsroot
535</pre>
536<p>Note! Adding <tt class="docutils literal"><span class="pre">-o</span> nfsvers=3</tt> may help with some NTFv4 servers.</p>
537</li>
538<li><p class="first">Copy the debian root and dev file system onto nfsroot. If you have ssh
539access to the NFS server, the quickest way to do it is to use <tt class="docutils literal">tar</tt>:</p>
540<pre class="literal-block">
541tar -cz --one-file-system -f /mnt/testbox-maintenance-nfsroot.tar.gz . dev/
542</pre>
543<p>An alternative is <tt class="docutils literal">cp <span class="pre">-ax</span> . /mnt/. &amp;&amp;&nbsp; cp <span class="pre">-ax</span> dev/. /mnt/dev/.</tt> but this
544is quite a bit slower, obviously.</p>
545</li>
546<li><p class="first">chroot into the nfsroot: <tt class="docutils literal">chroot /mnt/</tt></p>
547<blockquote>
548<ul>
549<li><p class="first"><tt class="docutils literal">mount <span class="pre">-o</span> proc proc /proc</tt></p>
550</li>
551<li><p class="first"><tt class="docutils literal">mount <span class="pre">-o</span> sysfs sysfs /sys</tt></p>
552</li>
553<li><p class="first"><tt class="docutils literal">mkdir <span class="pre">/mnt/testbox-tftp</span> <span class="pre">/mnt/testbox-backup</span></tt></p>
554</li>
555<li><p class="first">Recreate <tt class="docutils literal">/etc/fstab</tt> with:</p>
556<pre class="literal-block">
557proc /proc proc defaults 0 0
558/dev/nfs / nfs defaults 1 1
55910.42.1.1:/export/testbox-tftp /mnt/testbox-tftp nfs nfsvers=3 2 2
56010.42.1.1:/export/testbox-backup /mnt/testbox-backup nfs nfsvers=3 3 3
561</pre>
562</li>
563<li><p class="first">Do <tt class="docutils literal">mount <span class="pre">/mnt/testbox-tftp</span> &amp;&amp; mount <span class="pre">/mnt/testbox-backup</span></tt> to mount the
564two shares. This may be a good time to execute the instructions in the
565sections above relating to these two shares.</p>
566</li>
567<li><p class="first">Edit <tt class="docutils literal"><span class="pre">/etc/initramfs-tools/initramfs.conf</span></tt> and change the <tt class="docutils literal">MODULES</tt>
568value from <tt class="docutils literal">most</tt> to <tt class="docutils literal">netboot</tt>.</p>
569</li>
570<li><p class="first">Append <tt class="docutils literal">aufs</tt> to <tt class="docutils literal"><span class="pre">/etc/initramfs-tools/modules</span></tt>. The advanced
571multi-layered unification filesystem (aufs) enables us to use a
572read-only NFS root. <a class="footnote-reference" href="#id8" id="id3">[3]</a> <a class="footnote-reference" href="#id9" id="id4">[4]</a> <a class="footnote-reference" href="#id10" id="id5">[5]</a></p>
573</li>
574<li><p class="first">Create <tt class="docutils literal"><span class="pre">/etc/initramfs-tools/scripts/init-bottom/00_aufs_init</span></tt> as
575an executable file with the following content:</p>
576<pre class="literal-block">
577#!/bin/sh
578# Don't run during update-initramfs:
579case &quot;$1&quot; in
580 prereqs)
581 exit 0;
582 ;;
583esac
584
585modprobe aufs
586mkdir -p /ro /rw /aufs
587mount -t tmpfs tmpfs /rw -o noatime,mode=0755
588mount --move $rootmnt /ro
589mount -t aufs aufs /aufs -o noatime,dirs=/rw:/ro=ro
590mkdir -p /aufs/rw /aufs/ro
591mount --move /ro /aufs/ro
592mount --move /rw /aufs/rw
593mount --move /aufs /root
594exit 0
595</pre>
596</li>
597<li><p class="first">Update the init ramdisk: <tt class="docutils literal"><span class="pre">update-initramfs</span> <span class="pre">-u</span> <span class="pre">-k</span> all</tt></p>
598<dl class="docutils">
599<dt>Note! It may be necessary to do <tt class="docutils literal">mount <span class="pre">-t</span> tmpfs tmpfs /var/tmp</tt> to help</dt>
600<dd><p class="first last">this operation succeed.</p>
601</dd>
602</dl>
603</li>
604<li><p class="first">Copy <tt class="docutils literal">/boot</tt> to <tt class="docutils literal"><span class="pre">/mnt/testbox-tftp/maintenance-boot/</span></tt>.</p>
605</li>
606<li><p class="first">Copy the <tt class="docutils literal"><span class="pre">testbox-maintenance.sh</span></tt> file found in the same directory as this
607document to <tt class="docutils literal">/root/scripts/</tt> (need to create the dir) and make it
608executable.</p>
609</li>
610<li><p class="first">Create the systemd service file for the maintenance service as
611<tt class="docutils literal"><span class="pre">/etc/systemd/system/testbox-maintenance.service</span></tt> with the content:</p>
612<pre class="literal-block">
613[Unit]
614Description=Testbox Maintenance
615After=network.target
616Before=getty&#64;tty1.service
617
618[Service]
619Type=oneshot
620RemainAfterExit=True
621ExecStart=/root/scripts/testbox-maintenance.sh
622ExecStartPre=/bin/echo -e \033%G
623ExecReload=/bin/kill -HUP $MAINPID
624WorkingDirectory=/tmp
625Environment=TERM=xterm
626StandardOutput=journal+console
627
628[Install]
629WantedBy=multi-user.target
630</pre>
631</li>
632<li><p class="first">Enable our service: <tt class="docutils literal">systemctl enable <span class="pre">/etc/systemd/system/testbox-maintenance.service</span></tt></p>
633</li>
634<li><p class="first">xxxx ... more ???</p>
635</li>
636<li><p class="first">Before leaving the chroot, do <tt class="docutils literal">mount /proc /sys <span class="pre">/mnt/testbox-*</span></tt>.</p>
637</li>
638</ul>
639</blockquote>
640</li>
641<li><p class="first">Testing the setup from a VM is kind of useful (if the nfs server can be
642convinced to accept root nfs mounts from non-privileged clinet ports):</p>
643<blockquote>
644<ul>
645<li><p class="first">Create a VM using the 64-bit debian profile. Let's call it &quot;pxe-vm&quot;.</p>
646</li>
647<li><p class="first">Mount the TFTP share somewhere, like M: or /mnt/testbox-tftp.</p>
648</li>
649<li><p class="first">Reconfigure the NAT DHCP and TFTP bits:</p>
650<pre class="literal-block">
651VBoxManage setextradata pxe-vm VBoxInternal/PDM/DriverTransformations/pxe/AboveDriver NAT
652VBoxManage setextradata pxe-vm VBoxInternal/PDM/DriverTransformations/pxe/Action mergeconfig
653VBoxManage setextradata pxe-vm VBoxInternal/PDM/DriverTransformations/pxe/Config/TFTPPrefix M:/
654VBoxManage setextradata pxe-vm VBoxInternal/PDM/DriverTransformations/pxe/Config/BootFile pxelinux.0
655</pre>
656</li>
657<li><p class="first">Create the file <tt class="docutils literal"><span class="pre">testbox-tftp/pxelinux.cfg/0A00020F</span></tt> containing:</p>
658<pre class="literal-block">
659PATH bios
660DEFAULT maintenance
661LABEL maintenance
662 MENU LABEL Maintenance (NFS)
663 KERNEL maintenance-boot/vmlinuz-3.16.0-4-amd64
664 APPEND initrd=maintenance-boot/initrd.img-3.16.0-4-amd64 ro ip=dhcp aufs=tmpfs \
665 boot=nfs root=/dev/nfs nfsroot=10.42.1.1:/export/testbox-nfsroot
666LABEL local-boot
667LOCALBOOT
668</pre>
669</li>
670</ul>
671</blockquote>
672</li>
673</ul>
674</blockquote>
675<hr class="docutils" />
676<table class="docutils footnote" frame="void" id="id6" rules="none">
677<colgroup><col class="label" /><col /></colgroup>
678<tbody valign="top">
679<tr><td class="label"><a class="fn-backref" href="#id1">[1]</a></td><td>See <a class="reference external" href="http://www.syslinux.org/wiki/index.php?title=Category:Modules">http://www.syslinux.org/wiki/index.php?title=Category:Modules</a></td></tr>
680</tbody>
681</table>
682<table class="docutils footnote" frame="void" id="id7" rules="none">
683<colgroup><col class="label" /><col /></colgroup>
684<tbody valign="top">
685<tr><td class="label"><a class="fn-backref" href="#id2">[2]</a></td><td>See <a class="reference external" href="http://www.syslinux.org/wiki/index.php?title=PXELINUX#Configuration">http://www.syslinux.org/wiki/index.php?title=PXELINUX#Configuration</a></td></tr>
686</tbody>
687</table>
688<table class="docutils footnote" frame="void" id="id8" rules="none">
689<colgroup><col class="label" /><col /></colgroup>
690<tbody valign="top">
691<tr><td class="label"><a class="fn-backref" href="#id3">[3]</a></td><td>See <a class="reference external" href="https://en.wikipedia.org/wiki/Aufs">https://en.wikipedia.org/wiki/Aufs</a></td></tr>
692</tbody>
693</table>
694<table class="docutils footnote" frame="void" id="id9" rules="none">
695<colgroup><col class="label" /><col /></colgroup>
696<tbody valign="top">
697<tr><td class="label"><a class="fn-backref" href="#id4">[4]</a></td><td>See <a class="reference external" href="http://shitwefoundout.com/wiki/Diskless_ubuntu">http://shitwefoundout.com/wiki/Diskless_ubuntu</a></td></tr>
698</tbody>
699</table>
700<table class="docutils footnote" frame="void" id="id10" rules="none">
701<colgroup><col class="label" /><col /></colgroup>
702<tbody valign="top">
703<tr><td class="label"><a class="fn-backref" href="#id5">[5]</a></td><td>See <a class="reference external" href="http://debianaddict.com/2012/06/19/diskless-debian-linux-booting-via-dhcppxenfstftp/">http://debianaddict.com/2012/06/19/diskless-debian-linux-booting-via-dhcppxenfstftp/</a></td></tr>
704</tbody>
705</table>
706<hr class="docutils" />
707<table class="docutils field-list" frame="void" rules="none">
708<col class="field-name" />
709<col class="field-body" />
710<tbody valign="top">
711<tr class="field"><th class="field-name">Status:</th><td class="field-body">$Id: TestBoxImaging.html 64523 2016-11-02 20:07:37Z vboxsync $</td>
712</tr>
713<tr class="field"><th class="field-name">Copyright:</th><td class="field-body">Copyright (C) 2010-2016 Oracle Corporation.</td>
714</tr>
715</tbody>
716</table>
717</div>
718</div>
719</body>
720</html>
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette