Candid photograph of a Linux server terminal with a soft olive-green glow against a dark slate background, conveying a calm technical atmosphere.

Step-by-step guides for system administrators — covering command-line basics, web server setup, and preparation material for technical interviews.

Browse Tutorials

Recovering a failed server disk with rsync and dd

A bare-metal recovery replaces a failed system disk with a newly prepared one while keeping the operating system, bootloader and data reachable. rsync handles file-level content efficiently; dd is useful for capturing or reproducing exact blocks such as an EFI partition or MBR boot code. Using both gives administrators a flexible restore path, but only if the partition map and firmware mode match.

Treat the target disk as destructive until proven otherwise. Record its serial number and keep one verified backup outside the source machine. The wider Linux system notes at Linuxtpoint provide useful adjacent preparation guidance, while the commands below focus on a controlled RHEL, CentOS or Fedora recovery.

Plan the restore and protect the source

Identify every filesystem before copying. Run sudo lsblk -e7 -o NAME,SIZE,MODEL,SERIAL,TRAN,FSTYPE,MOUNTPOINTS and findmnt; record the EFI system partition, /boot, root, /home, /var, and any database or application volumes. Match the destination by model and serial rather than relying on /dev/sda or /dev/sdb.

Use a scheduled arvo maintenance window and isolate the target so its automatic formatting cannot trigger. A Melbourne source with a Sydney recovery site is a practical Australian pattern, but bandwidth and retention rules still need checking. Keep the original disk untouched until the new host has passed its acceptance checks.

Capture partition and boot metadata

For an MBR disk, save the partition map and first sector: sudo sfdisk --dump /dev/sda > /mnt/recovery/sda.sfdisk and sudo dd if=/dev/sda of=/mnt/recovery/mbr.bin bs=512 count=1 conv=fsync status=progress. For GPT, use sudo sgdisk --backup=/mnt/recovery/sda.gpt /dev/sda and verify it with sudo sgdisk -v /dev/sda. Replace the device name with the recorded source disk.

On UEFI systems, image the EFI partition exactly with sudo dd if=/dev/sda1 of=/mnt/recovery/esp.img bs=4M conv=fsync status=progress. Keep the image size equal to the source partition. On BIOS systems, the saved MBR contains the boot code, while /boot contents are restored separately.

Build the rsync file backup

Create the file backup on a mounted volume outside the source root, such as /mnt/recovery. Mirror root with sudo rsync -aHAXS --numeric-ids --delete --one-file-system / /mnt/recovery/root/; --one-file-system prevents mounted data and recovery media from being pulled into root. Check the destination path carefully before allowing deletion.

Copy each separate mount explicitly, for example rsync -aHAXS --numeric-ids --delete /boot/ /mnt/recovery/boot/ and the same pattern for /home or /var. Use findmnt to avoid missing data volumes, and retain application or database backups because a running service’s files are not a substitute for a consistent database dump.

Prepare the replacement disk

For GPT, create the target layout with sudo sgdisk --load=/mnt/recovery/sda.gpt /dev/sdb. For MBR, write the captured first sector with dd if=/mnt/recovery/mbr.bin of=/dev/sdb bs=512 count=1 conv=fsync status=progress, then apply sudo sfdisk /dev/sdb < /mnt/recovery/sda.sfdisk. Confirm the serial immediately before either command.

Format the new partitions with the same filesystem family, such as mkfs.xfs for XFS or mkfs.ext4 for ext4, and mount root, /boot and /boot/efi at /mnt/target. An operator can use Magik Emacs on a workstation to review staged files, then record the change in an authorised runbook using dates such as 27/04/2026.

Restore files and reconcile identifiers

Restore root with sudo rsync -aHAXS --numeric-ids --delete /mnt/recovery/root/ /mnt/target/, then repeat for each separately backed-up mount. For the UEFI partition, write the block image with sudo dd if=/mnt/recovery/esp.img of=/dev/sdb1 bs=4M conv=fsync status=progress; keep it unmounted during the copy.

Because fresh partitions receive new UUIDs, compare blkid with the saved metadata and amend /mnt/target/etc/fstab where necessary. Run restorecon -Rv /mnt/target after the copy and inspect lsblk -f to confirm every mount. For a host that also runs mail, check service expectations against the Postfix server configuration.

Install boot code and verify the clone

After binding /dev, /proc and /sys into the chroot, install GRUB for the original firmware mode. On BIOS, use grub2-install /dev/sdb; on UEFI, mount /boot/efi and use grub2-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=RedHat. Generate /boot/grub2/grub.cfg with grub2-mkconfig, preserving signed shim and the Secure Boot policy on production systems.

Before testing, compare the copied boot code with cmp -n 446 /mnt/recovery/mbr.bin /dev/sdb and compare a complete EFI image with cmp /mnt/recovery/esp.img /dev/sdb1. Run sgdisk -v /dev/sdb for GPT targets. Any mismatch means the restore is not ready, regardless of how complete the rsync output looked.

Test the recovered system and retain evidence

Boot the replacement in an isolated network segment and test from the console. Check lsblk, findmnt, df -hT, systemctl --failed, journalctl -b -p err, application data and the backup job. Only when mounts, services and storage checks are clean is it a fair dinkum restore.

For Australian teams, AUSTRAC obligations, internal policy or customer contracts can make data residency important. An encrypted copy in an Australian region such as AWS Sydney may satisfy an approved design, but the responsible owner must confirm the rule. Keep the source and recovery evidence through the agreed rollback period.

Remember the boundary: rsync restores file content, dd reproduces blocks, and partition metadata, UUIDs and boot code must agree before the rebuilt server is trustworthy.