This is a diary/worklog that tells the story of installing windows and linux on a second harddrive in a single laptop. I publish this with the hope that it might help others facing the same problems I had.
For a project I am doing, I needed to run some windows software. I use Linux as my main
system usually Fair enough, just use a VM.
I downloaded a Windows 7 32-bit virtual machine as an .ova file at:
https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/linux/
However, the machine was really large and I did not have enough space to install it.
This was because the Virtual Disk size was set to +100 GB, but the actual disk was much smaller than that.
The .ova file is in effect a .tar archive of a .vmdk disk image and a
.ovf xml file. I untared the ova file, had a quick look in the ovf file
and created a new virtual machine using the vmdk disk.
Now I could finally run the machine and install the software I wanted, or no. It required
a 64-bit version of windows. My 32-bit installation of Linux could not run 64-bit VM's.
Installing windows on a second harddrive, how to download from DreamSpark under Linux
I have two harddrives in my laptop, I switched the the optical reader
to a holder for a second drive. I have not really used the second harddrive
yet though. I'm running 32-bit Linux as my main system on the other drive.
My university makes it possible for students to download some software
from microsoft for free via DreamSpark. I could not do this directly from
Linux though! You need to do this from a windows system. The virtual machine
I just installed worked fine though.
Soon I had (a legal copy of)
en_windows_7_professional_n_with_sp1_x64_dvd_u_677207.iso
and transfered it to my linux system using a shared folder in Virtual Box.
Loading an ISO with grub
Now, I somehow needed to run a system (real or virtual) connected to both
the installation image and the harddrive.
It seemed like GRUB could boot a disk image:
http://www.howtogeek.com/196933/how-to-boot-linux-iso-images-directly-from-your-hard-drive/
I tried this briefly, but it did not work well for me.
Connecting virtualbox to a physical disk
Maybe I could use virtualbox for the installation?
It is possible to create a vmdk file that is connected to a physical disk.
http://www.serverwatch.com/server-tutorials/using-a-physical-hard-drive-with-a-virtualbox-vm.html
larsh@blaxie:~/VirtualBox VMs$ VBoxManage internalcommands createrawvmdk -filename SecondHDD.vmdk -rawdisk /dev/sdb
RAW host disk access VMDK file SecondHDD.vmdk created successfully.
larsh@blaxie:~/VirtualBox VMs$
Now, just create a virtual machine and connect it to the ISO and the physical
disk. Oh, wait. I need to have a 64 bit virtual machine.
Hosting a 64-bit guest vm on a 32-bit host
This is possible for some processors
https://www.virtualbox.org/manual/ch03.html#intro-64bitguests
if they have the VT-x feature enabled
https://en.wikipedia.org/wiki/X86_virtualization#Intel_virtualization_.28VT-x.29
wich my processor did not have..
larsh@blaxie:~$ cat /proc/cpuinfo | grep vmx
larsh@blaxie:~$
Back to GRUB
So, trying the GRUB/iso solution once again. Some more research at
http://askubuntu.com/questions/367011/boot-windows-7-iso-from-grub2
showed that others had tried, but failed and resorted to putting the ISO
on a USB stick and then install from there.
Putting a windows ISO on a usb stick
I don't need an elegant solution, I need to get this going.
http://askubuntu.com/questions/289559/how-can-i-create-a-windows-bootable-usb-stick-using-ubuntu
sudo add-apt-repository ppa:colingille/freshlight
sudo apt-get update
sudo apt-get install winusb
larsh@blaxie:~$ sudo winusb --format en_windows_7_professional_n_with_sp1_x64_dvd_u_677207.iso /dev/sdc
Formating device...
Mounting...
mount: block device /home/larsh/en_windows_7_professional_n_with_sp1_x64_dvd_u_677207.iso is write-protected, mounting read-only
Copying...
2%
(took about 20 minutes to complete, the iso was about 2.9 GB)
Using that usb stick to reboot and install on other hdd.
Installing windows from USB stick
This could have been fine, but no. The windows installer did not like the partition
table - and did not want to create a new one nicely...
http://druss.co/2013/10/fix-error-during-installing-windows-7-from-usb-setup-was-unable-to-create-a-system-partition-or-locate-an-existing-partition/
Aaah, I'm getting quite frustrated now. I should give up and install linux64
to be able to run virtualbox with 64 bit instead...
Installing 64-bit linux distro
Downloaded
ubuntu-15.10-desktop-amd64.iso and made a bootable usb-stick from
it. Installed 64 bit linux on hdd2, went very smoothly. Booted up and installed virtualbox with apt-get. I now noticed that Virtualbox can not run 64-bit machines, even on 64-bit systems.
Nooooooooo...
Installing 64-bit windows besides linux
I kind of like having a 64-bit linux installation on my laptop as well, so I think I keep
it. But now I need to shrink the partition on the other disk.
gparted is
a nice tool! Easy to use! It is a GUI wrapper for may cool commands.
I shrinked the partition I had installed linux64 on and created a new one to
install windows on. Perhaps I have better luck this time.
The output from
fdisk for my second disk is now:
Device Boot Start End Blocks Id System
/dev/sdb1 * 2048 204802047 102400000 83 Linux
/dev/sdb2 879118334 976771071 48826369 5 Extended
/dev/sdb3 * 409602048 614402047 102400000 7 HPFS/NTFS/exFAT
/dev/sdb5 879118336 976771071 48826368 82 Linux swap / Solaris
A tutorial at
http://druss.co/2014/07/fixed-setup-was-unable-to-create-a-new-system-partition-or-locate-an-existing-system-partition-during-installing-windows-8-18-7-vista-etc-from-usb/ suggested that the installation disk should be copied to the disk, make the partition bootable and then run the installer from the hard disk without having the USB-stick inserted. I tried this.
D:\boot>bootsect.exe /nt60 c:
Target volumes will be updated with BOOTMGR compatible bootcode.
Successfully updated NTFS filesystem bootcode.
Bootcode was successfully updated on all targeted volumes.
D:\boot>
But now hdd2 needs to have the bootloader updated booting up in 64-bin linux and running update-grub
larsh@blaxie:/media/larsh/1CDCF34FDCF32226$ sudo update-grub
[sudo] password for larsh:
Generating grub configuration file ...
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
Found Ubuntu 14.04.4 LTS (14.04) on /dev/sda1
Found Windows Recovery Environment (loader) on /dev/sdb2
done
Rebooted without USB stick inserted, and the copied windows installer started fine! But, I still got same error...
Could it be that the windows installer does not like multiple disks?
I opened my laptop, took out hdd1 and rebooted. Installation now worked! :D
I created a new partition to install Windows on, as I had copied the
installation to a partition on the disk.
Making both Linux and Windows bootable
The windows installer overwrote the previous installed grub bootloader,
so I could not boot linux64 bit from hdd2 any more. But maybe I can from
hdd1? Inserted hdd1 again and booted up linux32.
The installation of windows had left hdd2 in this state:
Device Boot Start End Blocks Id System
/dev/sdb1 2048 204802047 102400000 83 Linux
/dev/sdb2 * 409602048 614402047 102400000 7 HPFS/NTFS/exFAT
/dev/sdb3 614402048 879116287 132357120 7 HPFS/NTFS/exFAT
/dev/sdb4 879118334 976771071 48826369 5 Extended
/dev/sdb5 879118336 976771071 48826368 82 Linux swap / Solaris
So I made /dev/sdb1 bootable with fdisk, and updated the bootloader in hdd1:
larsh@blaxie:~$ sudo update-grub
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.13.0-79-lowlatency
Found initrd image: /boot/initrd.img-3.13.0-79-lowlatency
...
Found linux image: /boot/vmlinuz-3.2.0-61-generic
Found initrd image: /boot/initrd.img-3.2.0-61-generic
Found memtest86+ image: /boot/memtest86+.elf
Found memtest86+ image: /boot/memtest86+.bin
Found Ubuntu 15.10 (15.10) on /dev/sdb1
Found Windows 7 (loader) on /dev/sdb2
done
larsh@blaxie:~$
So I can now boot all my three OS'es from hdd1, but only windows from hdd2.
I'm OK with this solution for now. I will change the bootloader on hdd2 to
grub later. I want my program to work, preferably two days ago.
Getting the program onto the windows disk
This was easy, the windows partition is easily mounted from linux32.
I copied the program to the desktop folder and rebooted into windows,
installation went fine. Now on to what I was supposed to do.
Conclusions
- It is possible to have three OS'es on two hard disks in a single laptop.
- Make sure that your processor can virtualize 64-bit systems before you try that.
- It is hard for the Windows 7 installer to handle multiple disks.