PDA

View Full Version : HOWTO: Linux (Ubuntu) and Windows in Parallels from Boot Camp / rEFIt install


Milamber_Cubed
Jun 9, 2007, 08:30 AM
Moved from "Parallels Desktop for Mac"

This has been a bit of a work in progress - READ ALL THE WAY THROUGH TO THE END OF THE THREAD FOR MY LATEST ADDITIONS AND CHANGES

Hi All.

Got my MBP a week or so ago and I have now got this working pretty seamlessly, including automatic selection of xorg config at boot time, thanks to info from this threads on here and other places. I thought I would share my experience.

I'll detail what I did from the point where I had triple boot via EFI and windows "boot camp" booting properly in Parallels. There are plenty of guides out there on how to get to this point, so I won't try to re-invent the wheel.

Bear in mind that I am using Ubuntu Feisty and your distro might behave a bit differently. DO NOT try this if you are not reasonably familiar with your flavour of Linux and are happy being stranded at a command line. Also, a fair bit of this is from memory, so don't blindly follow my instructions... especially do not copy and paste! Look at the commands and think it through. I am not responsible if you hose your installation - back stuff up first!

Another thing to keep in mind is that I'm not using version 3.0 of parallels I'm using build 3188. If you have a different version, things might not (but really should) work out the same. I would be interested to see how well the Linux tools performed in this setup though. Unlikely to happen given all the bad stuff I've heard about 3.0 on this forum.... Anyway, on with the guide.

First I created a new VM, I think I chose Linux and Other Linux, and I gave it a dynamic hard disk of about 300MB. I then went off and downloaded Damn Small Linux ISO (only 50MB) and made it the boot CD for the new VM. I followed its instructions to do a full install (not frugal) to the virtual disc (cfdisk /dev/hda to create partition hda1) and eventually chose GRUB as its boot loader. Then reboot to make sure all worked okay. Once you're happy shut down the VM.

NOTE - for some reason, the VM never seems to shut down properly and I have to wait until I am sure all is done before forcing it.

Hopefully you have got to this point, otherwise I am going to be writing a lot of stuff that is no use to anyone!

Once shut down, you want to add a boot camp drive to the VM - i.e. your linux partition. I also added support for a few resolutions in the video setting at this point - especially 1440x900 for my MBP. Remember to edit the file in textedit and change the "Boot Camp" to "Boot Camp;disk0s3". In my case, I arranged the drives like so:

Virtual Disk (DSL) - IDE 0:0
Linux Partition (disk0s3) - IDE 0:1
DVD Drive (now empty) - IDE 1:0

This has the effect of making my Ubuntu partition (hd1,0) - make sure you know where your Linux partition is!

Now all that you need to do is boot into DSL again and edit the /boot/grub/menu.lst to load up your Linux installation. I mounted my ubuntu partition within DSL (mount /dev/hdb1 /mnt) so I could copy and paste the contents of the menu.lst from one to the other.

The orignal was


title Ubuntu 2.6.20-15-generic kernel
root (hd0,3)
kernel /boot/vmlinuz-2.6.20-15-generic root=UUID=d5d9c44a-d2e4-4a3b-a53f-00409e27fd59 ro quiet splash
initrd /boot/initrd.img-2.6.20-15-generic
savedefault


I changed it to be

title Ubuntu for Parallels
root (hd1,0)
kernel /boot/vmlinuz-2.6.20-15-generic root=UUID=d5d9c44a-d2e4-4a3b-a53f-00409e27fd59 ro quiet splash vga=792
initrd /boot/initrd.img-2.6.20-15-generic
savedefault


The root drive is now hd1,0 and the vga=792 allows me to see the boot splash screen. If the vga doesnt work for you, try removing everything after "ro".

Now, I think a big part of the reason this works for me is that Ubuntu uses UUID for GRUB and fstab - meaning that even if partitions/drives move around etc Ubuntu still mounts the right ones in the right places. Your mileage may vary with other distros and you may need to make some tweaks.... or you may not.

Restart DSL after you made the changes and you should be able boot into Ubuntu - YAY!. But you'll get no X server - BOO!

From here on in you'll need root privileges to do a lot of the things required so instead of putting "sudo" at the beginning of every line, I do the following:


sudo su


and enter my user password. Other distros usually let you just use "su" and enter the root password.

