22
14
I have a system running as a server that has a failing harddrive. While all important data is on a RAID and backed up and all that, I don't have an image of the system itself. There is no specific need as I can do the install of course, but I still want to try to do a hotcopy first before just going down the restore path. I know there are some downsides to this as a process, but there I don't think there are much downsides to trying it as a first resort.
- OS: Ubuntu 12.04.4 LTS
- Headless
- I'm not hoping to install too much new software as the disk is allready failing :)
- The system is running. I'm scared stopping it increases the chance of the disk not comming back up. This means dd might be out?
- The new disk is not the same size (it's twice as big) as the old one further complicating the dd issue.
My idea was to
- hotplug the new drive in the system
- make a filesystem
- mount it in /mnt/somedir
- rsync the files
- some fstab magic
- some booting magic
The questions I still have are:
What would be a good rsync command? I was planning on:
rsync -aAXx / /mnt/somedir/
--exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found}
(I'm skipping some more dir's, e.g. my mounted raid's etc)
Where the options are:
-a, --archive archive mode; equals -rlptgoD (no -H,-A,-X)
-A, --acls preserve ACLs (implies -p)
-X, --xattrs preserve extended attributes
-x, --one-file-system don't cross filesystem boundaries
I'm specifically skipping -H, -v and --progress to speed up the process.
Would that work for Ubuntu? I'm not sure if Ubuntu uses any hardlinks, but I don't think I need the option, do I ?
After this run I could reboot (maybe with a live usb drive) and re-run the rsync if the old disk still starts. This would fix any non-readable/changed files because the system was running I suppose.
How to fix booting?
Then my plan would be to change the UUID for /
in my fstab (still have to google how to find the uuid), and do some magic so the system actually boots from the new disk
Have I forgotten something or have I planned something specifically stupid?
This saved my a$$. I cloned 12GB+ system on Linode to brand new node. After 5+ years later, this still works. Thanks guys! – geeth – 2019-05-30T00:48:32.417
So when partitioning the cloned filesystem ready to accept the clones, should my root partition have the boot flag set while I am keeping them insync, or do I set it just before putting the cloned drive into production. Otherwise I would assume the cloned drive is then bootable which is not really wanted. In my situation my clone drive is a disk on a separate server. And Rsync is used to keep it aligned with prod. – NZ Dev – 2019-06-10T02:30:55.793
I don't believe I have them on separate systems I'm afraid, so the exclude seems prudent. I'm reading mixed stuff about the speed of - v, so I'm not sure what to do there ;). Git is a good point, I'm sure /home have some of that! – Nanne – 2014-01-30T17:19:46.197
1Well, /proc, /sys and most likely /dev are definitely different filesystems/mountpoints from /, so there is absolutely no reason to exclude those when you have -x. If you're not sure what is part of your root filesystem or not, just run
mount
to check. Anything that's in there won't need to be excluded manually. – bparker – 2014-01-30T18:23:43.980I'm not sure how and why, but the excludes were wrong anyway. They actuallywere in the dry-run I did, not sure why. (well, I copied the format from a semi-random place, so that might be the reason?). Anyway, with the -x firmly in place per your advice I didn't worry too much, only thing extra happened was that some unimportant stuff (old backups-of-backups for instance) have been 'saved' as well. – Nanne – 2014-01-31T10:01:17.407