Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
How to migrate Gentoo installation?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
AndrejaKo
n00b
n00b


Joined: 25 Apr 2008
Posts: 25

PostPosted: Wed May 04, 2011 9:04 pm    Post subject: How to migrate Gentoo installation? Reply with quote

I want to migrate Gentoo installation from one HDD in my computer to another.

On my current HDD I have a boot, root, swap and a couple of windows partitions. I want to move the data from boot and root partitions to bigger partitions on a new HDD. How do I do this without using disk cloning tools (I have nowhere to store the partition images)?

I imagine that cp with correct settings may do it. The classical dd way looks bad in my case because I want to move data to a bigger partition.



Also where would partition lists that can cause problems be stored? I expect that I'll need to modify grub configuration and install it to new HDD's MBR. There's also the fstab which I'd need to change. Is there anything else?
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 33262
Location: 56N 3W

PostPosted: Wed May 04, 2011 9:44 pm    Post subject: Reply with quote

AndrejaKo,

I will describe the use of cp -a, others after me will recommend rsync or even tar.
Boot with a liveCD - its easier to avoid copying /proc /dev and /sys this way, at least, you can copy them provided they are not a part of a live system.

Partition your new drive the way you want it and make filesystems on the new partitions. Make a mount point to mount your new space,
Code:
mkdir /mnt/new
mount the new root partition there.

Make a mount point for the new boot
Code:
mkdir /mnt/new/boot
and mount the new boot space there.

So far, thats pretty much as for installing a new system.

Do the same for your old system ... make a mount point /mnt/old and mount the old root there. Use -o ro in the mount command. Thats read only. Its a safety net in case you copy the blank drive to your old drive.
Mount the old boot the same way.

