Clone-HOWTO(1).pdf
(
39 KB
)
Pobierz
HOWTO Clone Disk Images on Linux Booted from a Network
HOWTO Clone Disk Images on Linux Booted from
a Network
Guilherme Tupynambá
gtupy (at) uol.com.br
2002−09−09
Revision History
Revision 0.3
2002−09−24
Revised by: gct
Review suggestions incorporated
Revision 0.2
2002−09−23
Revised by: jyg
Minor revisions
Revision 0.1
2002−09−09
Revised by: gct
First draft.
This document describes a setup that allows a machine to boot Linux from BOOTP/TFTP, using the Grub
boot loader, and save and restore disk and partition images to and from a TFTP server.
HOWTO Clone Disk Images on Linux Booted from a Network
Table of Contents
1. Legal Notices.
...................................................................................................................................................1
1.1. Disclaimer.
........................................................................................................................................1
1.2. Copyright.
.........................................................................................................................................1
1.3. Feedback.
..........................................................................................................................................1
2. Introduction.
....................................................................................................................................................2
2.1. Why clone disk images.
....................................................................................................................2
2.2. Why boot from a network.
................................................................................................................2
2.3. Network boot process overview..
......................................................................................................2
3. Setting up DHCP and TFTP servers.
............................................................................................................3
3.1. Setting up DHCP
..............................................................................................................................3
3.2. Setting up TFTP.
...............................................................................................................................3
3.3. Using different servers.
.....................................................................................................................4
4. Preparing boot files.
........................................................................................................................................5
4.1. Kerne.
...............................................................................................................................................5
4.2. Files on initrd.
...................................................................................................................................5
4.3. Packing initrd.
...................................................................................................................................6
5. Booting from Grub floppy disk
.....................................................................................................................8
5.1. Grub menu file.
.................................................................................................................................8
5.2. Compiling Grub with network support.
............................................................................................8
5.3. Making the boot floppy disk.
............................................................................................................9
6. Running the clone script.
..............................................................................................................................10
6.1. Saving and restoring disk images
...................................................................................................10
6.2. Using fdisk.
.....................................................................................................................................10
7. Extending the solution.
.................................................................................................................................11
7.1. Saving and restoring files instead of file systems.
..........................................................................11
7.2. Setting up the master boot record.
..................................................................................................11
7.3. Loading necessary modules.
...........................................................................................................11
7.4. Predefined operations on grub.conf.
...............................................................................................11
A. List of files on initrd.
....................................................................................................................................12
B. Clone script.
..................................................................................................................................................13
References.
.........................................................................................................................................................16
i
1. Legal Notices
1.1. Disclaimer
This article assumes that the reader using the described setup is familiar with the technical concepts and
commands. If you are not comfortable issuing the commands in this document or don't understand the clone
script, don't try these instructions.
Additionally, if you do not know the difference between
/dev/hda
and
/dev/hda1
, please do not use this
HOWTO. This may be the difference between restoring a partition and losing all your data. Please note that I
take no responsibility for anything that may go wrong, even if the error resulting from any incorrectness in
this article.
For the purpose of this document, the RedHat 7.3 distribution has been used in both server and client.
Although this shouldn't make great difference, no test has been made on other distributions or custom setups.
1.2. Copyright
Copyright (c) 2002 Guilherme Tupynambá
Permission is granted to copy, distribute and/or modify this document under the terms of the
GNU Free
Documentation License (GFDL)
,
Version 1.1 or any later version published by the Free Software Foundation;
with no Invariant Sections, with no Front−Cover Texts, and with no Back−Cover Texts. The clone script is
licensed in the terms of the
GNU General Public License (GPL)
.
1.3. Feedback
Comments on this article will be highly appreciated. Direct your comments to
<
gtupy (at)
uol.com.br
>
.
1. Legal Notices
1
2. Introduction
2.1. Why clone disk images
The main reason to clone disk images is to ease the installation of an operating system and a basic set of
applications over a large number of machines. One standard machine is prepared and its pristine image is
saved to be restored on other machines saving efforts and simplifying procedures.
2.2. Why boot from a network
Booting from hard disk would limit the possibilities of copying images. It wouldn't be possible, for instance,
to safely copy to and from a partition mounted by the booted operating system. Also, the operating system
may not be Linux, in which case free options to clone are not available.
2.3. Network boot process overview
The client machine boots from a Grub floppy disk. Then, using the Grub BOOTP support, it gets an IP
address from a DHCP server. Next, the client machine downloads the kernel and initrd images from the TFTP
server. Once the initrd image is mounted in memory, the initialization script is run, making use of the
programs and files stored in this image. This script allows block devices contents to be saved in the TFTP
server, and contents from the TFTP server to be written to the block devices.
2. Introduction
2
3. Setting up DHCP and TFTP servers
A DHCP server is required to provide IP addresses for the clients when booting Grub (BOOTP) and later
when booting Linux. A TFTP server is required to make the boot images available on the network for Linux
to boot. The TFTP server is also necessary to make it possible to save and restore the disk images.
3.1. Setting up DHCP
Details on DHCP are beyond the scope of this article. The "Linux Networking HOWTO" has a chapter on
DHCP.
Setting up DHCP is very easy, but if you are in a network environment administered by someone else, it's
advisable to use a preexisting DHCP server. If you "own" the network then you can follow this procedure.
Install DHCP, if not installed, from the rpm package, normally found in Linux distributions:
# rpm −ihv dhcp−*.rpm
Edit the
/etc/dhcpd.conf
file to configure DHCP service. In our setup, the server has IP address 10.0.0.1
and provides IP addresses up to 253 clients. Configure
/etc/dhcpd.conf
according to your environment:
#/etc/dhcpd.conf
server−identifier dhcp.clonedomain.com;
default−lease−time 172800;
max−lease−time 604800;
option domain−name "clonedomain.com";
subnet 10.0.0.0 netmask 255.255.255.0 {
range dynamic−bootp 10.0.0.2 10.0.0.254;
}
Start the dhcpd server:
/etc/rc.d/init.d/dhcpd start
.
3.2. Setting up TFTP
Setting up TFTP is almost as easy as DHCP.
First install from the rpm package:
# rpm −ihv tftp−server−*.rpm
Create a directory for the files:
# mkdir /tftpboot
# chown nobody:nobody /tftpboot
3. Setting up DHCP and TFTP servers
3
Plik z chomika:
megaskrypty
Inne pliki z tego folderu:
3-Button-Mouse(1).pdf
(58 KB)
XWindow-Overview-HOWTO(1).pdf
(30 KB)
Xterm-Title(1).pdf
(39 KB)
Xterminals(1).pdf
(30 KB)
Xinerama-HOWTO(1).pdf
(33 KB)
Inne foldery tego chomika:
Programowanie
Zgłoś jeśli
naruszono regulamin