Tuesday, January 25, 2011

Creating a hidden Linux installation

You have a Windows pc maybe somewhat older; wife and kids are using it, and don't want to migrate to Linux; but you hate waiting endlessly till updates and virus checkers an all other bloat has finished and you want to be able to quickly boot up and access internet for example.
You want a Linux install but you don't want to present them a grub menu, even with autoboot in Windows.

If they don't mind seeing and waiting for the grub menu to pass by:
Auto-boot in Windows with grub:
# By default, boot the first entry.
default 0

#sets the delay for mounting in seconds
timeout 3

## hiddenmenu
# Hides the menu by default (press ESC to see the menu)
#hiddenmenu

# Fallback to the second entry.
fallback 1

# (0)Windows XP
title Windows XP
rootnoverify (hd0,0)
chainloader +1
makeactive

# (1) Arch Linux
title ArchBang Linux
root (hd0,7)
kernel /boot/vmlinuz26 root=/dev/sda8 ro noresume
initrd /boot/kernel26.img


You can set the grub delay; with timeout you can influence how long the menu is shown in seconds.

Hiddenmenu the simple option to hide grub

but you overwrite the MBR, the master boot record (more on that below).
As you see you also have the option hiddenmenu that you activate by editing out the # before hiddenmenu (third line). You will have to time exactly when pressing the ESC key to reach your Linux installation, when Windows is the default boot.
You will see a notification that grub is loaded and that you have to press the escape key to load the menu.
By making the timeout very short (2-3 seconds) you can also make this almost hidden too. Or use grub with 0 sec timeout and hold shift when booting for getting the grub menu.
When we want to hide it altogether and leave the mbr untouched, we have to find another way to reach the grub menu. How to arrange that , I'll show below.
But I will already reveal how we are going to do that. We will use a CDROM with the supergrub disk on it.
Hermans dual boot page explains the functionality of the supergrub disk better than I can.

Note that partition sda8 is (hd0,7).

Note further that the first entry in the menu.l st is 0 zero and the second1, etc. When I declare 1 to default, it means that the second entry in the menulist will be the default system, that is loaded without intervention or making a choice with the up/down arrow keys. This order is not corresponding to the order of partitions or so. If you put a Linux or a window distro the first entry in the menu.lst is also of no relevance as long as a default number is mentioned in the menu.lst.



Preparing the Hard Disk
I will write about a XP install.
Don't use this method on win 7: there you need the native Win 7 partition tool to shrink D see this and this post .

The backup data on D can be easily stored on a external hard drive, if you haven't enough space left. So first make D as empty as you can, move files, delete obsolete ones. Remember you will need at least 20 % free space on D after you have made D smaller. After the big cleanup do the defragmentation of D.

