December 30th, 2012
6:39 pm
Imedia Embedded Linux – Backup using tar

Posted under Linux
Tags , ,

This article here discusses how to perform Linux backups and restores using tar ( I have also saved a pdf of the post in the Linux section of the repository).

I wanted to at least backup my system so that I had all the custom configuration and shell scripts backed up.

I was not looking to do a full restore – if I lost the system I would reinstall from CD and then probably pull from the backup piecemeal manually as required.

As an Imedia system is so small (mine is only 2GB), I backed up to a FAT32 flash drive and then archived the backup elsewhere. Imedia does a good job of handling USB drives, but will need FAT32 rather than NTFS.

tar appears to do a pretty good job of backups – symbolic links are handled correctly by default (it backs up the links rather than following to the files), and permissions etc. are backed up as per the above article.

The following example shows my backup script, generated with the help of the above article:-

#!/bin/bash

if [ -z $1 ]; then read -p "Enter Backup Name:" name;     else name=$1; fi
if [ -z $2 ]; then read -p "Enter output directory:" dir; else dir=$2; fi

file="${name}_`date +%Y-%m-%d_%H-%M-%S`"
if [[ $dir != */ ]]; then dir=$dir/; fi
file=$dir$file

echo Backup: $name started at: `date +"%d-%m-%Y %H:%M:%S"` > $file.log
echo Output File: $file.tar.gz >> $file.log
echo >> $file.log

tar -cvpzf $file.tar.gz --exclude=$file.* --exclude=/proc --exclude=/lost+found --exclude=/sys \
    --exclude=/mnt --exclude=/media --exclude=/dev --exclude=/var --exclude=/tmp / >> $file.log 2>&1

echo >> $file.log
echo Backup: $name completed at: `date +"%d-%m-%Y %H:%M:%S"` >> $file.log

No Comments »

November 8th, 2011
8:02 pm
iMedia Linux– configuration/application install issues

Posted under Linux
Tags , , , , , , ,

This post brings together a number of past issues which I have not posted previously, discovered while setting up and using iMedia embedded Linux on my diskless LinITX Jupiter test box.

A zip of all the customised scripts and various config files (such as the infamous xorg.conf) are in the repository.

Shell Script Usage

1/ The startup scripts for applications and drivers etc. are in /etc/rcS.d/. You just add scripts to that and they are automatically run. They are all run by /etc/rcS in alpha order. They are grouped by a prefix of M05, M10, M20, M30 etc. – this seems just to be an arbitrary grouping that determines the order for dependencies etc. Note that all of rcS.d/ is run at run level 3 as set in /etc/inittab

The general order of startup is therefore (see /etc/inittab):-

  • /etc/rc.init runs, and calls rc.sysinit directly
  • /etc/rc.sysinit iterates init.d and runs everything in it. The order is partly determined by an initial grouping number – note the first to run is 00createvar which creates the /var tree on startup (see later)
  • /etc/rcS runs as above, iterating /etc/rcS.d/

2/ /usr/local/bin/ has the extra shared shell scripts – rlog, rlog-leafpad, sx (start X), sxr (start X as root), plus start/stop scripts for Tomcat and Glassfish.

In Thunar, you can add file associations for scripts by right clicking in the file and selecting open with other application – for each app you can add a custom launch command below. (I added rlog and rlog-leafpad). If you add an incorrect one (I added beaver by mistake) Thunar may not let you remove it from the list. Just edit ~/.local/share/applications/defaults.list and remove it from there. Note that /usr/local/bin/ is already on the path so all the script in it are visible – good place to put other global scripts.

Note that you can add scripts to e.g. a program launcher on the top panel bar – right click and create a program launcher, then add items to it – useful for scripts which run without parameters (unlike the rlog and rlog-leafpad above which act on files and therefore are Thunar’s context menu for the files they operate on). When adding a script as an item to a program launcher, the ‘startup notification’ just gives a wait cursor while the script is running (useful). Running in an explicit terminal window is WEIRD – for example for glassfish I set the middle icon on the RHS pane to “terminal”, and set the command to be “aterm -e start-glassfish”. I did not tick “Run in Terminal” as this did not work however!

Logging under iMedia Linux

