
They brought me the other day the hard drive right in the package and puzzled us with the operational cloning of the system disk of one of the servers. The task is, on the whole, rather trivial, and easily doable. Everyone probably has a technique of this kind of action, I don’t know better or worse my approach, but I think they should share this.
Introductory:*
linux server
*
all partitions on
XFS*
GRUB 0.97 bootloader
* original disk
/ dev / sda , clone to
/ dev / sdb* sections / dev / sda [1,5-7] (general useful information ~ 1GB)
In essence, the task is decomposed into its components:
- mark up the new disc as well as the original
- copy data to a new disk
- make a new disk bootable
And this is how it is done:
sfdisk -d / dev / sda | sfdisk / dev / sdb
xfs_copy / dev / sda1 / dev / sdb1
xfs_copy / dev / sda5 / dev / sdb5
xfs_copy / dev / sda6 / dev / sdb6
xfs_copy / dev / sda7 / dev / sdb7
grub
> root (hd1,0)
> setup (hd1)
Done! By time ~
30 seconds .
Now in detail with explanations:
1. Copying the partition table to / dev / sdb is done with sfdisk
2. xfs_copy copies useful data and, if necessary, automatically formats partitions that wish to remount partitions in readonly or use xfs_freeze while copying to preserve data integrity.
3. The grub configuration (version
0.97! ) In /boot/grub/menu.lst should look something like this:
default 0
timeout 5
color cyan / blue white / blue
title Debian GNU / Linux, kernel 2.6.30-2-686
root (hd0,0)
kernel /boot/vmlinuz-2.6.30-2-686 root = / dev / sda1 ro
initrd /boot/initrd.img-2.6.30-2-686
With the grub - root, setup commands we make the second disk bootable.
4. When two disks work, the second disk is identified as / dev / sd
b , if the original disk is put out, the second disk will be / dev / sd
a . Hence the conclusion that you do not need to change / etc / fstab. However, on some Linux, in / etc / fstab, instead of / dev / sd
XN, there may be partition identification by UUID. In this case, there are two options:
- we copy xfs_copy with a key-
d (we do full cloning, including UUID)
- change in / etc / fstab all UUIDs to the corresponding / dev / sda
N (where N is the partition number, the blkid command will help you with this)
')
PS grub2 did not set, if someone has a similar experience of replicating the bootloader to the second disk, share.