Create a portable USB flash drive and run the dd command to run Linux ghost.

Source: Internet
Author: User

1. Use iso to create a portable USB flash drive.

1.0. format the USB flash drive in FAT32 format.

Commands can be used in linux

Device path of mkfs. vfat USB flash disk

For example:

Mkfs. vfat/dev/sdb

The path of the USB flash disk can be viewed by running df.

1.1, the simplest method (but in some cases it will fail, and the USB flash drive can no longer store other files, which must be formatted before use ):

Dd if = ISO path of = USB flash drive device path

For example:

Dd if = CentOS-6.5-LiveDVD.iso of =/dev/sdb4

1.2. use tools

Many tools can complete this job, and UltraISO in Windows can. Thank you, Wang Tao, you know.

UNetBootin is recommended here. It is a cross-platform open-source tool with friendly interfaces. I will not repeat it here.

Http://unetbootin.sourceforge.net/

General requirements for such tools

1.3. boot or install the system through iso

Restart the machine and choose to boot with a USB device.

If you write a Live system (similar to WinPE), you can boot a CD/U disk system.

2. Create a disk image

Sometimes you need to install the same system on a large scale (such as installing a hadoop cluster). The installation and configuration of one machine and one machine are obviously unrealistic. you can install the configuration on one machine and then create an image, you can export images directly from other machines.

You can use a third-party tool Ghost4Linux, but its functions are very limited and sometimes become invalid. Here we will introduce how to use the linux built-in command dd to complete this task.

2.0. Use a USB flash drive/CD to start a system

Theoretically, you can directly use the hard disk system to create an image. However, when creating an image, if the key file of the system is in an unstable state, the image you created may not start on other machines.

2.1. Create an image

Create an image and write it to a file on the USB flash drive.

Sudo dd bs = BYTES if = input disk of = output file

For example:

Sudo dd bs = 128 K if =/dev/sda1 of = ghost. img

The bs parameter indicates the number of bytes for an operation. The default value is 512 bytes. A larger value can improve the efficiency. However, it is recommended that the value be a multiple of 512 because the minimum disk read/write unit is a sector, one slice is 512 bytes. You can use the command dd -- help to view specific parameters. The most important thing for an individual is "K = 1024, KB = 1000"

2.1.1. compress the image

If the image is large, compression can be considered. You can use tar to compress the image after it is created, or you can compress it when it is created.

Sudo dd bs = 128 K if =/dev/sda1 | gzip> ghost.img.gz

Or

Sudo dd bs = 128 K if =/dev/sda1 | bzip2> ghost.img.bz2

Gzip is fast and bzip2 is small. It depends on the requirement.

2.2. Restore the image

Use a USB flash drive or a CD to start other machines and write the images into it.

Sudo dd bs = 128 K if = ghost. img of =/dev/sda1

2.2.1 restore a compressed image

Of course, you can decompress the package and then follow the above method. You can decompress the package and write it again:

Gzip-dc ghost.img.gz | dd bs = 128 K of =/dev/sda1

Or

Bzcat ghost.img.bz2 | dd bs = 128 K of =/dev/sda1

Reminder:
If you restore the image to another computer, you may find that your network adapter is eth1, not eth0. This is because
The/etc/udev/rules. d/70-persistent-net.rules file registers the NIC of the computer you are using as eth0.
If your network script processes eth0 but does not process eth1, you may not be able to access the Internet without modifying the network script.
You may want to delete the/etc/udev/rules. d/70-persistent-net.rules file before creating an image. In this way, when you restore the image, the NIC name is eth0. It will not cause your computer to be unable to access the Internet after recovery.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.