I recently read about Cupt a rewritten apt-get replacement that apparently would be more suitable for low end machines. Well it's not specifically written for low end machines, I guess it's just less resource demanding.
Anyway I decided to try upgrading my old Toshiba 320CDS from Debian Squeeze to Wheezy using cupt. Upgrading in Cupt comes in a couple of different flavors. I decided to go with the one I know best: sudo cupt update sudo cupt dist-upgrade
Actually all things went fairly smooth apart from conky breaking the upgrade halfway through. I resolved this minor issue by just removing conky (sudo cupt remove conky) when the upgrade broke and then just start the upgrade from scratch (or whatever state my system was left in).
When the upgrade was done, everything seemed to be ok, but at reboot I was dropped to busybox...(sigh) as usual. This happens because I have to used the ide-generic kernel module to boot from my ide disks.
I typed in: modprobe ide-generic
But my system said that no module with that name was available... (this is where I panicked and retyped that about twenty times trying different combinations of ide, -,_ and generic). Naturally that didn't accomplish anything so I googled a bit and found that ide-generic had been removed from the kernel packages and been replaced by pata_legacy.ko
So instead I tried: modprobe pata-legacy
The module loaded and my drives were recognized. I hit CTRL-D and the boot resumed.
As soon as my system was up and running I replaced ide-generic with pata-legacy in /etc/initramfs-tools/modules
and issued: sudo update-initramfs -u
...and rebooted without a hitch. Well actually, first I replaced it with pata-generic, which of course is very wrong and got dropped to busybox again. But I will never admit to that. ;)
Also I must say that cupt feels a tad bit snappier than apt-get.
Forget everything I wrote in my previous post. Like Andrew pointed out in the comments on my youtube video and the blog, running a cron job every minute isn't really optimal. There is a better way to do it.
The fun part is that it doesn't require autofs since it uses udev rules and can find out the id of a USB stick (or any other device I guess) upon connection instead of going through the mounting process. At the same time it also manages quite nicely renders my script obsolete since you can issue "shutdown -h now" directly. Oh, did mention it's A LOT faster.
Well enough with the talk here's how you do it:
Find out the vendorId and productId of your USB stick:
$ lsusb
Here's my output, the numbers you want are the ones after "ID" the first one is the vendorId and the latter productId:
Bus 001 Device 003: ID 0781:7114 SanDisk Corp. Cruzer Mini
Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Then create an aptly named file in: /etc/udev/rules.d/ I went with: 100-usb-device-action.rules
Then add the following line, just substitute your vendorId and your productId
This post is sort obsolete since there is another way to shutdown linux nicely that requires less of everything. You can read about it here. However maybe you came for the script that looks for a file and issues a command. Well then you're in the right place, just scroll down a bit.
Shutdown Linux nicely with a USB stick
If I had such a thing like a following from regular readers you would probably know about my ancient Toshiba Satellite 320CDS laptop that now serves as a digital picture frame. The only problem is to have it shut down properly.
Why is that a problem you ask?
Well, I can't use the power button as it just cuts the power and I risk getting disk errors that most likely forces me to hook up a keyboard on the next boot. Something that I rather avoid.
But I can do it via a ssh connection. However that requires a working network connection and another device. That leaves me with the option I'd rather avoid. Connecting a keyboard and manually shutting the system down. Ok, not the end of the world but it's a bit tedious to have to drag out a keyboard each time I want to do a shut down.
My solution for this is a script that checks if a certain file is present in a defined directory. If the file is present the script issues the "shutdown -h now" command. The physical part of this is that the file is contained on a USB stick that when inserted automounts to a certain location. By running the script from root's crontab I now have a way to make Linux shut down nicely without a working network connection or keyboard.
Howto: Shutdown Linux nicely with a USB stick
So what is needed for this to work? Well first of all here's my script. It's not very complicated and you should be able to tailor it according to your needs. Perhaps you want to run a slideshow with the pictures on a USB stick when inserted or maybe even completely wipe your system.
The next step is to make a USB stick automount in a certain directory.
For this we need to install autofs. There's good tutorial on this here and here, but I'll give you the basics below.
Since I run debian installation is as easy as: $sudo apt-get install autofs
To configure autofs I started by adding this line to /etc/auto.master /media /etc/auto.removable --timeout=2
Then I added this line to /etc/auto.removable usb-shutdown -fstype=ext2UUID=UUIDOFYOURDEVICE
The UUID is the Universally unique identifier of a disk. In this case we use it as way to know what USB stick to mount in /media/usb-shutdown/
You can find out the UUID of your device with: $ls -la /dev/disk/by-uuid/
This will give you a list of your devices with symlinks pointing to their labels i.e /dev/sda1 etc. Alternatively you could run the following command, substituting /dev/sda1 to your device. $sudo blkid /dev/sda1
Finally to make autofs recognize your changes run: $ /etc/init.d/autofs restart
Last but not least we have to make the script run at a certain interval. This is done via the cron daemon. To edit root's crontab type following, if you want to edit the current user's crontab just omit the "sudo": $ sudo crontab -e
Add the following lines:
# Check if USB device with "systemHaltNow" is present * * * * * /PATH/yourscript.sh >/dev/null 2>&1
The stars tell cron to run the script once every minute forever and ever and ever. The last part stops cron from e-mailing you and logging everytime it executes the script, more info on that here.
Well like the title says shairport works quite nice with really old hardware and I do think 16 years qualifies as really old when it comes to computers.
Here's the specs: Toshiba Satellite 320CDS CPU: 233 Mhz Pentium MMX RAM: 96 MB HDD: SandDisk Compact Flash 8 GB Extreme IV via Lycom CF 2 IDE Bridge OS: Debian Gnu/Linux Squeeze
When streaming music from iTunes shairport uses about 38% CPU, quite a lot compared to mpg123 that only draws 10 % CPU. But really I'm just impressed that it works. When it comes to RAM shairport uses roughly 4 % of my available 95 MB.
The output of shairport isn't really that much fun
to look at so here's a screenshot of top instead.
I'm not going to tell you how to do it. That's pretty much covered here.
I've recently grown quite fond of my old Toshiba Satellite* that currently exists in the form of a digital picture frame. I'm still not sure what to do with it but I've started exploring the possibilities of removing xorg completely and focusing solely on a command line interface.
First thing is that I want to make it more robust, i.e. protect the CF-card from excessive disk writes and possible power failure. I could go with a dedicated dist such as Slitaz, Puppy or Tiny Core but I kind of like my own debian system. So I decided to go with reducing disk writes.
I've taken a few steps to reduce disk writes already. But then there is the never ending logging. So I took some of my precious RAM and put /var/log in it. I found some instructions on that here.
To accomplish this I added the following line in /etc/fstab tmpfs /var/logtmpfssize=4M,defaults,noatime,mode=075500
So far I'm only using 4 MB but I could probably lower this. I just need to keep it running for a while and see how logrotate works.
To prevent the 4 MB of log space to fill up uncontrollably I've configured logrotate from the default weekly rotation of logs to daily rotation and keeping only 1 day of backlog. I also added a size limit to each log file to 100k. But as far as "man logrotate" tells me this won't affect the logs more than once daily as the logrotate cron job only runs once each day.
As of now I've edited /etc/logrotate.conf accordingly.
# rotate log files daily
daily # keep 2 days worth of backlogs rotate 2
**PLEASE NOTE!
The above had little effect on my running system. Turns out many of the logs had separate instructions in:/etc/logrotate.d
Update them accordingly and you should be in business.
* Toshiba Satellite 320CDS CPU: 233 Mhz Pentium MMX RAM: 96 MB HDD: SandDisk Compact Flash 8 GB Extreme IV via Lycom CF 2 IDE Bridge OS: Debian Gnu/Linux Squeeze
For some reason I can't use PTT Twitter anymore so I started to look around for another console based twitter client. I found TTYtter. However I ran in to problems with the time being way off on my Digital Picture Frame. Probably because I haven't bothered to set it at all.
My browser of choice is Kazehakase, a small foot print browser that can use either the Webkit or the Gecko rendering engine. It can handle alot more than Dillo but uses way less resources than Firefox. I found out about Kazehakase while reading the blog of K. Mandla.
However there is a problem. Kazehakase is not a very well documented browser. In it's manual there is a reference to using "Actions" with the browser, but the actions themselves aren't documented. Luckily enough I found out how to start Kazehakase in full screen mode by some trial and error.
The short story: kazehakase -a "ToggleFullScreen" your_url_here
I got kind of bored of my digital picture frame, like i normally do when a project is finished. So I wanted to do something else with it. One of the things I wanted to try to use was the command line interface instead of X. The idea was to get some nice scrolling text on the screen. An IRC-frame sounded like a nice idea until I realized I really want the system to be automatic and since IRC sometimes requires you to interact I decided to go with twitter instead.
I surfed around and found that PTT (Python Twitter Tools) seemed to be what I needed. To install PTT in Debian (I guess the same goes for all other debian derivatives like Ubuntu and so on) you first need to install the packages python-twitter and python-setuptools, and their respective dependencies. To do this simply type the following in a console/terminal: sudo aptitude install python-twitter python-setuptools
Then install installed PTT with: sudo easy_install twitter
Now it's just a matter of either using the proper command line options to get PTT to do your bidding. To get an idea of what you can do simply type: twitter -h
Since I like config-files I created one in my home dir called .twitter (this also happens to be the default config file PTT looks for. This is what my .twitter file contains:
The email and password options are pretty self explanatory if you have a twitter account. Format however is the way twitter presents itself on your screen. format: verbose | Prints out the full twitter post rather than just one line as per default. format: ansi | Uses ansi coloring on the different usernames.
Since .twitter contains your password it can be a good idea to only allow your user to read it: chmod 400 .twitter
Now that I had PTT working the way I wanted I simply added "twitter -r" to my .bash_profile to have it automatically launch after my system boots up. The "-r" causes PTT to continue running and updating the twitter feeds every five minutes.
Inspired by the many digital picture frame tutorials online I decided to make one myself. First I jotted down some goals:
Use a minimal amount of hardware and achive total silence. Solution: Strip away, speakers, battery, CD- and floppy drive. Instead of the hard drive use a Compact Flash card with a CF-IDE bridge.
Use a minimal amount of wires. Solution: Use wireless networking.
Design with a thin and flat formfactor. Solution: Mount everything between two sheets of transparent polycarbonate or acrylic glass (plexi glass).
Run without keyboard or mouse. Solution: Remote control via ssh and/or vnc.
Easy power up/down via the power button. Solution: Autologin in console and run X and other stuff from .bash_profile Problem: Since the Toshiba 320CDS uses an APM BIOS it cannot read events on the power button. In other words it cannot power down nicely using the power button. Any ACPI BIOS would be able to.
Display a slide show of images. Solution: Use Feh, a very capable lightweight image viewer.
Lenghten the life of the CF card by minimising disk writes/reads after boot. Solution: Do not use swap on the CF card, store images online, configure the system to report less.
Display a Pong Clock. Solution: Use the pong xscreensaver. Problem: Won't run smoothly @233 MHz
To use multiple networks, use the following configuration to activate roaming mode:
Edit /etc/network/interfaces: allow-hotplug wlan0 auto wlan0 iface wlan0 inet manual # this has to be set to manual, dhcp configuration is done later wpa-driver wext wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf #id_str="[NAME_OF_NETWORK]" is the identifier that corresponds to the network configuration in wpa_supplicant.conf iface [NAME_OF_NETWORK] inet dhcp
Add your USER to the group fuse: sudo adduser USER fuse For this to activate you have to log in again, the easiest way to do this is: su USER
Mount your remote directory by adding this line to .bash_profile: curlftpfs -r -o user=FTPUSERNAME:FTPPASSWORD FTPURL DIRTOMOUNTIN
If you ever have to unmount the directory you can do this with umount as root or with fusermount -u as a user.
Start remove mouse cursor and start slideshow after starting x:
Add these lines to ~/.config/openbox/autostart.sh: unclutter & feh --full-screen --randomize --auto-zoom --slideshow-delay 10 /home/makkan/images/ &
Disable screen blanking:
First of all make sure the bios doesn't blank the screen.
Add these two lines to .bash_profile: setterm -blank 0 setterm -powersave off
Edit /etc/console-tools/config Change this line: BLANK_TIME=30 To: BLANK_TIME=0
In your ~/.config/openbox/autostart.sh add these lines: xset -dpms & xset s off & xset s noblank &
Reduce disk writes
If you have to use swap to get things working set it to minimal use by editing: /etc/sysctl.conf Add the line: vm.swappiness=0
In /etc/sysctl.conf also activate laptop mode by adding the line: vm.laptop_mode=5
Activate your new configuration by typing: sudo sysctl -p
Rsyslog writes a MARK every 20:th minute, disable this by editing /etc/default/rsyslog and set: RSYSLOGD_OPTIONS="-m 0" Restart rsyslog with: sudo /etc/init.d/rsyslog restart
Cron writes a report every hour/day/week and so forth. Disable this by editing: /etc/crontab
I've tried a wide range of Linux distributions on this old laptop, from Slackware to Ubuntu via DSL. But I finally settled with Debian. I've used Slackware since 3.X and I originally intended to use here aswell. However that was a couple of years ago and I had alot of issues with sound and the wireless. Then Ubuntu came along and sound and wireless worked without any problems at all. But Ubuntu is not really ideal to run on a 233MHz system with only 96 MB RAM. So I tried other variants of Ubuntu like: Xubuntu, Fluxbuntu and server installations of Ubuntu. However when I was looking for a good tutorial to do a minimal installation of Ubuntu I came across a good tutorial for Debian aswell.
The reason I tried Debian is because I had alot of trouble with Ubuntu dropping out to busybox while booting the installation CD. I temporarily solved that as described below but I got really tired of it aswell.
Load ide-generic on failed boot of an installation CD. In busybox type: modprobe ide-generic Press: CTRL-D to continue booting.
A similar problem might arise during the installation process. Ubuntu will fail to find your CD and ask to scan for it. Before scanning open up another terminal and load the module from there.
Load the ide-generic module on a running system. Press ALT-FX to open up a free terminal. X= 1-4 Type: modprobe ide-generic Now scan again for the CD.
On a final note, since this problem will persist until you do something about it. After your first successful boot, before you do anything else.
Load the ide-generic module on boot. Type: sudo nano /etc/initramfs-tools/modules Add the line: ide-generic Save and quit. Type: sudo update-initramfs -u
The above issues does not exist in Debian and like I said before, thats why I ulitmately went with Debian. To do a minimal install with Debian just follow the above link to the tutorial and you're set.
Other stuff worth mentioning. Wireless: 3com Office Connect 11g PCIMCA card. The card will be detected by the kernel while installing. But it won't start since the firmware is missing. The firmware can be aquired here. There's a really good tutorial in the ubuntuforums.org that describes how to set up a wireless card and have it working with WPA encryption from boot. Sound: OPL3-SA2 Just run alsaconf and have it autodetect your soundcard. Boot options: acpi=off, noapic, nolapic, vga=788 I use the above line, try to find out whats best for your setup.