Owen的酒楼

--酒楼上渡过的人生--
生命太短,人生太长,但愿别喝醉了。

导航

Installing ZeroShell in Hard Disk ZT

Posted on 2008-11-29 14:11  Hicome  阅读(1700)  评论(0编辑  收藏  举报

Hello,

I have accomplished the following steps in order to install ZeroShell in my hard disk. At least it boots, but further probing is necessary.

Let suppose a free partition (e.g. /dev/hda5) of type ext2. We also have the LiveCD iso file (Zeroshell-1.0.beta3.iso). First, we mount this file in some folder:

# mkdir $HOME/zeroshell
# mount -t iso 9660 -o loop Zeroshell-1.0.beta3.iso $HOME/zeroshell

(Of course the mount command must be invoked from the folder that holds the .iso file. Otherwise its complete path must be provided)

Next we copy all the files to the target partition:

# mkdir /media/hda5
# mount -t auto /dev/hda5 /media/hda5
# cd $HOME/zeroshell
# cp -r * /media/hda5
# cd /media/hda5
# umount $HOME/zeroshell

In the 'isolinux' folder there are two compressed filesystem images: 'initrd.gz' and 'rootfs'. The last one contains most of the ZeroShell root file system and it is dumped to a ramdisk when working from the CD. In the next few steps this file system will be copy to the root folder of /dev/hda5:

(from /media/hda5)
# gunzip -c isolinux/rootfs > rootfs.unzip
# mkdir rootfsFolder
# mount -t auto -o loop rootfs.unzip rootfsFolder

Before copy it we need to remove some soft links that otherwise will be broken when booting from /dev/hda5

# cd rootfsFolder
# unlink sbin
# unlink usr
# unlink lib/modules
# ln -s /modules lib/modules

And we also have to modify the fstab table in /media/hda5/etc/fstab (use your favorite text editor). Be careful *not* to edit your host system fstab (which is found in /etc/fstab not in /media/hda5/etc/fstab). The /dev/hda5 must be mounted as root file system and we don't need to mount /cdrom (next you can see the new fstab):

# cat etc/fstab

/dev/hda5 / ext2 defaults 1 1
# /dev/cdrom /cdrom iso9660 ro 0 0
proc /proc proc defaults 0 0
none /sys sysfs defaults 0 0
devpts /dev/pts devpts gid=4,mode=620 0 0
shm /dev/shm tmpfs defaults 0 0

(Note that the cdrom entry is commented)

Now we can copy the contents of rootfsFolder to /media/hda5

# cp -r * ..

and unmount it.

# cd ..
# umount rootfsFolder

Note that 'rootfs.unzip' contain an image of every modification we have done, so if we need to use the original rootfs image we must use the compressed one in the 'isolinux' folder.

The initrd image does not supply device nodes for partitions in the hard disk. We need to modify it and add, at least, a device node for the target partition (/dev/hda5 in our example).

# gunzip -c isolinux/initrd.gz > initrd.unzip
# mkdir initrdFolder
# mount -t auto -o loop initrd.unzip intirdFolder
# cd initrdFolder
# mknod dev/hda5 b 3 5

Of course, we have to invoke mknod with the proper device name and major and minor numbers (see mknod man page and http://www.lanana.org/docs/device-list/ for more details. For partitions in the master device of the primary IDE -hda-, the major number is 3 and the minor one must equals the number of the partition -the number at the end of its name-).

We don't need the linuxrc script in initrd, so we modify it (use again your favorite text editor) like this:

# cat linuxrc

#!/bin/bash
#
# Modified from the original linuxrc (created by Fulvio Ricciardi 16-11-2003)
# 6-feb-2007
#
mount -t proc proc /proc

(I think it is not necessary to leave /proc to be mounted, anyway...)

Now the initrd filesystem must be unmounted and compressed again. For convenience we will put it on to the 'boot' folder, so we do with the kernel image:

# cd ..
# unmount initrdFolder
# gzip -c initrd.unzip > boot/initrd.gz
# cp isolinux/vmlinuz boot/vmlinuz

Now the system is ready! We only have to make it bootable by using our preferred boot loader. I use grub, so I added the following entries in the menu.lst file:

title ZeroShell
root (hd0,4)
kernel /boot/vmlinuz root=/dev/hda5 quiet init=/bin/init ramdisk_size=131072
initrd /boot/initrd.gz
boot

and ZeroShell boots from hard disk. Boot options are copied from the original isolinux.cfg. Further tests must be acomplished in order to ensure that everything works properly, but I hope this helps.

Thanks Fulvio for this wonderful system!

===============================================

Hello,

When I posted the installation proccess I had only booted it up and browsed the login page. When I finally tried to login into the system, it never ends the authentication process Embarassed.

I am really confused: the 'kerbynet' program (in /usr/local/apache2/cgi-bin), which is launched as a cgi script when the user press the login button, seems to start a never-end loop: it begins but it never ends (you can see it with a 'top' command from a shell prompt in the server.)

When the root file system is mounted from as a ram disk (default in the liveCD) kerbynet works without problems, so I have modified the "installation" method in a manner that the root file system still remains in a ram disk. It seems to work (at least kerbynet doesn't hang), but, again, further testing must be accomplished.

In order to install zeroshell in /dev/hda5:

# mkdir $HOME/zeroshell
# mount -t iso 9660 -o loop Zeroshell-1.0.beta3.iso $HOME/zeroshell
# mkdir /media/hda5
# mount -t auto /dev/hda5 /media/hda5
# cd $HOME/zeroshell
# cp -r * /media/hda5
# cd /media/hda5
# umount $HOME/zeroshell

Now we modify the linuxrc script in initrd in order to link /dev/cdrom to /dev/hda5 instead of to the actual CDROM device.

# mkdir initrdFolder
# gunzip -c isolinux/initrd.gz > initrd.unzip
# mount -t auto -o loop initrd.unzip initrdFolder
# cd initrdFolder
# cp linuxrc linuxrc.old
# cat > linuxrc << EOF

> #!/bin/bash
> #
> # linuxrc by Fulvio Ricciardi 16-11-2003
> # Modified by Fernando Gonzalez 7-2-2007
> mount -t proc proc /proc
> if mount -t auto /dev/hda5 /cdrom 2>/dev/null ; then
> echo Success
> echo -n "Loading root filesystem into RAM device... "
> if gzip -dc /cdrom/isolinux/rootfs >/dev/ram2 2>/dev/null ; then
> echo Success
> umount /cdrom
> /sbin/insmod /lib/loop.ko
> mount -o loop /dev/ram2 /cdrom
> cd /cdrom/dev
> ln -s hda5 cdrom
> cd /
> umount /cdrom
> else
> echo Fail
> umount /dev/hda5 > /dev/null
> fi
> else
> echo "Fail"
> fi
>
> EOF

# mknod dev/hda5 b 3 5
# cd ..
# umount initrdFolder
# cp isolinux/initrd.gz initrd.gz.old
# gzip -c initrd.unzip > isolinux/initrd.gz


(I am not sure if it is necessary or not to create the device node.)

And we change fstab in rootfs to mount /dev/cdrom as ext2 instead of iso9660:

# mkdir rootfsFolder
# gunzip -c isolinux/rootfs > rootfs.unzip
# mount -t auto -o loop rootfs.unzip rootfsFolder
# cd rootfsFolder
# cp etc/fstab etc/fstab.old
# cat > etc/fstab << EOF

> /dev/ram2 / ext2 defaults 1 1
> /dev/cdrom /cdrom ext2 ro 0 0
> proc /proc proc defaults 0 0
> none /sys sysfs defaults 0 0
> devpts /dev/pts devpts gid=4,mode=620 0 0
> shm /dev/shm tmpfs defaults 0 0
>
> EOF

# cd ..
# umount rootfsFolder
# cp isolinux/rootfs isolinux/rootfs.old
# gzip -c rootfs.unzip > isolinux/rootfs

Now the system is ready, only rest to make it bootable. With grub, append in /boot/grub/menu.lst

title ZeroShell
root (hd0,4)
kernel /isolinux/vmlinuz quiet root=/dev/ram2 ramdisk_size=131072 init=/bin/init
initrd /isolinux/initrd.gz
boot

-------------------------------------------------------

It must be improved: Although booting from hard disk, the whole root file system is mounted as a ram disk. I think it can be a problem if there is not enough memory installed.

I hope this can be helpful. Any idea about why kerbynet hangs when it the root file system is mounted from a partition in hard disk? Question

 

===================================================

Try to use cp -rp that preserves the permissions better than cp -r
Take in mind that the kerbynet cgi runs with the apache web server privileges. Hence the /etc/sudo program must have the setuid flag active.
Try if it works after you use the command chmod u+s /etc/sudo

Regards
Fulvio

 

======================================================

Thanks Fulvio,

It works well by changing the 'cp -r' in the first post:

**************************************************************
Now we can copy the contents of rootfsFolder to /media/hda5

# cp -r * ..

and unmount it.
**************************************************************

for 'cp -a' when copying the contents of rootfsFolder:

**************************************************************
Now we can copy the contents of rootfsFolder to /media/hda5

# cp -a * ..

and unmount it.
**************************************************************

Regards,

Fernando
==============================================

 

Thank you for your how-to. I'm at the end of it and i'm a little bit stuck. I have to make it bootable. You suggest to use grub. But ZeroShell doesn't install grub, does it? When i run shell prompt from ZeroShell console, i don't see /boot/grub/menu.lst.... I see directory /mnt/sdb1/boot/grub but there's no menu.lst. I created my own and added what you said to add but after reboot, there's 'No operating system installed'....

How to install grub loader from ZeroShell 'shellprompt'?
Thanx.

====================

Hello,

I'm sorry. I forgot to say that I was using a previously installed system (Ubuntu) as a "host" system so I have grub already installed. In order to "install" Zeroshell I booted Ubuntu and followed the steps.

It seems that you have done it from zeroshell 'shellprompt', and that you don't have any other OS in your disk. I suppose you have to obtain grub and install it following the instructions in http://www.gnu.org/software/grub/ I will try it...

========================

Yes, i used clean hard drive (without any OS).
After some time i was able to install ZeroShell (AFAIR there's grub-install somewhere in /usr or /var) but after all i had to switch to IPCOP because VPN available on ZeroShell is different than VPN on IPCOP and i didn't have much time to get know how to connect net-to-net VPN from ZS to Procurve router.
Anyway, ZeroShell is great (with http proxy and scanning for viruses by clamav it will be even more powerful).

Best regards.

============================

 thanks for this way that we can install zeroshell on HDD and change its FS ...
i did it step by step , my HDD part was sda3 instead of hda5 , so i modified some things , also regarding the files editing (CAT ..) i used text editor in ubuntu and replaced all the content with the lines you mention ..
then i tried to boot , a Kernel Panic error occurs :

Code:
kernel panic - not syncing : VFS : unable to mount root fs on unknown-block (1,2)

i dont know exactly what this error means ...
anyhow , is there is another way to make zeroshell FS editable ??? i just want to modify the user interface to add and remove some options ...
waiting for the professionals help Wink