Jaunty Server on Compact Flash: running Ubuntu 9.04 on a Thin Client
Previously on UnixWars …
I said in another post that I would be using a Thin Client as my home server. The machine is fanless, diskless and it makes no noise. The system boots from a low power Compact Flash. After setting things up, some friends decided to buy the exact same machine, so I’m going to write down the steps I followed to configure the server. Please note that Ubuntu Jaunty is still in Alpha 5 stage, so you might want to rethink which release you are going to install. I’ve had no problems whatsoever, so for a setup such as mine you should be safe. Alpha 6 is due to be released shortly and the first beta will be out on March 21st. Then, just one month will separate us from the official release day, so by now I’d say Jaunty has done most of it’s homework.
The easiest thing to do would be installing the system normally through PXE (look for the link at the end of this post if you’re interested), but there is a problem. Flash devices have a limited number of write-cycles, and wear levelling is not used on consumer grade cards. There are file systems optimized for flash devices -such as JFFS2- but the benefits are not obvious here. As I understand it, these are designed for industrial devices with direct access to the memory cells. Consumer devices have an abstraction layer that make them transparent and enable us to use them as any other normal storage. It should provide everything we need, such as wear levelling. But as I said before, it normally doesn’t for consumer-type devices.
Alternatives
Having discarded the optimal solution for both technological and budget limitations, we are left with three alternatives.
- Use the CF as an ordinary device, with total disregard for the premature death of the drive. This is the simplest, and provided you have a lifetime warranty for your media it might not be such a bad idea.
- Use the CF as if it were a LiveCD, maybe even adding persistence for our changes. This option should prove perfect if we want to use the Thin Client as a desktop system. Temporary changes are written to RAM, permanent changes will be stored on disk and even software updates will remain between reboots. It is a bit more complicated, so I’ll leave this in my TO DO list for now.
- Install everything by hand on a local copy, configure the system to be able to run with as little disk access as possible (ideally, from a read-only root file-system), and dump it to the CF. Since space is not a problem for me (I have both a 1GB and 8GB CF cards), I’ll prefer this approach. In case everything was set as read-only, we would only have to remount the file systems as writable during the process. As for SquashFS, though it seems an ideal choice for an embedded system that needs no upgrades, I’ll discuss this in other posts. It is simpler to deal with a “standard” system, not having to recreate binary boot images every time you update the box.
My home server is used to share media and printers on my local network, manage downloads, and above all, provide a permanent access to my home network from wherever I might be. This is, by far, the handiest thing ever. At least it is for me. You never know when you are going to need to bypass Internet filters when you are roaming, for example. The wonders of SSH truly never cease to amaze me :)
I’ve opted for letting some writing be done to the CF, albeit the write-intensive tasks have been dealt with, because it is easier for the system to be updated, and because some of the services I’ll be using refuse to work on read-only mode. However, my next entry will be about using aufs/unionfs, and replicating this setup on totally read-only and compressed system that will run from the 256MB standard CF that comes with the computer.
Things to install
- Basic system: since Jaunty is still in Alpha stage, downloading the whole ISO is not worth it. Just grab the NetBoot mini ISO and download the rest as you go. You’ll have to update frequently until it is released anyhow.
- linux-image-server: A scheduler less suited for multimedia but with some advantages for a server.
- ssh: Access point to/from your server.
- cups: printer support. Note that CUPS alone will add around 100 MB to your installation.
- portmap, nfs-kernel-server: NFS file server.
- samba: sharing files and printers for Windows boxes.
- nmap, mc, wget, curl, unrar, p7zip-full, arj, unzip, unp, unace, qemacs-nox: some handy tools I can’t live without. Mostly Swiss-army knives, decompressors and a tiny Emacs-like editor. It’s bigger than mg, but it has UTF8 support. I love Emacs but it is huge for a system like this.
- usbmount, ntfs-3g: to automatically mount USB devices. Nice if you plan to plug and unplug your external drives to share them on your LAN.
- mldonkey-server: for our every day download-needs.
These were the steps I followed. Keep in mind these are mainly notes to myself. They should work for you, but they might not. At the very least these steps will give you some useful hints. Please note that there might be some rough edges in the tutorial, since I actually wrote this after having everything installed. I tooks some notes during the process, and this setup is working flawlessly for me. I don’t think any important (read non-trivial) steps were left out, but if that’s the case and it is giving you any kind of problem, just ask in the comments!
The CF shouldn’t suffer much IO, so the idea is to install and customize everything on a virtual machine, and then dump the resulting image to the CF after making every needed adjustment.
I originally intended to make the system completely read-only, but then decided that preventing /tmp and /var/log from massacring the CF would be more than enough. You can skip completely some of these steps, since the root-fs will not be totally read-only. For that, check the next post.
Installing the base system
I’ll be using VirtualBox because I find it easier to work with than plain QEMU, particularly since I’m going to be needing the network from within the virtual machine. Just create a new one with a disk size that can fit in you CF. I’ll use a 1GB card that I have laying around. Also configure the CDROM drive to use the NetBoot mini ISO that you have downloaded.
Before booting the machine, add PAE/NX support to the virtual CPU. The generic kernel doesn’t need it, but once you try to boot with the linux-image-server branch you will need this to proceed. That is done from the virtual machine definition section following the path: Details -> General -> Advanced.
Boot the machine and type ‘cli’ if you want to minimize the installations. Then manually partition the hard drive if you want to use the new EXT4 file-system type, and go through the process as you normally would. Of course, disregard the swap partition. You can’t have that on a CF or it will die soon for sure.
I use the French repositories because those are the fastest for me. I always start by modifying the list of repositories on the recently installed system, in case I want to install things not present in universe. Edit it manually or just append the needed info.
echo "deb http://fr.archive.ubuntu.com/ubuntu jaunty \ main restricted universe multiverse" >> /etc/apt/sources.list
And install the packages.
sudo su - apt-get clean apt-get update apt-get install linux-image-server openssh-server samba cups \ wget p7zip-full portmap nfs-kernel-server nmap mc \ qemacs-nox unp arj unrar unzip usbmount mldonkey-server apt-get clean
No real need to mention it, but don’t forget to delete the generic kernel and associated files if you want to save another 100MB or so.
Now to handle issues related to readable-writable paths, as well as config files. Some steps are only useful if you will mount the rootfs as read-only. I’ll mark them as “Optional”:
- Optional: /etc/mtab: We will link it to a file that can describe the mounted file-systems without requiring write access.
rm /etc/mtab ln -s /proc/mounts /etc/mtab
- /etc/network/interfaces: static IP for the server. Bare in mind you’ll need writable /etc/resolv.conf and /var/lib/dhcp3 if you intend to use dynamic IPs. You’ll probably have to edit /sbin/dhclient-script to account for this if you are going for a full-ro filesystem. This is how my /etc/network/interfaces looks like.
auto lo iface lo inet loopback auto eth0 iface eth0 inet static address 10.0.0.100 gateway 10.0.0.1 broadcast 10.0.0.255 netmask 255.255.255.0
- /etc/etc/fstab: define the mountpoints. Ensure that directories that need to be writable ar mounted as tmpfs rather than letting the system write them to flash. Alternatively you can mount them on external media. You need this to run the rootfs mounted as read-only. Even if you are not going to do so, you *MUST* set the ‘noatime’ flag when mounting, or at least ‘relatime’. If you don’t, every single access to the files will require a read operation to modify the access time, and this is pure overhead for the CF that will significantly shorten its life span. Using journaling is probably another bad idea, since many commits will also affect the CF. Either use EXT2, or use this as a temporary solution and go for the SquashFS-Live system of approach #2.
/dev/sda1 / ext4 noatime,errors=remount-ro 0 0 proc /proc proc defaults 0 0 tmpfs /var/log tmpfs defaults 0 0 tmpfs /tmp tmpfs defaults 0 0 tmpfs /var/lib/urandom tmpfs defaults 0 0 # Define the following ones if you use NFS or dynamic IPs. # Writable paths should be tmpfs or be on external media. # Both settings are OPTIONAL for our current setup. tmpfs /var/lib/nfs tmpfs 0 0 tmpfs /var/lib/dhcp3 tmpfs defaults 0 0
- Logging: either log to a tmpfs as shown above, to an external media, remotely or remove logging capabilities. This step is not optional at all. If you choose any option other than the first one, you’ll probably want to take a look at /etc/syslog.conf, /etc/default/syslogd and your /etc/rc?.d for links to /etc/init.d/sysklogd. Don’t forget the syslog.conf man entry. Note that logging to a tmpfs will give you some warnings at boot-time since some files are expected to exist. It’s probably not such a good idea, since you’ll loose the logs between reboots, troubleshooting vulnerabilities becomes more difficult, and so on. If you do proceed with the idea, you should keep this in mind: some logfiles are expected to be present at boot-time, so you’ll get some errors if you boot with an empty /var/log. Mldonkey also doesn’t boot if it can’t access the logs, so populate the directory with a trivial script such as the following. It must be run at boot-time before /etc/init.d/bootlogs.sh and /etc/init.d/sysklogd are invoked:
#!/bin/sh
### BEGIN INIT INFO
# Provides: madoka
# Required-Start: $local_fs
# Required-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 1
# X-Start-Before: bootlogs sysklogd
# Short-Description: recreate /var/log structure for Madoka
# Description: recreate /var/log structure for Madoka
### END INIT INFO
do_start () {
mkdir -p /var/log/mldonkey
mkdir -p /var/log/news
cd /var/log
touch \
dmesg \
mail.warn \
user.log \
daemon.log \
messages \
debug \
auth.log \
mail.err \
syslog \
mail.log \
kern.log \
lpr.log \
mail.info \
news/news.crit \
news/news.err \
news/news.notice
chgrp adm dmesg
chown syslog:adm \
mail.warn \
user.log \
daemon.log \
messages \
debug \
auth.log \
mail.err \
syslog \
mail.log \
kern.log \
lpr.log \
mail.info
chown news:news news
chown root:news news/*
}
case "$1" in
start)
do_start
;;
restart|reload|force-reload)
echo "Error: argument '$1' not supported" >&2
exit 3
;;
stop)
# No-op
;;
*)
echo "Usage: $0 start|stop" >&2
exit 3
;;
esac
I saved it in /etc/init.d/madoka, and added it to my default runlevel to execute before init.d/bootlogs.sh and /etc/init.d/sysklogd
update-rc.d madoka start 05 2 .
Adding some more goodies
- mldonkey: I just made symbolic links to an external drive. /var/lib/mldonkey/incoming, /var/lib/mldonkey/temp and /var/lib/mldonkey/torrents are the most frequently written directories by far. It also rewrites the configuration files whenever changes are made. Those are also stored under /var/lib/mldonkey/.
- /etc/usbmount/usbmount.conf: this is great if you are going to have lots of external drives. It automatically mounts the devices wherever you choose to (in my case, under my shared samba directory). It just works after rebooting. I only edited the file to specify the mount point and to add more file-systems that I wish automatically mounted:
FILESYSTEMS="ntfs vfat ext2 ext3"
- /etc/samba/smb.conf: to share files and printers, edit yours to resemble these pointers.
# add to [global] section, and edit the rest to your heart's contempt workgroup = WARPCORE printcap name = cups printing = cups security = share socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192 # make sure [printers] section looks like this [printers] browseable = yes printable = yes public = yes create mode = 0700 guest only = yes use client driver = yes path = /tmp
#define at least one share point [shared] comment = Shared media path = /media guest ok = Yes
To have the printers actually work you’ll need to configure them with cups. After having everything tuned, remember to mount the root file-system read-only. Adding the printer is trivial thanks to the administration web interface. Just forward the needed port or make cups accept connections from interfaces other than localhost, and launch your web browser.
ssh -L 2000:localhost:631 10.0.0.100
Then, access the configuration wizard visiting http://localhost:2000. On Windows systems you can add this by simply add ing a new printer with the wizard and browse your samba shares. You should see the printer there, hanging from your samba server. User your disks with the drivers and it should be a done deal.
- /etc/exports: remember to set up this if you are using NFS shares. I export the same things as with Samba.
/media 10.0.0.0/24(rw,sync,no_subtree_check)
Copying the image to the CF
Ok, so now you have a perfectly working system in your virtual machine. That’s great. Time to copy it to the CF. Convert your VDI file to a raw image as shown below, and dump it to the CF.
If you are using the OSE edition of VirtualBox:
vditool DD machine.vdi raw_image.img
If it is the closed-source release, vditool is not available. You’ll have to do it like this:
VBoxManage internalcommands converttoraw machine.vdi raw_image.img
Once you have that, simply dump it to your CF with dd and you are good to go! Mine is detected on /dev/sdc
dd if=raw_image.img of=/dev/sdc bs=1024
Other installation tips
Going for a completely read-only system, even running something as mldonkey, is not that complicated either. Just trace the paths that need to be written frequently with “lsof /” and if you find something that has to modify many files, either replicate the file-structure on tmpfs/ramfs (preferably the former), or better yet, use aufs/unionfs on a temporary file system. Thats the great thing about the live-system approach that I”ll be using next. I’m still working on some rough edges, but I’ll blog about it as soon as the results are perfect :)
Another, simpler approach if you don’t mind the hassle and some extra wear on your CF, simply make a PXE install and customize afterwards following my steps. Here is a nice and easy tutorial to make an Ubuntu net installation in case you want to try that.
Anyway I hope you find this useful. It certainly was for me. Let me know if you find a cheap thin client on Ebay and follow this tutorial. A noiseless server does really make a difference!
You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
Hi! Thanks for this guide. I have bought a Futro S400 and I have installed Ubuntu on it. I have noticed that the write performance on my CF (Kingston 16 gb 133x) is disappointing. 3 mb/sec and less. It’ s the same for you? Hdparm in reading test shows 20mb/sec. Maybe the CF a fake? Thanks. Ivan.
I’m afraid I also noticed the write process was actually kind of slow, but I’m using a white label CF, so it could perfectly be that.
I’d be glad to try out the test you are doing if you want to compare figures ;-)
My reading tests with hdparm showed this, that actually seem worse than yours:
taher@madoka:~$ sudo hdparm -Tt /dev/sda1
/dev/sda1:
Timing cached reads: 228 MB in 2.00 seconds = 113.82 MB/sec
Timing buffered disk reads: 8 MB in 3.13 seconds = 2.56 MB/sec
Again, I haven’t tried this with either the original CF that came with the Futro or a well renowned brand. But writing to the CF should be kept to a minimum, so I’m not really concerned.
You could also install a 2.5″ HDD in the Futro. I’m waiting for the adapter I bought on Ebay to arrive to test how that works out.
Hi Taher,
Firstly let me just tell you that I have been looking for a decent howto for doing this exact thing for some time and am so pleased that yours was so comprehensive and worked first time for me. -
Thanks
Question -
If I have a machine that can take a compact flash and a 2.5″ drive what is the best way to get the core OS onto the compact flash but use the 2.5″ for the tmp /var and anything else that gets written after ?
Do you think if I created a Virtualbox machine with 2 disks and partitioned them at install that I could dd the / into the compact flash and the rest (with a swap ) onto the 3.5″ disk ?
Also I can’t wait until your next post about the different filesystems and optimising the filesystem for flash :-)
Hey Darren!
I’m glad it helped. I’ve had a draft about the whole aufs thing on hold since I installed a 2.5″ HDD on my Futro, but one of these days I want to finish the post. Currently I’m just using the CF as a backup (sdb) in case the HDD (sda) fails or is compromised. Everything is running from sda.
If you insist on running the root filesystem from the CF, I guess you’re left with two options:
1) creating individual partitions and mountpoints for each writable path. /home, /var and /tmp mostly. It’s a good practice anyway, including the /tmp one: this way even if an attack somehow fills up that directory, the root filesystem would still have have space left and the whole system should be able to keep running.
2) a less typical way would be running everything from the CF read-only and mapping all the changes to the HDD by using aufs or unionfs.
Having a regular hard drive on the system I’m not really sure if any of the options are actually worth the trouble. Except for the learning part, of course ;-)
Regarding the other thing you said about using several virtual disks, I don’t see why it wouldn’t work besides the total size of the virtual disk. Remember you have to export the device as raw, so it will take up a lot of space.
If you can hook up the hard drive to the computer running VirtualBox you could also use it directly and save yourself the cloning process. It’s something like this:
VBoxManage internalcommands createrawvmdk -filename YOUR_VMDK_FILE -rawdisk /dev/sdb -register
Another thing: since dd is so slow, you are probably better off without swap in your virtual machine. You can add it later on with mkswap and save some time in the cloning process.
Now that I think about it… to keep it simple I would probably install on a single VirtualBox hard drive. Once cloned to the CF, I’d simply copy the writeable directories to their own filesystems on the HDD, create the swap and fix fstab accordingly.
hmmm… everybody is doing the same thing at once…
Being a very ignorant linux newbie. i just got some sandisk 4gig flash memory at Costco for about $20 each and some ide2cf adapters from ebay for under $5. stuck’em together set the voltage jumper to 5v and loaded in Debian 5 lenny (stable) on one machine (an old Toshiba 7020) & then an earlier sid on another 7020ct, then tried knoppix 6.1 on (all from the various linux mags out there) on yet another ancient device and was off and running. everything works fine on everything. i think point and click linux is here for us dummies. Now for my commercial:
the old pentiums, bless their hearts, run hot. i run simple. so i loaded the old dos6.22 and every dos application almost in existence onto some 2gig compact flash from Staples for about $12 each. but dos is limited in memory use so i did the ramdrive thing and created 2 ramdrives of 30+ megs each (but only one is really necessary but what are you going to do with the remaining blank memory? nothing uses it, so what the heck, make a second ramdrive.) all you have to do is sys the compact flash if it is 2 gig or under. Don’t format it. just sys it for now. hopefully it is empty. anyhow after loading on dos & apps then xcopy your
application(s) to the ramdisk(s) and then copy back to the flash after you are through with your session. That way, the 100,000 write limitation of the ssd’s will not be approached in your lifetime. so for under $20 you have a very nice system with no old hd noise. Plus the cf uses only 50 mw instead of 500 so the battery seems to last longer and it seems that the old mmx or later pentium even runs a LOT cooler. all in all, you get a nice system(s) if you are a minimalist. if not, there is always VISTA with its gazillion files and constant disk access.
and some old 256k, 512k, 1gig, 2gig compact flash from friends and staples
I am having a strange problem with Grub.
It seems if the vga calb eis out – the machine willnot boot (I have set it up to boot to serial (this way I free up my screen at home).
If I connect my work laptop via serial and the vga screen I see the console on both and everything loads fine – If I unplug the screen I see the grub menu and then it just sits there ..
any ideas on this one ?
When you see Grub, you can’t even get to single user mode, right? Not even replugging the vga cable?
I’m completely lost here! Let’s hope some other reader throws some light on this.
I figured it out – I had to change the video memory in the bios to zero (mostly trial and error to get this answer).
Weird stuff since definately got to grub – just could not get further unless I plugged in a vga cable … anyway solved. Yeehah!!
Thanks for the feedback :-)
Just out of curiosity: what thin client were you using exactly? :-)
This is really an excellent write-up. It’s saving me hours of scrambling. I’ve got one tiny problem, though, that I can’t figure out. Everything on this page works just fine, but when I plug the CF card into my SBC (this is an Alix board, and I’m trying to load Ubuntu 8.04 Server), and apply power, I get the message “No boot device available” on the serial port. I know I need to make the CF bootable, but I can’t seem do that with gparted or cfdisk like I have for other boot disks (back in the mists of time.)
Any suggestions? Am I missing a crucial step? Formatting the CF _before_ the installation, maybe? I’m going to try a few things, but I was hoping I was just being an idiot and missing something.
I would suspect either the CF is damaged or the CF reader on your board. I only have 3 ideas to try out, but I doubt they’ll work if the hardware is faulty:
1) fdisk, though it will probably fail if cfdisk couldn’t do the job.
2) Use dd to copy MBR+partition table of a device that has the correct boot flag enabled. Either use another CF to create the same partition table you’ll be needing, or make a raw device to use with QEMU or VirtualBox. If it is a real drive, just use this to obtain the data “dd if=/dev/sdX of=/tmp/sdX.bin bs=512 count=1″, and this to dump it to the destination drive: “dd of=/dev/sdX if=/tmp/sdX.bin bs=512 count=1″. The first 446 bytes are the MBR, and the rest is the partition table. If you are using a virtual (non-physical) device, the commands differ a little depending on what virtualization software you are using.
3) Try to make it active on another reader, such as an external USB CF reader.
I’ll tell you one thing though. I have a CF MicroDrive that behaves exactly the same way you are saying, and none of the above work. But I’m pretty sure the drive itself is broken since it behaves strangely both on my board and an external reader. Good luck! ;)
Hmmm…I just tried it with another CF card that I edited with cfdisk, and got the same error, so I’m going to try another CF reader that I’ve got in the garage that I’ve used before.
This might be my version of VirtualBox OSE, but my vditools command has the order reversed of the in and out files:
vditools DD output_img.img input_vm.vdi
Of course, this is the last I get to play with it for the next three days. Appreciate the help, though, and if I get an answer to my problems, I’ll be sure to post it here. Again, really excellent guide…thanks for the work.
heh – I couldn’t just leave town without knowing. I tried a different CF, formatted a partition as ext3 and set the boot flag with gparted, performed the dd successfully thru another CF reader, and got the same results. Not sure where to go from here, but I’ll try #2 above when I get back to town.
By way of dumping more data on you, _after_ the dd copy of the image, when I try to look at the CF with cfdisk or gparted, it shows not to have a partition table, like it’s a completely new unformatted disk. I must be doing something wrong on image creation of the .vdi, all I can guess.
Apart from an error during creation, I can think of nothing else. Partition editing does require rebooting for the kernel to use the new settings, though with removable devices simply replugging them in should do.
I’ll send you right away the first 512 bytes of a 1GB CF I have that is working. I hope it helps ;-)
Also, I’ve also just tested the method documented above with VirtualBox 2.2.4, and it still works. Not the OSE version, though.
Hi Taher and all,
Let me start by placing a compliment on you tut as it is very clear and easy to follow.
I have a Futro S400 which runs ubuntu 8.10. It runs perfect from an 8 GB CF. Then I tried to get it running ubuntu 9.04 from a 2.5″ HDD. It is great and pretty fast comparing to CF. The only thing I noticed is that the Chip Set heat-sink is becoming pretty hot. It looks like the usage of a HDD requires more effort from the Chip Set. Is it something you experience as well?
I don’t think it is significantly hotter, although it is true that the HDD is adding some heat of its own. Before and after the HDD, the S400 produces enough heat to warm the case a lot, but you can still hold it in your hands indefinitely with no problem (which is something I couldn’t say about the heatsinks on their own).
I do keep the S400 on it’s stand and the HDD has the upper surface totally in contact with the computer case, and I haven’t had any problems running the thing 24/7 since I bought the machine.
Btw, despite lacking temperature sensors both in the processor and board, by examining /proc/acpi/thermal_zone/THRM/trip_points it would seem that 100ºC would be a criticall point. When my desktop reaches 55ºC it feels a lot hotter that the Futro, so I’m not too concerned with reaching 100. All this is a subjective feeling, of course.
It’s great you are looking into this, since I can’t find any other info on how to do this. I really need option #2 – everything in memory. Have you been able to make any progress? I’ve successfully used Ubuntu’s USB Creator to create a bootable USB from my ISO, but I’d like to do the same with an IDE flash drive too.
I started playing around with live-helper, which seemed the way to go back in March. But really never had the chance to actually finish and document the process before I added the 2.5″HDD. It definitely is still on my to-do list.
Hi all,
Can any one tell me how to install grub on compact flash
I’m using kernel 2.26.8
Very interesting article, I have not implemented any of the suggestions as yet as I am still researching.
I set up my Acer laptop a couple of days back using a IDE CF card adapter I purchased form Hong Kong for £1.99 GBP and an 8GB x200 CF card for £18.86 GBP. I installed the latest Ubuntu 9.04 – Jaunty.
For file storage I am using Amazon S3 and jungleDisk mapping my storage as drives on my laptop so basically I have unlimited storage. This works grate for Documents which now point to my S3 storage and I also have a separate storage area for Photo’s.
The system runs quit fast and boots a lot quicker, my original Laptop HD was a 100gb 7200rpm drive so quite quick.
I have as yet not turned off my swap file or moved any log files to tempfs.
chris@chris-laptop:~$ sudo hdparm -tT /dev/sda
/dev/sda:
Timing cached reads: 888 MB in 2.00 seconds = 443.59 MB/sec
Timing buffered disk reads: 80 MB in 3.00 seconds = 26.65 MB/sec
Chris: Nice setup, but I’ve read that CFs tend to die in a couple of months, so at the very least I would turn off the swap.
Ravi: Assuming your CF /dev/sda1 is mounted under /mnt/cf, something like this should do:
grub-install /mnt/cf –recheck /dev/sda
This will install the bootloader, which you’ll have to configure. Enter a chroot environment on your cf card and use update-grub
If you need more details, you could check out this post. There’s a script that will show you every step needed: http://blog.quinthar.com/2008/07/building-1gb-bootable-qemu-image-using.html
Hi Taher,
From the reading I have done on the swap partition it does not get used unless you run out of RAM, as I have 2GB this is fairly unlikely depending on what I get up to of course. So far my monitoring has shown 0 swap usage.
I have followed your advice on moving the log files to tmpfs, I did consider disabling these completely but decided that for debug they would be useful. I have also moved my browser cache to tmp which is in tmpfs.
So far everything is running great with a full Ubuntu install on the 8gb card, still have 3.3gb free on the card though with the Amazon S3 it is really unlimited.
I will give it a few weeks and maybe splash out on a 300x CF card, the card make is SILICON POWER from Taiwan.
Hello Taher,
Thank you for this posting!
I’m trying to apply this on a pure Jauntu Server installation. All seems to work except the script (madoka) that is supposed to re-create the environment inside the ‘/var/log directory’.
First,
Running ‘update-rc.d madoka start 05 2′ gives an error back, complaining about a missing “.” at the end of the arguments.
I think I’ve solved it by running “update-rc.d madoka start 05 2 .” instead.
Second,
The script doesn’t run at boot, making the log file daemon complaining on missing files and folders.
I have not tried to apply the post on a Jauntu Desktop, since this is not my goal. So, how can the script execution be solved?
Sincerely,
Peter
Hi Peter! You’re absolutely right!
I posted the wrong script, the first -non LSB-Init conformant- version that would have update-rc.d choke on it. I also missed the ‘.’ on the invocation. I’ve just updated the post. Thanks.
I’m afraid I was a bit sloppy when I took the notes to write this ;-)
Hopefully I’ll do a better job when I write about the Live-system installation. I’m currently installing this same setup in under 200MB, so I’ve got another 50-60 to save updates in my 256MB card.
I just need to make some free time to document the process, though.
Let me know if you find any more errors.
Hello again, Taher!
Now I finally made it to work. (Ubuntu Server 9.04 LAMP + SSH + Samba)
Ok… Found a typo in your posting. The lines for the fstab:
“tmpfs /var/lib/nfs tmpfs 0 0″
Should be:
“tmpfs /var/lib/nfs tmpfs default 0 0″
Then I wonder if the “proc /proc proc defaults 0 0″ really is necessary, since the “/proc” is already made into tmpfs by default(?). You probably know that better than me.
The mtab solution gives an “fail” message during boot process:
rm /etc/mtab
ln -s /proc/mounts /etc/mtab
But it looks like everything is still okay. The “/proc/mounts” do have a little bit more lines and information than the regular “/etc/mtab” got. Maybe the fail message can be ignored without any worries.
The madoka -file for my setup looks like this:
——————————————————
#!/bin/sh
### BEGIN INIT INFO
# Provides: madoka
# Required-Start: $local_fs
# Required-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 1
# X-Start-Before: bootlogs sysklogd
# Short-Description: recreate /var/log structure for Madoka
# Description: recreate /var/log structure for Madoka
### END INIT INFO
do_start () {
# mkdir -p /var/log/mldonkey
mkdir -p /var/log/apache2
touch \
/var/log/apache2/access.log \
/var/log/apache2/error.log \
/var/log/apache2/other_vhosts_access.log
chown root:adm \
/var/log/apache2 \
/var/log/apache2/access.log \
/var/log/apache2/error.log
chmod 710 /var/log/apache2
chmod 640 \
/var/log/apache2/access.log \
/var/log/apache2/error.log
chmod 644 /var/log/apache2/other_vhosts_access.log
mkdir -p /var/log/apparmor
chmod 755 /var/log/apparmor
mkdir -p /var/log/apt
touch /var/log/apt/term.log
chmod 755 /var/log/apt
chmod 600 /var/log/apt/term.log
mkdir -p /var/log/ConsoleKit
touch /var/log/ConsoleKit/history
chmod 755 /var/log/ConsoleKit
chmod 644 /var/log/ConsoleKit/history
mkdir -p /var/log/dist-upgrade
chmod 755 /var/log/dist-upgrade
mkdir -p /var/log/fsck
touch \
/var/log/fsck/checkfs \
/var/log/fsck/checkroot
chown root:adm \
/var/log/fsck/checkfs \
/var/log/fsck/checkroot
chmod 755 /var/log/fsck
chmod 640 \
/var/log/fsck/checkfs \
/var/log/fsck/checkroot
mkdir -p /var/log/installer
chmod 755 /var/log/installer
mkdir -p /var/log/landscape
touch /var/log/landscape/sysinfo.log
chown landscape:root \
/var/log/landscape \
/var/log/landscape/sysinfo.log
chmod 755 /var/log/landscape
chmod 644 /var/log/landscape/sysinfo.log
mkdir -p /var/log/mysql
chown mysql:adm /var/log/mysql
chmod 2750 /var/log/mysql
mkdir -p /var/log/news
touch \
/var/log/news/news.crit \
/var/log/news/news.err \
/var/log/news/news.notice
chown news:news /var/log/news
chown syslog:adm \
/var/log/news/news.crit \
/var/log/news/news.err \
/var/log/news/news.notice
chmod 2755 /var/log/news
chmod 640 \
/var/log/news/news.crit \
/var/log/news/news.err \
/var/log/news/news.notice
mkdir -p \
/var/log/samba \
/var/log/samba/cores \
/var/log/samba/cores/nmbd \
/var/log/samba/cores/smbd \
/var/log/samba/cores/winbindd
chown root:adm /var/log/news
chmod 750 /var/log/news
chmod 700 \
/var/log/samba/cores/nmbd \
/var/log/samba/cores/smbd \
/var/log/samba/cores/winbindd
touch \
/var/log/auth.log \
/var/log/boot \
/var/log/btmp \
/var/log/daemon.log \
/var/log/debug \
/var/log/dmesg \
/var/log/dpkg.log \
/var/log/faillog \
/var/log/kern.log \
/var/log/lastlog \
/var/log/lpr.log \
/var/log/mail.err \
/var/log/mail.info \
/var/log/mail.log \
/var/log/mail.warn \
/var/log/messages \
/var/log/mysql.err \
/var/log/mysql.log \
/var/log/pycentral.log \
/var/log/syslog \
/var/log/udev \
/var/log/user.log \
/var/log/wtmp
chown syslog:adm \
/var/log/auth.log \
/var/log/daemon.log \
/var/log/debug \
/var/log/kern.log \
/var/log/lpr.log \
/var/log/mail.err \
/var/log/mail.info \
/var/log/mail.log \
/var/log/mail.warn \
/var/log/messages \
/var/log/syslog \
/var/log/user.log
chown root:utmp \
/var/log/btmp \
/var/log/lastlog \
/var/log/wtmp
chown root:adm \
/var/log/boot \
/var/log/dmesg \
/var/log/dpkg.log
chown mysql:adm \
/var/log/mysql.err \
/var/log/mysql.log
chown root:root \
/var/log/faillog \
/var/log/pycentral.log \
/var/log/udev
chmod 640 \
/var/log/auth.log \
/var/log/boot \
/var/log/daemon.log \
/var/log/debug \
/var/log/dmesg \
/var/log/dpkg.log \
/var/log/kern.log \
/var/log/lpr.log \
/var/log/mail.err \
/var/log/mail.info \
/var/log/mail.log \
/var/log/mail.warn \
/var/log/messages \
/var/log/mysql.err \
/var/log/mysql.log \
/var/log/syslog \
/var/log/user.log
chmod 664 \
/var/log/btmp \
/var/log/lastlog \
/var/log/wtmp
chmod 644 \
/var/log/faillog \
/var/log/pycentral.log \
/var/log/udev
}
case “$1″ in
start)
do_start
;;
restart|reload|force-reload)
echo “Error: argument ‘$1′ not supported” >&2
exit 3
;;
stop)
# No-op
;;
*)
echo “Usage: $0 start|stop” >&2
exit 3
;;
esac
——————————————————
Here’s a significantly different approach… Just [dramatically] reduce the frequency at which the kernel flushes the disk cache! To do that, you add the appropriate modifications to kernel parameters in /etc/sysctl.conf:
vm.laptop_mode = 600
vm.dirty_ratio = 40
vm.dirty_background_ratio = 1
vm.dirty_writeback_centisecs = 60000
In this way, you run a much higher risk losing (the recently written) data during a power loss, but just add a UPS with comms and you can save and shutdown cleanly, then no problems at all!
If you want to get a little bit more fancy (and have sufficient RAM), you can mount most of the /var stuff on a RAM drive (during boot up using simple tmpfs entries in mtab), and you can probably reduce the number of archive copies of each log file (see the cron logrotate configs) just to save precious CF space…
I’ll admit that I only have about a year’s worth of run time on the dozen or so machines that I set up this way, however the first experiment (close eyes and pretend it’s magnetic media) failed reliably within a month!
Greetings, You write some very good blogs. I verify back here always to find out should you have kept as much as date. I notion you’ll be able to desire to know, once I click your RSS feed it re-directs me to an additional website
7 osi layers…
[...]Jaunty Server on Compact Flash: running Ubuntu 9.04 on a Thin Client | UnixWars[...]…
电动调压器厂家…
[...]Jaunty Server on Compact Flash: running Ubuntu 9.04 on a Thin Client | UnixWars[...]…
smaba…
[...]Jaunty Server on Compact Flash: running Ubuntu 9.04 on a Thin Client | UnixWars[...]…
no 1 host…
[...]Jaunty Server on Compact Flash: running Ubuntu 9.04 on a Thin Client | UnixWars[...]…
Free Download Software, Games, Movie, eBook, Music, TV-Shows, GFX…
[...]Jaunty Server on Compact Flash: running Ubuntu 9.04 on a Thin Client | UnixWars[...]…
pool table room size…
[...]Jaunty Server on Compact Flash: running Ubuntu 9.04 on a Thin Client | UnixWars[...]…
tools in Ukraine…
[...]Jaunty Server on Compact Flash: running Ubuntu 9.04 on a Thin Client | UnixWars[...]…
Woah this weblog is excellent i like studying your articles. Stay up the good work! You realize, many people are looking around for this info, you can aid them greatly.
metal in Ukraine…
[...]Jaunty Server on Compact Flash: running Ubuntu 9.04 on a Thin Client | UnixWars[...]…