Now to fix the X server... You dont want to loose your current xorg.conf settings - you need them for when you want a native boot, so make a copy of it in the /etc/X11 directory as native-xorg.conf.


cd /etc/X11
cp xorg.conf native-xorg.conf


Then I had to run "dpkg-reconfigure -phigh xserver-xorg" to select the vesa driver and correct resolutions (as added to the VM earlier). This step will vary according to distro as well.

After doing this and "/etc/init.d/gdm restart" (maybe twice) you should have a working desktop. (May have to use kdm or just run startx on other distros.)


Awesome.


Not done yet though. Open up a terminal (remember to become root) and save the current settings for later use:



cd /etc/X11
cp xorg.conf parallels-xorg.conf


Now, the final piece of the puzzle is to get the system to load up the correct xorg file on boot. I use the fact that my linux partition is a different block device in native boot (/dev/sda3) and Parallels (/dev/sdb1 - NOT /dev/hdb1 for some reason)


I have a little script that does the job for me that gets run every boot just before the X server gets loaded. First off, here's the script - it should be pretty universal at least. Bear in mind that it relies on sdb1 being mounted in parallels and NOT AT ALL in native mode:


#! /bin/bash

cd /etc/X11
mount | grep sdb1 > /dev/null

if [ $? == 0 ]

then

echo Parallels booted, selecting relevant xorg file
cp parallels-xorg.conf xorg.conf

else

echo Native boot, selecting relevant xorg file
cp native-xorg.conf xorg.conf

fi


So basically, I'm looking to see if sdb1 is mounted or not and choosing the xorg config based on that. Pretty simple right? Save that somewhere sensible. I put it at /parallels/detect-xorg - remember to chmod +x the file to make it executable.

Now the slightly trickier part - making the script run at the right time.

Ubuntu defaults to runlevel 2 whereas most distros use runlevel 5 so you need to be a bit wary of this step. Also, the location of the init scripts might be different for you - look this stuff up and adapt the insrtuctions to your own distro. Knowing that Ubuntu uses run level 2, i had a look in /etc/rc2.d/ and found that gdm is started by "S13gdm".

If you do


cd /etc/rc2.d
ls -l S12gdm


you'll see that S13gdm is just a link to a different script called simply "gdm". The reason this is done is so that the scripts can be executed in the right order. To make our script execute at run level but BEFORE gdm starts, we need to link to it in this directory with a name alphabetically before S13gdm. Here's what I did


cd /etc/rc2.d
ln -s /parallels/detect-xorg S12detect-xorg


Now every time ubuntu boots it will run our script before starting X and choose the right configuration.


And that's all folks. You now have a seamless parallels way of booting your Linux install. The DSL virtual disk takes up less than 150MB on my system - which is perfectly acceptable to me in order to get this going - but a frugal install would take up only 50, if you need the extra 100MB badly. It's also a useful thing to have to try and fix things if they go wrong on your Linux partition.

I know that the quality of my guide isnt the best and the amount of detail I go into changes a lot, but there are some pretty distro-specific things to take into account and I can't really make a one size fits all guide.

Hope it's of some help though.

Good Luck!




FUTURE CHANGES

I am going to try changing my GRUB entry from

title Ubuntu for Parallels
root (hd1,0)
kernel /boot/vmlinuz-2.6.20-15-generic root=UUID=d5d9c44a-d2e4-4a3b-a53f-00409e27fd59 ro quiet splash vga=792
initrd /boot/initrd.img-2.6.20-15-generic
savedefault


TO

title Ubuntu for Parallels
root (hd1,0)
kernel /vmlinuz root=UUID=d5d9c44a-d2e4-4a3b-a53f-00409e27fd59 ro quiet splash vga=792
initrd /initrd.img
savedefault


I THINK that when ubuntu installs new kernels it updates these links in the root directory to point to the latest kernel. This would save having to boot into DSL to update its menu.lst every time there is a new kernel. I'm pretty sure that you should install any such updates in native mode - just to avoid any complications. Just thougt I'd share my musings.

Milamber_Cubed
Jun 9, 2007, 01:48 PM
A couple of things to add.

1. When I pasted this in the first time, I was doing it from memory and thought ubuntu defaults to run level 3, whereas it's actually run level 2. If anyone is having xorg issues and saw this post early on make sure you are using the right run level.

