-1

I am using Ubuntu 15.10 (64-bit) as a virtual machine (vmware workstation) on my desktop PC with Windows 10 Education (64-bit) being the host. With my desktop PC having enough horsepower, I can run Ubuntu just like an other app. There are no compatibility issues with Windows and vmware Workstation helping out, so I am very content with this setting.

My problem is that I have to program in OCaml for the time being and running OCaml under Windows is really no fun. The compiler has been ported to Windows (with a few adjustment and the removal of make files) by some company but there isn´t any real documentation, yet. And with cygwin there is the GPL issue I try to avoid whenever possible.

Running a virtual machine on my Laptop is possible and no problem for occasional uses but it drains the battery and can get sometimes slow.

So I created a second partition on my Laptop and installed EsayBCD on Windows 10.

While doing that, I had the idea of copying the content of my virtual machine to an external drive and from that internal drive to the newly created partition. This way I would save myself a lot of tweaking, configuring, installing (Ubuntu´s software center´s software is far too outdated and I need quite a bit of extra software). But I haven´t tried this yet, guessing that this wouldn´t just work.

I know that while I can copy Windows from one partition to an other, I cannot do so to an other PC. Googleing, I found out that this is also true for Ubuntu.

So is there a way to achieve this (without rewriting the whole OS :) )? Both PCs use an Intel core processor (though not the same one).

0

Unlike windows, linux systems can easily be cloned from one machine or disk to another as just a file copy. The only thing you have to be careful about is making sure grub is properly installed and has a working grub.cfg

If you can mount the extra partition in your VM, you should just be able to rsync your VM's files over to the new partition. You can run the rsync as many times as you like until you are ready to finish the final setup.

If the VM is on your desktop PC and the partition is on your laptop, just boot a rescue CD/USB stick on the laptop, get networking and sshd up and running, format and mount the partition, and then rsync via ssh from the running VM to the laptop's partition.

To finalise the clone, you'll need a rescue CD or USB stick. gparted or clonezilla or systemrescuecd will do.

  • install os-prober if it isn't already installed. this is so grub will be able to find your windows partition and add it to the grub boot menu.

  • Boot the rescue USB or CD.

  • get to a root shell
  • mount the target partition as, say, /target
  • bind-mount /sys, /proc, and /dev under /target

for i in proc dev sys ; do mount -o bind /$i /target/$i ; done

  • chroot /target

  • edit /etc/fstab so that it refers to your new partition. You may need to run blkid to get the UUID of the partition if you are mounting by UUID=

  • run update-grub

  • run grub-install /dev/sdX where /dev/sdX is the device name of your boot drive (probably /dev/sda`)

  • exit from the chroot

  • unmount the bind mounts and /target

for i in proc dev sys / ; do umount /target/$i ; done

  • reboot.

  • you should now get a grub menu offering you a choice of your linux distro or windows.

Astute readers will notice that this is basically identical to the procedure for cloning any other system or for repairing a broken grub install.

0

You can use dpkg --get-selections > software.txt to save a list of all packages you have installed, install Ubuntu to the laptop, copy just that file over, and run dpkg --set-selections < software.txt to reinstall all of the same applications on the new system. This is probably the easiest way.

If you really want to copy the whole system as is, then you need to copy all of the files over, then manually install grub. Boot the install cd, mount the new partition, chroot into it, and reinstall grub to make it boot:

sudo -s
mount -t ext4 /dev/sdaX /mnt
for f in proc sys dev dev/pts run; do mount --bind /$f /mnt/$f ; done
chroot /mnt
dpkg-reconfigure grub-pc

Select /dev/sda for where to install grub to and update the UUIDs in /etc/fstab ( you can see the current UUIDs with lsblk ) and you should be able to reboot from the hard drive now.

  • Yes, I really want to copy the entire OS. It´s not so much about installing the same set of programs but about having to tweak them and Ubuntu (and Ubuntu needs a lot of tweaking in my opinion). So thanks. I am going to try it later. This seems far easier than I thought it would be. I hope it will work. – Willi Dec 4 '15 at 1:40
  • @Willi, ahh, I forgot the part about updating the UUIDs in /etc/fstab that cas included in his answer ( I usually use LVM names instead of UUIDs ). – psusi Dec 4 '15 at 23:11
  • On my laptop sadaX = sada3. That's where I want grub to be installed in order to keep Windows boot loader in charge and intact. When I enter dpkg-reconfigure grub-pc and try to install grub, I get following error message: – Willi Dec 5 '15 at 14:21
  • root@ubuntu:/# dpkg-reconfigure grub-pc Generating grub configuration file ... Found linux image: /boot/vmlinuz-4.2.0-18-generic Found initrd image: /boot/initrd.img-4.2.0-18-generic Found linux image: /boot/vmlinuz-4.2.0-17-generic Found initrd image: /boot/initrd.img-4.2.0-17-generic Found linux image: /boot/vmlinuz-4.2.0-16-generic Found initrd image: /boot/initrd.img-4.2.0-16-generic Found memtest86+ image: /boot/memtest86+.elf Found memtest86+ image: /boot/memtest86+.bin – Willi Dec 5 '15 at 14:23
  • logger: socket /dev/log: No such file or directory logger: socket /dev/log: No such file or directory logger: socket /dev/log: No such file or directory logger: socket /dev/log: No such file or directory logger: socket /dev/log: No such file or directory logger: socket /dev/log: No such file or directory logger: socket /dev/log: No such file or directory logger: socket /dev/log: No such file or directory logger: socket /dev/log: No such file or directory logger: socket /dev/log: No such file or directory – Willi Dec 5 '15 at 14:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.