• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

moving linux installation to a new hard drive

oog

Golden Member
i have a gentoo installation on a laptop where i started with a pretty small hard drive. because this is a laptop, i don't it easy to add more space without replacing the whole drive. i would consider an external drive, but i may be able to get my hands on a larger laptop hard drive anyway.

anyway, what's the best way of moving my existing gentoo installation to the new hard drive? use tar to copy everything over to a new set of partitions and then install grub on the new drive? will that work?
 
I like cp.

Boot up with a cdrom to make everything easy (otherwise you have to deal with /tmp /dev/ /proc and /sys type directories) then go

cp --archive /this/mount /that/mount

tar is fine, too.

You can do some cool things, like using split to divide a tar file into many small files then compress each small file. (if you compress it before spliting then one small corruption you'll lose everything, if you compress it after splitting then if a part gets corrupted you lose only that small section).

All sorts of fun stuff.

If you have a large harddrive in a desktop that can hold your OS you can even pipe tar thru FTP and create a big tarball of your filing system on your desktop machine, then when you have the new harddrive installed you can pipe it back thru.

Or if you don't want to setup a ftp server on your desktop you can use netcat (nc), and pipe it over the network.

Then all you have to do after that is resetup grub and your set.

edit:

The only gotcha is you have to pay attention to command switches and such to preserve things like permissions and symbolic links.
 
drag this is why I prefer to do a tar | tar to do the movement of an OS to another HDD. cp can (and in my experience has) caused issues with data not being copied properly since it has no built in error correction, where tar will always bomb out if it sees any problems with data corruption (in my experience).

oog one thing to remember is that cp and tar both will do the job, neither gets the boot block therefore you may need to reinstall your MBR so that you can boot. For lilo, you would need to run lilo or for grub run grub -install. dd will get the boot block BUT since it is a block based duplication if any blocks are marked bad on the filesystem, these will be moved as well. So, you are better off using cp or tar (with my preference being tar).

with tar you could do this:

boot into a rescue environment off CD, mount the source drive and all of its partitions under /tmp/source and do the same for the destination disk under /tmp/destination then run the following command "cd /tmp/source && tar cfv - . | (cd /tmp/destination;tar xf -)" without the quotes of course. This will do a file based copy from the source to the destination. Of course to do this the filesystems on the destination have to be created beforehand (the same needs to be done with cp). Then after tar is done, "cd /tmp/destination && chroot . && grub -install" if using grub, or "cd /tmp/destination && chroot . && lilo" then you can type exit, swap disks and reboot and test the new disk.

I hope this makes sense, I do this way too often unfortunately so I might not be clear enough in the explanation. 🙂

 
thanks for the suggestions. i'll probably try the sequence of tar commands that tonyric suggested. i'm on a business trip now, away from that linux laptop so i'll have to try it maybe this weekend.

i did a quick google on ditto and linux and didn't find much. what is it?
 
tar, rsync and cp with the right options will all work.

But the only thing you have to watch out for is the bootloader. Grug is braindead in that if you install it from -say- /dev/hda t /dev/hdb, and then make hdb your primary drive it has remembered that there are hda and hdb and won't boot because it's missing hdb.

Either use the FreeBSD bootloader or you prepare the target disk with partitions and grub before you start copying, while the target disk is connected as the only disk.
 
hello again. i copied everything through tar while booted up through a boot cd. i then physically installed the new hard drive (while copying it was in a hard drive enclosure), and installed grub. it looks like everything is running smoothly. thanks for the help!
 
oog, did I get the command correct? I ran that off the top of my head, so I would love to know if I made any mistakes in syntax. 🙂
 
well, my initial copy was done using the command that you wrote. i then had to shutdown, swap hard drives and re-mount the new drive partitions, and then chroot. the grub command that you gave wasn't quite right. i ended up running grub and doing the commands from the command-line. i think that grub-install needed some other parameters and you were specifying grub -install. but overall it got me close enough that i could finish the job 🙂
 
Back
Top