Ubuntu

How to Install ubuntu on a booby-trapped windows netbook?

Asked by Stephen Hamer on 2012-04-23

OK, here's the situation.

I have a Samsung N110 netbook which is currently running Windows XP. The windows software was supplied – already installed – with the netbook. Thus I have no external re-install option – no installation CD/DVD and no external download option – that I can use to recover my Windows system should it develop a problem. I am thus entirely reliant, in the event of a major difficulty, on the on-board recovery solution (Samsung Recovery Solution III). I want to set up a dual boot, XP-Ubuntu, system on the netbook. This should be easy, but its not. There's a problem – described in the first post in this thread:

http://www.sammynetbook.com/forum/threads/11956-N110-Dual-booting-XP-and-Ubuntu-on-N110-and-retaining-SRS-via-F4

The URL for the above thread says it all really, but just to expand a little: the unmodified Windows boot manager will not, of its own accord, find the second OS on a newly-created dual-boot system and boot it. One way round this difficulty – referred to in the above post – is to let the Ubuntu installer replace the Windows boot manager with its own boot-loader, GRUB. This appears to be a perfectly viable solution, see, for example, the 4th post in this thread (which, admittedly, relates to the N140, rather than the N110, but the principle is the same):

http://www.sammynetbook.com/forum/threads/12293-Grub-Loader?highlight=grub

But, as both the posts quoted above make clear, there is a snag with this method: allowing the ubuntu installer to over-write the Windows MBR with GRUB breaks access to Samsung's Recovery Solution via the F4-key at boot. This does not mean that the user has lost all access to the Recovery Solution. N110 dual-booters who have gone ahead and replaced the MBR with GRUB report that they can access the SRS from the GRUB boot-menu (I had a reference to another post confirming this for the N110, but I can't find it now). I can, in fact do this myself, when I boot into Ubuntu from an ext USB HDD attached to the N110.

All the same, adopting this install-approach involves some loss, albeit small, of original functionality, and this is something I would prefer to avoid.

A more serious objection to this method is that it entails making modifications to the installed Windows software – getting rid of the MBR – which are not, for the non-expert, easily revertable.

Thus what I want to do is install Ubuntu 12.04 on the netbook, keeping it as seperate as possible from the Windows system, and, in particular, making only minimal (and revertable) changes to my (deliberately, it seems to me) “fragilised” Windows set-up.

Any ideas?

Actually getting Ubuntu onto the N110 without allowing GRUB to over-write the Windows MBR seems to be straightforward enough (the installer, at least in past versions of Ubuntu, allows the user to decide where GRUB is installed), but this leaves the Windows boot-loader in place and unwilling to boot the new system, so how do you boot it? Is there a trick for this?

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu ubiquity Edit question
Assignee:
No assignee Edit question
Last query:
2012-04-24
Last reply:
2012-04-26

You can resize the NTFS in the liveCD. If it uses Windows7 then it can resize it's own partition but Ubuntu can resize NTFS ok. I suggest you run a full backup just in case of catastrophe. You can then install to the freed space and the dual boot will be automagically handled :)

Thanks for posting a reply, ap; your reassurance is heartening, but the suggestion you make does not really answer my Q. If I let ubiquity handle the install, then surely it's going to over-write the Windows MBR, which is something I want to avoid.

Would this work:

Stick an extended on the end of my D:-drive (I already have three primaries on my HD), and install 12.04 into it, plus, perhaps, an ntfs-partition to act as “common-ground” between Windows and Ubuntu.

Tell ubiquity to install grub to the start of the extended, rather than to the start of the Windows-partition, where it would normally want to put it.

Boot 12.04, using the trick described in this post:

http://www.linuxdevcenter.com/pub/a/linux/archive/dual-boot-laptop.html

In brief, make a file (“ubuntu.bin”), in some external location, containing data copied from the first 512 sectors of the linux partition, with this command:

dd if=/dev/hda2 of=/mnt/share/ubuntu.bin bs=512 count=1

Copy this file (as an administrator) to the Windows C:-drive from with the Windows-system (thus avoiding “permissions”-problems?). Then access a certain Windows file - the boot.ini-file (details omitted, but easily done) - and add this line to the end of it:

C:\UBUNTU.BIN="Ubuntu Linux"

Why the capitals in the file-name?

