VirtualBox

Ignore:
Timestamp:
Nov 2, 2016 8:07:37 PM (9 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
111674
Message:

TestBoxImaging: Updates & service script.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/docs/TestBoxImaging.html

    r64498 r64523  
    386386<dd><ul class="first last simple">
    387387<li>backup</li>
    388 <li>redo-backup</li>
     388<li>backup-again</li>
    389389<li>restore</li>
     390<li>refresh-info</li>
     391<li>rescue</li>
    390392</ul>
    391393</dd>
     
    393395<p>Possible modifier that indicates a subset of disk on testboxes with other OSes
    394396installed.  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>
    395401</div>
    396402<div class="section" id="storage-server">
     
    400406<blockquote>
    401407<ol class="arabic simple">
    402 <li>/exports/testbox-tftp    - TFTP config area.  Read-write.</li>
    403 <li>/exports/testbox-backup  - Images and logs.  Read-write.</li>
    404 <li>/exports/testbox-nfsroot - Custom debian.  Read-only, no root squash.</li>
     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>
    405411</ol>
    406412</blockquote>
    407413</div>
    408 <div class="section" id="tftp-exports-testbox-tftp">
    409 <h1>TFTP (/exports/testbox-tftp)</h1>
     414<div class="section" id="tftp-export-testbox-tftp">
     415<h1>TFTP (/export/testbox-tftp)</h1>
    410416<p>The testbox-tftp share needs to be writable, root squashing is okay.</p>
    411417<p>We need files from both PXELINUX and SYSLINUX to make this work now.  On a
     
    419425Perform the following copy operations:</p>
    420426<pre class="literal-block">
    421 cp /usr/lib/PXELINUX/pxelinux.0 testbox-tftp/
    422 cp /usr/lib/syslinux/modules/*/ldlinux.* testbox-tftp/
    423 cp /usr/lib/syslinux/modules/bios  testbox-tftp/
    424 cp /usr/lib/syslinux/modules/efi32 testbox-tftp/
    425 cp /usr/lib/syslinux/modules/efi64 testbox-tftp/
     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/
    426432</pre>
    427433<p>For simplicitly, all the testboxes boot using good old fashioned BIOS, no EFI.
     
    445451</pre>
    446452<p>This will make the default behavior to boot the local disk system.</p>
    447 </div>
    448 <div class="section" id="images-and-logs-exports-testbox-backup">
    449 <h1>Images and logs (/exports/testbox-backup)</h1>
     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>
    450473<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>
    451480<p>We use a directory layout based on dotted decimal IP addresses here, so for a
    452 server with the IP 10.40.41.42 all its file will be under <tt class="docutils literal">10.40.41.42/</tt>.</p>
    453 <p>Files found under <tt class="docutils literal">10.40.41.42/</tt>:</p>
     481server with the IP 10.40.41.42 all its file will be under <tt class="docutils literal">10.40.41.42/</tt>:</p>
    454482<dl class="docutils">
    455483<dt><tt class="docutils literal">&lt;hostname&gt;</tt></dt>
     
    473501</dl>
    474502</div>
    475 <div class="section" id="debian-nfs-root-exports-testbox-nfsroot">
    476 <h1>Debian NFS root (/exports/testbox-nfsroot)</h1>
     503<div class="section" id="debian-nfs-root-export-testbox-nfsroot">
     504<h1>Debian NFS root (/export/testbox-nfsroot)</h1>
    477505<p>The testbox-nfsroot share should be read-only and must <strong>not</strong> have root
    478506squashing enabled.</p>
     
    484512<blockquote>
    485513<ul>
    486 <li><p class="first"><tt class="docutils literal"><span class="pre">apt-get</span> install pxelinux syslinux <span class="pre">initramfs-tools</span> gddrescue joe</tt> and
    487 optionally <tt class="docutils literal"><span class="pre">apt-get</span> install smbclient <span class="pre">cifs-utils</span></tt>.</p>
     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>
    488516</li>
    489517<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
     
    493521</li>
    494522<li><p class="first">Create the directory <tt class="docutils literal">/etc/systemd/system/getty&#64;tty1.service.d</tt> and create
    495 the file noclear.conf in it with the following content:</p>
     523the file <tt class="docutils literal">noclear.conf</tt> in it with the following content:</p>
    496524<pre class="literal-block">
    497525[Service]
     
    501529messages, which includes messages from the testbox-maintenance service.</p>
    502530</li>
    503 <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
    504 document to <tt class="docutils literal">/root/scripts/</tt> (need to create the dir) and make it
    505 executable.</p>
    506 </li>
    507 <li><p class="first">Create the systemd service file for the maintenance service as
    508 <tt class="docutils literal"><span class="pre">/etc/systemd/system/textbox-maintenance.service</span></tt> with the content:</p>
    509 <pre class="literal-block">
    510 [Unit]
    511 Description=Testbox Maintenance
    512 After=network.target
    513 Before=getty&#64;tty1.service
    514 
    515 [Service]
    516 Type=oneshot
    517 RemainAfterExit=True
    518 ExecStart=/root/scripts/testbox-maintenance.sh
    519 ExecStartPre=/bin/echo -e \033%G
    520 ExecReload=/bin/kill -HUP $MAINPID
    521 WorkingDirectory=/tmp
    522 Environment=TERM=xterm
    523 StandardOutput=journal+console
    524 
    525 [Install]
    526 WantedBy=multi-user.target
    527 </pre>
    528 </li>
    529531<li><p class="first">Mount the testbox-nfsroot under <tt class="docutils literal">/mnt/</tt> with write privileges.  (The write
    530532privileges are temporary - don't forget to remove them later on.):</p>
    531533<pre class="literal-block">
    532 mount -t nfs myserver.com:/exports/testbox-nfsroot
    533 </pre>
     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>
    534537</li>
    535538<li><p class="first">Copy the debian root and dev file system onto nfsroot.  If you have ssh
     
    544547<blockquote>
    545548<ul>
    546 <li><p class="first">Enable our service: <tt class="docutils literal">systemctl enable <span class="pre">testbox-maintenance.service</span></tt></p>
     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>
    547566</li>
    548567<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>
     
    556575an executable file with the following content:</p>
    557576<pre class="literal-block">
     577#!/bin/sh
    558578# Don't run during update-initramfs:
    559579case &quot;$1&quot; in
     
    576596</li>
    577597<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>
    578 </li>
    579 <li><p class="first">Either copy the initrd.img and corresponding kernel to the
    580 <tt class="docutils literal"><span class="pre">testbox-tftp/maintenance-boot/</span></tt> directory, or create
    581 <tt class="docutils literal"><span class="pre">testbox-tftp/maintenance-boot</span></tt> as a symbolic link to
    582 <tt class="docutils literal"><span class="pre">testbox-nfsroot/boot/</span></tt>.</p>
    583 </li>
    584 <li><p class="first">Recreate <tt class="docutils literal">/etc/fstab</tt> with:</p>
    585 <pre class="literal-block">
    586 proc          /proc    proc    defaults        0 0
    587 /dev/nfs      /        nfs     defaults        1 1
    588 # Mount tftp and backup too.
    589 </pre>
    590 </li>
    591 <li><p class="first">xxx</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>
    592637</li>
    593638</ul>
    594639</blockquote>
    595640</li>
    596 <li><dl class="first docutils">
    597 <dt>Testing the setup from a VM is kind of useful:</dt>
    598 <dd><ul class="first last">
     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>
    599645<li><p class="first">Create a VM using the 64-bit debian profile.  Let's call it &quot;pxe-vm&quot;.</p>
    600646</li>
     
    617663  KERNEL maintenance-boot/vmlinuz-3.16.0-4-amd64
    618664  APPEND initrd=maintenance-boot/initrd.img-3.16.0-4-amd64 ro ip=dhcp aufs=tmpfs \
    619          boot=nfs root=/dev/nfs nfsroot=10.42.1.1:/exports/testbox-nfsroot
     665         boot=nfs root=/dev/nfs nfsroot=10.42.1.1:/export/testbox-nfsroot
    620666LABEL local-boot
    621667LOCALBOOT
     
    623669</li>
    624670</ul>
    625 </dd>
    626 </dl>
     671</blockquote>
    627672</li>
    628673</ul>
Note: See TracChangeset for help on using the changeset viewer.

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