How to make drive image on live linux system?
I want to make copy of partition/disk which is mounted and used on live server. Obviously first comes dd
in mind, but there is a problem with having non-consistent data when the process is running and something changes while copying. So it's not good.
Second comes to my mind using RAID - imaging having 2 SSDs in RAID0 as /dev/md0. I would add third SSD of the same size to /dev/md0 and RAID would take care of syncing that newly added disk with those others. When the third drive would be in sync, I would remove it from this array and I would have fully functional copy of /dev/md0 with no worries about unconsistent data. Is it right ?
Or is there some utility which would function like this without using this "RAID hack" ?
Thank you very much for any help or hints.
I assume you are using a flavour of Linux.
If you installed your system with an LVM-based partitioning schema, you can create LVM snapshots of mounted logical volumes and copy from there, ensuring a quiescent state of data during transfer.
This does not guarantee that data is consistent at snapshot creation by itself; you should also be enough diligent to stop the greatest number of services as possible, expecially DB servers and any other file write intensive application before creating the snapshot. But this should not be a real pain, since snapshot creation is almost instantaneous and you can immediately restart services back.
This method won't copy the MBR, GPT and boot loader, for that you still need a low-level copy tool like dd
, but this is just static data, so you can copy once and then update the rest of the disk by LVM snapshot method.