WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Custom Distro for Linode  (Read 9175 times)

xnix

  • Guest
Custom Distro for Linode
« on: November 03, 2010, 05:39:35 PM »
Well, I'm going to do my best to think this through before just writing and hoping someone will answer my musings. I want to ask questions that bear some meaning, and not just random and pointless 'can I do this?'

I just moved my VPS over to Linode, since my previous VPS provider was overkill for my needs and Linode offers better control for my experience level, and have been reading a bit about deploying a custom distro on their servers. I thought about taking a run at deploying TinyCore, considering it is already minimal and taking into consideration that on a desktop it is blazing fast, I do think that TC might be a nice project to put together and eventually use on a production server.

So my first question: would TC be a decent option to use as a production server's distro? Taking into consideration that it is built on the same kernel as those other commonly excepted distro's, why would TC fit into this category as a power house? I mean, you would have to be meticulous about what you run in RAM and mount to disk, considering the limitations of RAM, but having the web server running in the RAM might be an extremely fast server. Maybe I am not considering how much RAM it actually takes to run, say, httpd, but perhaps nginx ot lighttpd, or even cherokee might be lihgt enough to run in this matter.

My intention is to have a web server, sql server, and mta (mail) server so that a custom TC distro could focus its efforts on those tasks, thus freeing up resources. I believe this would allow me to load, say, the web server into RAM and not have to worry about using too much RAM since this would be its primary purpose. Of course, I'm not taking into consideration how much RAM my applications would use, but I don't intend on using resource-heavy software either. Let's put that RAM to work for me, making Apache (definitely not my first choice for server if I go this route, but using it as an example here), or whatever flavor of web server I choose, and get it loading and serving that much faster. Am I dreaming here?

I know there is more for me to research, and I need to buy a dev VPS so I can play with it, but would this be feasible, worthwhile, and efficient to pursue?

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11049
Re: Custom Distro for Linode
« Reply #1 on: November 04, 2010, 04:03:16 AM »
Considering the usual VPS is ram-constrained, and many of the virt/isolation techniques do not allow swap, TC would be fairly ideal in that environment. Or better yet, MC with possibly Xlibs.gz, no need for an X server there.

Security-wise TC isn't quite on the level of the enterprise distros, what we have is speed and features.
The only barriers that can stop you are the ones you create yourself.

xnix

  • Guest
Re: Custom Distro for Linode
« Reply #2 on: November 04, 2010, 12:48:32 PM »
I had already intended on MC, since I don't need or want GUI or X11, I was just posting TC for the sake of simplicity. I can understand that TC/MC doesn't have the security features and robustness of an enterprise distro, but how hard could it be (coming from a Linux noob) to enhance it's security? Harden the shell, throw in a firewall, and whatever else that would be absolutely necessary. I definitely need to take security into consideration, but this shouldn't be a hurdle which is exceptionally difficult to overcome. I'm hoping to add a low-resource node to my Linode account soon and start playing with this possibility, I just wanted some advice in what might make this process more painless and usable.

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11049
Re: Custom Distro for Linode
« Reply #3 on: November 04, 2010, 01:32:43 PM »
If you have a properly set up firewall and keep your servers up to date, it should work just fine.
The only barriers that can stop you are the ones you create yourself.

Offline danielibarnes

  • Hero Member
  • *****
  • Posts: 548
Re: Custom Distro for Linode
« Reply #4 on: November 04, 2010, 04:45:09 PM »
Linode is a interesting option. For $20/mo you get 512MB RAM, 16GB HDD, and 200GB data transfer. Their plans scale linearly: 2x the price gets you 2x RAM, HDD, and data transfer, so no discount for higher usage.

Linode has a blog post which describes Custom kernels with pv-grub. When you read the wiki article referenced in the post, there are some important details:

The host must either be running xen-sources or another kernel that supports pv_ops. In order to work with Xen, a number of options that must be selected:
CONFIG_PARAVIRT_GUEST=y
CONFIG_XEN=y
CONFIG_PARAVIRT=y
CONFIG_PARAVIRT_CLOCK=y
CONFIG_XEN_BLKDEV_FRONTEND=y
CONFIG_XEN_NETDEV_FRONTEND=y
CONFIG_HVC_XEN=y
CONFIG_XEN_BALLOON=y
CONFIG_XEN_SCRUB_PAGES=y

The default 3.x Tiny Core kernel has:
CONFIG_PARAVIRT_GUEST=y
CONFIG_PARAVIRT=y
CONFIG_PARAVIRT_CLOCK=y

Note that the Xen-specific flags are not present. The LKDDB entry for "CONFIG_XEN" states: "Enabling this will allow the kernel to boot in a paravirtualized environment under the Xen hypervisor." This appears to imply that Tiny Core will not boot in Xen without this option. I know little of Xen, but I believe this to be the case. My initial conclusion is you will need to build a custom kernel based on the Tiny Core kernel, but that isn't too difficult.

Whatever you do, my advice is to script everything you build. This makes it easy to save your work for reference and re-use later. I find that invaluable when building extensions and remastering.

xnix

  • Guest
Re: Custom Distro for Linode
« Reply #5 on: November 05, 2010, 12:13:43 AM »
My initial conclusion is you will need to build a custom kernel based on the Tiny Core kernel, but that isn't too difficult.