Now you can do
Code:
cp -a /mnt/old/* /mnt/new/
to actually make the copy.
Have a coffee, it will take a while. If you get 40Mb/sec you are doing well.

With the copy done, edit /mnt/new/etc/fstab to point to the new drive and partitions.
Chroot into /mnt/new ... as per the handbook, and install grub to the MBR.
Update grub.conf so the root (hd...) points to your new /boot and the real_root= or root= statements point to your new root.
Don't forget the splashimage line too.

Reboot but go into the BIOS and choose your new drive as the boot drive. It should just boot.

If not, post the error messages. You can probably fix it by booting the old install.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
d2_racing
Moderator
Moderator


Joined: 25 Apr 2005
Posts: 13046
Location: Ste-Foy,Canada

PostPosted: Thu May 05, 2011 12:55 pm    Post subject: Reply with quote

You can also use the Rsync method.
_________________
Sysadmin of GentooQuébec.org
Wiki
Signature
IRC on Freenode : #gentoo-quebec
Back to top
View user's profile Send private message
FastTurtle
Guru
Guru


Joined: 03 Sep 2002
Posts: 413
Location: Shake & Bake

PostPosted: Fri May 06, 2011 3:40 am    Post subject: Reply with quote

NeddySeagoon: Thank you for the quick and easy explanation. Should help me once I'm ready to clone my current setup to new drives.
Back to top
View user's profile Send private message
miket
Apprentice
Apprentice


Joined: 28 Apr 2007
Posts: 240
Location: Gainesville, FL, USA

PostPosted: Fri May 06, 2011 6:18 am    Post subject: What about extended attributes? Reply with quote

I'm having quite a trouble with the moving of the installation. Since I want to do a backup as well as to transfer files, I want to use tar. (I was trying out a nice little trick. I did a big upgrade lately without the downtime for the big rounds of emerge world, revdep-rebuild, and python-updater: I copied the needed parts of /bin, /etc, /lib, /opt, /usr, and /var to another partition, did a chroot and did the updating in the chroot. My machine remained fully usable. When the updates finished, I copied everything back to my main partition.) This worked well--almost.

The odd little hitch is that tar did not copy the POSIX capabilities of /usr/bin/dumpcap (part of the wireshark package) when it copied the file. This broke wireshark for use by normal users. I took up the hint I found on the forums to set the capabilities explicitly, (setcap cap_net_admin,cap_net_raw+ep dumpcap) but what I really want is to have tar do the job for me. Everything I've read would make me think that tar should do that.

POSIX capabilities, like access-control lists, are stored as extended attributes. They say that tar is supposed to read them. I have my filesystems mounted with the user_xattr option. I am able to set and read POSIX capabilities (as root), and I can set and read normal user extended attributes. This tells me my mount options must be correct.

The problem: tar does not restore my external attributes when I untar an archive containing a file with extended attributes. I have tried this several times both with both user extended attributes and with POSIX capabilities. I both cases I can read the relevant attributes from the files before tarring them, but when I restore the files, the extended attributes disappear. I even tried again by adding the acl mount option. Still no luck.

What am I doing wrong?
Back to top
View user's profile Send private message
d2_racing
Moderator
Moderator


Joined: 25 Apr 2005
Posts: 13046
Location: Ste-Foy,Canada

PostPosted: Fri May 06, 2011 12:28 pm    Post subject: Reply with quote

Hi, you should try the rsync method :

Code:

# time rsync -aHAX --del --force --stats --progress /mnt/gentoo /mnt/backup

Or

# time rsync -aHA --del --force --stats --progress /mnt/gentoo /mnt/backup


_________________
Sysadmin of GentooQuébec.org
Wiki
Signature
IRC on Freenode : #gentoo-quebec
Back to top
View user's profile Send private message
miket
Apprentice
Apprentice


Joined: 28 Apr 2007
Posts: 240
Location: Gainesville, FL, USA

PostPosted: Fri May 06, 2011 1:07 pm    Post subject: Reply with quote

I'm glad to see that rsync would do the job for doing a copy--and it would be faster than tar to boot. This still doesn't help me to do a backup. Can tar be coaxed to do that or do I need to try some other tool?
Back to top
View user's profile Send private message
gerard82
Advocate
Advocate


Joined: 04 Jan 2004
Posts: 2243
Location: Netherlands

PostPosted: Fri May 06, 2011 9:20 pm    Post subject: Reply with quote

I regularly make backups of my system and all the rest.
I only use the method outlined by NeddySeagoon.
Simple and guaranteed not to give any problems.
Couple of years ago I still had WinXP on my box,it worked even for that!
Gerard.
_________________
To install Gentoo I use sysrescuecd.Based on Gentoo,has firefox to browse Gentoo docs and mc to browse (and edit) files.
The same disk can be used for 32 and 64 bit installs.
You can follow the Handbook verbatim.
http://www.sysresccd.org/Download
Back to top
View user's profile Send private message
miket
Apprentice
Apprentice


Joined: 28 Apr 2007
Posts: 240
Location: Gainesville, FL, USA

PostPosted: Fri May 06, 2011 11:01 pm    Post subject: Reply with quote

Yes, cp -a is the easiest way to move the files, and yes, that copies the capabilities and the other extended attributes without any problem. Yes, I could do a backup into a filesystem on a USB drive, but I do kind of like to have the backup into a single file so that I can compress it. :wink: This takes me back to needing tar, star, pax, or something similar.

By the way, I have used dd to copy whole filesystems to a larger disk. The trick was to make the target partition the same size as the original and then, after having copied the image, I used parted to expand it to the size I wanted.
Back to top
View user's profile Send private message
DNAspark99
Guru
Guru


Joined: 03 Sep 2004
Posts: 321

PostPosted: Fri May 06, 2011 11:09 pm    Post subject: Reply with quote

d2_racing wrote:
Hi, you should try the rsync method :

Code:

# time rsync -aHAX --del --force --stats --progress /mnt/gentoo /mnt/backup

Or

# time rsync -aHA --del --force --stats --progress /mnt/gentoo /mnt/backup



Wouldn't that syntax effectively cerate a /mnt/backup/gentoo directory ?


Personally, I actually migrate systems fairly often with rsync. I'd do it as follows:

1: boot liveCD

2: fdisk to setup partitions on new drive.

2: mount both disks (for my example, I'll refer to them as '/mnt/old & /mnt/new') - depending on your planned partition layout you may need to create some initial mount points on the new disk (say if /var was to be a seperate parititon) and mount them accordingly.

3: rsync -raptv /mnt/old/ /mnt/new/ (trailing slash on /mnt/old/ ensures it copies the contents of the src dir, and not the complete 'old' dir itself)

4: chroot /mnt/new /bin/bash

5: grub
root (hd0,0) (* your actual disk may be seen differently)
setup (hd0)
quit

6: exit chroot, umount & reboot (or optionally tar up the old system onto the new disk for your backup first)
Back to top
View user's profile Send private message
miket
Apprentice
Apprentice


Joined: 28 Apr 2007
Posts: 240
Location: Gainesville, FL, USA

PostPosted: Sat May 07, 2011 6:23 am    Post subject: Reply with quote

I've finally found a solution. I don't know about how GNU tar is shaping up, but app-arch/libarchive comes to the rescue. It has a command-line client, bsdtar, that records the extended attributes as I expected them.

GNU tar (app-arch/tar) is going to have to catch up. Considering the trend among distributions to get away from using the setuid bit in favor of POSIX capabilities, and considering how Gentoo tends to incorporate practices that promote security, we're going to need a tar that handles extended attributes.

In any event, I'm doing my backup with bsdtar.
Back to top
View user's profile Send private message
AndrejaKo
n00b
n00b


Joined: 25 Apr 2008
Posts: 25

PostPosted: Thu May 12, 2011 10:39 pm    Post subject: Reply with quote

I too solved my problem. A big thanks to all those who responded here!

In the end, I used the method described here: http://www.greenfly.org/tips/filesystem_migration.html.

I did get some complaints at start about missing /dev entries, but the provided guide fixed the problem.
Back to top
View user's profile Send private message
bammbamm808
Guru
Guru


Joined: 08 Dec 2002
Posts: 368
Location: Hawaii

PostPosted: Sun May 15, 2011 8:15 am    Post subject: Simple way that I've done it a few times Reply with quote

https://forums.gentoo.org/viewtopic-t-149152-highlight-.html
_________________
Asus m5a99x Evo Rev 2
Phenom II X4 965 BE
8Gb DDR3
Geforce GTX 460
Etc....
Back to top
View user's profile Send private message
JohnBlbec
Apprentice
Apprentice


Joined: 08 Feb 2003
Posts: 185

PostPosted: Mon May 16, 2011 7:35 am    Post subject: Re: How to migrate Gentoo installation? Reply with quote

AndrejaKo wrote:
I want to migrate Gentoo installation from one HDD in my computer to another.

On my current HDD I have a boot, root, swap and a couple of windows partitions. I want to move the data from boot and root partitions to bigger partitions on a new HDD. How do I do this without using disk cloning tools (I have nowhere to store the partition images)?

I imagine that cp with correct settings may do it. The classical dd way looks bad in my case because I want to move data to a bigger partition.



Also where would partition lists that can cause problems be stored? I expect that I'll need to modify grub configuration and install it to new HDD's MBR. There's also the fstab which I'd need to change. Is there anything else?


hello,

i recommend to use mc, it is simple and reliable. I have used it many times ;-)
Back to top
View user's profile Send private message
sr66
n00b
n00b


Joined: 30 May 2005
Posts: 56

PostPosted: Fri Oct 28, 2011 1:45 am    Post subject: Reply with quote

Thank you NeddySeagoon!

Your instructions were flawless and cp -a worked great.

The only places were I stumbled were

  • Partitioning: After some research I used "parted" so that I didn't have to deal with logical and extended
  • Grub Install: I fumbled here. I then found my answers here http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=1&chap=10
  • grub.conf: I changed the priority of HD with the boot partition to be the first disk in my BIOS. So I had to use hd0. Haven't touched grub in a while so it confused me.
  • swap: forgot to do a mkswap on swap partition.
  • labels: Used parted to create disk labels and used LABEL=BOOT etc in my fstab
  • LVM: configured my /usr /home etc using LVM by following this document http://www.gentoo.org/doc/en/lvm2.xml


Before starting the project my biggest worry was moving the data (from a broken/clicking disk to a new disk) but it turned out to be the easy part because of NeddySeagoon's instructions
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum