Showing posts with label grub. Show all posts
Showing posts with label grub. Show all posts

Saturday, August 28, 2010

Install Ubuntu from a Linux partition

Its been far too long, so I thought I'd post something :)

Generally the prefered method of installing Ubuntu is via CD or (these days) from a USB stick.
But there is also another way if you already have an existing Linux partition around.

I'll list down the steps to installing Ubuntu from the hard disk itself without using any other external media.

To perform this installation I used the Maverick (ubuntu 10.10) pre-beta image from 27th Aug 2010. This has been tested with the alternate ISO. I have not tested this using the live ISO.

Step 1
Download the alternate ISO image from your local mirrors or use bittorent, or any other method.

Step 2
Download the vmlinuz and initrd.gz files from here:


In my case it is "maverick". Change the URL according to the version of ubuntu you want to install

Step 3
You need to place these two files (vmlinuz & initrd.gz) on the existing linux partition from which you plan to install ubuntu.
REMEMBER you cannot install ubuntu to the same partition from where the installer will run.

For example :
Location of installer (existing linux partition) : /dev/sda1
Location of the new installation : /dev/sda2

Create a temporary directory on /dev/sda1 as "/maverick" and place the two files in it.

Also place the alternate iso in the "/" directory of /dev/sda1
This allows the installer to pickup the iso image and read its contents.

Step 4
Now you need to edit GRUB.
In my case I had GRUB2 present on my system.
(You can use legacy GRUB as well for this but I have not tried it)

Add the following lines to the end of the file "/etc/grub.d/40-custom"

menuentry "Install Ubuntu" {
insmod ext2
set root=(hd0,1)
search --no-floppy --fs-uuid --set 8c4ec935-1a99-42c9-bbc9-c0400ba9d7fd
linux /maverick/vmlinuz vga=normal ramdisk_size=14972 root=/dev/rd/0 rw --
initrd /maverick/initrd.gz
}


Remember to change the UUID shown after "set" to the UUID of your partition.
Find that out by seeing the contents of /dev/disk/by-uuid

$ ls -lh /dev/disk/by-uuid

Also change your partition correspondingly if it is not /dev/sda1
Save and close the file.

Before the next step create a backup of your "/boot/grub/grub.cfg" file just in case !

Now run
$ sudo update-grub

The custom entry you just added should be appended to the end of your new /boot/grub/grub.cfg file. It should, of course, contain all your earlier entries too.

Step 5
Reboot and choose the "Install Ubuntu" option from the Grub2 menu.

This should start the installer and it should find your alternate iso image in the / directory as well.
From here on out just follow the steps as they come up in the installer. Even though the alternate installer is text-based, it is really not difficult to understand if you read each step clearly.

Just make sure you are extra careful when the paritioning steps come up and select the correct paritions to format. (As specified in my example, I formatted /dev/sda2 as ext4 and set it as my "/" partition for this new ubuntu installation)

Select the "Ubuntu desktop" option of the installer prompts you for a software selection. This should install the default Ubuntu GNOME desktop.


I made this blog post because I did not find any unified howto for this particular installation method.

I took bits and pieces from the following places:

Ubuntu Forums
Ubuntu Forums
Ubuntu Forums
Ubuntu Commmunity Help


Friday, December 26, 2008

Something about hard disk partition naming !

With GNUnify 09 coming up in a month or so... its about time i started this.

Been using Linux (Ubuntu Hardy Heron mostly, but tried out a Fedora 9 as well openSuse 11 and Mandriva Spring 2008) for 6-7 months now.
And as a newbie user, I have done a fair bit of tinkering around ( as much as could grasp with my limited knowledge so far).

This will be where I'll just be putting down stuff that I have been able to do since then, so that I dont lose it and can use it sometime in the future... quite apart from putting the knowledge out there ;)

So here is some gyaan on how hard disk partions are named by Linux and by GRUB, since, while installing Linux, this is probably crucial for newbies so that they dont kick their earlier OS off.

Something basic first.
Every computer can only have 4 partitions. Thats been fixed from ancient times and nobody has changed it. This means that you can have 4 primary partitions and no more.
To counter this issue the extended partition has been used which can have multiple logical partitions within it.
This means that you can have at max 3 primary partitions with the 4th being an extended partition within which there may be multiple logical partitions.
There is no issue if you only have 1 primary partition and the rest as logical partitions within the extended partition.

So with that issue settled.....


For GRUB :

Points to remember -
  • naming always includes a pair of parenthesis ( .... )
  • numbering starts from zero not one.

(hd0) - the first physical hard disk (also the Master Boot Record on the first hard disk). And thats a 'zero' btw.

(hd1) - the second physical hard disk (~~~ same as above ~~~)
... and so on

(hd0,0) - the first partition on the first hard disk.

(hd0,4) - the first extended partition on the first hard disk. It will always be this regardless of whether there are 1,2 or 3 primary partitions on the disk. This number is given to the logical partition created within the extended partition.

All the logical partitions within the extended partition will always be (hdx,y).
x = the physical hard disk
y = number greater than or equal to 4

(hd1,6) - the 7th partition( logical partition since y > 3) on the 2nd physical hard disk.



For Linux:

hda or sda -
first physical hard disk.
'h' and 's' depends on whether it is an IDE (or ATA) or a SCSI (or SATA) respectively

hdb or sdb - second physical disk .... and so on

hda1 or sda1 - first primary partition on the first disk

hda5 or sda5 - the first logical partition within the extended partition.

Logical partitions will always have their numbering start from 5, irrespective of whether there are 3 or less primary partitions excluding the extended partition.

One example of this:

hda1 - first partition of first hard disk which is an IDE ATA disk
hda2 - second partition of the first disk

sdb1 - first partition of the second hard disk which is a SATA disk
sdb5 - the first logical partition within the extended (notice that even though there is only one primary partition the logical partitions will always start from 5)
sdb6 - second logical partition on the second disk
sdb7 - third logical partition on the second disk
... and so on...

Just giving the GRUB equivalent names for the above to make it clear.

hda1 = (hd0,0)
hda2 = (hd0,1)
sdb1 = (hd1,0)
sdb5 = (hd1,4)
sdb6 = (hd1,5)
sdb7 = (hd1,6)

So there. Hope that helps.

A good link to look up on more details about GRUB:
GRUB manual on the GNU website

Feeback welcome

Follow this blog !!!