1/ Logs are stored under the /var tree which is recreated at startup each time see above, so log files are purged as we are running on a small flash based distro. Therefore, Tomcat and Glassfish for example are set to use sym links to link their log directories from their normal install directories to be under /var/log/. There is some trickery to this – for Glassfish I make sure that the *normal* log folder is not present (renaming it with a date/time stamp if required) else the sym link is set up wrongly.

2/ Some logs (but by no means all) in /var/logs/ are circular buffers handled by emlog  – see here for details. They show in Thunar as ‘character type devices’ and  need copying to be visible – /usr/local/bin/rlog does this using nbcat as per the emlog site. I also added /usr/local/bin/rlog-leafpad which does the copy and fires up leafpad on the result. Note that as the emlog site states, you cannot list such a log when active using cat as a non blocking read is required – hence the need for nbcat as used by rlog and rlog-leafpad.

Installing new Applications

1/ Installing new apps is a pain, as rpm installs don’t appear to be supported etc. I tried installing various zipped tarballs of VNC/RDP alternatives for remote desktop but they all needed dependant libraries I did not have, so I had to give up. I think you can build from source to add things but did not go that far! The apps I did install successfully – java 1.6.0_29, tomcat 6.0.29 and Glassfish 3.0.1 – was all installed in folders under /opt as this appeared to be the correct place. Note that for Tomcat, I placed the config files under /etc/apache-tomcat-6.0.20/conf/ and sym-linked them from the ‘expected’ place, /opt/apache-tomcat-6.0.20/opt/, as this appeared to be correct protocol – other apps placed their config under /etc/ and linked to it from their install directory under /opt/. However I did not go to the trouble of doing this for Glassfish – it would be possible (I did do it for the log directory) but the directory structure is more complex.

2/ I did have success with Java – I just ran the .bin install kit of the latest Linux version of the sun Java SE (jdk6u29), and it all unzipped properly and ran fine. Thankfully there were no library problems – probably because there had already been an earlier working jdk6 already installed by default. I added a shell script /etc/profile.d/java-jdk1.6.0_29.sh which created the JAVA_HOME and added the bin directory to the path, but note that this did not work for init time shell scripts for either Tomcat or Glassfish, so their startup scripts had to add their own definitions to work.

3/ I successfully installed Glassfish 3.0.1 (from the zip kit download). To get it to work I had to upgrade Java as above as I got errors otherwise, and the old jdk was below the minimum certified version. However, it worked fine after upgrading java. Note that to stop it checking for updates on startup I just renamed /opt/glassfish-3.0.1-web/glassfish/modules/console-updatecenter-plugin.jar by adding “.disabled” on the end. You can achieve the same thing using the updatetool, but this failed to install properly due to a python error/dependency. I also removed the default jsf-api.jar and jsf-impl.jar from the same folder as above, and added the Mojarra 2.0.4 FCS jars to the folder instead, as my apps needed this version. Note that this also speeds up the startup of the Glassfish admin tool. See my notes here about clearing the osgi cache if you do this.

4/ For Tomcat and Glassfish I separated out the log directory creation from the actual startup, using separate scripts. The log creation is always run, and so sits under /etc/rcS.d/, and the auto startup is optional and may sit under /etc/rcS.disabled/ as a placeholder if it is not autostarted. However, as the log directories under /var/ are always setup, you can then manually start them if desired and they will still work. This is done with the scripts in /usr/local/bin/start-glassfish/stop-glassfish/start-tomcat/stop-tomcat. As this directory is on the path, the scripts can be directly run from a terminal window OR from a remote SSH window BUT you would need to be logged in as root to do it.

Graphical Remote Desktop

Re remote desktop, it is in theory possible to use a windows based X server and connect in that way. To do this, you need to run an X display manager on the Linux box to handle the xdmcp protocol etc. imedia linux does have /usr/bin/xdm which is an old display manager. I did manage to run it from the initial login prompt before typing startx, just by typing xdm, and it popped a login screen. However it would not connect to xfce. It recognised a valid login and tried to do something, failed, and redisplayed itself. An invalid login gave a login failure. I also managed to run the launcher from XMING under windows, and got as far as connecting to xdm. to do this I edited /etc/X11/xdm/Xaccess to enable the “*” entry to allow all comers. I also experimented with editing /etc/X11/xdm/xdm-config and set DisplayManager*authorize to false, and tried commenting out the last line as follows :-

