Mar 112012
 

Recently I had some issues with my free DNS service, it wasn’t updating my DNS so I couldn’t access my server remotely.
After this happened a few times, I decided to modify one of the configuration files so that it would email me my external IP address each time the PPP connection came up. This ensured that I would get the latest IP address emailed to me ASAP.

What You Will Need :

Sendmail or equivalent on the linux box that you doing this on.
The PPP connection needs to be on the linux box also for this tutorial, however I will write up a guide that uses an external website instead later on.
A commandline mail sending program, I have used mailx in this example, which is symlinked to mail.

How To Do It :

To do this, I added a file in this directory ( on my Debian System ) –

/etc/ppp/ip-up.d/

which I have named “EmailIP”.
Scripts in this directory are run when the ppp connection goes up.

The file contains the following line which does the gruntwork

echo Connection has come up - New IP Address : `ifconfig ppp0 | grep inet | awk -F' ' '{ print $2 }'|awk -F: '{print $2}'` | /usr/bin/mail -r <From@example.com> -s IP-Address <Email@example.com>

What that command does is pipe the text “New IP Address : ” followed by the output of ifconfig ppp0 which is then grepped down to the inet line, and then awked down to the actual IP address and pipe it into the mail command which can send an email via sendmail or whatever mail daemon you have installed.
The sendmail command has the following parameters specified –
-r : specifies the address that the email appears to be coming from (From@example.com in the example)
-s : specifies the subject of the email (IP-Address in the example)
Email Address (Email@example.com in the example)

Then once you have the script in place, when the ppp connection goes down then comes back up, you should get an email to the email address you specified with the text “Connection has come up – New IP Address : <Your New IP Address>

Share

Jul 192011
 

Hi All, just a quick update today.

I was trying to get NFS working today but kept running into errors.
Whenever I tried to start imapd, I would keep getting this error –

rpc.idmapd[12599]: main: fcntl(/var/lib/nfs/rpc_pipefs/nfs): Invalid argument

Turns out, I didn’t have dnotify support enabled in the kernel.
Enabling this now, and will be testing very soon.

Just a quick tip for anyone coming across this issue !

Cheers all.

Share

Jun 232011
 

Hi All,

I’ve been working on fitting a webcam streaming server on a thin client.

Using Debian, I managed to get the base distribution down to 150 megabytes with my own kernel and stripping out unwanted packages like aptitude, logrotate, vim, and the default kernel with all of it’s modules.

After installing ffmpeg and openssh server, the distribution was brought to just under 200 megabytes.

Once I have the kernel installed and detecting my webcam, I can use ffmpeg and ffserver to stream video from the webcam to my network.

I created this ffserv.conf file in my root home directory –


Port 81
BindAddress 0.0.0.0
MaxClients 10
MaxBandwidth 50000
NoDaemon

<Feed webcam.ffm>
file /tmp/webam.ffm
FileMaxSize 10M
</Feed>

<Stream webcam.mjpeg>
Feed webcam.ffm
Format mjpeg
VideoSize qvga
VideoFrameRate 10
VideoBitRate 100
</Stream>

That conf file will setup the parameters, and stream settings for ffserver to use when it starts streaming.

The first stanza sets up the port that the server will listen on, and the address.
The other 3 lines are self explanatory.

The Feed stanza is just defining the feed name and file it will use, while the stream stanza sets up the stream.

I am using mjpeg format as it’s light on the CPU but you can use other formats like FLV or ASF.

Once the config file has been created, you can use this command to start the streaming server.


ffserver -f /root/ffserv.conf & ffmpeg -v verbose -r 5 -s 320x240 -f video4linux2 -i /dev/video0 http://localhost:81/webcam.ffm

That command with start ffserver with the parameters in /root/ffserv.conf, and then start ffmpeg with a verbosity level of verbose, a default frame rate of 5, a size of 320×240, format of video4linux2, and an input device of /dev/video0, streaming it to http://localhost:81/webcam.ffm.

If you want to add audio to the stream, add the parameters –

-f oss -i /dev/dsp

Once the server has started streaming, you should be able to open the stream with a browser if the webcam is being streamed via mjpeg using the address of http://yourwebcamserver:81/webcam.mjpeg – replacing ‘yourwebcamserver’ with the IP address of the server hosting the stream.

You can also use a player like VLC to open a FLV or ASF stream.

Any questions of feedback ?
Please leave me a comment :)

Share

May 262011
 

Hi All,

Recently I decided to update my Lenovo laptop’s BIOS, but I didn’t have any blank CDs to burn the update iso onto.
Now that I have my PXE server running though, I can boot the ISO over PXE !

