LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-12-2008, 05:04 AM   #1
sathiyadev
LQ Newbie
 
Registered: Sep 2008
Posts: 3
Blog Entries: 1

Rep: Reputation: 0
Linux Re-imaging.....


Hi friends,

I am having RHEL-5.1 in a machine. I want to re-image the set of machine (nearly 10) connect in a network with same OS (RHEL-5.1). I want to reimage the each machine weekly (it will take more than 30 min to reimage every machine). Is there is any open source available in Linux to reimage the machine with shorter time.

Previously I have tried with g4l (Linux ghost) to backup the entire OS of the particular machine. I doesn’t get any How-to’s to use g4l (Linux ghost).

Regarding this issue can someone point me to the right direction?

Thanks in advance
Sathiyadev.
 
Old 09-13-2008, 12:41 AM   #2
manoj.u.kumar
LQ Newbie
 
Registered: Apr 2007
Posts: 6

Rep: Reputation: 0
Hi

You can try using dd. Hope you will the following useful

The dd command copies data from one place to another. Sometimes cat can do the same thing (with redirection), but dd has options to translate data, selectively copy only part of a data stream, and buffer its reads and writes.

dd can copy a CD to an ISO file, copy one partition to another, or restore an image file to a disk. Using the seek and count options, an individual sector of a disk can be extracted without having to wait for the entire rest of the disk to be read.

dd may also be used to extract data from or insert data into arbitrary positions in a file. This can be useful as a way of working with binary files from the command line.

Examples

The main options to be concerned about are if= (input file) and of= (output file). By default, dd reads from stdin and writes to stdout. Here are some examples of how dd may be used:

Creating a hard drive backup directly to another hard drive

# dd if=/dev/hda of=/dev/sda conv=noerror,sync bs=4k

This command is used often to create a backup of a drive (/dev/hda) directly to another hard drive (/dev/sda). (The device name /dev/hda is typical of an IDE hard drive, the device /dev/sda is typical of a USB disk.) This works only if the hard drive has enough storage to accommodate the source drive's filesystem. The advantage of this is that you do not have to mount the hard drive to make a backup and the only reference to hda is in /dev and in the command which is usually in a script in cron.

The option "bs=4k" is used to specify the block size used in the copy. The default for the dd command is 512 bytes: use of this small block size can result in significantly slower copying. However, the tradeoff with larger block sizes is that when an error is encountered, the remainder of the block is filled with zero-bytes. So if you increase your block size when copying a failing device, you'll lose more data but also spend less time trying to read broken sectors. Tools like dd_rescue and dd_rhelp can provide a more flexible solution in such cases, combining the speed of a large block size for the regions without errors with finer-grained block-copies for regions with errors.


Creating a hard drive backup image

# dd if=/dev/hda | gzip > /mnt/hdb1/system_drive_backup.img.gz

Here dd is making an image of the first harddrive, and piping it through the gzip compression program. The compressed image is then placed in a file on a seperate drive. To reverse the process:

# gzip -dc /mnt/hdb1/system_drive_backup.img.gz | dd of=/dev/hda

Here, gzip is decompressing (the -d switch) the file, sending the results to stdout (the -c switch), which are piped to dd, and then written to /dev/hda.
Copy floppy

# dd if=/dev/fd0 of=/tmp/floppy.img bs=10240

That will copy the contents of the floppy to a file. Then, to put the image onto a new floppy, swap "if" and "of" params.

# dd if=/tmp/floppy.img of=/dev/fd0 bs=10240

Backing up your Master Boot Record (MBR).

You should do this before you edit your partition table so that you can put it back if you mess things up.

# dd if=/dev/hda of=/root/hda.boot.mbr bs=512 count=1

If things mess up, you can boot with Knoppix, mount the partition containing /root (hda1 in this example) and put back the MBR with the command:

# dd if=/mnt/hda1/root/hda.boot.mbr of=/dev/hda bs=512 count=1

Obviously, if you have a GPT system (like the intel mac for instance) this will need some adjustment.

see: http://forum.onmac.net/showthread.php?t=136

You can backup only the MBR and exclude the partition table with the command:

