A server's main disk is about to fail, you see a lot os I/O error in the /var/log/messages, it's not good.
Let's clone that server before it dies. I've choosen to clone it into a VM but the steps are exactly the same with another physical machine/disk
Create or use any existing linux machine, I'm using a toolbox VM running Ubuntu on a Xen hypervisor. Create a disk about the same size as the failing one and attach it to your toolbox machine.
If the old disk is OK, copy the whole disk using dd over the network (netcat or ssh), there is a dedicated tutorial for that here : http://matfrapp.blogspot.com/2015/01/how-to-clone-disk-using-dd-over-network.html
If the old disk is not good looking and you cannot read everything but the machine still works, here is the procedure :
- Backup the MBR ```dd if=/dev/sda of=/root/mbr bs=514 count=1```
Save the UUID of the partition on a notepad, you will need it:
ls -l /dev/disk/by-uuid
-Copy it on the new host using scp for example and restore it on the new drive
```scp failingmachine:/root/mbr /tmp/oldmbr
dd if=/tmp/oldmbr of=/dev/<freshlyattacheddrive> bs=514 count=1```
Reboot the toolbox machine so the new MBR can be read. Using fdik -l, format the partitions with the same filesystem than before.
```
mkfs.ext3 /dev/xvb2
mkfs.ext4 /dev/xvb3
mkswap /dev/xvdb4
```
Change the UUID of the freshly formated partitions to match the previous UUID
EG. tune2fs /dev/xvdb3 -U 20e9a9d5-809c-4773-8d33-a0434c712345
Mount the partitions and Launch the copy
```
mount /dev/xvdb3 /mnt/newmachine
rsync -avP --numeric-ids --exclude='/dev' --exclude='/proc' --exclude='/sys' root@failingmachine:/ /mnt/newmachine
```
Remember to manually create a /dev, /proc, /sys paritition otherwise the system won't boot.
```
mkdir /mnt/newmachine/proc
mkdir /mnt/newmachine/sys
mkdir /mnt/newmachine/dev
```
Delete the /mnt/newmachine/etc/udev/rules.d/70-persistent-net.rules file
edit the /mnt/newmachine/etc/network/interfaces file to match the new NIC names if the configuration if different.
That's it
Subscribe to:
Post Comments (Atom)
Popular posts
-
Yesterday I opened my brand new Pioneer VSX-921. The goal was to build a pre-out connector to connect a real amplifier : a Rotel RA-820A. ...
-
ffmpeg -i GOPR0459.MP4 -r 24 -vf "setpts=(10/1)*PTS" -vcodec libx264 -an GOPR0459_10.MP4
-
You want to drive a passive subwoofer or amplify your Hi-Fi system with real Bi-amplification? Then this little trick will explain you how ...
No comments:
Post a Comment