So first step was to grab the ISO file from the Lenovo website.
Once you have the ISO file, you will need to copy it to your /tftpboot/ directory, and depending on your style, a subdirectory. I have my ISO file in a subdirectory called lenovo, so the full path would be /tftpboot/lenovo.

Next up is to modify the pxelinux.cfg/default file to add the lines you will need for the ISO file.
Now you will need the memdisk kernel before you add these lines.
If you haven’t already found it, it can be found in the /usr/lib/syslinux/ directory.
I have put memdisk into the boot subdirectory for this exercise, and then added the following block to my default file.


label LenovoBios
menu label Lenovo BIOS 66ET60WW
kernel boot/memdisk
append initrd=lenovo/66et60ww.iso iso

You’ll have to replace the ISO file name with the file that you downloaded, but you should be able to boot off that and update the BIOS that way as I’ve managed to do it with my Lenovo 3000 N200 laptop.

Share

May 192011
 

Hi All,

I’m in the process of setting up PXE for some computers of mine, but I wanted them to have a separate configuration file as they do not have the power to run some of the other options, so I don’t want them to show up. I didn’t want to define specific IP addresses for the computers either or use IP specific configuration files as IP address may change.

So, what I did is to make a configuration file with the SYSUUID as the filename, since the SYSUUID is based off the mac address of the computer.
Then when it loads, the computer will boot off the SYSUUID configuration file instead of the default one.
You can find the SYSUUID on the boot page when a computer is booting from the network.

The SYSUUID is outlined in red, and quite long, but if a file is named that then the computer will boot off it, as that one is currently doing.

Share

May 172011
 

Hi All,

In my previous post regarding booting Tiny Core Linux over PXE, we were booting a premade image that did not have much installed by default.
In this post, we will remaster the image into something usable that we can boot off by extracting all the files that we need and merging the directories then repacking it all into one. One of the advantages of doing it this way is that it lets you modify all the files in the root file system before you repack it all up.

What we will need to do is to get the tcz files for the applications we want to install, and merge them into the default tinycore.gz image. This will result in a larger tinycore.gz file but when the image is booted, applications will be pre-installed. This can be useful for diskless workstations in an office or netcafe for example.

So, onto the hard parts.


Step 1 – Getting the TCZ files

Ok, so once we’ve decided what software we want, we will need the TCZ files for the software we want.
This Site has a list of all the software we need and their dependencies, though it’s a bit tedious to download every single file as I haven’t found any other way to download what we need.

So, I took a shortcut.
Boot up Tiny Core Linux either using a virtual machine or real machine using PXE or some other boot media.
Install all the software you want via the app manager, and then all the files you need are in /tmp/tce/optional/.
To do this, you will need an internet connection on the computer that you’re booting Tiny Core on.

For me, I will install Firefox, OpenSSH (SSH Client and server), conky, pci-utils, and util-linux-ng, but you can choose what you want to install.
After I have installed the software, all the tcz files I need will be in /tmp/tce/optional/ and should look something like this :

After all the files are there, we will need to transfer them to a different computer to do the remastering.
In this case, I will be transferring them to my PXE server which will be doing the remastering.

Step 2 – Uncompressing Everything

Once we have all the tcz files where we need them, we will need to uncompress them as they are all compressed using squashfs.
We will need to install some additional tools to do that, namely squashfs-tools.

apt-get install squashfs-tools

Once that is installed, we can unsquash all the files so that we can access them like a normal filesystem.
I’ve written up a little script to do it all for me in this case :


#!/bin/bash
for i in $( ls ); do
if [ ! $i == "unsquashall.sh" ] && [ -f $i ]; then
unsquashfs -f $i
fi
done

I’ve named this unsquashall.sh, and have put this into the directory where all the tcz files are.
If you copy and paste this into a .sh file, don’t forget to make it an executable file by running :

chmod +x unsquashall.sh

After you run unsquashall.sh, you will have a directory called squashfs-root which will contain the contents of all the tcz files.

What you will also need, is the core of Tiny Core, the tinycore.gz file. This is a gzipped cpio file which contains the main file system of Tiny Core Linux.
You will want tinycore.gz in it’s own directory when you extract it to make things easier, I have used /tftpboot/tc/temp for that.
To extract tinycore.gz, you will need to run this command as root, or alternatively use sudo before this command.


zcat tinycore.gz | cpio -i -H newc -d

Step 3 – The Merge

Once you’ve extracted the contents, you should see something similar to this :

Looks just like the root file system of a Linux distribution doesn’t it ?
Now, we need to copy the contents of that squashfs-root directory that we created before into this directory.
I have the squashfs-root directory in the /tftpboot/tc/tcz directory, so the command I will be running is :


