[ Solved ] Moving UBUNTU to a new hard drive (HD)

Discussions about using Linux guests in VirtualBox.
Post Reply
mr.deek
Posts: 9
Joined: 22. Feb 2011, 05:03
Primary OS: Ubuntu other
VBox Version: OSE Debian
Guest OSses: ALL

[ Solved ] Moving UBUNTU to a new hard drive (HD)

Post by mr.deek »

Hello,

How I moved Ubuntu 10.10 moved to new virtual disk.

--- IN HOST OS ---
Example hdd.vdmk with a size of 16gb split into 2g files.
vboxmanage createhd --filename hdd --sizebyte 17179869184 --format vmdk --variant fixed,split2g

add to the your VBox VM as SATA0 and your old one as SATA1
boot your VM use F12 to select seccond HDD to boot.
Let Ubuntu boot as normal...

--- IN UBUNTU ---

sudo su
NOTE: My new hdd location as example: /dev/sda
fdisk /dev/sda
NOTE: make one partitions (os) make active
NOTE: make smaller partition (swap) make type 82 linux swap
NOTE: write changes.

mkfs -t ext4 /dev/sda1
mkswap /dev/sda2



Apt-get install grub2
NOTE: (new hdd location: /dev/sda)
grub-install /dev/sda
mkdir /mnt/sda
mount /dev/sda /mnt/sda
rsync -vd /proc /mnt/sda/proc
rsync -vd /sys /mnt/sda/sys
rsync -vd /dev /mnt/sda/dev
rsync -vd /tmp /mnt/sda/tmp

mount -t proc proc /mnt/sda/proc
mount -t sysfs sysfs /mnt/sda/sys
mount -t devtmpfs devtmpfs /mnt/sda/dev
rsync -avP / /mnt/sda --exclude /mnt /proc /sys /dev /tmp
update-grub2

--- IN CHROOT NEW HDD UBUNTU ---
chroot /mnt/hda
update-grub2
nano /etc/fstab
NOTE: Update your UUID to the new HDD UUID you have. You can use 'blkid' to obtain the new UUID.
reboot

hold shift boot from /dev/sda (new hdd at bottem of list)
Let Ubuntu boot as normal on new hdd ...

apt-get update
apt-get install grub2
grub-install /dev/sda
update-grub2

reboot

--- IN HOST OS ---
You can now remove the old HDD as start your vm on your new copy!
Running update-grub2 now will remove the old hdd if you would like to ...

Enjoy
Mr.Deek

My Other Posts:
Post Reply