Rondo 博客

谢谢来到Rondo的博客。
个人资料
rondo (热门博主)
  • 博客访问:
文章分类
正文

How to Install Linux distro directly from harddisk

(2008-07-25 08:44:23) 下一个

How to Install Linux distro directly from harddisk

After you download any Linux distro from the internet, you have to burn it to a DVD, CD or a number of CDs to install it. That CD or DVD is generally used only once after which it lies unused , and worse, almost every Linux distro comes up with a new release every 6 months. So if you are in the habit of upgrading to every

new version, you must have dozens of CDs lying at the bottom of your drawer. What a wastage of CDs! But with a little trick you can install any Linux directly from the hard disk without burning a single CD or DVD. The prerequisite of this trick is to have an operating system already installed on your computer. This is obvious because unless you are able to boot into your machine, you can't install anything; and we are not going to boot from the Linux disk because we aren't burning any. Here I'm going to focus on Microsoft Windows as the pre installed operating system.

Almost all Linux installers uses two files to boot the computer: a Linux kernel, and an initial root file system containing a minimal set of directories that is mounted prior to when the real root file system is available. This initial root file system is also called Ram disk (initrd). We will use these two files to boot our PC. Now lets get to the actual procedure.

1. The first thing you will have to do is copy the ISO file(s) of the Linux to your hard disk (ofcourse, you already have it). Make sure that the partition is FAT32 unless the distro you are installing has native NTFS read/write support. Some distros require you to copy the ISO file(s) to the root of the partition. If you keep it inside a folder, the setup might not be able to detect it.

2. Use Winrar to open the ISO file (you need not need to extract it). Now you will have to extract the two files I talked about earlier. The files are usually found inside a directory called isolinux. Different distros might place the files in different location; you just have to search for it, but it isn't hard to locate. These two files are also named differently in different distros. The files that you will need to search and extract are: (the kernel file is shown in green and the Ram disk is shown in red)

Fedora: vmlinuz and initrd.img

Suse: linux and initrd

Mandriva: vmlinuz and all.rdz

Ubuntu: vmlinuz and initrd.gz

Gentoo: gentoo and gentoo.igz

Knoppix: vmlinuz and initrd.img

Slackware: bzImage and initrd.img

Debian: vmlinuz and initrd.gz

3. After you have extracted the two files, copy them to c:\boot (you will need to create the folder "boot")

4. Now download the file called grub4dos from here. (Note: the new versions of grub4dos i.e. 0.4.2 and 0.4.3 does not work. So download the earlier version 0.4.1. Direct download link)  Extract the folder "boot" and the file "grldr" from the downloaded zip file. Inside the folder "boot" is another folder called "grub"; copy the folder "grub" to c:\boot. Copy the file "grldr" to c:\

5. Open c:\boot\grub\menu.lst and add these following lines. (Notice that hd0 refers to the first hard drive. If you have more than one hard drive, they will be named hd1, hd2 etc. Replace hd0 with the proper hard drive number incase you have windows installed on another drive.) Replace Linux_kernel and Ram_disk with the appropriate file names below. (the ones you copied to c:\boot)

<>
<>

title Install Linux
kernel (hd0,0)/boot/Linux_kernel
initrd (hd0,0)/boot/Ram_disk


6. Now you have to add grub to your c:\boot.ini file. You can open boot.ini by clicking on Start>Run and typing c:\boot.ini. If Windows does not allow the file to be modified, then go to Control Panel>System and click on the Advanced tab. Now under Startup and Recovery click Settings and then under System Startup click Edit. Open boot.ini and add this line in the end.

C:\grldr=”Start GRUB”

7. You are now ready to install Linux. Restart your PC and from the boot screen select "Start GRUB". This will load GRUB. From the grub screen select "Install Linux". During the setup you will be asked the source of installation. Choose hard disk and then select the hard drive partition where you copied the ISO files. Sometimes you might have to type the whole path of the partition and the exact name of the ISO. So write it down before you begin.

I have personally tested this with Fedora, Suse and Mandriva and it works without problem. I have no doubt it will work for others too.

Update: dougfractal adds that this is possible from Linux too. The method as he describes is:

From the terminal enter these commands

sudo mkdir /distro
sudo chmod `whoami`:`whoami`
cp MYLINUX.iso /distro/distro.iso

Now extract Linux_kernel & Ram_disk to /distro#

Open  /boot/grub/menu.lst

#ADD NEW ENTRY#
title Install Linux
root (hdX,X)
kernel /distro/Linux_kernel
initrd /distro/Ram_disk

Reboot and select "Install Linux" from grub.

[ 打印 ]
阅读 ()评论 (3)
评论
远上白云间 回复 悄悄话 就知道你会喜欢-)

坏了,我好像是没完没了了,哈哈,周末愉快!
rondo 回复 悄悄话 Thanks 远上白云间, I found one. Nice. Love it.
远上白云间 回复 悄悄话 试试这个连接能听到吗?http://www.tudou.com/programs/view/GUN0fGBeX3g

你准是偷懒,没找吧,呵呵,
登录后才可评论.