View previous topic :: View next topic |
Author |
Message |
SDNick484 Apprentice
Joined: 05 Dec 2005 Posts: 231
|
Posted: Sun Jan 06, 2013 11:06 pm Post subject: Best Way To Move An Existing Install Between Drives? |
|
|
What's the best way to migrate an existing Gentoo install between two drives? My laptop (Lenovo T400) currently has a 60GB SSD, and I picked up a much newer 120GB SSD that I'd like to move my install to. Am I better off doing a dd from one drive to the other then growing the file system, or should I do a copy? Any other thoughts or suggestions? I realize I could do a fresh install on my new drive, but I'm pretty happy with the current state and don't want to have to recompile everything. In case it matters, my laptop has a second disk drive bay instead of an optical drive, so I shouldn't be too limited in terms of bus speed. |
|
Back to top |
|
|
The Doctor Moderator
Joined: 27 Jul 2010 Posts: 2678
|
Posted: Sun Jan 06, 2013 11:33 pm Post subject: |
|
|
I believe your best course of action is to partition your new drive, mount any partitions and copy. I believe dd is very bad for SSDs because it copies everything, include empty disk space. The extra writes are, of course, bad for the SSD. Make sure your preserve your permissions when you copy (cp -ax / /mnt/newDisk). -a to preseve premissions, x to avoid coping the new disk and /proc to the new disk. more ideas on this here
Chroot and install your boot loader and you should be good to go.
NOTE: Backups are good, especially when messing with your entire system. _________________ First things first, but not necessarily in that order.
Apologies if I take a while to respond. I'm currently working on the dematerialization circuit for my blue box. |
|
Back to top |
|
|
Hypnos Advocate
Joined: 18 Jul 2002 Posts: 2889 Location: Omnipresent
|
Posted: Mon Jan 07, 2013 1:24 am Post subject: |
|
|
tar is preferred over "cp -a" because it handles hard links properly, and also because the "-a" switch is not available on many non-GNU platforms.
You would do something like this to copy files properly using tar:
Code: | # tar -cvf - / | ( cd /mnt/backup && tar -xvf - ) |
Alternatively, if you have rsync installed (as every Gentoo does), you can just use "rsync -a".
But, as The Doctor says, you should have full backups anyway, You can read about my method for regular backups. _________________ Personal overlay | Simple backup scheme
Last edited by Hypnos on Tue Jan 08, 2013 6:22 pm; edited 1 time in total |
|
Back to top |
|
|
SDNick484 Apprentice
Joined: 05 Dec 2005 Posts: 231
|
Posted: Mon Jan 07, 2013 2:29 am Post subject: |
|
|
Ah yes, rsync is a good suggestion, I will likely go that route. How well are hard links handled in rsync? On this laptop I don't have many hard links that I created myself, so it would only be ones generated by the OS/portage. My concern with a tarpipe was that the buffer size would severely limit the transfer rate.
I do have backups of all the data/media that I care about, but that's primarily limited to /home. I guess I should also back up /etc since it's fairly small and would compress very well. My concern with doing a fresh install of Gentoo on the new drive and just restoring is that I'd lose a lot of stuff that isn't portaged maintained. For example, I have a 32bit Debian chroot environment that I'd need to re-create. Also this install is a few years old and has packages no longer in portage that I still occasionally used. It's all stuff I could re-create if I really wanted to, but I'd rather not waste the time if I don't have to. |
|
Back to top |
|
|
Hypnos Advocate
Joined: 18 Jul 2002 Posts: 2889 Location: Omnipresent
|
Posted: Mon Jan 07, 2013 3:48 am Post subject: |
|
|
SDNick484 wrote: | Ah yes, rsync is a good suggestion, I will likely go that route. How well are hard links handled in rsync? On this laptop I don't have many hard links that I created myself, so it would only be ones generated by the OS/portage. |
To copy hard links as hard links pass the "-H" switch to rsync.
Quote: | My concern with a tarpipe was that the buffer size would severely limit the transfer rate. |
The SSDs may be fast enough for this to be a bottleneck, but that's something you can test with large test files.
Quote: | I do have backups of all the data/media that I care about, but that's primarily limited to /home. I guess I should also back up /etc since it's fairly small and would compress very well. My concern with doing a fresh install of Gentoo on the new drive and just restoring is that I'd lose a lot of stuff that isn't portaged maintained. For example, I have a 32bit Debian chroot environment that I'd need to re-create. Also this install is a few years old and has packages no longer in portage that I still occasionally used. It's all stuff I could re-create if I really wanted to, but I'd rather not waste the time if I don't have to. |
I back up my home directory every day, /etc every week, and everything else (except certain temporary directories) once a month. This way if I have a hard disk failure or a laptop theft I'll not lose any time to rebuilding necessary things, nor lament lost emails or family photos. _________________ Personal overlay | Simple backup scheme |
|
Back to top |
|
|
d2_racing Bodhisattva
Joined: 25 Apr 2005 Posts: 13047 Location: Ste-Foy,Canada
|
Posted: Mon Jan 07, 2013 4:24 am Post subject: |
|
|
I use rsync to switch my hardware.
I upgraded from a HDD to SSD with Rsync. |
|
Back to top |
|
|
cwr Veteran
Joined: 17 Dec 2005 Posts: 1969
|
Posted: Tue Jan 08, 2013 9:08 am Post subject: |
|
|
I've always used tar to copy filesystems as Hypnos suggested, except that I also use the p flag.
It's always worked, but there are other methods; I wouldn't use dd if I were you, since it copies
junk as well as files and needs either exact partition matching or a certain amount of tinkering.
(Definitely back up /etc, which is a pain to re-create; also /boot and /lib/modules, and /home
of course).
Will |
|
Back to top |
|
|
SDNick484 Apprentice
Joined: 05 Dec 2005 Posts: 231
|
Posted: Tue Jan 08, 2013 6:20 pm Post subject: |
|
|
Thanks again for the suggestions. I ended up going the rsync route and so far, so good. I was getting 60+MB/s after I disabled compression (limited by the slower SSD).
The exact string I ended up using was:
# rsync -av --exclude '/mnt/newroot' --exclude '/proc' --exclude '/dev' --exclude '/sys' --exclude '/net' --exclude '/lost+found' --exclude '/run' / /mnt/newroot
I should also mention I had /boot mounted under /mnt/newroot/boot, and while the contents copied fine, I forgot I had to re-run grub to install the new MBR on it. Fortunately I was able to boot off the old drive in the second drive bay to quickly make the fix. |
|
Back to top |
|
|
Wallsandfences Guru
Joined: 29 Mar 2010 Posts: 378
|
Posted: Tue Jan 08, 2013 10:29 pm Post subject: |
|
|
There is a little script called mkstage4.sh around (google it...) that does what it's called after. (Nearly) no settings or options are wanted, and it works at the actual /
It's basically a tar-command with some nice tricks and ideas.
Rüdiger |
|
Back to top |
|
|
cach0rr0 Bodhisattva
Joined: 13 Nov 2008 Posts: 4123 Location: Houston, Republic of Texas
|
Posted: Fri Jan 11, 2013 5:52 am Post subject: |
|
|
Wallsandfences wrote: | There is a little script called mkstage4.sh around (google it...) that does what it's called after. (Nearly) no settings or options are wanted, and it works at the actual /
It's basically a tar-command with some nice tricks and ideas.
Rüdiger |
should be findable here, that is, once gentoo-wiki.com comes back online - http://en.gentoo-wiki.com/wiki/Custom_Stage4
still available in google cache.
that's the method I've been using for some time now. So far so good. _________________ Lost configuring your system?
dump lspci -n here | see Pappy's guide | Link Stash |
|
Back to top |
|
|
SDNick484 Apprentice
Joined: 05 Dec 2005 Posts: 231
|
Posted: Fri Jan 11, 2013 6:38 am Post subject: |
|
|
Thanks, good to know about that mkstage4.sh for future reference. |
|
Back to top |
|
|
toralf Developer
Joined: 01 Feb 2004 Posts: 3922 Location: Hamburg
|
Posted: Fri Jan 11, 2013 2:19 pm Post subject: |
|
|
Use the adviced tar command + the tar option "-p" to preserve file attributes. |
|
Back to top |
|
|
|