! SECURITY: do not listen for XDMCP or Chooser requests
! Comment out this line if you want to manage X terminals with xdm
!DisplayManager.requestPort:    0

I managed to get XMING to display the same xdm login screen that I got locally, which was a good start – I knew I had a connection working. However, I realised in the end that xfce does not appear to be using a display manager – it simplifies things and bypasses it, and to set up xdm to link properly to xfce and to work remotely looked like loads of setting up with no instructions on how to do it properly.

I therefore sadly gave up on this and admitted defeat on installing any kind of graphical remote desktop!

Samba

I got the samba server to share folders successfully – I added the shares in /etc/samba/smb.conf. Security was set to user (security = user). I tried setting “valid users=” to a list of users, to allow restriction of users e.g. to glassfish/tomcat log folders, but could not get this to work, so I left it out.

Note that I did need to use “smbpasswd -a username” to add an existing linux user to the samba user list, and give it a password. You need to run as root to do this, or it merely allows you to change your own password. smbusers allows you to map external users (used by windows clients) to linux users – see here. Note that you don’t need to do this – you can just use the linux names. Note also that when adding/setting passwords with smbpasswd, you *always* use the Linux name, not the samba alias. Some other useful links for Samba follow:-

Ftp, Telnet and SSH

1/ ftp is enabled by default via vsftp. The config file is in /etc/vsftpd/vsftpd.conf. The default settings are pretty sensible in opening it up for use in a secur local lan. ftp works via all the local linux accounts including root. The log is in /vat/log/vsftpd.log.

2/ Telnet works but does not allow root access (presumably as too insecure). utelnetd is the daemon but there is no documentation for it on the net I could find. SSH works fine via the sshd and allows root access, but could not find any config files or logging for it, although it is documented on the net – the man pages are here, however the config files mentioned for the daemon do not appear to be present under imedia Linux. No problem, it is set up fine for LAN use and works well from putty in ssh mode.

No Comments »

February 20th, 2010
1:33 pm
Imedia Embedded Linux – xorg.conf configuration issues

Posted under Linux
Tags , ,

These issues came about when trying to change the screen resolution/refresh rate on my diskless LinITX Jupiter PC.
This simple exercise became a real nightmare with a really steep learning curve. However, as they say, experience is what you get when you are looking for something else! The full details of this saga are as follows. Motherboard documentation and sample xorg.conf files are just below.

Resources

CVCM2 Motherboard Manual
my xorg.conf for ADI Microscan G910

my xorg.conf for Samsung Syncmaster 2443BW

Hardware Configuration

LinITX Jupiter Fanless Diskless PC
Boot from LAN, USB or internal IDE socket.
Motherboard: CV7CM2
CPU: VIA C7 1Ghz Processor
Chipset: VIA CN700 Northbridge and VT8237R Southbridge
Memory: 1GB DDR2 RAM Installed
LAN: VT 6103 10/100 Fast Ethernet
IDE: One 40pin IDE connector – suitable for use with a 40pin FDM module
USB: Four Rear USB ports and Two Front USB ports
Audio: AC’97 Compliant Audio
BIOS: Award BIOS
Power: Internal DC-DC power supplied from an external AC/DC Adapter (12V 5A DC)
Dimensions: 213mm x 200mm x 45mm

EDC 4000 2GB 40 pin IDE flash drive

Monitor :-
ADI Microscan G910 (original configuration)
Samsung Syncmaster 2443BW (later replacement)

Software Configuration

Imedia embedded Linux 6.0.4
Kiosk build selected
All packages selected (everything installed in addition to Kiosk build)

Configuration Issues

1/ Debugging/usage Tips :-

a/ Details of all the login accounts are posted in the library.

b/ The startup can be interrupted via ctrl/C when the display says “entering run level 3”.
Note that continued pressing of ctrl/C is required to be sure it catches it.
This will then give you an mms prompt.

c/ mms is the autologin user. this is set up in /etc/inittab via the –autologin=mms switch
XFCE is then fired up via the users profile “.profile” in /home/mms.
Note that there are a number of such setup files in the home directory, but the “.xxx” syntax indicates that they are hidden.
You must turn on viewing hidden files to see them.

d/ You can exit from XFCE and restart it without a reboot, using “startx”. Note that you can also just say “X”,
but this does not work – presume it does not use the same script!