So you defragmented your partitions; especially the partition you want to resize. I use the free tool Auslogics Defragment for this task (don't choose the right option Bootspeed; that you will have to pay).
You will need at least 10 gb hard disk space. Optimal double the size of your memory as swap partition and the rest for the Linux install.
I put the Linux install at the end of the second partition; often C is the system partition; D is the backup partition on which all files that should be recovered in case of system crash, E is often a smaller recovery partition.
I will put the new partition after D and before E. It is not wise to change size of C in case you have to use your recovery tool that is set to a specific size of C.
Also it is save to leave the recovery partition intact.


Partitioning with GParted using a live CD

Now we can partition. I always create the partitions with GParted before an install.

If the partition seems locked
Using a live CD, you will be have to aware that if there is already a Linux install on the hard drive the live CD may have started using the swap partition; because only unmounted partitions can be partitioned that may cause a locked extended partition. In that case right click on the swap partition and swap it off.

We have to create two partitions at least swap and the file system partition; some people prefer to have a separate home partition. But if you are short of hard disk space that isn't the fist choice.
Choose ext 3 or the newer ext4 or what you want as file system.
If you're unfamiliar with partitioning using gparted there are enough tutorials with screenshots around. It is fairly simple: first resize D by sliding the ruler back to the desired size creating new unallocated space. After that is created you can create the 1,5 or 2 GB swap space and the new 10 GB partition.
After we have created the two partitions we login in Windows XP. Windows will have some adapting to do, noticing that the partition D has been resized; partition tables are adapted automatically; probably you will get a notification: new devices discovered or installed. So now Windows is OK.
Now we are installing form the live CD; using Archbang this is a fairly simple process; note that you can cancel the partition process and that you will be asked to specify the partitions; first the mount point of the swap partition is asked; than the mount point of / , the filsystem. You will have to set root password, give a username and password.

Where to install GRUB, the bootloader?
Not in the mbr!!! At least without testing the grub setup.
The critical point is the installation of the bootloader: grub has become the standard. By default it will install itself in the mbr, the master boot record.
I prefer to install the bootloader in for example sda8, in the file system of the just installed Linux installation.
Note: sometimes the option of where to install the bootloader is hidden by an advanced button; always use the advanced option to set the custom place where you want it.

The great advantage is that if you decide to install more Linux installations next to each other, each grub bootload file is easily to be found linked to its typical install.

This always leaves all options open; to install another Linux distro and to remove it again; to install grub 2 on one partition next to grub legacy on another. I will prefer to install a distro with grub legacy first on a Linux-free hard drive, because the easy of adapting it and integrating later installations.

A complicated aspect of the present situation is that 2 versions of grub are used next to each other grub legacy 0.97 and grub2. Grub 2 has some advantages but I prefer to use grub legacy because of the easy configuration. Arch comes with grub legacy as default.

So now the install is finished and we haven't touched the mbr, the master boot record.

Tada, now comes the moment supreme for the SUPERGRUB DISK

We have burned the supergrub disk iso: download here

Supergrub makes all kind of wizardry tricks with grub possible.
If you want to login on your hidden partition, put the Supergrub disk in your CD-ROM drive. Ignore the language choice and go in the main orange screen to the option Linux manual. All the boot/grub/ directories in all partitions will be shown. In the scenario I described we only have one; we only have to select it and we're sent to the grub menu and login.
This is the most secure way of testing your grub configuration before touching the mbr.
How many people haven't got shaky when they had overwritten their mbr and booting the first time weren't able to boot in XP any more and also maybe not in the Linux partition. And then had to find out how to fix the mbr. The menu.lst file in /boot/grub (which I had installed in the new Linux partition sda8) is always easily edited using an text editor like leafpad or nano, working as root from a live CD.

The big pay-off is that after you test the grub file logging in in Windows and in the new Linux install and everything is indeed OK, you can with a confident mind overwrite the MBR. For insecure newcomers, making the first Linux install, mostly always a dual boot, this will be a secure and trusted path to walk.
The whole procedure, I mean booting with help of the Supergrub cdrom goes so fast and slick that this is a feasible alternative to installing grub in the mbr. In this way you will have a completely hidden Linux installation without touching the mbr!!

So with all the other benefits of this method, this post might have well been called:

How to overwrite your mbr in the full confidence that you will have a dual boot system after doing so


Some people still don't want to touch the master boot record.
A perfect solution uses the boot.ini file to make a dual boot with Wingrub that finds your grub menu for you. Again this is clearly described in a wonderful tutorial by Herman.

When it is safe and you want install grub in the mbr, to overwrite the MBR
But if you do want to overwrite the mbr and let grub do the booting for you, you just have to use the Supergrub disk again and select grub ==>mbr & !linux! (1) auto in the main page (option two is manual and makes choice for a specific, one out of more grub installs possible).
Some people are simple terrified about touching the mbr, but the mbr is easily fixed again with the wonderful supergrub disk. See option fixmbr.
Or select win ==> mbr &!Win! in the main page.

No comments:

Blog Archive