Installing ZeroShell in Hard Disk

Home Page Forums Network Management ZeroShell Installing ZeroShell in Hard Disk

This topic contains 27 replies, has 0 voices, and was last updated by  fergon 5 years, 1 month ago.

Viewing 15 posts - 1 through 15 (of 29 total)
  • Author
    Posts
  • #40552

    fergon
    Member

    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!

    #45123

    fergon
    Member

    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 :oops:.

    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? ❓

    #45124

    imported_fulvio
    Participant

    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

    #45125

    fergon
    Member

    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

    #45126

    marcin
    Member

    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.

    #45127

    fergon
    Member

    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…

    #45128

    marcin
    Member

    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.

    #45129

    Lohuis
    Member

    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 :

    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 😉

    #45130

    Howie69
    Member

    @lohuis wrote:

    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 :

    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 😉

    If you changed everything to sda3 instead of hda5, I bet you forgot to change the root image in the grub entry, this part:

    @fergon wrote:

    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

    the ‘root(hd0,4)’ part points do /dev/hda5. If you are using sda3, I believe you would change that to ‘root(hd0,2)’. Otherwise the kernel is looking in the wrong place for the root filesystem and will panic.

    root(hd0,4) means ‘look for root on first hard drive ( hd0 ), partition 5 ( since the bios starts counting at 0 instead of 1, the first partition would be 0, the fifth would be 4).

    I hope this helps. I will be attempting to do just this on a system tomorrow. Will let you know how it goes.

    #45131

    Lohuis
    Member

    thanks for your reply …
    it has been along time since i did that , but i think that changed that also as you said …
    did you succeed with installing it on a hard disk ?

    #45132

    Howie69
    Member

    Not yet. Me and my kids all ended up with the flu, so I haven’t been back to work since I posted that yet.

    Should be sometime this week. Will be testing the features of the captive portal on livecd first, then attempting to install to HD if all goes well.

    #45133

    Lohuis
    Member

    oh …
    i am sorry for that , i hope you and your family pass this soon .

    #45134

    thistleknot
    Member

    makefs “filesystem larger than apparent device size”

    also my ramdisk got some sort of write error on a particular number.

    any ideas? It locked up at the filesystem remark. I got it to boot though! partly

    IT WORKED!
    btw, I never really troubleshot the makefs, but I realized it was ramdisk related.
    I read the second post by the thread starter saying he needed to mount the rootfs on a ramdrive, so I heeded what he said and overlaid those steps over the initial steps, and it worked.

    I read the second post and it worked. Of course mine is hda1, but it booted!

    One thing to note. Zeroshell doesn’t like ext2 (at least in the gui). I would recommend converting everything to ext3.

    converting to ext3 worked, but for some reason in the gui, it doesn’t see the hosting partition. It does see the backup partition I made (which is an ext2 clone of the first partition). I created a 3rd partition (ext3) to host the profiles, and it sees this as well.

    #45135

    thistleknot
    Member

    well, I got zeroshell to boot from a hard drive following the instructions on how to make a writeable copy.

    I was able to do it without using a ramdrive (and I logged in). I had enough free space to extract apt.bin (which I didn’t do just yet); however, on subsequent reboot, it wouldn’t boot, got a message about a bunch of files not found in /etc.

    Maybe my hd is corrupt. will try again with an ssd flash card I have.

    To make matters worse, my profile got corrupt.

    So in theory, if I get it up and running I should be able to get those linux headers with apt-bin (cross fingers), and then compile the compat wireless drivers.

    btw, the error I got earlier was related to the ramdrive, I made a menu.lst file and verified I typed everything right, and I didn’t get the error the second time.

    #45136

    ngwasuma
    Member
Viewing 15 posts - 1 through 15 (of 29 total)

You must be logged in to reply to this topic.