Is it really that simple?
July 5, 2005 7:58 PM   Subscribe

Can I just copy a Linux system from one disk to another and expect it to work?

My server's main disk died on me. Ouch. And then came back to life. Yay. So I copied the contents to a new disk (with similar, but not identical partitions - the disk itself is a completely different make) using rsync --archive -H (by booting the machine from CD, running in memory, and mounting both disks). After running grub-install, editing /etc/fstab, and swapping them physically (so that /dev/hda is now the copy) everything appears to work. Should it?! Or is there some evil gotcha that will bite me in several months time? This is SuSE 9.3 (installed the day before the disk died...) and everything (/boot /usr /var /etc /dev... was on the one partition.

It took me three days to get the install working, fully configured, with all my old data on it, and just half a day to copy across. I'd rather leave it like that, but am worried it was too easy.
posted by andrew cooke to Computers & Internet (12 answers total)
back in the day when i ran linux, i did this, using another method ... it's a pain in the ass, but if you've gotten this far, you should be ok
posted by pyramid termite at 8:05 PM on July 5, 2005

Nope, you're fine from here on. The only way you would have had problems is if you hadn't created the boot sector (you did, with grub-install or if you had added/removed other hard disks or CD-ROMs, making the boot device show up differently in the order of detection (e.g. if you'd moved it from /dev/hda -> /dev/hdc)
posted by 5MeoCMP at 8:06 PM on July 5, 2005

I haven't done this with rsync, but when I used dd to make a byte-for-byte copy (also to save a system from a dying disc), I had no problems. Everything worked, as it should in principle, according to what I've read....
posted by mr_roboto at 8:07 PM on July 5, 2005

Response by poster: waheeeeee. thanks guys. i can go to bed now :o)
posted by andrew cooke at 8:10 PM on July 5, 2005

Response by poster: for the record, in case it helps anyone googling info, i didn't use dd because i was worried the disks weren't identical (and i don't really understand file systems that well). i ended up with rsync rather than cp because it had a clearer man page - turned out to be faster too (first time i used cp, but i ended up with everything owned by root...)
posted by andrew cooke at 8:14 PM on July 5, 2005

tar or cpio are the conventional tools for mirroring a disk while maintaining the proper permissions. I would expect them to run a fair bit faster than rsync... but as long as you're up and running, who cares?
posted by Galvatron at 8:39 PM on July 5, 2005

Response by poster: ah, thanks - cpio looks lit would have been the right tool from the start... next time, maybe :o)
posted by andrew cooke at 8:49 PM on July 5, 2005

I used to re-image Linux machines with a simple cp -a and it worked great.
posted by zsazsa at 9:17 PM on July 5, 2005

This is one of the reasons I like Unixy systems, stuff like this works.
posted by blm at 10:05 PM on July 5, 2005

ddrescue is a nice script for copying data off drives. It puts everything in one big file, which you mount as a filesystem ( has a page on how to do this), then you can copy things where you want them.. Great way to deal with dying disks. Or with one of those "gee, I should have used more partitions when I set this server up" days.

Linux, unlike certain other nameless OSes, doesn't hide hidden stuff all over the bloody place. It is all there where you can see it, if you are god (root, god, what is the difference?).
posted by QIbHom at 10:09 PM on July 5, 2005

Yeah, the only exception to that is the bootloader --- it needs to know where on disk to find the rest of itself, and it isn't smart enough to read the actual filesystem, so it stores a little list of sector numbers somewhere. Copying the files over will probably have put them on different sectors than they were originally, so you might need to run some utility to update that, which is what 5MeoCMP is talking about.
posted by hattifattener at 10:31 PM on July 5, 2005

True, hattifattener. I guess running grub-install becomes a habit. But, you have to set up some kind of bootloader before copying data on to any drive you wish to be bootable, no matter which OS.

I had a similar reaction to andrew cooke the first time I did something like this. It was just too easy. Then again, I'm known for muttering things at work like, "this would be easy with a proper unix system" or "you mean you have to pay for basic tools with this silly OS?"

You want to really freak out a Windows admin, ask where vi is.
posted by QIbHom at 11:13 PM on July 5, 2005

« Older Plan our holiday in the northeast!   |   2 moodle or not to moodle. Newer »
This thread is closed to new comments.