View previous topic :: View next topic |
Author |
Message |
rsborn Tux's lil' helper
Joined: 10 Feb 2004 Posts: 105 Location: Webster, NY
|
Posted: Wed Jan 17, 2007 2:40 am Post subject: Moving gentoo to new virtual hard drive in VMWare/VirtualPC |
|
|
I was going to try this (http://gentoo-wiki.com/HOWTO_Move_Gentoo_Installation_to_new_hard_disk) but I didn't like the tar command, seemed to be overkill just for a disk to disk copy but maybe not
So I have a Virtual PC based gentoo install (appliance is what vmWare would call this) and out of stupidity I kept the default virtual hard drive size of 16 gig. Since I distribute this thing to others I hate to make them extract a 16 gig image file when using it even though it zips down to under 600 meg. Now I am left with the dilemma on how to move this installation to a smaller drive. I first tried g4u (ghost for unix) but it reported an out of disk space error when trying to restore the info to a 4 gig disk file. Searching here and google I think I have probably the easiest solution for this, my apologies if this has been discussed many times before but the only ones I found were references to a custom stage4 install and a tar method, I think this one is a bit easier.
Step 1 - Use virtual Disk Wizard to create new hard drive of the desired size and attach it to the primary ide or scsi controller. I used 4 gig as a drive size attached to my primary IDE controller (in spot 2). Virtual machine needs to be shut down to attach the image file although it can be running to create the disk.
Step 2 - Power on Virtual Image and open a terminal if a GUI is running
Step 3 - run fdisk on the new virtual drive in my case this was fdisk /dev/hdb. An interesting thing about how virtualPC works with drives is that the primary controller contains /dev/hda and /dev/hdb. For the secondary controller the default master is the cd/dvd rom drive at /dev/hdc and the 3rd hard drive ends up being /dev/hdd, also for some reason the gentoo boot disk would not boot if all spots were taken, not sure why, I just eliminated the data drive I had attached to /dev/hdb to continue. It seemed to complain about not being able to mount the squashfs, I did not investigate since I had a workaround.
Step 4 - Create Partition scheme desired, I followed the same pattern as my original install with a smaller root so I had:
Partition 1: 32meg ext2
Partition 2: 512meg linux swap
Partition 3: The remaining (about 3.5 gig) ext2
Step 5 - Format partitions
Partition 1 mke2fs /dev/hdb1
Partition 2 mkswap /dev/hdb2
Partition 3 mke2fs -j /dev/hdb3 (This turns on Journaling but you probably knew that)
Step 6 - Capture a gentoo boot disk to virtual cdrom drive. I recommend the minimal install since it is the smallest
Step 7 - Reboot machine, it should boot from the cd-rom and present you with a prompt
Step 8 - Mount old drive to /mnt/gentoo and /mnt/gentoo/boot
Partition 3 mount /dev/hda3 /mnt/gentoo
Partition 1 mount /dev/hda1 /mnt/gentoo/boot
Step 9 - enable swap by running: swapon /dev/hda2
Step 10 - create mount points and mount drive to the livecd filesystem for the new drive
mkdir /mnt/newGentoo
mount /dev/hdb3 /mnt/newGentoo
mkdir /mnt/newGentoo/boot
mount /dev/hdb1 /mnt/newGentoo/boot
Step 11 - copy entire gentoo file structure to new drive using the following command:
cp -a /mnt/gentoo/* /mnt/newGentoo/ (I personally used cp -dpPR but people tell me that the -a does the same thing)
depending on the size of your install, this could take some time
Step 12 - mount proc file system
mount -t proc proc
Step 13 - install grub to new drives MBR
Type grub to enter the grub shell
then at the grub prompt type the following:
grub> root (hd0,0) (Specify where your /boot partition resides)
grub> setup (hd0) (Install GRUB in the MBR)
grub> quit (Exit the GRUB shell)
Step 14 - exit chrooted environment then unmount all mounted file systems and shutdown the virtual machine
Step 15 - Unattach old hard drive file from VirtualPC and point primary master to newly created hard drive
Step 16 - Power on virtual Machine and if all went well, it will be an exact copy of your old install excpet on a smaller drive
Rick |
|
Back to top |
|
|
matja n00b
Joined: 19 Jan 2007 Posts: 34
|
Posted: Fri Jan 19, 2007 11:26 am Post subject: |
|
|
Thanks, good instructions. I've had to do this myself a few times in the past.
My current method of moving physical machines to VM's accross the network involves netbooting a kernel with a custom initrd containing a shell and some basic tools for doing the move.
Ie:
1) netboot physical machine, bring up network and export the physical disks via ATAoE (vblade 0 0 eth0 /dev/...)
2) netboot VM, bring up network and mount the ATAoE target
3) mount the virtual disk(s) in the VM
4) copy from the physical mount to the virtual mount inside the VM
5) fix-up fstab and exit shell to boot the VM
6) install bootloaded from the Linux now booted, or netboot a GRUB disk and setup |
|
Back to top |
|
|
|
|
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
|
|