This procedure (apparently) gets the Windows bootloader (which is still in place) to “chainload” grub, which then takes over the boot. In practical terms, after carrying out the above procedure, and re-booting, the system should put up the Windows boot-manager-screen, offering “Ubuntu Linux”, i.e., 12.04, as an option.

This seems straightforward and requires no modifications to Windows files that cannot be easily undone; i.e., it is (in principle) easily revertible.

Ah, but does the above dodge still work (the post that suggesting it dates from 2009)? This is what I am wondering. It certainly worked once, “bodhi-zazen”, who seems to have accumulated a sackful of beans, recommended it, albeit somewhat waspishly, in this thread (also from 2009)

http://ubuntuforums.org/showthread.php?t=1032026 (bodhi.zazen)

But is this method still current and viable? Anyone done this recently?

Chris (fabricator4) said : #3

Actually, it's quite simple to back up the existing MBR and partition table, for later recovery if you wish. I suggest you investigate the bash utility dd. This command is quite capable of copying the mbr to a file on a memory stick for re-instigation at a later date if you wish. What dd copies dd can put back - it's a backup/recovery tool as well as one that can make the mbr into a bootstrap programs as listed above (bodhi). Just reverse the if (input file) and of (output file). Just make sure you've got the correct device name - I'd suggest that it should actually be /dev/sda1 in both cases, however this fact should be verified before copying or restoring the MBR to avoid disappointment or damage.

I'm also a little confused, because my understanding of the Windows recovery partition is that it is a hidden FAT partition on the hard drive at a set location. Booting into it is therefore an operation involving the BIOS hotkey (in this case <F4>) which tells it to boot into the hidden recovery partition instead of the normal bootstrap and boot partition. It's generally done this way, because if the mbr is damaged (as a Windows only machine) it's necessary to boot into the recovery partition to fix it. In other words, the OEM recovery partitions really should work independently of the MBR.

So, if the BIOS works with the OEM recovery partition as I suggest, or if you've got the MBR backed up safely, then the only thing you have to be careful off is not deleting the hidden OEM partition while you are installing Ubuntu.

I suggest backing up all important data anyway - it's SOP.

Chris

Yes the installer will overwrite the MBR with the one for Grub. You can back up the current one with dd but Grub can boot both OSes without issue. If you want to avoid this I suggest virtualize Ubuntu.

You could use Wubi too but it's not really a long term solution and a disk image of Ubuntu is loop mounted at boot but stored in NTFS. It is easily removable via add/remove programs as you would a conventional program.

Alternatively you could install to a large-ish USB/SD card and have a large persistance assigned so that updates to the OS stick. You can then use F12 (as most BIOSes use this) and change the bootable device.

A big thank you to chris and ap for taking the trouble to compose such thoughtful posts.

I am almost 100% sure ap is right: it I let grub install itself on my hd by over-writing the mbr, there would be no big problem; grub would take over all the booting that needs to be done. Specifically, it would allow me to access XP, 12.04 and SRS (in the guise of 'vista bootloader' - more on this in a moment) - all 3 options would be offered in the grub boot-menu. This is actually what happens at the moment when I run ubuntu (10.04 and 11.10) on the N110 via an external grub-enabled USB HDD (grub labels the recovery partition as 'vista bootloader'). All that I would have lost by letting grub over-write the mbr is access to SRS (the recovery solution) via the F4 key at boot - in a sense, a trivial loss. The only reason that I am not 100% sure ap is right is because I havn't actually done the install yet (It would be nice to here from someone with an N110 who has - hint, hint).

Should I then, as a nervous computer-user, 'virtualise' ubuntu? Well that's sort of what I've been doing for the last two years by running ubuntu on the N110 from an ext HDD; and it's something that I want to stop doing. I want full-strength ubuntu running on my machine, and I want it now.

