Clone a Linux System Using rescue's Skip Mode

Source: Internet
Author: User

Although the Linux system can be directly backed up using tar, cpio, dd, and other methods, if the system is running, the backup system cannot be completely clean. Therefore, you can use the rescue's skip mode to back up the operating system and recreate initrd. img and grub to clone Linux instances across hardware platforms. The following uses RHEL6.2 as an example for testing. This method can also be used to back up Windows systems.

Build a Linux rescue Environment

  • Create a local rescue Environment
  1. # Cp-rp/mnt/RHEL6/images // boot // copy the images directory from the system disk to the corresponding directory.
  2. # Vi/etc/grub. conf // Add the following content to the grub. conf file:
  3. Title RHEL6_rescue
  4. Kernel/boot/images/pxeboot/vmlinuz rescue
  5. Initrd/boot/images/pxeboot/initrd. img
  • Create a PXE-based rescue Environment
For more information about how to set up the PXE environment, see "DHCP + TFTP + PXE automatic network boot to install Linux OS". For more information, see: You can also start the environment by using a system disk and select to enter the rescue environment.

Backup/clone Linux

  1. # Mkdir/source/backup
  2. # Mdadm-As/dev/md0 // if the system partition is created on RAID
  3. # Lvm vgscan // if the system partition is created on LVM
  4. # Lvm vgchange-a y/dev/Lrhel6
  5. # Mount/dev/Lrhel6/root/source // mount all system directories according to the actual system conditions
  6. # Mount/dev/Lrhel6/home/source/home
  7. # Mount/dev/sda1/source/boot
  8. # Mount/dev/Lrhel6/backup
  9. # Tar zcvf/backup/OS. tgz/source // back up a clean System File

Restore/migrate Linux

Start the system to enter the rescue Skip Mode
  1. # Fdisk/dev/sdb // partition the Newly Added Disk
  2. # Mkdir/backup/dest
  3. # Mount/dev/sda2/backup
  4. # Mount/dev/sdb2/dest
  5. # Tar zxvf/backup/OS. tgz/dest
  6. # Vi/dest/etc/grub. conf // edit the grub configuration file as needed
  7. # Vi/dest/etc/fstab // edit the fstab file based on the actual situation
  8. # Rm-rf/dest/etc/mtab // Delete the mtab file. After logging on to the system, the mtab file is automatically created.
  9. # Exit
  10. Reboot
  11. Restart the system to enter the rescue Continue mode, re-produce initramfs, and install grub
  12. # Chroot/mnt/sysimage
  13. # Cd/boot
  14. # Mkinitrd-f initramfs-$ (uname-r). img $ (uname-r) // regenerate the initramfs File
  15. # Grub-install -- recheck -- no-floppy/dev/sda
  16. If the prompt "cocould not find device" is displayed, exit the root partition and reinstall grub, and specify the path of the root partition.
  17. # Exit
  18. # Cp/mnt/sysimage/sbin/grub/sbin
  19. # Grub-install -- recheck -- no-floppy -- root-directory =/mnt/sysimage/dev/sda
  20. # Exit
  21. # Exit
  22. Reboot

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.