1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

CentOS 5.3 on NAS200

Discussion in 'Cisco/Linksys Network Storage Devices' started by alejandro_liu, Aug 15, 2009.

  1. alejandro_liu

    alejandro_liu Addicted to LI Member

    So I tired of porting software to my NASCC project everytime I wanted to add functionality.

    Instead I decided to see if I can squeeze CentOS http://www.centos.org, the Linux distro that I use into the NAS200.

    So far I can say I was able to get it to install and run. It was not very pretty but I can report that I am able to run Centos v5.3 on a NAS200.

    No surprise, it actually feels slower than the original firmware. After the initial install (with basically nothing more than yum and openssh-server) it took almost 10 minutes to do a "yum install samba".

    On the positive side, this is a full Linux distro, so any functionality (assuming you put up with the poor performance) is possible.

    Is anybody interested in seeing a posted root image or the instructions on how to create one? My guess that it the instructions should work for installing any RPM based distro (Like Fedora or different RHEL versions)
     
  2. jackito

    jackito LI Guru Member

    Alejandro I was about to do exactly the same.
    To install CentOS 5.3 on the NAS200. But I didn´t have time yet to do it.
    Can you write a summary of how did you do it? I would like to know if I was in the right path, at least in theory. :)
    Thanks.
     
  3. alejandro_liu

    alejandro_liu Addicted to LI Member

    The quick summary is I use yum with the "--installroot" and "--exclude *.i[56]86" options to create a root file system. Then I put that file system on a USB drive and use my "nascc-boot" firmware to chroot to it. I assume that Jac4 would work, but I don't know how Jac does it chroot.

    Some further fixes:

    1) create a valid /etc/rpm/platform, otherwise rpm (and therefore Yum) will not work.
    2) disable mii-tool and ethtool otherwise the network startup scripts will think that the network cable is unplugged.
    3) If you have a serial cable installed you need to tweak /etc/inittab and /etc/securetty.

    Like I said before, it is not pretty.
     
  4. jac_goudsmit

    jac_goudsmit Super Moderator Staff Member Member

    Jac4 can automatically pivot_root to any other root filesystem. Documentation about this will appear in the Jac4 thread this weekend, I'm working on it "as we speak". Meanwhile, you can peruse the /init script file in the root of Jac4 for more information on what's not documented yet.

    Basically, you can dump all the files you need for e.g. CentOS straight into one of the config partitions (you have 128MB, should be enough for anything basic) and create an executable file "init" in the root of that partition, and it should automatically pivot_root it. Once it pivot-roots it, Jac4 will exec your /init, which can simply be a symlink to /sbin/init, or a script if you want to do something cool before init starts. Of course you will end up having the Linksys/Sercomm config files in your root directory but they should not interfere and you can simply switch back to Jac4 by renaming or deleting the init file in the root of your file system.

    Alternatively you can put your entire root filesystem in a file and Jac4 will loop-mount it on /dev/loop7 during startup and will pivot-root to it. The file needs to be called "nas200.XXX.rootfs" where XXX is one of the supported file systems in the kernel (squashfs, ext2, ext3 or xfs). Once it pivots the root, it will exec /sbin/init.

    Besides the config partitions, you can also use a USB storage device: the /init script in Jac4 will first try to mount USB port 2 (near the edge of the box) as vfat filesystem, and if it doesn't succeed it will mount USB port 1 (near the center of the box) as ext2 filesystem. You can either use the USB device directly or store a loop filesystem on it as mentioned above. If mounting USB devices is not successful or it can't find a file it recognizes, Jac4 will mount the config partitions on the hard disks and it will do the same there. If you place your root filesystem on one of the hard disks and you paint yourself into a corner where it won't start and you can't make a change, you can always reboot from a USB stick that will allow you to fix the problem.

    If you build your distro into a bin file that the NAS200 can download from the web GUI, (i.e. using the "bind" command from the Linksys source tarball, or an equivalent program), you can simply name your file something matching NAS200_*.bin. If you place this file on a USB stick and plug it in at boot time, Jac4 will automatically loopmount your squashfs root filesystem right from the BIN file and will run /sbin/init. That way, users can decide whether they want to flash it or try it out by pivoting to it from Jac4 first. This will give users an easy way out if they decide they don't like it: arguably a big problem with creating alternative firmwares is that users need a way to uninstall it; with Jac4 the uninstall would be as simple as unplugging the USB stick.

    I think there would be significant interest in running other firmware on the NAS200, so yes, do post here. I myself am very interested, and I'm "working" on a Gentoo for the NAS200 and maybe later a Debian (I have limited experience with Debian but it appears that it's more or less a de facto standard for other embedded devices such as NSLU2). It will take a while before I get those finished so if I challenge you to release a standard Linux distro that will run on the NAS200 before I get one running, you should be able to win from me easily :biggrin::wink:

    ===Jac

    (PS my earlier experiments with Gentoo don't count, I was never able to log in to it)

    (PPS I'll explain in my article why I chose to exec /init in some cases, /sbin/init in other cases)
     
  5. alejandro_liu

    alejandro_liu Addicted to LI Member

    Running CentOS 5.3 on NAS200

    Hi,

    So for those crazy nuts who want to run CentOS on your NAS200. You can find here some instructions on how to do it.

    https://nascc.svn.sourceforge.net/svnroot/nascc/CentOS/scripts/

    If you don't feel like rolling your own filesystem, you can download a prebuilt one here:

    Source Forge Download Page

    I would most defintely recommend to create a root filesystem on your desktop first as trying to resolve complicated dependancies on a NAS200 can be a bit painful.

    Note that for this to work you either need a Jac4 firmware or a nascc-boot firmware.

    This has only been tested on nascc-boot, so, if this works for you on a Jac4 system, I would like to hear from you.
     
  6. jac_goudsmit

    jac_goudsmit Super Moderator Staff Member Member

    Hey Alejandro, does NAS-CC have a way of automatically detecting and pivot_rooting file systems on USB like I mentioned in my post above? If so, we should sync up to make our pre-init work identically so that whatever root filesystem anyone wants to boot from USB or hard disk, will run under both NAS-CC as well as my firmware...

    I haven't read through all of your instructions yet and I'm still downloading the binary, but I'm very impressed!

    ===Jac
     
  7. alejandro_liu

    alejandro_liu Addicted to LI Member

    While it is able to handle USB and internal discs for boot media, it requires users to put configuration files in the right places.

    Also, will pivot_root, kexec a new kernel or even boot a Linksys firmware file, all from USB or internal disc.

    BTW, when booting from a Linksys firmware it actually kexec's the firmware kernel along with the embedded file system.

    In general, unless for development, I hardly ever flash my NAS200.
     
  8. jac_goudsmit

    jac_goudsmit Super Moderator Staff Member Member

    Ah yes, that's right... NAS-CC caters to a whole different audience than my firmware...

    Any chance you could make a Centos version without docs, locales, manpages and other bloat so it would fit in (let's say) 200MB? That way you could fit it on a config partition (236160 blocks) and it would be easy to run if Jac4 is in the flash too...

    I would certainly be interested to see how you did that. I tried getting kexec to work just after I started on the NAS200 firmware and didn't get it to work for some reason. I stopped researching it because I felt there was better low-hanging fruit but it's definitely on my todo list.

    Now that I can automatically pivot-root into a Linksys compatible image file, I won't have to flash nearly as often as I used to... As a matter of fact I'm now seriously considering moving the NAS to a different room :eek: -- it's sitting on a table next to the couch where my laptop is because I still need the serial port every once in a while but now I can just plug in a USB stick to boot from, I won't need a serial port nearly as often anymore...

    ===Jac
     
  9. alejandro_liu

    alejandro_liu Addicted to LI Member

    The reason why that CentOS file system is done that way is because it is a "straight" install from a Yum Repository. The stuff added are the *bare* minimum to get it working.

    Also it is setup so it boots from a /dev/sdc1 partition (usually the first USB drive in a 2 SATA drive setup).

    If you were to switch to the config partiion you would need to:

    1) Unpack everything to a temp directory
    2) Edit etc/fstab to match the partitioning you use.
    3) If you would want to cut down the image further you could: rm -rf the following directories: usr/include usr/share/doc usr/share/man usr/share/info usr/share/locale usr/lib/locale.

    This would make the rootfs 126MB.

    Of course you are going to those extremes to get a CentOS image working it probably means that it is not worth the effort doing as the image as is already very bare.

    I would really recommend boot from USB as you can find 2GB memory sticks rather cheaply and that gives ample room for adding all the packages you will need.
     
  10. alejandro_liu

    alejandro_liu Addicted to LI Member

    As far as kexec'ing goes there is no trick. You need to do the following:

    Load the new kernel:

    kexec -l <kernel-file-name> --initrd=<initrd-image> --append=<cmdlineoptions>

    The --initrd and --append options are not mandatory, but you probably will need them otherwise the kernel may not be able to run properly.

    If that went fine, you have a kexec kernel ready to boot. Next you may want to do some clean-up (I try to keep things tidy).

    In my case, I do unmount filesystems, stop lvm and MD partitions so at least filesystems are in a sane state.

    You then activate the kernel wil:

    kexec -e

    This of course means that you need to have kexec-tools software and kexec configured in the kernel.
     
  11. jac_goudsmit

    jac_goudsmit Super Moderator Staff Member Member

    Heh, I think CentOS and I disagree on what "bare minimum" means... :rolleyes:

    Unfortunately I had left all my USB sticks at work this weekend :biggrin:

    ===Jac
     
  12. alejandro_liu

    alejandro_liu Addicted to LI Member

    Hi

    I discovered a bug that prevents the CentOS file sytem from running when loaded on a LVM2 partition. So I know how to fix it, but I haven't created a new image yet.

    Until then, the CentOS build is only for external USB keys.
     
  13. alejandro_liu

    alejandro_liu Addicted to LI Member

    OK,
    You can run CentOS from internal discs but for that you need to make your own file system. Adding all the RPM packages to do so makes the root file system quite big so I am not providing a binary version.

    The link in the first post contains scripts that will let you create your own CentOS file system, which you can customise (to include LVM and MDADM for example) before you place it on the NAS200. This is probably desirable as doing YUM INSTALL from the NAS200 tend to be quite slow.
     

Share This Page