# dd if=/dev/hda of=/root/hda.mbr.noparttab bs=446 count=1

Getting around file size limitations using split

When making images, it's quite easy to run up against various file size limitations. One way to work around a given file size limitation is to use the split command.

# dd if=/dev/hda1 | gzip -c | split -b 2000m - /mnt/hdc1/backup.img.gz.

1. This example is using dd to take an image of the first partition on the first harddrive.
2. The results are passed through to gzip for compression
* The -c option switch is used to output the result to stdout.
3. The compressed image is then piped to the split tool
* The -b 2000m switch tells split how big to make the individual files. You can use k and m to tell switch kilobytes and megabytes (this option uses bytes by default).
* The - option tells split to read from stdin. Otherwise, split would interpret the /mnt/hdc1... as the file to be split.
* The /mnt/hdc1... is the prefix for the created files. Split will create files named backup.img.gz.aa, backup.img.gz.ab, etc.

To restore the multi-file backup, do the following:

# cat /mnt/hdc1/backup.img.gz.* | gzip -dc | dd of=/dev/hda1

1. Cat recombines contents of the compressed and split image files to stdout, in order.
2. Results are piped through gzip for decompression.
3. And are then written to the first partition of the hard drive with dd.

Creating empty disk images

To create an empty disk image, to be used as the disk for an emulator for example, one can get data from /dev/zero. To create a 10mb image:

$ dd if=/dev/zero of=myimage bs=1024 count=10240

A clever alternative is:

$ dd of=myimage bs=1024 count=0 seek=10240

Here we don't write anything, not even zeroes, we just seek 10mb into the file and close it. The result is a sparse file that is implicitly full of 10mb of zeroes, but that takes no disk space. ls -l will report 10mb, while du and df will report 0. When the file is written to, either as an emulator disk or a loopback device, Linux will allocate disk space for the data. ls will still show 10mb, while du will gradually approach 10mb.

For swap images, where it's more important to reserve the data than to save disk space, a non-sparse file is better.
Jargon File Entry

This is what the Jargon File has to say about dd:

[Unix: from IBM JCL] Equivalent to cat or BLT. Originally the name of a Unix copy command with special options suitable for block devices; it was often used in heavy-handed system maintenance, as in "Let's dd the root partition onto a tape, then use the boot PROM to load it back on to a new disk". The Unix dd(1) was designed with a weird, distinctly non-Unixy keyword option syntax reminiscent of IBM System/360 JCL (which had an elaborate DD "Dataset Definition" specification for I/O devices); though the command filled a need, the interface design was clearly a prank. The jargon usage is now very rare outside Unix sites and now nearly obsolete even there, as dd(1) has been deprecated for a long time (though it has no exact replacement). The term has been displaced by BLT or simple English "copy".

Although deprecated, dd is still widely in use on many systems.
 
Old 09-13-2008, 11:05 AM   #3
huwnet
Member
 
Registered: Jan 2006
Location: England
Distribution: Arch
Posts: 119

Rep: Reputation: Disabled
You could try looking at clonezilla.

There are also some alternatives things which you may be able to try:

--Running the OS in a VM so you can roll back using snapshots
--Some file systems support snapshots (I believe XFS via LVM is one)
--Perhaps use unionfs to copy-on-write the files you don't want to be modified
 
Old 09-15-2008, 12:17 AM   #4
sathiyadev
LQ Newbie
 
Registered: Sep 2008
Posts: 3
Blog Entries: 1

Original Poster
Rep: Reputation: 0
hi,

Thanks for your reply...

I want to re-image the other P.C connected in network (Using the same OS, which i did backup.

Here I got the information about, how to backup the entire OS image.

Thanks
sathiyadev
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Software for imaging linux SlacUser Linux - General 3 02-23-2008 12:01 AM
Is there an imaging program for Linux jacatone Linux - Software 2 04-24-2007 09:30 PM
Linux Imaging? waelaltaqi Linux - Software 1 12-12-2006 05:33 PM
imaging linux euforia Linux - Distributions 2 11-02-2004 03:22 PM
Linux Imaging??? Devboy Linux - Newbie 2 01-11-2004 09:32 PM


All times are GMT -5. The time now is 10:34 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration