How do I create a compressed backup image of a Red Hat Enterprise Linux machine to an external drive using dd?
Environment
- Red Hat Enterprise Linux 4
- Red Hat Enterprise Linux 5
- Red Hat Enterprise Linux 6
- Red Hat Enterprise Linux 7
Issue
- How do I create a compressed backup image of a Red Hat Enterprise Linux machine to an external drive using dd?
- Is it possible to create an image of installed system and use it to boot the system?
Resolution
Disclaimer: The following information has been provided by Red Hat, but is outside the scope of our posted Service Level Agreements and support procedures. The information is provided as-is and any configuration settings or installed applications made from the information in this article could make your Operating System unsupported by Red Hat Support Services. The intent of this article is to provide you with information to accomplish your system needs. Use the information in this article at your own risk.
To create a compressed disk image with "dd" :
-
Boot into rescue mode with the installation media
-
Create a mount point for your external drive:
# mkdir /mnt/external
-
Mount your external drive:
# mount /dev/sdb1 /mnt/external
-
Create the compressed disk image:
# dd if=/dev/sda | gzip -9 > /mnt/external/filename.img.gz
To recover this in future, run the following command :
# zcat /mnt/external/filename.img.gz | dd of=/dev/sda
Note: Do not use dd to backup block devices that are currently in use. Doing so will likely cause inconsistency on the filesystem(s).
Create an image of installed system
- To create an image of installed system, get
USB
of exact same size. - Recreate the initrd with USB support
# vi /etc/dracut.conf
add_drivers+="ehci-hcd uhci-hcd xhci-hcd usb-storage scsi-mod sd-mod sd hid-microsoft hid-generic usbhid"
# dracut -f -v
- Force a file check on boot
# touch /forcefsck
- Create image using
dd
command:
# dd if=/dev/sda of=/dev/<usb device> bs=8192
- Add any subsequent partitions to the usb drive in 4gb chunks.
- Insert usb and boot machine.
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Comments