Create a bootable USB drive system under Linux and use the DD command for Linux Ghost

Source: Internet
Author: User

1. Create a bootable USB drive system with ISO.

1.0. Format USB flash drive to FAT32 format

Commands can be used under Linux:

Mkfs.vfat device path for USB flash drive

Like what:

Mkfs.vfat/dev/sdb

The path of the U disk can be viewed by command DF (DF-H)

extension: mkfs command usage : Format the partition with a specific file system, the file system is specified by adding a dot to the command and the file system name (the command line can double-click the TAB key to see if the current system supports creating those types of file systems)

Create FAT32 partition Mkfs.vfat

Create an NTFS partition, MKFS.NTFS

Create EXT2 partition Mkfs.ext2

Create EXT4 partition MKFS.EXT4

1.1, the simplest method (but some cases will fail, and the USB stick can no longer put other files, need to format after the ability to use again):

DD If=iso path to the device of the Of=u disk

Like what:

DD If=centos-6.5-livedvd.iso OF=/DEV/SDB4

1.2, using the tool

Very many tools are able to finish this work, Windows UltraISO can, thank you Wang Tao, you understand.

UNetbootinis recommended here, it is a cross-platform open source gadget, the interface is very friendly, here do not repeat. (UNetbootin was used at the back end of the "Deepin boot Maker" released on June 11, 2014)

http://unetbootin.sourceforge.net/

1.3. Booting or installing the system via ISO

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

Assuming that you are writing a live-form Linux system (similar to WinPE), you can boot a CD/u disk system.


2. Create and restore disk images

Sometimes it is necessary to install the same system on a large scale (such as installing a Hadoop cluster), a machine with a machine installation configuration is obviously unrealistic, can be installed in a machine configuration, and then create a mirror, on other machines directly export the image.

The ability to use third-party tools Ghost4linux, but it is very limited, and sometimes invalid, here is how to use the Linux built-in command DD to complete this task.

2.0. Start a system with a USB flash drive/disc

It is theoretically possible not to do so, and to use the hard disk system directly to make the image, but the use of this method is limited to backup non-critical location partition. In detail: (1) Assume that to create a mirror about the operating system, when creating the image, assume that an important file of the system is the advantage of an unstable state, the image you created may not start on other machines. (2) Another common problem is that the image that needs to be created is for the entire disk, not for a partition, so it is not clear that the output image file is on the local disk that is being backed up.

Therefore, it is also theoretically possible to select the disk to be operated (backup/restore) mounted on another machine as a slave disk.

2.1, create mirror

Create a mirror and write to a file on a USB flash drive

sudo dd bs=bytes if= input disk of= output file

Like what:

sudo dd bs=128k if=/dev/sda1 of=ghost.img

The BS reference indicates how many bytes are to be manipulated at one time, the default is 512 bytes, and the appropriate size increases the efficiency, but it is important to note that a multiple of 512 is preferable, because the minimum unit of disk read and write is the sector, and a sector is 512 bytes. Detailed parameters can be viewed using the command DD--help, the most important thing for the individual is "k=1024,kb=1000"

2.1.1, compress image

Assuming that the image is very large, it is possible to consider compression, be able to create it after using tar compression, and also be able to create compression.

sudo dd bs=128k if=/dev/sda1 | gzip > ghost.img.gz

Or

sudo dd bs=128k if=/dev/sda1 | bzip2 > ghost.img.bz2

Gzip Fast, bzip2 small, see demand decision.


The blogger test shows that the image size created is not compressed to disk size ..... must be compressed .

When not compressed bs=128k speed of about 284m/s, with gzip bs=128k speed of about 113m/s, using gzip bs=512k speed about 120m/s, using gzip bs=1m speed about 130m/s, using gzip bs= The speed of the 10M is approximately 128m/s.

The blogger details here may not be of much value, and bloggers simply want to explain briefly the effects of compression and BS values on speed.

Therefore: recommended to use 1M or 2M as a BS value , too small slow, too big meaningless.


2.2, Restore image

Start the other machine with a USB flash drive/CD and write the image.

sudo dd bs=128k if=ghost.img of=/dev/sda1

2.2.1, recovering the compressed image

Of course, can be extracted and then according to the above method to do, but also can be decompressed once again write:

GZIP-DC ghost.img.gz | DD bs=128k OF=/DEV/SDA1

Or

Bzcat ghost.img.bz2 | DD bs=128k OF=/DEV/SDA1



Originally contained in Http://blog.csdn.net/yanxiangtianji

Reprint please indicate the source



Below from: http://blog.csdn.net/shendl/article/details/7384755

Remind:
If you restore the image to a computer, you may find that your network card is eth1, not eth0. This is due to
The/etc/udev/rules.d/70-persistent-net.rules file registers the network card of your mirrored computer as eth0.
Assuming that your network script handles eth0 and does not process the eth1, you may not be able to surf the web without altering the network scripts.
You might want to delete the/etc/udev/rules.d/70-persistent-net.rules file before you do the image (Bo main note: This file records the relationship between the PCI device designator and the displayed device name, If it does not exist, it will take the initiative to generate a new file based on the current device connection, and can safely delete it. So you restore the mirror, the name of the network card is eth0 (Bo main note: If your device has not only a piece of network card, then for some cases still need to manually adjust). It won't cause you to be unable to surf the internet on your restored computer.



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.