2. I've discovered that if you put your mac into sleep mode while parallels is running the Ubuntu installation, then Ubuntu doesn't like it and it hangs. If you click the pause button on the parallels window before going into sleep mode, then all is well when you wak up your mac and click on start on the parallels window.

Milamber_Cubed
Jun 14, 2007, 06:12 AM
Update:

Changing the menu.lst config within DSL to


title Ubuntu for Parallels
root (hd1,0)
kernel /vmlinuz root=UUID=d5d9c44a-d2e4-4a3b-a53f-00409e27fd59 ro quiet splash vga=792
initrd /initrd.img
savedefault


Seems to have worked. Now I will always have the latest kernel running when booting via parallels and should never need to boot into the DSL partition again :)

Sweeeeeet

fellow
Jun 14, 2007, 08:14 PM
Will this process work with ubuntu on bootcamp? I would rather note install rEFIt and DSL. Is there any way to get Parallels to recognize the Ubuntu partition and boot it?

Milamber_Cubed
Jun 15, 2007, 05:30 AM
I don't see why this wouldn't work for a Boot Camp install - but I have never used boot camp myself, so I am not 100% sure.

Post your partition table if you are at all unsure about what's going on.

If your Linux install is on disk0s3 then I THINK that you should follow this guide exactly as I have written it. You will still need to do the DSL installation, but bear in mind that you aren't installing DSL onto your boot camp partition. You make a virtual disk for it inside Parallels and after it's working you add the Boot Camp partition to the virtual machine and use the GRUB settings in DSL to load up your Ubuntu installation. This only takes up approx 130MB of extra space on your OS X partition. I think this is a small price to pay for booting your Boot Camp install within Parallels... Some might say that this should be something that Parallels takes care of by itself, but that's a totally different discussion.

billjank
Jul 31, 2007, 12:16 AM
This works for me like a champ, right up to restarting with the detect-xorg file. For some reason, I cannot get the boot script to detect properly. If I take the step of running 'dpkg-reconfigure -phigh xserver-xorg' every time, and restarting gdm, it works like a champ.

But I cannot get the script to work.

Milamber_Cubed
Jul 31, 2007, 03:35 AM
This works for me like a champ, right up to restarting with the detect-xorg file. For some reason, I cannot get the boot script to detect properly. If I take the step of running 'dpkg-reconfigure -phigh xserver-xorg' every time, and restarting gdm, it works like a champ.

But I cannot get the script to work.

I think that it might be a typo on my side. In the detect script there is a line that has


if [ $0 == 0 ]


Thinking about it, it should probably be


if [ $? == 0 ]


That's what I get for not copying and pasting. I'll fix the first post of the thread as well - thanks for the heads up!

Also, if you are still having problems after this, feel free to give me a shout in here and I'll help out any way I can.

billjank
Jul 31, 2007, 07:11 AM
Hey, that worked like a champ - I hadn't thought to go back and check the variable name.

One other suggestion that would have helped n00bs like me would be to note that most of the commands listed need to be run as the superuser (ie sudo. Only took about 1 minute to realize, but other than that it was great.

Thanks again!

Milamber_Cubed
Jul 31, 2007, 07:19 AM
No problemo.

Fair comment as regards the sudo thing. I have a habbit of running "sudo su" before starting stuff like this so I don't have to keep typing sudo in front of everything - I'll add it into the guide.

Glad it's all working for you - at least 1 person has been helped out! The 3rd post on the thread might be a useful thing to do if you haven't already. Hasn't caused me any problems and saves having to boot DSL at all.

billjank
Oct 3, 2007, 10:58 PM
I'm having a heck of a time getting this to work wiht 3.0.

I can get through the walkthrough to the point where I'm booting up Ubuntu after adjusting grub, but then it hangs without giving me a command line.

Milamber_Cubed
Oct 16, 2007, 05:15 AM
Hi,

Sorry for taking so long to get back to you. I have just (last night) upgraded to parallels 3.0 and everything worked as it should after the upgrade.

Have you tried removing the quiet splash and vga= settings from the GRUB configuration? It might be that your system is booting but you just aren't seeing the output.

Cheers,

Milamber_Cubed

Milamber_Cubed
Dec 7, 2007, 11:45 AM
Hey all,

Thought I'd update on the situation here. I've since upgraded to Parallels version 3 and all went well.

I installed parallel tools while booted in the Parallels VM and saved the X config file that parallels tools creates over the xorg-parallels file so that it gets loaded on every VM boot and I have desktop resizing and "clever" mouse support. Fun :)