e/ You can switch to another login (e.g. root) from any terminal prompt by saying e.g. “su root”.
You can then start XFCE as root (but BE CAREFUL – Linux is easier to trash than windows when fully privileged)

f/ For iMedia Linux with flash, the log files are under a ram disk called /var/log.
The logs are rotating files so that they do not fill the disk.
To read them you must use cat (NOT cp) and/or copy them to another file via cat, e.g.
cat Xorg.0.log > X.log
(followed by a ctrl/d or ctrl/c to terminate as cat also reads from standard input)
Then the resulting file can be copied with cp or viewed with nano/leaf.

g/ For viewing/editing, nano is good in a terminal window as it is modeless and notepad like
leaf is good when in XFCE

2/ After installation, the system would boot to a shell prompt only and would not start XFCE
The solution for this is documented on the iMedia forums here: http://forums.imedialinux.com/index.php?topic=62.0

We had many reports and complaints about graphical mode not working.
Sorry guys for that, we are tying to maintain configuration files for each and every architecture, but it time this proved to a real pain in the ..
Because of hardware differences, many times user could not use at all X graphical mode.
That’s why, in the latest release I created a simple bash script that will force X to auto detect it’s settings and overwriting everything we had in the xorg.conf file.
For those of you who are not so lucky and be prompted with a shell prompt, stopping autologin is pretty easy. As soon as you see “Entering level 3” start pressing CTRL+C key till you get a shell prompt.
Then go to Console 2 or su as root and run xorg-auto-config
NB This causes xorg.conf to be overwritten so save it first!

This auto configure allowed xfce to start but with low refresh rate.

3/ VBEModes was enabled in the “Device” section, to enable the Unichrome Hardware acceleration

Option      “VBEModes” “true”

This improved the resulution but the refresh rate was still low (56Hz or 60Hz)

4/ The correct monitor definition section was then added. The HorizSync and VertRefresh values are important here.
I had to google them for my monitor – the defaults are very low.
(Note that turning off DDC with…

Option  “noddc”

or similar had no effect on increasing the refresh rate.)

Section “Monitor”
Identifier   “Monitor0”
VendorName   “ADI”
ModelName    “ADI Microscan G910”
HorizSync    30-110
VertRefresh  50-160
Option       “DPMS” “true”
EndSection

5/ I added display modes (and a DefaultDepth to set the colour depth that XFCE uses) to the Screen section as follows.
Note that these modes are names which are known internally. I think that it uses a set of VESA modes,
and allows additional ones to be added to here. I’m not quite sure what is going on, but according to the log file,
XFCE needed at least one of these to stop it ‘tripping up’ as it did not find a decent vesa mode/resolution for 1280×1024.
Some forums use e.g. “1280×1024@85” instead of “1280x1024_85” – looks like both syntaxes work but have not confirmed.

Section “Screen”
Identifier “Screen0”
Device     “Card0”
Monitor    “Monitor0”
DefaultDepth 32
SubSection “Display”
Viewport   0 0
Depth     8
Modes     “1280x1024_85” “1152x864_85” “1024x768_100” “800x600_100”
EndSubSection
SubSection “Display”
Viewport   0 0
Depth     16
Modes     “1280x1024_85” “1152x864_85” “1024x768_100” “800x600_100”
EndSubSection
SubSection “Display”
Viewport   0 0
Depth     24
Modes     “1280x1024_85” “1152x864_85” “1024x768_100” “800x600_100”
EndSubSection
SubSection “Display”
Viewport   0 0
Depth     32
Modes     “1280x1024_85” “1152x864_85” “1024x768_100” “800x600_100”
EndSubSection
EndSection

Following this, I had a reasonable choice of resolutions and refresh rates within XFCE.

6/ My final choice (in XFCE) was 1280×1024 @ 86Hz, with a default depth of 32 set in xorg.conf.
I chose 96DPI in the XFCE settings and this gave an excellent display on a 19″ monitor.
75DPI gave more detail on the screen but as I intended to use a CAT5 KVM remote control (i.e. somewhat fuzzy),
I stuck with 96DPI

7/ Keyboard internationalisation was a pain – I first set the correct keyboard settings here :-

Section “ServerLayout”
Identifier     “X.org Configured”
Screen      0  “Screen0” 0 0
InputDevice    “Mouse0” “CorePointer”
InputDevice    “Keyboard0” “CoreKeyboard”
EndSection