Really, I feel that the boys from Seattle (or wherever they're hanging out these days) have conned me: when I first took delivery of the N110, I got the impression that installing any other OS on it would 'kill', that is, render inutile, the supplied recovery option (which seemed like a grievous loss at the time). 'Recovery' Partitions are, in this sense a bit of a scam - they masquerade as something of benefit to the user, but have hidden costs - well hidden, in my case - associated with them.

As I say, I am almost certain that an orthodox install would work, but I am still intrigued by other possibilities.

Turning now to Chris's contribution. I note what he says about the dd utility (and may well press this device into service). About the mbr, my understanding (derived from a hasty reading of a wikipedia article) is that it exists independently of the OSs installed on the HDD containing it. It contains information about how a HDD is partitioned and other matters needed (in the case of Windows, at least) by a bootloader program (which may itself be part of an OS) to load and run other OS software.

In normal boot on the N110, the C:-drive is made the active partition, and it is NTLDR (New Technology loader) - part of the XP OS - that handles the boot, albeit using info read from the mbr.

The F4 key makes the (hidden) Recovery Partition the active partition, activates the Vista bootloader (which resides on this partition, er, I think), which then boots SRS, again using info read from the mbr. Thus the vista bootloader operates independently of XP (as a sort of pale imitation of grub), but not of the mbr

If the mbr were deleted (or over-written by grub), neither of the windows bootloaders would work; the system would have to use another bootloader (grub say) for booting purposes. I could still activate vb with the F4 key, but it would go look for the mbr and find nothing; i.e., the F4-key would fail. I think this is what happens in a conventional ubuntu install, you get access (I think) to SRS, via grub, but not via the F4-key.

Regarding my own suggested solution, taken, just to remind you, from this post (page 3)

http://www.linuxdevcenter.com/pub/a/linux/archive/dual-boot-laptop.html

Could someone comment on the syntax of the dd-command:

dd if=/dev/hda2 of=/mnt/share/ubuntu.bin bs=512 count=1

I am correct in thinking, am I, that this command simply makes 1 copy of the first 512 'sectors' of the file-system /dev/hda2 and copies them (as a file - 'ubuntu.bin') to the ext volume 'share' mounted on the mnt-folder as mount-point

Chris, above, seems to suggest that the solution I outlined in my second post would work: 'dd ... a recovery tool as well as one that can make the mbr into a bootstrap program as listed above (bodhi)...'. Should I then go ahead and try it? It seems to me that it is entirely revertible, so what can I lose? If it doesn't work, or if I don't like it as a solution, I can simply nuke the partition containing grub (which will be an extended partition on the end of my D:-drive and nothing to do with the Recovery partition or the Windows C:-drive), re-edit the boot.ini-file in Windows (I can always get access to Windows via my ext USB HDD) and then go ahead with an orthodox install.

I don't know what reading all this has done for you, dear reader, but writing it has certainly clarified my mind. Before the month of May is out, I will have installed Ubuntu 12.04 on my machine, and will have reported back here on how I did it and how it turned out.

Chris (fabricator4) said : #6

Stephen said:
"I am correct in thinking, am I, that this command simply makes 1 copy of the first 512 'sectors' of the file-system /dev/hda2 and copies them (as a file - 'ubuntu.bin') to the ext volume 'share' mounted on the mnt-folder as mount-point"

That's correct, except it is 512 *bytes*, not sectors, I believe. I'd like to refine that command line a little:

sudo dd if=/dev/sda of=dosmbr.bin bs=512 count=1

If you boot the ubuntu LiveCD you will need sudo to do the copy. The first hard drive in the system will be /dev/sda
and you are writing the first 512 bytes of this to the file dosmbr.bin in the current directory. (don't forget to copy it to somewhere permanent!)

If you want to put the MBR back again at some point just reverse the input and output files:
dd if=dosmbr.bin of=/dev/sda

Note that you'd need to use sudo again in front of this, but I haven't put it there in case someone reading this cuts and pastes this line instead of the other one. The other line is harmless on all systems as all it does is read the first HDD and make 1 tiny file. The second line modifies the first hard drive and is not safe to do unless it's what you really want (ie replace the mbr with dosmbr.bin

I'd bet though that the presence of grub in the mbr of /dev/sda will in no way prevent <F4> from starting the OEM windows recovery partition. (a scrambled MBR on a windows machine is exactly one reason why you might want to boot off the OEM partition).

Note however that booting off the OEM partitions may be hazardous to the grub bootloader. Often the first thing these OEM installers do is replace the mbr with the windows one again. Not to worry! I suggest that the first thing you do after verifying that your new Ubuntu boot partitions works is to _also_ copy the mbr with the new grub2 bootloader. Just use the same dd command, but change the output file to (say) grub.bin. This way if grub ever gets broken you are never further away than a LiveCD boot from getting it going again.

Chris

Thanks for the advice, Chris - I intend to make use of it.

Can you help with this problem?

Provide an answer of your own, or ask Stephen Hamer for more information if necessary.

To post a message you must log in.