Mwuahahaha, so we'll find out. You did notice my comment about being a Linux noob, yes? I'm not afraid to explore this, and actually am eager to see what may come, so really if all I need to do is add those options and variables to a custom kernel of micro's already custom kernel, then hey, it shouldn't be too hard. Now if those added variables require more than simply a 'y' then I might be in for an adventure.

Whatever you do, my advice is to script everything you build. This makes it easy to save your work for reference and re-use later. I find that invaluable when building extensions and remastering.

Scripting? Meh, I just encountered my first experience with shell scripting, and while it didn't not work, it didn't quite work as planned. How about I start by simply documenting every little detail I can come up with, then come hunt you down for that said scripting? Kidding, really!

I'm going to purchase a dev VPS from Linode December 1, when the next billing cycle rolls around for my account, so hopefully I will be able to start looking at MC as a distro for Linode.

Offline danielibarnes

  • Hero Member
  • *****
  • Posts: 548
Re: Custom Distro for Linode
« Reply #6 on: November 07, 2010, 11:07:16 PM »
Quote
Now if those added variables require more than simply a 'y' then I might be in for an adventure.
A small adventure, perhaps, but I can help:

1) Load the compiletc, bash, perl5, and coreutils extensions.
2) Get the patched Tiny Core kernel source.
3) Extract it
4) make mrproper
5) Copy the Tiny Core kernel config into the directory as .config
6) make menuconfig
7) Select the following features (in order):

Processor type and features --> Processor family --> Pentium-Classic (or later of your choosing)
Processor type and features --> High Memory Support --> 64GB
Processor type and features --> PAE Support
Processor type and features --> Paravirtualized quest support --> Xen guest support

8) make bzImage

I don't know if these kernel options are significant enough to require re-compiling all the modules. If so, I could probably script a solution without too much effort.
« Last Edit: November 08, 2010, 12:04:45 AM by danielibarnes »

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14849
Re: Custom Distro for Linode
« Reply #7 on: November 07, 2010, 11:37:15 PM »
I could be mistaken, but doesn't "make mrproper" have to come before copying the .config file across (it'll be deleted otherwise)?

Offline danielibarnes

  • Hero Member
  • *****
  • Posts: 548
Re: Custom Distro for Linode
« Reply #8 on: November 08, 2010, 12:03:23 AM »
Oops. Post edited for correctness. :)

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11049
Re: Custom Distro for Linode
« Reply #9 on: November 08, 2010, 09:43:12 AM »
CPU type change makes existing modules incompatible, and I think so does the mem change.
The only barriers that can stop you are the ones you create yourself.

Offline tc@tinycore:#/

  • Newbie
  • *
  • Posts: 5
Re: Custom Distro for Linode
« Reply #10 on: November 08, 2010, 07:17:02 PM »
Howdy, xnix here. Requested for xnix to be deleted, and registered this username instead, so there is no confusion as to who I am and why I'm continuing the topic.

I appreciate the offer about the script, and while I would definitely like that, I would still like to explore doing it myself. If you feel up to the task, having a script would give me something to refer to as I learn the process myself.

I'm curious as to more specifics to curaga's post, about this making existing modules incompatible. If all I'm doing is recompiling the kernel, then what modules are we talking about? I hear modules, and think extensions, so if this is something more specific to the kernel, then I'll read up on it.

edit - I'm guessing that these modules are the LKM's and not extensions. I suppose I should have made a quick search first. Where can I read about these said modules that apparently TC makes use of?

I'm going to try this out on my VM, see what I get from it. I'll keep this topic up to date on what happens, and I would much appreciate some more feedback and direction as well. Of course, if I don't do it myself, I'll never learn myself!
« Last Edit: November 08, 2010, 07:28:01 PM by tc@tinycore:#/ »

Offline danielibarnes

  • Hero Member
  • *****
  • Posts: 548
Re: Custom Distro for Linode
« Reply #11 on: November 08, 2010, 07:31:55 PM »
Quote
I'm guessing that these modules are the LKM's
Yes, you'll need to recompile all of the .ko.gz files under /lib/modules/2.6.33.3-tinycore/kernel. A simple "make" should build everything. You'll need to create a new "tinycore.gz" or "microcore.gz" with the new files, then boot your new kernel and core.gz in Xen.

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: Custom Distro for Linode
« Reply #12 on: November 08, 2010, 08:14:15 PM »
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline tc@tinycore:#/

  • Newbie
  • *
  • Posts: 5
Re: Custom Distro for Linode
« Reply #13 on: November 08, 2010, 09:24:38 PM »
Thanks for the link. It all sounds pretty straight forward, but since this will be my first time messing with it, we'll see.

make bzImage
make modules
make modules_install

Although I don't get how making the modules will find themselves in the bzImage, I'll figure it all out when I actually do it. Perhaps I would be all the wiser not even bothering to make another post until I actually do a 'test,' that way I can come back with something worth posting.

Offline danielibarnes

  • Hero Member
  • *****
  • Posts: 548
Re: Custom Distro for Linode
« Reply #14 on: November 08, 2010, 11:29:14 PM »
The bzImage is the kernel. In Tiny Core, the modules are contained in microcore.gz. You can see this for yourself:

$ mkdir /tmp/rootfs
$ cd /tmp/rootfs
$ zcat /mnt/hdc/boot/microcore.gz | cpio -idv
$ ls lib/modules/2.6.33.3-tinycore/kernel

Note this assumes you have microcore on a cd mounted at /mnt/hdc.