cp -Rp /tftpboot/tc/tcz/squashfs-root/usr/ /tftpboot/tc/temp/

Step 4 – Repacking Everything

After doing that, we need to repack everything up.
I have made another script for that –


#!/bin/bash
find | cpio -o -H newc | gzip -2 > /tftpboot/tc/tc.gz

Once again, you will need to make the file executable and it should be placed in /tftpboot/tc/temp/.
Once run, this script will create the tc.gz file in /tftpboot/tc which will replace the tinycore.gz file.
I have also copied the kernel bzImage from the iso file into the /tftpboot/tc directory also.

Step 5 – Configuring PXE

Once all that is done, we now need to reconfigure pxe to boot the new Tiny Core initrd file.


LABEL tinycorerm
MENU LABEL Tiny Core 3.6 Remaster
kernel tc/bzImage
append initrd=tc/tc.gz

Should look something like :


So when you boot up the remastered Tiny Core, you should see Firefox in the dock – that’s if you chose to install it.

Share

May 162011
 

Hi all,

I’ve had a play around with Tiny Core Linux recently, and I’m amazed at how they have fit in a window manager and some basic utilities into 10 megabytes.
You start off with a very basic system, consisting of only the Window Manager, and Application manager.

With Tiny Core Linux, you install applications by downloading the tcz files, and loading them via the Application Manager. Alternatively you can remaster the default image to add more applications, which I will also cover later on as it can work extremely well in conjunction with netbooting.

So without further ado, onto the simple process of PXE booting Tiny Core !


Step 1 – Getting Tiny Core

As always, we need to get the files we need first before we can boot from them.

wget http://distro.ibiblio.org/tinycorelinux/3.x/release/tinycore-current.iso

We will grab the ISO file first, and then we will need to extract the files we need from the ISO.
Now from here, we have 2 options.
We can mount the ISO image and boot straight from that to achieve a basic system, or we can extract the files so that we can use them later on to create a remastered image for multiple use situations, e.g. net cafe or diskless workstations.

In this post, I will go with the former option of just mounting it and booting from that.
I will cover the extraction of files and remastering in the next post.

Step 2 – Mounting the ISO

We now need to create a directory on our tftp server so we have a place to mount the ISO file.

mkdir /tftpboot/tinycore

After we’ve done that, we can now use the mount command to mount the ISO in loopback mode.

mount -o loop tinycore-current.iso /tftpboot/tinycore

Once that’s mounted, we can now do a ls in /tftpboot/tinycore to see what’s in there.

ls /tftpboot/tinycore

Should see something similar to this :

This is the contents of the ISO file, which should contain just a ‘boot’ folder.

Step 3 – Configuring the boot menu

So once we have the files where we need them, we can now edit the pxelinux.cfg/default file to include Tiny Core.
We will need this codeblock in there :


LABEL tinycore
MENU LABEL Tiny Core 3.6
kernel tinycore/boot/bzImage
append initrd=tinycore/boot/tinycore.gz

So it should look something similar to this if you have been following my blog up until now :

Once that is complete, when you boot from the network, you should see Tiny Core 3.6 as an option in the menu now.

Share

May 132011
 

Hi All,

Since I’ve recently done a post on how to setup a PXE network boot server, I thought I would do a few on distributions that can be booted through PXE.
First up, is xPUD. I’ve used this before for diskless workstations.
It is a packaged distribution suitable for light computer use with Firefox built in and also a media player.
Further applications can be added via use of additional opt packges which can then extend the functionality of xPUD.

In this post, I will just be booting a vanilla xPUD image from the PXE server.
The alternative way of booting xPUD via PXE is to extract the contents of the ISO file and using NFS to boot from the files themselves, but this is more complicated as it involves the use of an NFS server and permissions to setup. This will be something that I will cover in a different post.

Step 1

We will need to get the xPud image file first.

wget http://download.xpud.org/xpud-0.9.2-image

This will download the xPud image to the hard drive of the PXE server.

Step 2

Next up, we will need to move the file to the tftpboot directory.
Once again, I have chosen to have a subdirectory for xPud to keep it nice and tidy.

mkdir /tftpboot/xpud
mv xpud-0.9.2-image /tftpboot/xpud

Step 3

After we’ve copied the files over, we now need to modify the default file to setup the extra menu option so we can boot xPud.
Once you’ve added this codeblock, you should now be able to boot xPud over the network.

label xpud
menu label xPud 0.9.2
kernel xpud/xpud-0.9.2-image


It might take a little while to boot as the server needs to transfer ~45 megabytes over the network, but once it’s up and running, it’s all run from ram and should be pretty snappy.

Share