After that I upgraded to the latest version of Ubuntu (Gusty), which uses XGL by default. To turn off XGL when in VM mode (so things aren't horribly slow) I had to add a couple of lines to my boot detection script.

Also, I came across an error where if I had done a native linux boot and then tried to do a parallels boot of my XP install, it would say that there was no operating system found. Also not good! This is because rEFIt changes which partition is marked as active. The way round this one is as follows: Whenever linux does a native boot, mark the windows partition as active. This is also done in my boot script using a program called "activate" - I think it's part of the lilo tools, so you'll need to do an "apt-get install lilo*" to get it onto your system.

I'll paste in my full boot up script now, so that people can have a look at all the stuff that's going on. I've changed some of the filenames, but it should be clear what's going on - hopefully the comments will be useful! Post in here if you have any questions.

Milamber_Cubed


#! /bin/bash

#Check for the existence of sdb1 - if its there then we are in a Parallels VM
mount | grep sdb1 > /dev/null

if [ $? == 0 ]

then
echo "***********************************************"
echo Parallels found, switching to VESA xorg.conf...
echo "***********************************************"
cd /etc/X11
cp vesa-xorg.conf xorg.conf
#
#Disable XGL
#
touch /home/shiv/.config/xserver-xgl/disable

#
#Automatically run the DHCP client on eth1
#to make ubuntu get network access without intervention
#
dhclient eth1

else
echo "************************************************"
echo Native boot found, switching to ATI xorg.conf...
echo "************************************************"
cd /etc/X11
cp ati-xorg.conf xorg.conf

#
#Enable XGL
#
rm -f /home/shiv/.config/xserver-xgl/disable

# Load ndiswrapper modules for built-in wifi
# ndiswrapper no longer needed - latest ath_pci compiled and installed
# modprobe ndiswrapper

# rEFIt sets the linux partition as active on boot
# this breaks windows from running in parallels
# Set windows to be the active partition again
echo "************************************************"
echo Re-setting the windows partition as active......
echo "************************************************"
/sbin/activate /dev/sda 4

fi

Milamber_Cubed
May 28, 2008, 10:44 AM
UPDATE: Upgraded to 8.04 (Hardy Heron) the other day and it all went a bit wrong. The native boot still worked but the parallels boot died during the loading of the kernel image with the following message:

'Setup signature not found'

Turns out that this is because Damn Small Linux uses a pretty old version of GRUB. Even the latest version of DSL has this problem. I worked around this by overwriting my install of DSL with Puppy Linux (downloaded puppy-4.00-k2.6.21.7-seamonkey.iso from their site) and set up the menu.lst just as before and all worked well.

Still waiting for the parallels tools support for 8.04 to come out, but at least I still have all my booting options available to me. I had to overwrite the ati-xorg.conf and vesa-xorg.conf files with new ones as auto-generated by the new version of Ubuntu so that the settings weren't lost after the next reboot, but that was just about the only problem.

Hope this info is of some help to people - I haven't really had many questions inline on the thread but have had plenty of page views. If you have any problems, post and I'll try and get back to you.

JustaceC
Sep 25, 2009, 05:27 AM
I have recently installed Gentoo on a Boot Camp split out partition. I upgraded to snow leopard, and the ran boot camp to get the drive split to two equal areas. I then installed reFit (I think that is was it was called) and then booted to linux from a linux rescue CD. At this point I removed the last partition so that I could split it up into different regions. I created three new partitions, one for boot, the second for swap and the last for the root partition. I got Gentoo installed and all is going well. I can boot into either Mac OSX or Linux at boot time though the reFit menu. Now, I would like to get parallels booting this partition. So, I went and did a custom / advanced parallels setup and then pointed it at the boot partition [ (hd0,2) in grub language ]. I had installed grub at that location. I was expecting to see a new window when I booted the virtual OS presenting me with a grub menu. Unfortunately what I was greeted with was an error saying that I need to check to make sure that I have read/write perms for that disk... I am not sure that I need to do next to fix this... Any help is appreciated.

Justace