… then this later

Section “InputDevice”
Identifier  “Keyboard0”
Driver      “kbd”
Option      “CoreKeyboard”
Option      “XkbRules” “xorg”
Option      “XkbModel” “pc105”
Option      “XkbLayout” “gb”
EndSection

However, this appeared to be ignored and I still had a US keyboard with some keys crossed over etc.
I then discovered that by default, “hotplugging” was enabled, which caused the above settings to be ignored!
Whilst there appeared to be ways of telling hotplugging what the keyboard was, I elected to turn it off as follows :-
(This went right at the top of xorg.conf)

Section “ServerFlags”
Option “AutoAddDevices” “false”
EndSection

As a bonus, I noticed that with hotplugging off, I had less trouble with the mouse after KVM switching to the box.
This was presumably because it tried to reconfigure devices as it thought I had hotplugged something.

8/ Keyboard is still US when in a terminal window either inside or outside XFCE.
It appears that this can be set up here :-
/etc/sysconfig/console
This may also feed into xorg.conf hotplugging automatically should you want to turn this on but not sure.
I have yet to try this out.

9/ Since my original configuration, the monitor has been upgraded, so I have reconfigured xorg.conf. As the CVCM2 motherboard graphics chipset will not do 1920 X 1200, I set the resolution to the maximum I could that looked good, which was 1680 X 1050. For this version, I needed to take the refresh rates out of the Modes option thus :-

Section “Screen”
Identifier “Screen0”
Device     “Card0”
Monitor    “Monitor0”
DefaultDepth 32
SubSection “Display”
Viewport   0 0
Depth     8
Modes     “1680×1050” “1440×900” “1600×1200” “1280×1024” “1152×864” “1024×768” “800×600”
EndSubSection
SubSection “Display”
Viewport   0 0
Depth     16
Modes     “1680×1050” “1440×900” “1600×1200” “1280×1024” “1152×864” “1024×768” “800×600”
EndSubSection
SubSection “Display”
Viewport   0 0
Depth     24
Modes     “1680×1050” “1440×900” “1600×1200” “1280×1024” “1152×864” “1024×768” “800×600”
EndSubSection
SubSection “Display”
Viewport   0 0
Depth     32
Modes     “1680×1050” “1440×900” “1600×1200” “1280×1024” “1152×864” “1024×768” “800×600”
EndSubSection
EndSection

Taking out the refresh rates may have worked better in the original file with the G910, as it may have auto detected the highest refresh rate it could do based on the given horizontal and vertical frequencies. However I have not tried this.
Links to the xorg.conf files (together with the motherboard manual, or at least the best I could find) are at the top of this post. Note that my original xorg.conf for the G910 has an incorrect monitor name in it – this did not appear to cause a problem so I presume the field is just there for documentation purposes.

No Comments »

December 23rd, 2009
4:34 pm
How to set the Date and Time in Linux

Posted under Linux
Tags ,

Enter one or more of the following from a terminal (shell) prompt :-

# date set="2 OCT 2006 18:00:00"
# date -s "2 OCT 2006 18:00:00"
# date +%T -s "10:13:13"

 

See here for more examples

Comments Off on How to set the Date and Time in Linux

December 23rd, 2009
4:01 pm
How to list files with full path in Linux

Posted under Linux
Tags ,

Here is one way which also illustrates the use of the double backslash command substitution mechanism, whereby an embedded shell command in backquotes is replaced by the output of executing it :-

ls -lR `pwd`/* | grep 'epdfview'

 

The pwd command is expanded and replaced with the current working folder as the ls command is executed. In this example, the output is piped through the grep command to search for a file – this is for illustration, as you would normally do this with the find command as shown here.

Comments Off on How to list files with full path in Linux

December 23rd, 2009
3:30 pm
How to search for files in Linux

Posted under Linux
Tags ,

You can use the find command to do a wildcard search for files.
For example, the following will do a wild card name search :-

lynx / # find -name 'epdfview'
./home/mms/.config/epdfview
./usr/bin/epdfview
./usr/share/epdfview
lynx / #

 

The default is to search the current folder and all subfolders. You can search for a number of other fields as well as name, and there are lots of other options, see here

Comments Off on How to search for files in Linux