Difference between revisions of "AXY:Linux MIB"

From SoftMC-Wiki
Jump to: navigation, search
(File systems)
 
(40 intermediate revisions by 3 users not shown)
Line 1: Line 1:
== Preface ==
 
  
Audiance of this documents are:
+
== Introduction ==
 
# MC developers that compiles and links c/c++ code .
 
# QA team.
 
# Managers which take part in MIB development.
 
  
= MIB software components =
+
This documentation explains most parts of the Linux MIB. It is intended for the following users:
The software on a common Linux MIB is divided into to two main types.
 
  
The first type is software that Manz controls. Meaning, Manz builds it and holds its source code. The second type is software manz has no control ,ie like third party binaries.  
+
*softMC developers who are compiling and link C/C++ code
 +
*QA teams
 +
*Managers engaged in MIB development
 +
 
 +
= MIB Software Components =
 +
 
 +
The software on a common Linux MIB has two main types.
 +
 
 +
The first type is software controlled by Servotronix, who builds and maintains the source code. The second type is software over which Servotronix has no control, such as third-party binaries.
  
 
The first type includes:
 
The first type includes:
# The Linux operating system. This includes all services and utilities along with their shared objects (aka dll) which take part of maintaining the operating system.
 
# The Linux Kernel. The core of the operating system.
 
# mc. Manz’s motion control and its bash scripts extensions.
 
# /FFS0 with its mc basic programs.
 
# core dumper. Daemon used to redirect core files.
 
# pkgd. Package manager.
 
# various in house drivers,such as , sercos 2, ethercat and so on.
 
# In the future, any third party software that is added. Like pnp plugins and 3s.
 
  
All of the above software is built from source code. We do not ship any othe component without its source code. Binaries are passed to MIB through the aico are not considered part of Linux MIB system.  
+
*The Linux operating system. This includes all services and utilities along with their shared objects (aka dll) which take part of maintaining the operating system.  
 +
*The Linux Kernel. The core of the operating system.  
  
Further information of each component is detailed in the rest of this paper.
+
 
 +
 
 +
*<font color="red">mc. Manz’s motion control and its bash scripts extensions.</font>
 +
*<font color="red">/FFS0 with its mc basic programs.</font>
 +
*<font color="red">core dumper. Daemon used to redirect core files.</font>
 +
*<font color="red">pkgd. Package manager.</font>
 +
*<font color="red">Various in house drivers,such as , sercos 2, ethercat and so on.</font>
 +
*<font color="red">In the future, any third party software that is added, such as PNP plugins and 3s.</font>
 +
 
 +
<font color="red">All of the above software is built from source code. Servotronix does not ship any other component without its source code. Binaries passed to MIB through the aico are not considered part of Linux MIB system.</font>
  
 
= Accessing the MIB =
 
= Accessing the MIB =
The MIB is fully access-able from any machine. Accessing the LinuxMIB can be done in two ways, secure shell and rs232 connection.
 
  
== Access LinuxMIB through rs232 ==
+
The MIB is fully accessable from any machine. Accessing the LinuxMIB can be done in two ways – secure shell and RS232 connection.
I assume the user is familiar with rs232 connection.  
 
  
In windows User can access the MIB through hyperterminal or putty. putty.exe can be downloaded from http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html.
+
== Access LinuxMIB through RS232 ==
  
'''Rs232 configuration'''
+
It is assumed that you are familiar with RS232 connections.
  
 +
In Windows you can access the MIB through hyperterminal or putty.
 +
 +
putty.exe can be downloaded from [http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html].
 +
<pre>'''RS232 Configuration'''
 
Speed 115200
 
Speed 115200
 
 
StopBits: 1
 
StopBits: 1
 
 
Data: 8
 
Data: 8
 +
Parity:Odd ( N)
 +
</pre>
  
Parity:Odd ( N)
+
<font color="red">Once connected a login session will appear:</font>
  
Once connected a login session would appear
+
<font color="red">''manz login:''</font>
  
''manz login:''
+
<font color="red">enter '''mc'''</font>
  
enter '''root'''
+
<font color="red">and then:</font>
  
and then:
+
<font color="red">''Password:''</font>
  
''Password:''
+
<font color="red">Enter '''mc'''</font>
  
Enter '''1-login11'''.
+
&nbsp;
  
 
== Obtaining LinuxMIB IP ==
 
== Obtaining LinuxMIB IP ==
If you have aico around, use “Select Device” and look for Linux. This should be some LinuxMIB ip. The other way is to access through rs232 as act as bellow:
 
  
~ # '''''ifconfig'''''
+
If you have aico, use “Select Device” and look for Linux. This should be some LinuxMIB IP.
  
 +
Alternately, you can access through RS232:
 +
<pre>~ # '''''ifconfig'''''
 
eth0 Link encap:Ethernet HWaddr 00:50:C2:5D:0F:5E
 
eth0 Link encap:Ethernet HWaddr 00:50:C2:5D:0F:5E
 
 
inet addr:'''10.4.20.83''' Bcast:10.4.20.255 Mask:255.255.255.0
 
inet addr:'''10.4.20.83''' Bcast:10.4.20.255 Mask:255.255.255.0
 
 
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
 
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
 
 
RX packets:92287 errors:0 dropped:0 overruns:0 frame:0
 
RX packets:92287 errors:0 dropped:0 overruns:0 frame:0
 
 
TX packets:4462 errors:0 dropped:0 overruns:0 carrier:0
 
TX packets:4462 errors:0 dropped:0 overruns:0 carrier:0
 
 
collisions:0 txqueuelen:1000
 
collisions:0 txqueuelen:1000
 
 
RX bytes:13389368 (12.7 MiB) TX bytes:431984 (421.8 KiB)
 
RX bytes:13389368 (12.7 MiB) TX bytes:431984 (421.8 KiB)
 
 
 
lo Link encap:Local Loopback
 
lo Link encap:Local Loopback
 
 
inet addr:127.0.0.1 Mask:255.0.0.0
 
inet addr:127.0.0.1 Mask:255.0.0.0
 
 
UP LOOPBACK RUNNING MTU:16436 Metric:1
 
UP LOOPBACK RUNNING MTU:16436 Metric:1
 
 
RX packets:9 errors:0 dropped:0 overruns:0 frame:0
 
RX packets:9 errors:0 dropped:0 overruns:0 frame:0
 
 
TX packets:9 errors:0 dropped:0 overruns:0 carrier:0
 
TX packets:9 errors:0 dropped:0 overruns:0 carrier:0
 
 
collisions:0 txqueuelen:0
 
collisions:0 txqueuelen:0
 
 
RX bytes:612 (612.0 B) TX bytes:612 (612.0 B)
 
RX bytes:612 (612.0 B) TX bytes:612 (612.0 B)
 +
</pre>
  
== Access LinuxMIB through secure shell ==
+
== Access LinuxMIB through Secure Shell ==
To access the MIB from windows without direct connection use secure shell, or in short “ssh”.
 
  
If you login through putty please run it. You should see a window as bellow.
+
To access the MIB from windows without direct connection use secure shell, or in short “ssh”.
  
[[File:puttyconf.gif|picture|putty]]
+
If you login through putty, run it. A screen will appear.
  
Act according the steps bellow:  
+
[[File:puttyconf.gif|putty]]
<div align="left">1. Choose ssh button</div>
 
<div align="left">2. ssh port is 22 by default</div>
 
<div align="left">3. Fill LinuxMIB ip in both feilds,ie host name and saved sessions.</div>
 
<div align="left">4. save it</div>
 
<div align="left">5. open it</div>
 
  
 +
Perform the following steps:
 +
<div align="left">1. Choose ssh button</div> <div align="left">2. ssh port is 22 by default</div> <div align="left">3. Fill LinuxMIB ip in both feilds,ie host name and saved sessions.</div> <div align="left">4. save it</div> <div align="left">5. open it</div>
 +
A login screen will appear.
  
Once you open you get to a login screen as bellow:
+
[[File:login.gif|putty]]
  
[[File:login.gif|picture|putty]]
+
== Changing the password ==
  
== Changing the password ==
+
It is common to change the login password (for developers only):
It is common to change the login password ( for developers only):
 
  
 
~ # '''''passwd'''''
 
~ # '''''passwd'''''
Line 120: Line 110:
 
Enter q
 
Enter q
  
You will have a prompt saying
+
A prompt will appear:
  
Bad password: too short.  
+
Bad password: too short.
  
It is ok. “q” is bad password. but you’re likely to login so many times so you better of using this short password.  
+
It is ok. “q” is bad password. but you’re likely to login so many times so you better of using this short password.
  
Then it will ask you ro retype the password,  
+
Then it will ask you to retype the password,
  
 
'''''Retype password:'''''
 
'''''Retype password:'''''
Line 133: Line 123:
  
 
= Storage =
 
= Storage =
This section details the storage of the LinuxMIB. In storage we mean, the disks and file systems.
+
 
 +
This section details the storage of the LinuxMIB. Storage refers to the disks and file systems.
  
 
== Block Devices ==
 
== Block Devices ==
A block device is a device that is accessed with blocks of data. This includes, hard drives, DVD devices, usb flash cards and so on. In the MIB case the block device that holds the file system is called /dev/hda or hdb. It is referred to as /dev/root ( for reasons out this document scope I will not explain why ). To see that please :
 
  
~ # ''''dmesg | grep hd''''
+
A block device is a device that is accessed with blocks of data. This includes, hard drives, DVD devices, usb flash cards and so on. In the MIB case the block device that holds the file system is called /dev/sda or /dev/hda. It is referred to as /dev/root ( for reasons out this document scope I will not explain why ). Too examin the disk use the fdisk command&nbsp;:
  
 +
&nbsp;
  
Output<sup><nowiki>[1]</nowiki></sup> should like the bellow:
+
fdisk -l
  
<nowiki>[ </nowiki>0.000000] Kernel command line: root=/dev/hda1,/dev/hdc1 console=ttyS0,115200
+
Disk /dev/sda: 1014 MB, 1014644736 bytes
 +
255 heads, 63 sectors/track, 123 cylinders
 +
Units = cylinders of 16065 * 512 = 8225280 bytes
 +
    Device Boot      Start        End      Blocks  Id System
 +
      /dev/sda1  *          1          57      449850+ 83 Linux
 +
    Partition 1 does not end on cylinder boundary
 +
      /dev/sda2              57        116      475000  83 Linux
 +
    Partition 2 does not end on cylinder boundary
  
<nowiki>[ </nowiki>1.238729] hdc: TRANSCEND, CFA DISK drive
+
&nbsp;
  
<nowiki>[ </nowiki>1.850651] hdc: host max PIO4 wanted PIO255(auto-tune) selected PIO4
+
/dev/sda1 is / . /dev/sda2 is the backup partition. The backup partion is used /dev/sda1 is totally corrupted.
  
<nowiki>[ </nowiki>1.850666] hdc: UDMA/66 mode selected
+
== File systems ==
  
<nowiki>[ </nowiki>1.851138] hdc: max request size: 128KiB
+
LinuxMIB is composed from several independent file systems. To examine the file systems please enter:
  
<nowiki>[ </nowiki>1.851143] hdc: 1989792 sectors (1018 MB) w/1KiB Cache, CHS=1974/16/63
+
~ # ''''df -h''''
  
<nowiki>[ </nowiki>1.856857] hdc: hdc1
+
                          Filesystem Size    Used    Available  Use%  Mounted on
 +
<div align="left">''1)''</div>  
 +
                        /dev/root  485.5M  83.8M    377.3M    18%  / 
  
<nowiki>[ </nowiki>2.134028] register_blkdev: cannot get major 3 for hd
+
&nbsp;
 +
<div align="left">''2)''</div>  
 +
                          none      246.9M  4.0K    246.9M    0% /tmp 
 +
<div align="left">''3)''</div>
 +
                            none      246.9M  24.0K  246.8M    0%  /RAM
 +
                            none      246.9M  44.0K  246.8M    0% /var/log
 +
                            none      246.9M  24.0K  246.8M    0% /var/run
 +
<div align="left">''4)''</div>
 +
                            none      246.9M    0      246.9M  0%  /var/lock
 +
                            none      246.9M    0      246.9M  0%  /var/tmp
 +
                            tmpfs      246.9M    4.0K  246.9M    0%  /dev
  
<nowiki>[ </nowiki>2.847206] try device /dev/hda1 ROOT_DEV=0
+
&nbsp;
  
<nowiki>[ </nowiki>2.847833] EXT3-fs (hdc1): recovery required on readonly filesystem
+
#The main file system is called root file system. The root file system is said to be mounted on the mounting point “/. Any other file system in Linux is mounted on top of the root file system at some directory. Here the root file system is of size of 485MB, and 83MB of it are used.
  
<nowiki>[ </nowiki>2.847836] EXT3-fs (hdc1): write access will be enabled during recovery
+
#/tmp directory is mounted as tmpfs file system. This is a ram file system. It does not survive boots.
 +
#This is the RAM file system used by mc. It is also of type tmpfs.
 +
#/var/log , /var/run, /var/lock, and /var/tmp are tmps file system as well used by different services.
 +
#/dev/ is a file system that holds all device files. it is regenerated with each boot.
 +
#There is a nother file system called /dev/pts , it is visible through the mount command, it hold terminals information.  
  
<nowiki>[ </nowiki>4.836389] EXT3-fs (hdc1): recovery complete
+
= Basic commands =
  
<nowiki>[ </nowiki>4.838603] EXT3-fs (hdc1): mounted filesystem with ordered data mode
+
== File and file system ==
  
 +
=== ls ===
  
So we have TRANSCEND Compact flash drive, size of 1018MB , its name is hdc and it has a single partition called /dev/hdc1.
+
To examine the content the of current directory use ls:
  
 +
~ # ''ls''
  
<nowiki>[1]</nowiki> ''There are various ways to examine storage devices. The LinuxMIB lack the tools for that.''
+
&nbsp;
 +
<nowiki>To examine the content of another directory use ls <dir>. For example:</nowiki>
  
The device file /dev/root is considered the boot device because it contains the first file system that is explored by the kernel when it performs a boot. Please note that it that /dev/root is not the entire disk but the partition holding file system.
+
~ # ''ls /sbin/''
  
== File systems ==
+
adjtimex halt init modprobe setconsole udevadm
LinuxMIB is composed from several independent file systems. To examine the file systems please enter:
 
  
~ # df -h
+
blkid hdparm insmod poweroff sfdisk udevd
  
Like the in bellow example:
+
dhclient hwclock klogd reboot start-stop-daemon udhcpc
  
~ # df -h
+
fdisk ifconfig loadkmap rmmod sulogin umount.devkit
  
Filesystem Size Used Available Use% Mounted on<div align="left">1</div>
+
fsck ifdown lsmod route syslog-ng watchdog
  
/dev/root 485.5M 83.8M 377.3M 18% /<div align="left">2</div>
+
getty ifup modinfo runlevel threads
  
none 246.9M 4.0K 246.9M 0% /tmp<div align="left">3</div>
+
~ #
  
none 246.9M 24.0K 246.8M 0% /RAM
+
The “ls” commands have additional flags, such as&nbsp;: “ls –al” which provides more information about the files.
  
none 246.9M 44.0K 246.8M 0% /var/log
+
=== cat ===
  
none 246.9M 24.0K 246.8M 0% /var/run<div align="left">4</div>
+
To examine the content of a text file use the cat. For example:
  
none 246.9M 0 246.9M 0% /var/lock
+
~ # ''cat /etc/busybox.conf''
  
none 246.9M 0 246.9M 0% /var/tmp
+
you can also create new files with cat by redirecting cat’s output to a new file. For example:
  
tmpfs 246.9M 4.0K 246.9M 0% /dev
+
~ # ''cat /etc/busybox.conf > /tmp/busybox.conf''
  
~ #
+
you can concatenate two files in to a single file by using the >> sign.
  
 +
For example the command
  
# The main file system is called root file system. The root file system is said to be mounted on the mounting point “/”. Any other file system in Linux is mounted on top of the root file system at some directory.
+
~ # ''cat /etc/inet.conf >> /tmp/busybox.conf''
  
Here the root file system is of size of 485MB, and 83MB of it are used.  
+
will concatenate to /tmp/busybox.conf the content of /etc/inet.conf.
  
# /tmp directory is mounted as tmpfs file system. This is a ram file system. It does not survive boots.
+
=== echo ===
# This is the RAM file system used by mc. It is also of type tmpfs.
 
# /var/log , /var/run, /var/lock, and /var/tmp are tmps file system as well used by different services.
 
# /dev/ is a file system that holds all device files. it is regenerated with each boot.
 
# There is a nother file system called /dev/pts , it is visible through the mount command, it hold terminals information.
 
  
= Basic commands  =
+
echo is a command that send a string to a file, where a file can be the terminal itself or simply a regular text file or any other file which receives data.
== File and file system ==
 
=== ls ===
 
To examine the content the of current directory use ls:
 
  
~ # ls
+
~ # echo hello
  
<nowiki>To examine the content of another directory use ls <dir>. For example:</nowiki>
+
Hello
  
~ # ls /sbin/
+
&nbsp;
  
adjtimex halt init modprobe setconsole udevadm
+
=== less ===
  
blkid hdparm insmod poweroff sfdisk udevd
+
less is a textual viewer. It is used to examine text file content in read-only mode. Usage:
  
dhclient hwclock klogd reboot start-stop-daemon udhcpc
+
&nbsp;
 +
<nowiki>~# less <file name></nowiki>
  
fdisk ifconfig loadkmap rmmod sulogin umount.devkit
+
=== tail/head ===
  
fsck ifdown lsmod route syslog-ng watchdog
+
The tail comands prints last line of a file. The head command prints the first few lines of a file. tail is very useful a user wishes to examine how file is being updated , mostly logs.
  
getty ifup modinfo runlevel threads
+
For example:
  
~ #
+
~ # tail –f /var/syslog
  
 +
=== fsck – check file system consistency ===
  
The “ls” commands have additional flags, such as : “ls –al” which provides more information about the files.
+
LinuxMIB uses ext3 as its file system, ext3 is a journaling file system which means file system corruption is much less to occur, there are still times where corruptions do happen ( not by abrupt power off but by exploding the file system or deliberately corrupting ).
  
=== cat ===
+
LinuxMIB executes fsck.ext3 each time it is booted, if you wish to check file system integrity first create the device name:
To examine the content of a text file use the cat. For example:
 
  
~ # cat /etc/busybox.conf
+
''mknod /dev/hda1 b 3 1''
  
<nowiki>[SUID]</nowiki>
+
This is because /dev/hda1 does not exist on the MIB and neither /dev/root.
  
<nowiki>#lines starting with # are comments</nowiki>
+
Now issue the fsck command as bellow. I use –n flag to do that in read only mode.
  
<nowiki>#<applet> = [Ssx-][Ssx-][x-] (<username>|<uid>).(<groupname>|<gid>)</nowiki>
+
''fsck.ext3 –n /dev/hda1''
  
 +
=== grep ===
  
<nowiki>#reboot = ssx root.0 # applet reboot can be run by anyone and runs with euid=0/egid=0</nowiki>
+
grep prints lines matching a pattern. Example:
  
 +
/etc # ''grep mc /usr/bin/mc.sh''
  
you can also create new files with cat by redirecting cat’s output to a new file. For example:
+
/usr/bin/mc
  
~ # cat /etc/busybox.conf > /tmp/busybox.conf
+
The above command prints each line containing the word “mc”.
  
you can concatenate two files to single file by using the >> sign.
+
or check number of mc core files in the /cores/ directory.
  
For example the command
+
''nf=$(ls /cores/mc* | wc -l)''
  
~ # cat /etc/inet.conf >> /tmp/busybox.conf
+
''echo $nf''
  
will concatenate to /tmp/busybox.conf the content of /etc/inet.conf.
+
4
  
 +
=== awk ===
  
=== echo ===
+
awk is a parsing language. The awk command scans an input file searching for some text pattern and when finding this pattern awk act according to the action specified.
echo is a command that send a string to a file, where a file can be the terminal itself or simply a regular text file or any other file which receives data.
 
  
~ # echo hello
+
For example:
  
Hello
+
~# awk '$2 == 0 { printf $1 " " $2 " " $3 "\n"}' /proc/interrupts
  
 +
NMI: 0 Non-maskable
  
=== less ===
+
LOC: 0 Local
less is a textual viewer. It is used to examine text file content in read-only mode. Usage:  
 
  
<nowiki>~# less <file name></nowiki>
+
SPU: 0 Spurious
  
=== tail/head ===
+
PMI: 0 Performance
The tail comands prints last line of a file. The head command prints the first few lines of a file. tail is very useful a user wishes to examine how file is being updated , mostly logs.
 
  
For example:
+
IWI: 0 IRQ
  
~ # tail –f /var/syslog
+
TRM: 0 Thermal
  
=== fsck – check file system consistency ===
+
THR: 0 Threshold
LinuxMIB uses ext3 as its file system, ext3 is a journaling file system which means file system corruption is much less to occur, there are still times where corruptions do happen ( not by abrupt power off but by exploding the file system or deliberately corrupting ).
 
  
LinuxMIB executes fsck.ext3 each time it is booted, if you wish to check file system integrity first create the device name:
+
MCE: 0 Machine
  
mknod /dev/hda1 b 3 1
+
ERR: 0
  
This is because /dev/hda1 does not exist on the MIB and neither /dev/root.
+
MIS: 0
  
Now issue the fsck command as bellow. I use –n flag to do that in read only mode.
+
This command prints columns 1, 2 and 3 in the /proc/interrupts if the second column equal 0.
  
fsck.ext3 –n /dev/hda1
+
=== find ===
  
=== grep ===
+
find searches for files in directory recursively. For example, if a user wants to find all files named mc in the LinuxMIB:
grep prints lines matching a pattern. Example:
 
  
/etc # grep mc /usr/bin/mc.sh
+
~ # find / -name mc
 +
 
 +
/etc/init.d/mc
  
 
/usr/bin/mc
 
/usr/bin/mc
  
<nowiki># check number of mc core files in /cores/ dir</nowiki>
+
&nbsp;
  
nf=$(ls -l mc_* | wc -l)
+
=== watch ===
  
for i in `ls -t mc_*`; do
+
The watch command executes a command periodically. For example:
  
The above command prints each line containing the word “mc”.
+
watch –n1 ‘cat /proc/vmstat`
  
=== awk ===
+
print to screen the file /proc/vmstat .
awk is a parsing language. The awk command scans an input file searching for some text pattern and when finding this pattern awk act according to the action specified.
 
  
For example:
+
=== gzip/gunzip ===
  
~# awk '$2 == 0 { printf $1 " " $2 " " $3 "\n"}' /proc/interrupts
+
The gzip command compresses a file. The gunzip command decompress a file.
  
NMI: 0 Non-maskable
+
Example:
  
LOC: 0 Local
+
gzip /etc/busybox.conf
  
SPU: 0 Spurious
+
busybox.conf is compressed and renamed to busybox.conf.gz
  
PMI: 0 Performance
+
to decompress&nbsp;:
  
IWI: 0 IRQ
+
gunzip /etc/busybox.cong.gz
  
TRM: 0 Thermal
+
a new file /etc/busybox.conf is created.
  
THR: 0 Threshold
+
&nbsp;
  
MCE: 0 Machine
+
=== zcat ===
  
ERR: 0
+
zcat is used to print a content of a compressed text file without decompressing it.
  
MIS: 0
+
Example:
  
This command prints columns 1, 2 and 3 in the /proc/interrupts if the second column equal 0.  
+
zcat /etc/busybox.conf.gz
  
=== find  ===
+
This will dump to screen busybox.conf.a
find searches for files in directory recursively. For example, if a user wants to find all files named mc in the LinuxMIB:
 
  
~ # find / -name mc
+
== System ==
  
/etc/init.d/mc
+
=== free ===
  
/usr/bin/mc
+
free returns the amount of RAM in the machine, the amount of used memory in the machine and the amount of used memory in the machine.
  
 +
~ # free
  
=== watch ===
+
total used free shared buffers
The watch command executes a command periodically. For example:
 
  
watch –n1 ‘cat /proc/vmstat`
+
Mem: 505560 47912 457648 0 1356
  
print to screen the file /proc/vmstat .
+
Swap: 0 0 0
  
=== gzip/gunzip ===
+
Total: 505560 47912 457648
The gzip command compresses a file. The gunzip command decompress a file.
 
  
Example:
+
=== lshw ===
  
gzip /etc/busybox.conf
+
Lists the hardware configuration of the machine.
  
busybox.conf is compressed and renamed to busybox.conf.gz
+
~ # lshw
  
to decompress :
+
manz
  
gunzip /etc/busybox.cong.gz
+
description: Computer
  
a new file /etc/busybox.conf is created.
+
product: N/A
  
 +
vendor: N/A
  
=== zcat ===
+
version: N/A
zcat is used to print a content of a compressed text file without decompressing it.
 
  
Example:
+
serial: N/A
  
zcat /etc/busybox.conf.gz
+
width: 32 bits
  
This will dump to screen busybox.conf.a
+
capabilities: smbios-2.5 dmi-2.5
  
== System  ==
+
configuration: administrator_password=disabled boot=oem-specific frontpanel_
=== free ===
 
free returns the amount of RAM in the machine, the amount of used memory in the machine and the amount of used memory in the machine.
 
  
~ # free
+
password=unknown keyboard_password=unknown power-on_password=disabled
  
total used free shared buffers
+
&nbsp;
 +
<nowiki>*-core</nowiki>
  
Mem: 505560 47912 457648 0 1356
+
description: Motherboard
  
Swap: 0 0 0
+
product: MODB
  
Total: 505560 47912 457648
+
vendor: Kontron Embedded Modules
  
 +
physical id: 0
  
=== lshw ===
+
version: 05.00
Lists the hardware configuration of the machine.  
 
  
~ # lshw
+
serial: YXEBK0229
  
manz
+
&nbsp;
 +
<nowiki>*-firmware</nowiki>
  
description: Computer
+
description: BIOS
  
product: N/A
+
vendor: Phoenix Technologies LTD
  
vendor: N/A
+
physical id: 0
  
version: N/A
+
version: MODBR131 (06/27/0808)
  
serial: N/A
+
size: 104KiB
  
width: 32 bits
+
capacity: 960KiB
  
capabilities: smbios-2.5 dmi-2.5
+
capabilities: isa pci pcmcia pnp apm upgrade shadowing escd cdboot acp
  
configuration: administrator_password=disabled boot=oem-specific frontpanel_
+
i usb agp biosbootspecification
  
password=unknown keyboard_password=unknown power-on_password=disabled
+
&nbsp;
 +
<nowiki>*-cpu</nowiki>
  
<nowiki>*-core</nowiki>
+
description: CPU
  
description: Motherboard
+
product: Intel(R) Celeron(R) M processor 1.50GHz
  
product: MODB
+
vendor: Intel Corp.
  
vendor: Kontron Embedded Modules
+
physical id: 4
  
physical id: 0
+
bus info: cpu@0
  
version: 05.00
+
version: 6.13.8
  
serial: YXEBK0229
+
slot: U2E1
  
<nowiki>*-firmware</nowiki>
+
size: 1500MHz
  
description: BIOS
+
capacity: 2048MHz
  
vendor: Phoenix Technologies LTD
+
width: 32 bits
  
physical id: 0
+
capabilities: fpu fpu_exception wp vme de pse tsc msr pae mce cx8 sep
  
version: MODBR131 (06/27/0808)
+
mtrr pge mca cmov clflush dts acpi mmx fxsr sse sse2 ss tm pbe nx bts
  
size: 104KiB
+
&nbsp;
 +
<nowiki>*-cache:0</nowiki>
  
capacity: 960KiB
+
description: L1 cache
  
capabilities: isa pci pcmcia pnp apm upgrade shadowing escd cdboot acp
+
physical id: 5
  
i usb agp biosbootspecification
+
slot: L1 Cache
  
<nowiki>*-cpu</nowiki>
+
size: 64KiB
  
description: CPU
+
capacity: 64KiB
  
product: Intel(R) Celeron(R) M processor 1.50GHz
+
&nbsp;
  
vendor: Intel Corp.
+
=== udevadm ===
  
physical id: 4
+
udev is part of a linux device model. Udevadm is a tool used to query, monitor and control devices. For example, the hardisk “hda”,has a pci address, it belongs to the block device subsystem, and so on. To get this sort of information in one unified view, we do:
  
bus info: cpu@0
+
~ # udevadm info -a -p /sys/block/hda
  
version: 6.13.8
+
Udevadm info starts with the device specified by the devpath and then
  
slot: U2E1
+
walks up the chain of parent devices. It prints for every device
  
size: 1500MHz
+
found, all possible attributes in the udev rules key format.
  
capacity: 2048MHz
+
A rule to match, can be composed by the attributes of the device
  
width: 32 bits
+
and the attributes from one single parent device.
  
capabilities: fpu fpu_exception wp vme de pse tsc msr pae mce cx8 sep
+
looking at device '/block/hda':
  
mtrr pge mca cmov clflush dts acpi mmx fxsr sse sse2 ss tm pbe nx bts
+
KERNEL=="hda"
  
<nowiki>*-cache:0</nowiki>
+
SUBSYSTEM=="block"
  
description: L1 cache
+
DRIVER==""
  
physical id: 5
+
ATTR{range}=="64"
  
slot: L1 Cache
+
ATTR{ext_range}=="256"
  
size: 64KiB
+
ATTR{removable}=="0"
  
capacity: 64KiB
+
ATTR{ro}=="0"
  
 +
ATTR{size}=="1981728"
  
=== udevadm ===
+
ATTR{alignment_offset}=="0"
udev is part of a linux device model. Udevadm is a tool used to query, monitor and control devices. For example, the hardisk “hda”,has a pci address, it belongs to the block device subsystem, and so on. To get this sort of information in one unified view, we do:
 
  
~ # udevadm info -a -p /sys/block/hda
+
ATTR{discard_alignment}=="0"
  
 +
ATTR{capability}=="50"
  
Udevadm info starts with the device specified by the devpath and then
+
ATTR{stat}==" 342 173 15716 1119 47 25 1
  
walks up the chain of parent devices. It prints for every device
+
1768 0 2179 2886"
  
found, all possible attributes in the udev rules key format.
+
ATTR{inflight}==" 0 0"
  
A rule to match, can be composed by the attributes of the device
+
ATTR{events}==""
  
and the attributes from one single parent device.
+
ATTR{events_async}==""
  
 +
ATTR{events_poll_msecs}=="-1"
  
looking at device '/block/hda':
+
As one can observe, a disk called had is part of the block subsystem, there is no driver for it as I did not compile external modules, additional information appears such as its size and some statistics.
  
KERNEL=="hda"
+
&nbsp;
  
SUBSYSTEM=="block"
+
=== Reboot ===
  
DRIVER==""
+
To reboot the MIB use the “reboot” command.
  
ATTR{range}=="64"
+
=== Poweroff ===
  
ATTR{ext_range}=="256"
+
To turn off the MIB, use the “poweroff” command.
  
ATTR{removable}=="0"
+
=== hwclock ===
  
ATTR{ro}=="0"
+
To get or set the time to/from RTC hardware clock , use the “hwclock” command. In cases where RTC is broken, “hwlock” will hang or display bad time.
  
ATTR{size}=="1981728"
+
&nbsp;
  
ATTR{alignment_offset}=="0"
+
== Process ==
  
ATTR{discard_alignment}=="0"
+
In this section I show some commands related to processes management.
  
ATTR{capability}=="50"
+
=== Ps ===
  
ATTR{stat}==" 342 173 15716 1119 47 25 1
+
Use the “ps” command to list system processes. For example, the “ps aux” outputs:
  
1768 0 2179 2886"
+
~ # ps aux
  
ATTR{inflight}==" 0 0"
+
USER PID&nbsp;%CPU&nbsp;%MEM VSZ RSS TTY STAT START TIME COMMAND
  
ATTR{events}==""
+
root 1 0.0 0.1 2076 516&nbsp;? Ss 08:03 0:01 init
  
ATTR{events_async}==""
+
root 2 0.0 0.0 0 0&nbsp;? S 08:03
 +
<nowiki>0:00 [kthreadd]</nowiki>
  
ATTR{events_poll_msecs}=="-1"
+
root 3 0.1 0.0 0 0&nbsp;? S 08:03
 +
<nowiki>0:02 [ksoftirqd/0]</nowiki>
  
 +
root 5 0.0 0.0 0 0&nbsp;? S 08:03
 +
<nowiki>0:00 [kworker/u:0]</nowiki>
  
As one can observe, a disk called had is part of the block subsystem, there is no driver for it as I did not compile external modules, additional information appears such as its size and some statistics.
+
root 6 0.0 0.0 0 0&nbsp;? S 08:03
 +
<nowiki>0:00 [posixcputmr/0]</nowiki>
  
 +
root 7 0.0 0.0 0 0&nbsp;?
 +
<nowiki>S< </nowiki>
 +
08:03 <nowiki>0:00 [khelper]</nowiki>
  
=== Reboot ===
+
root 8 0.0 0.0 0 0&nbsp;? S 08:03
To reboot the MIB use the “reboot” command.
+
<nowiki>0:00 [kworker/u:1]</nowiki>
  
=== Poweroff ===
+
root 125 0.0 0.0 0 0&nbsp;? S 08:03
To turn off the MIB, use the “poweroff” command.
+
<nowiki>0:00 [sync_supers]</nowiki>
  
=== hwclock ===
+
root 127 0.0 0.0 0 0&nbsp;? S 08:03
To get or set the time to/from RTC hardware clock , use the “hwclock” command. In cases where RTC is broken, “hwlock” will hang or display bad time.
+
<nowiki>0:00 [bdi-default]</nowiki>
  
 +
root 128 0.0 0.0 0 0&nbsp;?
 +
<nowiki>S< </nowiki>
 +
08:03 <nowiki>0:00 [kblockd]</nowiki>
  
== Process  ==
+
root 135 0.0 0.0 0 0&nbsp;?
In this section I show some commands related to processes management.
+
<nowiki>S< </nowiki>
 +
08:03 <nowiki>0:00 [ata_sff]</nowiki>
  
=== Ps ===
+
root 142 0.0 0.0 0 0&nbsp;? S 08:03
Use the “ps” command to list system processes. For example, the “ps aux” outputs:
+
<nowiki>0:00 [khubd]</nowiki>
  
~ # ps aux
+
root 248 0.0 0.0 0 0&nbsp;? S 08:03
 
+
<nowiki>0:00 [kworker/0:1]</nowiki>
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
 
 
 
root 1 0.0 0.1 2076 516 ? Ss 08:03 0:01 init
 
 
 
root 2 0.0 0.0 0 0 ? S 08:03 <nowiki>0:00 [kthreadd]</nowiki>
 
 
 
root 3 0.1 0.0 0 0 ? S 08:03 <nowiki>0:02 [ksoftirqd/0]</nowiki>
 
 
 
root 5 0.0 0.0 0 0 ? S 08:03 <nowiki>0:00 [kworker/u:0]</nowiki>
 
 
 
root 6 0.0 0.0 0 0 ? S 08:03 <nowiki>0:00 [posixcputmr/0]</nowiki>
 
 
 
root 7 0.0 0.0 0 0 ? <nowiki>S< </nowiki>08:03 <nowiki>0:00 [khelper]</nowiki>
 
 
 
root 8 0.0 0.0 0 0 ? S 08:03 <nowiki>0:00 [kworker/u:1]</nowiki>
 
 
 
root 125 0.0 0.0 0 0 ? S 08:03 <nowiki>0:00 [sync_supers]</nowiki>
 
 
 
root 127 0.0 0.0 0 0 ? S 08:03 <nowiki>0:00 [bdi-default]</nowiki>
 
 
 
root 128 0.0 0.0 0 0 ? <nowiki>S< </nowiki>08:03 <nowiki>0:00 [kblockd]</nowiki>
 
 
 
root 135 0.0 0.0 0 0 ? <nowiki>S< </nowiki>08:03 <nowiki>0:00 [ata_sff]</nowiki>
 
 
 
root 142 0.0 0.0 0 0 ? S 08:03 <nowiki>0:00 [khubd]</nowiki>
 
 
 
root 248 0.0 0.0 0 0 ? S 08:03 <nowiki>0:00 [kworker/0:1]</nowiki>
 
 
 
root 268 0.0 0.0 0 0 ? S 08:03 <nowiki>0:00 [kswapd0]</nowiki>
 
  
root 269 0.0 0.0 0 0 ? S 08:03 <nowiki>0:00 [fsnotify_mark]</nowiki>
+
root 268 0.0 0.0 0 0&nbsp;? S 08:03
 +
<nowiki>0:00 [kswapd0]</nowiki>
  
root 271 0.0 0.0 0 0 ? <nowiki>S< </nowiki>08:03 <nowiki>0:00 [crypto]</nowiki>
+
root 269 0.0 0.0 0 0&nbsp;? S 08:03
 +
<nowiki>0:00 [fsnotify_mark]</nowiki>
  
root 869 0.0 0.0 0 0 ? S 08:04 <nowiki>0:00 [irq/15-ide0]</nowiki>
+
root 271 0.0 0.0 0 0&nbsp;?
 +
<nowiki>S< </nowiki>
 +
08:03 <nowiki>0:00 [crypto]</nowiki>
  
root 906 0.0 0.0 0 0 ? S 08:04 <nowiki>0:00 [irq/1-i8042]</nowiki>
+
root 869 0.0 0.0 0 0&nbsp;? S 08:04
 +
<nowiki>0:00 [irq/15-ide0]</nowiki>
  
root 913 0.0 0.0 0 0 ? S 08:04 <nowiki>0:00 [irq/8-rtc0]</nowiki>
+
root 906 0.0 0.0 0 0&nbsp;? S 08:04
 +
<nowiki>0:00 [irq/1-i8042]</nowiki>
  
root 921 0.0 0.0 0 0 ? S 08:04 <nowiki>0:00 [kworker/0:2]</nowiki>
+
root 913 0.0 0.0 0 0&nbsp;? S 08:04
 +
<nowiki>0:00 [irq/8-rtc0]</nowiki>
  
root 922 0.0 0.0 0 0 ? S 08:04 <nowiki>0:00 [irq/4-serial]</nowiki>
+
root 921 0.0 0.0 0 0&nbsp;? S 08:04
 +
<nowiki>0:00 [kworker/0:2]</nowiki>
  
root 923 0.0 0.0 0 0 ? S 08:04 <nowiki>0:00 [kjournald]</nowiki>
+
root 922 0.0 0.0 0 0&nbsp;? S 08:04
 +
<nowiki>0:00 [irq/4-serial]</nowiki>
  
root 945 0.0 0.1 1896 648 ? <nowiki>S<s </nowiki>08:04 0:00 /sbin/udevd --d
+
root 923 0.0 0.0 0 0&nbsp;? S 08:04
 +
<nowiki>0:00 [kjournald]</nowiki>
  
root 999 0.0 0.1 1892 608 ? <nowiki>S< </nowiki>08:04 0:00 /sbin/udevd --d
+
root 945 0.0 0.1 1896 648&nbsp;?
 +
<nowiki>S<s </nowiki>
 +
08:04 0:00 /sbin/udevd --d root 999 0.0 0.1 1892 608&nbsp;? <nowiki>S< </nowiki>
 +
08:04 0:00 /sbin/udevd --d root 1002 0.0 0.1 1892 604&nbsp;? <nowiki>S< </nowiki>
 +
08:04 0:00 /sbin/udevd --d root 1017 0.0 0.1 2992 716&nbsp;? Ss 08:04 0:00 /sbin/syslog-ng
 +
root 1025 0.0 0.1 3932 996&nbsp;? Ss 08:04 0:00 /usr/sbin/sshd
  
root 1002 0.0 0.1 1892 604 ? <nowiki>S< </nowiki>08:04 0:00 /sbin/udevd --d
+
root 1045 0.0 0.0 0 0&nbsp;? S 08:04
 +
<nowiki>0:00 [irq/9-eth0]</nowiki>
  
root 1017 0.0 0.1 2992 716 ? Ss 08:04 0:00 /sbin/syslog-ng
+
root 1056 0.0 0.0 0 0&nbsp;? S 08:04
 +
<nowiki>0:00 [irq/11-srcsII]</nowiki>
  
root 1025 0.0 0.1 3932 996 ? Ss 08:04 0:00 /usr/sbin/sshd
+
root 1075 99.7 0.0 1528 196&nbsp;? Rs 08:04 31:12 /usr/bin/pkgd /
 
 
root 1045 0.0 0.0 0 0 ? S 08:04 <nowiki>0:00 [irq/9-eth0]</nowiki>
 
 
 
root 1056 0.0 0.0 0 0 ? S 08:04 <nowiki>0:00 [irq/11-srcsII]</nowiki>
 
 
 
root 1075 99.7 0.0 1528 196 ? Rs 08:04 31:12 /usr/bin/pkgd /
 
  
 
root 1079 0.0 0.1 2080 544 ttyS0 Ss+ 08:04 0:00 /sbin/getty -L
 
root 1079 0.0 0.1 2080 544 ttyS0 Ss+ 08:04 0:00 /sbin/getty -L
  
root 1093 0.0 0.3 6536 2004 ? Ss 08:04 0:00 sshd: root@pts/
+
root 1093 0.0 0.3 6536 2004&nbsp;? Ss 08:04 0:00 sshd: root@pts/
  
 
root 1097 0.0 0.1 2080 632 pts/0 Ss+ 08:04 0:00 -sh
 
root 1097 0.0 0.1 2080 632 pts/0 Ss+ 08:04 0:00 -sh
  
root 1107 0.0 0.3 6536 1988 ? Ss 08:05 0:00 sshd: root@pts/
+
root 1107 0.0 0.3 6536 1988&nbsp;? Ss 08:05 0:00 sshd: root@pts/
  
 
root 1111 0.0 0.1 2080 664 pts/1 Ss 08:05 0:00 -sh
 
root 1111 0.0 0.1 2080 664 pts/1 Ss 08:05 0:00 -sh
  
root 1146 0.0 0.0 0 0 ? S 08:25 <nowiki>0:00 [flush-3:0]</nowiki>
+
root 1146 0.0 0.0 0 0&nbsp;? S 08:25
 +
<nowiki>0:00 [flush-3:0]</nowiki>
  
root 1177 0.2 0.3 6536 1988 ? Ss 08:35 0:00 sshd: root@pts/
+
root 1177 0.2 0.3 6536 1988&nbsp;? Ss 08:35 0:00 sshd: root@pts/
  
 
root 1181 0.0 0.1 2080 608 pts/2 Ss 08:35 0:00 -sh
 
root 1181 0.0 0.1 2080 608 pts/2 Ss 08:35 0:00 -sh
Line 660: Line 668:
 
root 1209 0.0 0.1 2228 824 pts/1 R+ 08:35 0:00 ps aux
 
root 1209 0.0 0.1 2228 824 pts/1 R+ 08:35 0:00 ps aux
  
 
+
all processes in the entire operating system along with their memory consumption, state, pid, cpu usage and so on. As one can see the next to last process is mc itself, so where are his threads. For this I created an abbreviation called threads:
all processes in the entire operating system along with their memory consumption, state, pid, cpu usage and so on. As one can see the next to last process is mc itself, so where are his threads. For this I created an abbreviation called threads:  
 
  
 
~ # threads
 
~ # threads
  
Warning: bad ps syntax, perhaps a bogus '-'? See http://procps.sf.net/faq.html
+
Warning: bad ps syntax, perhaps a bogus '-'? See [http://procps.sf.net/faq.html http://procps.sf.net/faq.html]
  
PID TID CLS RTPRIO NI PRI PSR %CPU STAT WCHAN COMMAND
+
PID TID CLS RTPRIO NI PRI PSR&nbsp;%CPU STAT WCHAN COMMAND
  
 
1 1 TS - 0 19 0 0.0 Ss wait init
 
1 1 TS - 0 19 0 0.0 Ss wait init
Line 679: Line 686:
 
6 6 RR 16 - 56 0 0.0 S posix_cpu_time posixcputmr/0
 
6 6 RR 16 - 56 0 0.0 S posix_cpu_time posixcputmr/0
  
7 7 TS - -20 39 0 <nowiki>0.0 S< </nowiki>rescuer_thread khelper
+
7 7 TS - -20 39 0
 
+
<nowiki>0.0 S< </nowiki>
8 8 TS - 0 19 0 0.0 S worker_thread kworker/u:1
+
rescuer_thread khelper 8 8 TS - 0 19 0 0.0 S worker_thread kworker/u:1  
 
 
 
125 125 TS - 0 19 0 0.0 S bdi_sync_super sync_supers
 
125 125 TS - 0 19 0 0.0 S bdi_sync_super sync_supers
  
 
127 127 TS - 0 19 0 0.0 S bdi_forker_thr bdi-default
 
127 127 TS - 0 19 0 0.0 S bdi_forker_thr bdi-default
  
128 128 TS - -20 39 0 <nowiki>0.0 S< </nowiki>rescuer_thread kblockd
+
128 128 TS - -20 39 0
 
+
<nowiki>0.0 S< </nowiki>
135 135 TS - -20 39 0 <nowiki>0.0 S< </nowiki>rescuer_thread ata_sff
+
rescuer_thread kblockd 135 135 TS - -20 39 0 <nowiki>0.0 S< </nowiki>
 
+
rescuer_thread ata_sff 142 142 TS - 0 19 0 0.0 S hub_thread khubd  
142 142 TS - 0 19 0 0.0 S hub_thread khubd
 
 
 
 
248 248 TS - 0 19 0 0.0 S worker_thread kworker/0:1
 
248 248 TS - 0 19 0 0.0 S worker_thread kworker/0:1
  
Line 699: Line 703:
 
269 269 TS - 0 19 0 0.0 S fsnotify_mark_ fsnotify_mark
 
269 269 TS - 0 19 0 0.0 S fsnotify_mark_ fsnotify_mark
  
271 271 TS - -20 39 0 <nowiki>0.0 S< </nowiki>rescuer_thread crypto
+
271 271 TS - -20 39 0
 
+
<nowiki>0.0 S< </nowiki>
869 869 FF 50 - 90 0 0.0 S irq_thread irq/15-ide0
+
rescuer_thread crypto 869 869 FF 50 - 90 0 0.0 S irq_thread irq/15-ide0  
 
+
906 906 RR 16 - 56 0 0.0 S irq_thread irq/1-i8042
906 906 RR 16 - 56 0 0.0 S irq_thread irq/1-i8042
 
  
 
913 913 RR 16 - 56 0 0.0 S irq_thread irq/8-rtc0
 
913 913 RR 16 - 56 0 0.0 S irq_thread irq/8-rtc0
Line 713: Line 716:
 
923 923 TS - 0 19 0 0.0 S kjournald kjournald
 
923 923 TS - 0 19 0 0.0 S kjournald kjournald
  
945 945 TS - -4 23 0 <nowiki>0.0 S<s </nowiki>poll_schedule_ udevd
+
945 945 TS - -4 23 0
 
+
<nowiki>0.0 S<s </nowiki>
999 999 TS - -2 21 0 <nowiki>0.0 S< </nowiki>poll_schedule_ udevd
+
poll_schedule_ udevd 999 999 TS - -2 21 0 <nowiki>0.0 S< </nowiki>
 
+
poll_schedule_ udevd 1002 1002 TS - -2 21 0 <nowiki>0.0 S< </nowiki>
1002 1002 TS - -2 21 0 <nowiki>0.0 S< </nowiki>poll_schedule_ udevd
+
poll_schedule_ udevd 1017 1017 TS - 0 19 0 0.0 Ss poll_schedule_ syslog-ng  
 
 
1017 1017 TS - 0 19 0 0.0 Ss poll_schedule_ syslog-ng
 
 
 
 
1025 1025 TS - 0 19 0 0.0 Ss poll_schedule_ sshd
 
1025 1025 TS - 0 19 0 0.0 Ss poll_schedule_ sshd
  
Line 757: Line 757:
 
1182 1191 RR 16 - 56 0 0.0 Sl+ inet_csk_wait_ tEthernInp2
 
1182 1191 RR 16 - 56 0 0.0 Sl+ inet_csk_wait_ tEthernInp2
  
1182 1192 RR 16 - 56 0 0.0 Sl+ wait_for_packe tEthernOut2
+
1182 1192 RR 16 - 56 0 0.0 Sl+ wait_for_packe tEthernOut2
  
 
1182 1193 RR 16 - 56 0 0.0 Sl+ inet_csk_wait_ tEthernInp0
 
1182 1193 RR 16 - 56 0 0.0 Sl+ inet_csk_wait_ tEthernInp0
Line 795: Line 795:
 
1216 1216 TS - 0 19 0 0.0 R+ - ps
 
1216 1216 TS - 0 19 0 0.0 R+ - ps
  
 +
The "threads" is actually a shortcut for the following ps command:
  
Thread is a shortcut for the following ps command:
+
''ps -axH -eo pid,tid,class,rtprio,ni,pri,psr,pcpu,stat,wchan:14,comm''
 
 
ps -axH -eo pid,tid,class,rtprio,ni,pri,psr,pcpu,stat,wchan:14,comm
 
 
 
  
 
The above command presents the following information for each task in the operating system:
 
The above command presents the following information for each task in the operating system:
Line 811: Line 809:
 
'''rtprio''' = real time priority, ranging from 99 to 0. When 99 is strongest.
 
'''rtprio''' = real time priority, ranging from 99 to 0. When 99 is strongest.
  
'''ni''' = niceness. Ranging from -19 to 20.  
+
'''ni''' = niceness. Ranging from -19 to 20.
  
'''pri''' = static priority.  
+
'''pri''' = static priority.
  
 
'''psr''' = processor id.
 
'''psr''' = processor id.
  
'''pcpu''' = overall cpu usage  
+
'''pcpu''' = overall cpu usage
  
'''stat''' = process state. R for runnable or S for sleeping, Z for zombie.  
+
'''stat''' = process state. R for runnable or S for sleeping, Z for zombie.
  
 
'''wchan''' = kernel function where process is waiting. If process is running a dash is displayed
 
'''wchan''' = kernel function where process is waiting. If process is running a dash is displayed
  
 
'''comm''' = name of process
 
'''comm''' = name of process
 
  
 
If you wish to sort the list by the processes real time priority, use the following command:
 
If you wish to sort the list by the processes real time priority, use the following command:
  
 
threads | sort –k4
 
threads | sort –k4
 
  
 
This command sorts the list according by the fourth column.
 
This command sorts the list according by the fourth column.
  
 
=== Kill ===
 
=== Kill ===
 +
 
To terminate a running process use the kill command. Kill needs the process id , so many times you can simply type:
 
To terminate a running process use the kill command. Kill needs the process id , so many times you can simply type:
  
Line 841: Line 838:
  
 
=== Top ===
 
=== Top ===
top is an interactive view of displaying system tasks. It refreshes the list every 1 or more second.
 
  
~ # top
+
top is an interactive view of displaying system tasks. It refreshes the list every 1 or more second.
  
 
~ # top
 
~ # top
Line 857: Line 853:
 
Swap: 0k total, 0k used, 0k free, 12288k cached
 
Swap: 0k total, 0k used, 0k free, 12288k cached
  
 
+
PID USER PR NI VIRT RES SHR S&nbsp;%CPU&nbsp;%MEM TIME+ COMMAND
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
 
  
 
1075 root 20 0 1528 196 148 R 98.9 0.0 77:03.44 pkgd
 
1075 root 20 0 1528 196 148 R 98.9 0.0 77:03.44 pkgd
Line 897: Line 892:
  
 
Top displays a nice summary before the list. Memory usage, cpu usage and so on. Important information is found in this line
 
Top displays a nice summary before the list. Memory usage, cpu usage and so on. Important information is found in this line
 
  
 
Cpu(s): 29.6%us, 70.3%sy, 0.1%ni, 0.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
 
Cpu(s): 29.6%us, 70.3%sy, 0.1%ni, 0.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
 
  
 
For example:
 
For example:
Line 918: Line 911:
 
'''st''' is virtualization usage ( always zero in mib)
 
'''st''' is virtualization usage ( always zero in mib)
  
 +
=== htop ===
  
=== htop ===
 
 
htop is like top but more interactive. You can asks for different sorting keys, like sort by memory usage, sort by cpu usage and so on.
 
htop is like top but more interactive. You can asks for different sorting keys, like sort by memory usage, sort by cpu usage and so on.
  
Line 927: Line 920:
  
 
=== Display process’s maps ===
 
=== Display process’s maps ===
 +
 
To watch a process’ segmented allocation use the following commands:
 
To watch a process’ segmented allocation use the following commands:
  
Line 937: Line 931:
 
08558000-085ed000 rwxp 00000000 00:00 0
 
08558000-085ed000 rwxp 00000000 00:00 0
  
09afd000-0b060000 rwxp 00000000 00:00 0 <nowiki>[heap]</nowiki>
+
09afd000-0b060000 rwxp 00000000 00:00 0
 +
<nowiki>[heap]</nowiki>
  
 
b5a1c000-b5a1d000 ---p 00000000 00:00 0
 
b5a1c000-b5a1d000 ---p 00000000 00:00 0
Line 1,109: Line 1,104:
 
b7819000-b781a000 rwxp 0001b000 03:01 16404 /lib/ld-2.13.so
 
b7819000-b781a000 rwxp 0001b000 03:01 16404 /lib/ld-2.13.so
  
bfd20000-bfd41000 rwxp 00000000 00:00 0 <nowiki>[stack]</nowiki>
+
bfd20000-bfd41000 rwxp 00000000 00:00 0
 
+
<nowiki>[stack]</nowiki>
ffffe000-fffff000 r-xp 00000000 00:00 0 <nowiki>[vdso]</nowiki>
 
  
 +
ffffe000-fffff000 r-xp 00000000 00:00 0
 +
<nowiki>[vdso]</nowiki>
  
 
From left to tight:
 
From left to tight:
  
# The segment ( also known as vma ) memory addresses
+
#The segment ( also known as vma ) memory addresses  
# The segment permission
+
#The segment permission  
# The segment offset into the file
+
#The segment offset into the file  
# The block device major/minor holding the file
+
#The block device major/minor holding the file  
# The size of the segment
+
#The size of the segment  
  
 
=== chrt ===
 
=== chrt ===
 +
 
change real time priority. You can control a processes scheduling class and priority level from the command line.
 
change real time priority. You can control a processes scheduling class and priority level from the command line.
  
For example:  
+
For example:
  
Ksoftirq is a kernel daemon that is widely used in the kernel.  
+
Ksoftirq is a kernel daemon that is widely used in the kernel.
  
 
~ # threads |grep sof
 
~ # threads |grep sof
  
 
3 3 RR 99 - 139 0 0.1 S run_ksoftirqd ksoftirqd/0
 
3 3 RR 99 - 139 0 0.1 S run_ksoftirqd ksoftirqd/0
 
  
 
ksoftirq pid is 3. Its real time priority is 99. So , let say we wish to change its priority to 19.
 
ksoftirq pid is 3. Its real time priority is 99. So , let say we wish to change its priority to 19.
Line 1,152: Line 1,148:
 
3 3 RR 19 - 59 0 0.1 S run_ksoftirqd ksoftirqd/0
 
3 3 RR 19 - 59 0 0.1 S run_ksoftirqd ksoftirqd/0
  
 +
&nbsp;
  
 
== Network ==
 
== Network ==
=== ssh sshd and scp ===
+
 
 +
=== ssh sshd and scp ===
 +
 
 
Secure shell is used to access remote machines. Sshd is service running in the target MIB and ssh is the client. You can login (perform ssh) to a MIB and login from a MIB to any other Linux machine. You can copy files with scp to and from Linux machines.
 
Secure shell is used to access remote machines. Sshd is service running in the target MIB and ssh is the client. You can login (perform ssh) to a MIB and login from a MIB to any other Linux machine. You can copy files with scp to and from Linux machines.
  
 
To login to MIB ip 10.4.20.240 from any Linux machine enter:
 
To login to MIB ip 10.4.20.240 from any Linux machine enter:
 
ssh [mailto:root@10.4.20.240 root@10.4.20.240]
 
  
 
~ # ssh root@10.4.20.240
 
~ # ssh root@10.4.20.240
Line 1,173: Line 1,170:
 
root@10.4.20.240's password:
 
root@10.4.20.240's password:
  
 
+
the first you will asked is enter yes/no. this happens only in the first time you access a remote machine. Enter “yes” and then you will be asked to enter a password, please do. Once entered, you will be in the MIB running in root privileges.
the first you will asked is enter yes/no. this happens only in the first time you access a remote machine. Enter “yes” and then you will be asked to enter a password, please do. Once entered, you will be in the MIB running in root privileges.  
 
  
 
To copy files from Linux machine to another Linux machine in the command line we use scp command: for example, the command:
 
To copy files from Linux machine to another Linux machine in the command line we use scp command: for example, the command:
Line 1,180: Line 1,176:
 
scp –r /tmp root@10.4.20.240:/root/
 
scp –r /tmp root@10.4.20.240:/root/
  
will copy tmp directory to to root directory in target machine. The “-r” means recursive copy, which is how we copy directories.
+
will copy tmp directory to to root directory in target machine. The “-r” means recursive copy, which is how we copy directories.
 
 
If you copy files from a windows machine to a linux machine you should use winscp.  
 
  
 +
If you copy files from a windows machine to a linux machine you should use winscp.
  
[[Image:]]
+
[[File:winscp1.png|winscp]]
  
 
The first window displays a list machines that were accessed previously. If this is the first time you use winscp this list is empty. To copy files to 10.4.20.240 please click on the New button.
 
The first window displays a list machines that were accessed previously. If this is the first time you use winscp this list is empty. To copy files to 10.4.20.240 please click on the New button.
  
[[Image:]]  
+
[[File:winscp2.png|winscp]]
 
 
  
 
Fill the MIB’s ip. The user name “root”, the password, and change the protocol from sftp to scp. Click on “Save” to save the new machine in the list and then click on Login.
 
Fill the MIB’s ip. The user name “root”, the password, and change the protocol from sftp to scp. Click on “Save” to save the new machine in the list and then click on Login.
  
[[Image:]]
+
[[File:winscp3.png|winscp]]
  
You will windows saying that the command “group” returned error, disregard it, it is because MIB does not have group command, after that you will have the above screen. Now you can simply drag and drop files.  
+
You will windows saying that the command “group” returned error, disregard it, it is because MIB does not have group command, after that you will have the above screen. Now you can simply drag and drop files.
  
 
=== Route ===
 
=== Route ===
 +
 
To watch the routing tables just type “route” or “netstat –r”. Here is route output in MIB
 
To watch the routing tables just type “route” or “netstat –r”. Here is route output in MIB
  
Line 1,207: Line 1,202:
 
Destination Gateway Genmask Flags Metric Ref Use Iface
 
Destination Gateway Genmask Flags Metric Ref Use Iface
  
10.0.0.0 <nowiki>* </nowiki>255.0.0.0 U 0 0 0 eth0
+
10.0.0.0
 
+
<nowiki>* </nowiki>
 
+
255.0.0.0 U 0 0 0 eth0 As the reader can see, there is not default route, so if we try to access a different network segment will be getting “unreachable network” . We can only access network on the 10.x.x.x. because the netmask is 255.0.0.0.  
As the reader can see, there is not default route, so if we try to access a different network segment will be getting “unreachable network” . We can only access network on the 10.x.x.x. because the netmask is 255.0.0.0.
 
 
 
 
The only Ethernet interface a MIB has is eth0.
 
The only Ethernet interface a MIB has is eth0.
  
 +
&nbsp;
  
 
=== tcpdump ===
 
=== tcpdump ===
 +
 
tcpdump is a packet capture program. To capture packets simply type:
 
tcpdump is a packet capture program. To capture packets simply type:
  
Line 1,232: Line 1,227:
 
This means that the captured data will be passed to a file called foo.cap.
 
This means that the captured data will be passed to a file called foo.cap.
  
 +
&nbsp;
  
 
=== ethtool ===
 
=== ethtool ===
ethtool is used to query and control network interfaces.  
+
 
 +
ethtool is used to query and control network interfaces.
  
 
~ # ethtool eth0
 
~ # ethtool eth0
Line 1,240: Line 1,237:
 
Settings for eth0:
 
Settings for eth0:
  
 +
&nbsp;
 
<nowiki>Supported ports: [ TP MII ]</nowiki>
 
<nowiki>Supported ports: [ TP MII ]</nowiki>
  
Supported link modes: 10baseT/Half 10baseT/Full
+
Supported link modes: 10baseT/Half 10baseT/Full
  
 
100baseT/Half 100baseT/Full
 
100baseT/Half 100baseT/Full
Line 1,284: Line 1,282:
 
Link detected: yes
 
Link detected: yes
  
 +
Common use for it is checking the link type, 10/100/1000 Mbps and if the network is actually up (Last line: Link Detected).
  
Common use for it is checking the link type, 10/100/1000 Mbps and if the network is actually up (Last line: Link Detected).
+
= Boot =
 
 
  
= Boot =
 
 
Linux MIB boot is a two-phase boot. Once the computer passed the POST stage (Power On Self Test) it passes the control to the operating system. The first operating system is actually a boot loader. The boot loader is called grub – “grand unified boot loader”. Grub has one main purpose, to boot Linux. At the moment, the MIB hardware prevents us from seeing the grub loads. When grub loads it splashes a menu to screen (it is called splashing). This menu is kept in /boot/grub/menu.lst which is accessible through the LinuxMIB.
 
Linux MIB boot is a two-phase boot. Once the computer passed the POST stage (Power On Self Test) it passes the control to the operating system. The first operating system is actually a boot loader. The boot loader is called grub – “grand unified boot loader”. Grub has one main purpose, to boot Linux. At the moment, the MIB hardware prevents us from seeing the grub loads. When grub loads it splashes a menu to screen (it is called splashing). This menu is kept in /boot/grub/menu.lst which is accessible through the LinuxMIB.
 
  
 
~ # cat /boot/grub/menu.lst
 
~ # cat /boot/grub/menu.lst
Line 1,297: Line 1,293:
  
 
terminal --timeout=0 serial console
 
terminal --timeout=0 serial console
 
  
 
default 0
 
default 0
Line 1,304: Line 1,299:
  
 
color cyan/blue white/blue
 
color cyan/blue white/blue
 
  
 
title Standalone Boot
 
title Standalone Boot
Line 1,311: Line 1,305:
  
 
kernel /boot/bzImage root=/dev/hda1,/dev/hdc1 console=ttyS0,115200
 
kernel /boot/bzImage root=/dev/hda1,/dev/hdc1 console=ttyS0,115200
 
  
 
title Network Boot
 
title Network Boot
Line 1,320: Line 1,313:
  
 
kernel (nd)/linux root=/dev/nfs console=ttyS0,115200 ip=:::::eth0: nfsroot=
 
kernel (nd)/linux root=/dev/nfs console=ttyS0,115200 ip=:::::eth0: nfsroot=
 
  
 
~ #
 
~ #
 
  
 
The boot loader menu has two entries, the first entry boots Linux from the disk, and the second one boots Linux from the network. The first one is the default one.
 
The boot loader menu has two entries, the first entry boots Linux from the disk, and the second one boots Linux from the network. The first one is the default one.
Line 1,333: Line 1,324:
 
This means that the kernel search for a root file system in a block device called /dev/hda1 and if it fails it tries /dev/hdc1. The “console=” means that the rs232 input and output redirected through a device file called /dev/ttyS0 in 115200 speed. These parameters are kernel parameters and do not relate to grub.
 
This means that the kernel search for a root file system in a block device called /dev/hda1 and if it fails it tries /dev/hdc1. The “console=” means that the rs232 input and output redirected through a device file called /dev/ttyS0 in 115200 speed. These parameters are kernel parameters and do not relate to grub.
  
 +
&nbsp;
  
 
= BSP =
 
= BSP =
The board specific package I used to create the MIB is Pengutronix. Pengutronix is software builds an entire Linux distribution from scratch. Linux MIB software does not contain any binaries with the sources. So, in this section I will describe how to build the MIB bsp and MC in the virtual disk I supply for this.  
+
 
 +
The board specific package I used to create the MIB is Pengutronix. Pengutronix is software builds an entire Linux distribution from scratch. Linux MIB software does not contain any binaries with the sources. So, in this section I will describe how to build the MIB bsp and MC in the virtual disk I supply for this.
  
 
== Virtual Build Machine ==
 
== Virtual Build Machine ==
 +
 
The virtual machine I use to virtual box. Please download and install it. The virtual machine is composed from two virtual disks, mib.vdi and buildDisk.vdi. The mib.vdi is 50MB disk, and buildDisk.vdi is 2 GB disk. This is because the build objects consume a lot of storage. Both disks can be found at //domainaxy/IL/MC/linux/buildmachine . Access to virtual machine is done through the terminal or through ssh with user root , no password required.
 
The virtual machine I use to virtual box. Please download and install it. The virtual machine is composed from two virtual disks, mib.vdi and buildDisk.vdi. The mib.vdi is 50MB disk, and buildDisk.vdi is 2 GB disk. This is because the build objects consume a lot of storage. Both disks can be found at //domainaxy/IL/MC/linux/buildmachine . Access to virtual machine is done through the terminal or through ssh with user root , no password required.
 
  
 
'''Virtual Box Configuration'''
 
'''Virtual Box Configuration'''
Line 1,345: Line 1,338:
 
storage
 
storage
  
[[Image:]]
+
[[File:vbox1.png|vbox]]
  
 
Network
 
Network
  
[[Image:]]
+
[[File:vbox2.png|vbox]]
 
 
  
 
share
 
share
  
[[Image:]]
+
[[File:vbox3.png|vbox]]
  
 
+
The guest gets static IP 192.168.56.101 . It is accessible only from the host. We decided to use this configuration as it simplifies things. If you wish to have the Linux connect to the network choose network card attached as bridge and choose intel PRO/1000 MT Desktop.
The guest gets static IP 192.168.56.101 . It is accessible only from the host. We decided to use configuration as it simplifies things. If you wish to have the Linux connect to the network choose network card attached as bridge and choose intel PRO/1000 MT Desktop.
 
  
 
To have the virtual build machine access s shared folder in the host machine, please add a share name called amcs to whatever folder you wish.
 
To have the virtual build machine access s shared folder in the host machine, please add a share name called amcs to whatever folder you wish.
Line 1,363: Line 1,354:
 
The “amcs” share will mount automatically. Any other share has to be mounted manually in the guest:
 
The “amcs” share will mount automatically. Any other share has to be mounted manually in the guest:
  
mount.vboxsf <nowiki><share name> </nowiki><nowiki><mount point> </nowiki>
+
mount.vboxsf
 
+
<nowiki><share name> </nowiki>
 +
<nowiki><mount point> </nowiki>
  
 
'''Virtual Linux Configuration'''
 
'''Virtual Linux Configuration'''
  
The virtual disk containing the toolchain is called buildDisk.vdi. Once you boot the virtual build machine you need to make sure build disk is mounted. So check is /opt directory contains OSELAS toolchain. Also, please check the you have network access (with ifconfig) .If all well, please check if you can connect with ssh.
+
The virtual disk containing the toolchain is called toolchain.vdi. Once you boot the virtual build machine you need to make sure build disk is mounted. So check is /opt directory contains OSELAS toolchain. Also, please check the you have network access (with ifconfig) .If all well, please check if you can connect with ssh.
  
 +
&nbsp;
  
 
=== Building MC ===
 
=== Building MC ===
# Make sure amcs share is mounted and contains all required sources. Make sure the toolchain is mounted on /opt.
 
 
 
  
 +
#Make sure amcs share is mounted and contains all required sources. Make sure the toolchain is mounted on /opt.
  
 
~ # df
 
~ # df
Line 1,399: Line 1,390:
 
tmpfs 191428 112 191316 0% /dev
 
tmpfs 191428 112 191316 0% /dev
  
/dev/sdb 8256952 1784056 6053468 23% /opt
+
''''/dev/sdb 8256952 1784056 6053468 23% /opt''''
  
 
none 4217028 1366328 2850700 32% /media
 
none 4217028 1366328 2850700 32% /media
  
 +
Change directory to mc sources (inside the amcs share) or clone them from the linux. if this is the first time you build these sources please configure the build as follows:
  
# Change directory to mc sources (inside the amcs share) or clone them from the linux.
+
$ sh run_configure_all and now you can build these sources:
# If this is first time you build these sources please:
 
 
 
$ sh run_configure_all
 
 
 
# build
 
  
 
$ make –j2
 
$ make –j2
  
Or through the eclipse choose the virtual machine configuration and have eclipse build it for you.
+
If you wish to configure eclipse ontop of the virtual box please refer to this document: [[Eclipse_Stand_Alone_Linux|Eclipse Stand Alone Linux]]
 
 
  
 
Once you’re done, you need to copy the binary to the target machine if you have external networking.
 
Once you’re done, you need to copy the binary to the target machine if you have external networking.
Line 1,422: Line 1,408:
 
else use eclipse terminal to copy.
 
else use eclipse terminal to copy.
  
 +
&nbsp;
  
Troubleshoot
+
==== Troubleshoot ====
 
 
'''run_configure_all '''
 
 
 
If run_configure_all fails with numerous errors, edit in linux, and remove all ^M signs.
 
 
 
  
'''Machine Name'''
+
'''run_configure_all'''
  
If you want to change the machine name, please:
+
If run_configure_all fails with numerous errors, edit in linux, and remove all ^M signs.
  
 
'''Out Of memory'''
 
'''Out Of memory'''
  
 
Incase during the build you see a message “out of memory” please remove the –j from the make and remake or increase the virtual machine RAM.
 
Incase during the build you see a message “out of memory” please remove the –j from the make and remake or increase the virtual machine RAM.
 
  
 
'''Out of disk space'''
 
'''Out of disk space'''
Line 1,443: Line 1,424:
 
You are probably building on the virtual machine disk. Change to share directory.
 
You are probably building on the virtual machine disk. Change to share directory.
  
 +
== Toolchain ==
  
== Toolchain ==
 
 
The toochain is installed in the /opt/ directory. This requirement is strict and I do not support any other configuration. The toolchain we use is:
 
The toochain is installed in the /opt/ directory. This requirement is strict and I do not support any other configuration. The toolchain we use is:
  
Line 1,455: Line 1,436:
 
Sanitized kernel headers 2.6.36
 
Sanitized kernel headers 2.6.36
  
Your /opt/ directory should contain a directory called:/opt/OSELAS.Toolchain-2011.03.1/.  
+
Your /opt/ directory should contain a directory called:/opt/OSELAS.Toolchain-2011.03.1/.
  
 +
&nbsp;
  
 
== The BSP ==
 
== The BSP ==
 +
 
To build the entire bsp you need a linux ubunto server. Building the bsp on a virtual box running ubunto is possible but will take a long time.
 
To build the entire bsp you need a linux ubunto server. Building the bsp on a virtual box running ubunto is possible but will take a long time.
  
You can find the toolchain tar ball  
+
You can find the toolchain tar ball
  
//domainaxy/IL/MC/linux/buildmachine/OSELAS.Toolchain-2011.03.1.tar  
+
//domainaxy/IL/MC/linux/buildmachine/OSELAS.Toolchain-2011.03.1.tar
  
Copy it and extract it in the ubunto :
+
Copy it and extract it in the ubunto&nbsp;:
  
 
$ sudo tar xvf OSELAS.Toolchain-2011.03.1.tar –C /opt/
 
$ sudo tar xvf OSELAS.Toolchain-2011.03.1.tar –C /opt/
 
  
 
Now, clone the bsp:
 
Now, clone the bsp:
  
git clone [mailto:git@10.4.20.38:/home/git/bsp.git git@10.4.20.38:/home/git/bsp.git]  
+
git clone [mailto:git@10.4.20.38:/home/git/bsp.git git@10.4.20.38:/home/git/bsp.git]
  
to build the bsp master branch :
+
to build the bsp master branch&nbsp;:
  
 
cd bsp/
 
cd bsp/
Line 1,486: Line 1,468:
 
the image is hd.img. To burn it to the sdcard please:
 
the image is hd.img. To burn it to the sdcard please:
  
sudo dd if=platform-i586/images/hd.img of=/dev/sdX  
+
sudo dd if=platform-i586/images/hd.img of=/dev/sdX
  
 
when /dev/sdX is the sdcard device name. if you don’t the device name, do not bother dd’ing, you will probably destroy the build server.
 
when /dev/sdX is the sdcard device name. if you don’t the device name, do not bother dd’ing, you will probably destroy the build server.
Line 1,497: Line 1,479:
  
 
=== Replicate an image ===
 
=== Replicate an image ===
 +
 
There are times where one wishes to replicate an existing image. To do that he must copy the source image as file to some Linux machine using dd and then burn the source file image to new card. Here are the steps to do that:
 
There are times where one wishes to replicate an existing image. To do that he must copy the source image as file to some Linux machine using dd and then burn the source file image to new card. Here are the steps to do that:
  
# Place in the card reader the source flash card. Linux will notice a new disk was pushed in.
+
#Place in the card reader the source flash card. Linux will notice a new disk was pushed in.  
# dmesg and look for the new disk name, like /dev/sdd or/dev/sdb.
+
#dmesg and look for the new disk name, like /dev/sdd or/dev/sdb.  
  
 
It will appear in the bottom of the dmesg log, for example:
 
It will appear in the bottom of the dmesg log, for example:
  
 +
&nbsp;
 
<nowiki>[422238.883418] sd 9:0:0:0: [sdd] Assuming drive cache: write through</nowiki>
 
<nowiki>[422238.883418] sd 9:0:0:0: [sdd] Assuming drive cache: write through</nowiki>
  
 +
&nbsp;
 
<nowiki>[422238.883423] sd 9:0:0:0: [sdd] Attached SCSI removable disk</nowiki>
 
<nowiki>[422238.883423] sd 9:0:0:0: [sdd] Attached SCSI removable disk</nowiki>
  
 +
&nbsp;
 
<nowiki>[422470.346994] EXT3-fs: barriers not enabled</nowiki>
 
<nowiki>[422470.346994] EXT3-fs: barriers not enabled</nowiki>
  
<nowiki>[422470.735075] kjournald starting. </nowiki>Commit interval 5 seconds
+
&nbsp;
 
+
<nowiki>[422470.735075] kjournald starting. </nowiki>
<nowiki>[422470.735121] EXT3-fs (sdd1): warning: maximal mount count reached, running e2fsck is recommended</nowiki>
+
Commit interval 5 seconds &nbsp; <nowiki>[422470.735121] EXT3-fs (sdd1): warning: maximal mount count reached, running e2fsck is recommended</nowiki>
  
 +
&nbsp;
 
<nowiki>[422470.736077] EXT3-fs (sdd1): using internal journal</nowiki>
 
<nowiki>[422470.736077] EXT3-fs (sdd1): using internal journal</nowiki>
  
 +
&nbsp;
 
<nowiki>[422470.736083] EXT3-fs (sdd1): recovery complete</nowiki>
 
<nowiki>[422470.736083] EXT3-fs (sdd1): recovery complete</nowiki>
  
 +
&nbsp;
 
<nowiki>[422470.737199] EXT3-fs (sdd1): mounted filesystem with ordered data mode</nowiki>
 
<nowiki>[422470.737199] EXT3-fs (sdd1): mounted filesystem with ordered data mode</nowiki>
 
  
 
The device ( disk ) in my machine is /dev/sdd. It has a single partition called /dev/sdd1.
 
The device ( disk ) in my machine is /dev/sdd. It has a single partition called /dev/sdd1.
  
 +
&nbsp;
  
# Now copy the card to a file using dd: for example, if my disk name is /dev/sdb I enter:  
+
#Now copy the card to a file using dd: for example, if my disk name is /dev/sdb I enter:  
  
$ dd if=/dev/sdb bs=1M of=/tmp/hd.img  
+
$ dd if=/dev/sdb bs=1M of=/tmp/hd.img
  
 
$ sync
 
$ sync
  
# Now pull out the source sd card, and place the new card.
+
#Now pull out the source sd card, and place the new card.  
# Push back the target flash card, and then:
+
#Push back the target flash card, and then:  
  
 
$ dd if=/tmp/hd.img of=/dev/sdb
 
$ dd if=/tmp/hd.img of=/dev/sdb
Line 1,537: Line 1,526:
 
$ sync
 
$ sync
  
 +
&nbsp;
  
 
= How to edit files in MIB =
 
= How to edit files in MIB =
 +
 
There are cases where a user needs to edit a text file in the LinuxMIB. LinuxMIB has two editors, nano and vi.
 
There are cases where a user needs to edit a text file in the LinuxMIB. LinuxMIB has two editors, nano and vi.
  
Line 1,544: Line 1,535:
  
 
= Upgrade Linux MIB =
 
= Upgrade Linux MIB =
Linux MIB is shipped with a debian based packaging system. This means that to any update is wrapped with ipkg. Once the package is ready, simply copy the package file to the target to the inbox directory.
 
  
scp mc-4.9.0-linux.ipk 10.4.20.240:/inbox/ or by drag-and-drop through windows operating system with winscp.  
+
Linux MIB is shipped with a debian based packaging system. This means that to any update is wrapped with ipkg. Once the package is ready, simply copy the package file to the target to the inbox directory.
 +
 
 +
scp mc-4.9.0-linux.ipk 10.4.20.240:/inbox/ or by drag-and-drop through windows operating system with winscp.
  
Packaging is triggered automatically. I wrote a package manager daemon that listens on /inbox directory and if a new file is put there it tries to install it.  
+
Packaging is triggered automatically. I wrote a package manager daemon that listens on /inbox directory and if a new file is put there it tries to install it.
  
 
You can list the packages with the following command:
 
You can list the packages with the following command:
Line 1,556: Line 1,548:
 
Currently you cannot uninstall a package, you have to remove the files manually.I believe it is a pengutronix bug.
 
Currently you cannot uninstall a package, you have to remove the files manually.I believe it is a pengutronix bug.
  
== Control MC Start ==
+
== Control MC Start ==
One of the first things a programmer does when developing is disabling the automatic start of the application he is debugging. In manz case it is mostly the mc.  
+
 
 +
One of the first things a programmer does when developing is disabling the automatic start of the application he is debugging. In manz case it is mostly the mc.
  
 
There are two ways to disable automatic starting:
 
There are two ways to disable automatic starting:
  
 +
&nbsp;
  
# Each time you boot.
+
#Each time you boot.  
  
 +
&nbsp;
 
<nowiki># ~ /etc/init.d/mc stop</nowiki>
 
<nowiki># ~ /etc/init.d/mc stop</nowiki>
  
# Edit /etc/init.d/mc script and remark the mc launching as follows:
+
#Edit /etc/init.d/mc script and remark the mc launching as follows:  
  
 
 
Line 1,574: Line 1,569:
 
/etc/init.d/run_config
 
/etc/init.d/run_config
  
 +
&nbsp;
 
<nowiki># nohup /bin/sh /usr/bin/mc.sh &</nowiki>
 
<nowiki># nohup /bin/sh /usr/bin/mc.sh &</nowiki>
 
  
 
Add # before the nohup as depicted in the line above.
 
Add # before the nohup as depicted in the line above.
  
 
= Debugging =
 
= Debugging =
 +
 
Debugging mc can mostly with eclipse. Please refer to eclipse documentation to learn how to do that.
 
Debugging mc can mostly with eclipse. Please refer to eclipse documentation to learn how to do that.
  
 
== Logs ==
 
== Logs ==
 +
 
In addition to the log files in /RAM file system. We added a linux-like logger which can be found at /var/syslog.
 
In addition to the log files in /RAM file system. We added a linux-like logger which can be found at /var/syslog.
  
 +
&nbsp;
  
 
== Core files ==
 
== Core files ==
 +
 
A core file is a snapshot of the process memory when it crashed. It is a post mortem debugging method commonly used. All cores files are generated to /cores directory. There will no more than 5 cores. The 6-th core is written on the first core.
 
A core file is a snapshot of the process memory when it crashed. It is a post mortem debugging method commonly used. All cores files are generated to /cores directory. There will no more than 5 cores. The 6-th core is written on the first core.
  
To debug a core dump you must compile the same mc with debug info and copy the core file to the ubunto ( virtual build machine is not suitable for that ). Then type:  
+
To debug a core dump you must compile the same mc with debug info and copy the core file to the ubunto ( virtual build machine is not suitable for that ). Then type:
  
 
gdb mc coredump
 
gdb mc coredump
  
 +
&nbsp;
  
 
== Memory Detector ==
 
== Memory Detector ==
 +
 
To debug memory leaks you need valgrind. Valgrind is not installed as is in the bsp, simply take a package and put it in the target. If you do not know how to use valgrind I suggest you refer to valgrind web site. It is beyond the scope of this paper.
 
To debug memory leaks you need valgrind. Valgrind is not installed as is in the bsp, simply take a package and put it in the target. If you do not know how to use valgrind I suggest you refer to valgrind web site. It is beyond the scope of this paper.
  
 +
&nbsp;
  
 
== MC cli ==
 
== MC cli ==
MC Linux is shipped with a telnet server. This telnet server resembles the vxworks terminal.  
+
 
 +
MC Linux is shipped with a telnet server. This telnet server resembles the vxworks terminal.
  
 
To login please:
 
To login please:
  
 
~ # telnet localhost:8000
 
~ # telnet localhost:8000
 
  
 
Entering character mode
 
Entering character mode
  
 
Escape character is '^]'.
 
Escape character is '^]'.
 
  
 
AMCS shell
 
AMCS shell
 
  
 
User name is root and password qwerty.
 
User name is root and password qwerty.
 
  
 
Username: root
 
Username: root
Line 1,621: Line 1,620:
 
Password:
 
Password:
  
 
+
The telnet is evolving and the command may differ from one version to another but to get help you can simply type help.
The telnet is evolving and the command may differ from one version to another but to get help you can simply type help.  
 
 
 
  
 
> help
 
> help
 
  
 
Commands available:
 
Commands available:
Line 1,643: Line 1,639:
  
 
exit exit the process
 
exit exit the process
 
  
 
>
 
>
  
 +
&nbsp;
  
 
== Profiling ==
 
== Profiling ==
Profiling MC can be done with oprofile. To use oprofile you need to boot a kernel with oprofile support, and replace the drivers. For this you will have to install a package called kernel-oprofile.ipk and boot this kernel.  
+
 
 +
Profiling MC can be done with oprofile. To use oprofile you need to boot a kernel with oprofile support, and replace the drivers. For this you will have to install a package called kernel-oprofile.ipk and boot this kernel.
  
 
To use oprofile please:
 
To use oprofile please:
  
$ opcontrol –reset  
+
$ opcontrol –reset
  
 
$ opcontrol –deinit
 
$ opcontrol –deinit
Line 1,663: Line 1,660:
 
$ opcontrol –list-events
 
$ opcontrol –list-events
  
Let say you wish to check memory references.  
+
Let say you wish to check memory references.
  
 
$ opcontrol –event:DATA_MEM_REFS:30000
 
$ opcontrol –event:DATA_MEM_REFS:30000
Line 1,686: Line 1,683:
  
 
$ opreport –session-dir=/home/raz/myprofile
 
$ opreport –session-dir=/home/raz/myprofile
 
  
 
CPU_CLK_UNHALT...|LLC_MISSES:466500|
 
CPU_CLK_UNHALT...|LLC_MISSES:466500|
  
samples| %| samples| %|
+
samples|&nbsp;%| samples|&nbsp;%|
  
 +
&nbsp;
 
<nowiki>------------------------------------</nowiki>
 
<nowiki>------------------------------------</nowiki>
  
Line 1,698: Line 1,695:
 
CPU_CLK_UNHALT...|LLC_MISSES:466500|
 
CPU_CLK_UNHALT...|LLC_MISSES:466500|
  
  samples| %| samples| %|
+
  samples|&nbsp;%| samples|&nbsp;%|
  
 +
&nbsp;
 
<nowiki>------------------------------------</nowiki>
 
<nowiki>------------------------------------</nowiki>
  
Line 1,705: Line 1,703:
  
 
  234 24.8144 0 0 libc-2.11.1.so
 
  234 24.8144 0 0 libc-2.11.1.so
 
  
 
To get annotation per line use, run this from the mc directory. This way opannotate will find the source code.
 
To get annotation per line use, run this from the mc directory. This way opannotate will find the source code.
  
 
$ opanotate –s session-dir=/home/raz/myprofile
 
$ opanotate –s session-dir=/home/raz/myprofile
 
  
 
Please note if you intend to use oprofile please read the tutotial as it is beyond the spec of this paper.
 
Please note if you intend to use oprofile please read the tutotial as it is beyond the spec of this paper.
  
 
== ftrace ==
 
== ftrace ==
 +
 
I do not want to write what is ftrace in this book, please refer to the ftrace tutorials to do that:
 
I do not want to write what is ftrace in this book, please refer to the ftrace tutorials to do that:
  

Latest revision as of 08:56, 21 February 2022

Introduction

This documentation explains most parts of the Linux MIB. It is intended for the following users:

  • softMC developers who are compiling and link C/C++ code
  • QA teams
  • Managers engaged in MIB development

MIB Software Components

The software on a common Linux MIB has two main types.

The first type is software controlled by Servotronix, who builds and maintains the source code. The second type is software over which Servotronix has no control, such as third-party binaries.

The first type includes:

  • The Linux operating system. This includes all services and utilities along with their shared objects (aka dll) which take part of maintaining the operating system.
  • The Linux Kernel. The core of the operating system.

 

  • mc. Manz’s motion control and its bash scripts extensions.
  • /FFS0 with its mc basic programs.
  • core dumper. Daemon used to redirect core files.
  • pkgd. Package manager.
  • Various in house drivers,such as , sercos 2, ethercat and so on.
  • In the future, any third party software that is added, such as PNP plugins and 3s.

All of the above software is built from source code. Servotronix does not ship any other component without its source code. Binaries passed to MIB through the aico are not considered part of Linux MIB system.

Accessing the MIB

The MIB is fully accessable from any machine. Accessing the LinuxMIB can be done in two ways – secure shell and RS232 connection.

Access LinuxMIB through RS232

It is assumed that you are familiar with RS232 connections.

In Windows you can access the MIB through hyperterminal or putty.

putty.exe can be downloaded from http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html.

'''RS232 Configuration'''
Speed 115200
StopBits: 1
Data: 8
Parity:Odd ( N)

Once connected a login session will appear:

manz login:

enter mc

and then:

Password:

Enter mc

 

Obtaining LinuxMIB IP

If you have aico, use “Select Device” and look for Linux. This should be some LinuxMIB IP.

Alternately, you can access through RS232:

~ # '''''ifconfig'''''
eth0 Link encap:Ethernet HWaddr 00:50:C2:5D:0F:5E
inet addr:'''10.4.20.83''' Bcast:10.4.20.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:92287 errors:0 dropped:0 overruns:0 frame:0
TX packets:4462 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:13389368 (12.7 MiB) TX bytes:431984 (421.8 KiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:9 errors:0 dropped:0 overruns:0 frame:0
TX packets:9 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:612 (612.0 B) TX bytes:612 (612.0 B)

Access LinuxMIB through Secure Shell

To access the MIB from windows without direct connection use secure shell, or in short “ssh”.

If you login through putty, run it. A screen will appear.

putty

Perform the following steps:

1. Choose ssh button
2. ssh port is 22 by default
3. Fill LinuxMIB ip in both feilds,ie host name and saved sessions.
4. save it
5. open it

A login screen will appear.

putty

Changing the password

It is common to change the login password (for developers only):

~ # passwd

Changing password for root

New password:

Enter q

A prompt will appear:

Bad password: too short.

It is ok. “q” is bad password. but you’re likely to login so many times so you better of using this short password.

Then it will ask you to retype the password,

Retype password:

Enter q again. You do not have to enter “q”, but you will learn that people access anyone’s MIB, so they will expect a short packet to be “q”.

Storage

This section details the storage of the LinuxMIB. Storage refers to the disks and file systems.

Block Devices

A block device is a device that is accessed with blocks of data. This includes, hard drives, DVD devices, usb flash cards and so on. In the MIB case the block device that holds the file system is called /dev/sda or /dev/hda. It is referred to as /dev/root ( for reasons out this document scope I will not explain why ). Too examin the disk use the fdisk command :

 

fdisk -l

Disk /dev/sda: 1014 MB, 1014644736 bytes
255 heads, 63 sectors/track, 123 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot      Start         End      Blocks  Id System
     /dev/sda1   *           1          57      449850+ 83 Linux
   Partition 1 does not end on cylinder boundary
     /dev/sda2              57         116      475000  83 Linux
   Partition 2 does not end on cylinder boundary

 

/dev/sda1 is / . /dev/sda2 is the backup partition. The backup partion is used /dev/sda1 is totally corrupted.

File systems

LinuxMIB is composed from several independent file systems. To examine the file systems please enter:

~ # 'df -h'

                         Filesystem Size     Used    Available  Use%  Mounted on
1)
                        /dev/root   485.5M   83.8M    377.3M    18%   /  

 

2)
                          none       246.9M   4.0K    246.9M    0% /tmp  
3)
                           none       246.9M   24.0K   246.8M    0%  /RAM 
                           none       246.9M   44.0K   246.8M    0% /var/log
                           none       246.9M   24.0K   246.8M    0% /var/run
4)
                           none       246.9M     0      246.9M   0%   /var/lock
                           none       246.9M     0      246.9M   0%   /var/tmp
                           tmpfs      246.9M     4.0K   246.9M    0%  /dev

 

  1. The main file system is called root file system. The root file system is said to be mounted on the mounting point “/”. Any other file system in Linux is mounted on top of the root file system at some directory. Here the root file system is of size of 485MB, and 83MB of it are used.
  1. /tmp directory is mounted as tmpfs file system. This is a ram file system. It does not survive boots.
  2. This is the RAM file system used by mc. It is also of type tmpfs.
  3. /var/log , /var/run, /var/lock, and /var/tmp are tmps file system as well used by different services.
  4. /dev/ is a file system that holds all device files. it is regenerated with each boot.
  5. There is a nother file system called /dev/pts , it is visible through the mount command, it hold terminals information.

Basic commands

File and file system

ls

To examine the content the of current directory use ls:

~ # ls

  To examine the content of another directory use ls <dir>. For example:

~ # ls /sbin/

adjtimex halt init modprobe setconsole udevadm

blkid hdparm insmod poweroff sfdisk udevd

dhclient hwclock klogd reboot start-stop-daemon udhcpc

fdisk ifconfig loadkmap rmmod sulogin umount.devkit

fsck ifdown lsmod route syslog-ng watchdog

getty ifup modinfo runlevel threads

~ #

The “ls” commands have additional flags, such as : “ls –al” which provides more information about the files.

cat

To examine the content of a text file use the cat. For example:

~ # cat /etc/busybox.conf

you can also create new files with cat by redirecting cat’s output to a new file. For example:

~ # cat /etc/busybox.conf > /tmp/busybox.conf

you can concatenate two files in to a single file by using the >> sign.

For example the command

~ # cat /etc/inet.conf >> /tmp/busybox.conf

will concatenate to /tmp/busybox.conf the content of /etc/inet.conf.

echo

echo is a command that send a string to a file, where a file can be the terminal itself or simply a regular text file or any other file which receives data.

~ # echo hello

Hello

 

less

less is a textual viewer. It is used to examine text file content in read-only mode. Usage:

  ~# less <file name>

tail/head

The tail comands prints last line of a file. The head command prints the first few lines of a file. tail is very useful a user wishes to examine how file is being updated , mostly logs.

For example:

~ # tail –f /var/syslog

fsck – check file system consistency

LinuxMIB uses ext3 as its file system, ext3 is a journaling file system which means file system corruption is much less to occur, there are still times where corruptions do happen ( not by abrupt power off but by exploding the file system or deliberately corrupting ).

LinuxMIB executes fsck.ext3 each time it is booted, if you wish to check file system integrity first create the device name:

mknod /dev/hda1 b 3 1

This is because /dev/hda1 does not exist on the MIB and neither /dev/root.

Now issue the fsck command as bellow. I use –n flag to do that in read only mode.

fsck.ext3 –n /dev/hda1

grep

grep prints lines matching a pattern. Example:

/etc # grep mc /usr/bin/mc.sh

/usr/bin/mc

The above command prints each line containing the word “mc”.

or check number of mc core files in the /cores/ directory.

nf=$(ls /cores/mc* | wc -l)

echo $nf

4

awk

awk is a parsing language. The awk command scans an input file searching for some text pattern and when finding this pattern awk act according to the action specified.

For example:

~# awk '$2 == 0 { printf $1 " " $2 " " $3 "\n"}' /proc/interrupts

NMI: 0 Non-maskable

LOC: 0 Local

SPU: 0 Spurious

PMI: 0 Performance

IWI: 0 IRQ

TRM: 0 Thermal

THR: 0 Threshold

MCE: 0 Machine

ERR: 0

MIS: 0

This command prints columns 1, 2 and 3 in the /proc/interrupts if the second column equal 0.

find

find searches for files in directory recursively. For example, if a user wants to find all files named mc in the LinuxMIB:

~ # find / -name mc

/etc/init.d/mc

/usr/bin/mc

 

watch

The watch command executes a command periodically. For example:

watch –n1 ‘cat /proc/vmstat`

print to screen the file /proc/vmstat .

gzip/gunzip

The gzip command compresses a file. The gunzip command decompress a file.

Example:

gzip /etc/busybox.conf

busybox.conf is compressed and renamed to busybox.conf.gz

to decompress :

gunzip /etc/busybox.cong.gz

a new file /etc/busybox.conf is created.

 

zcat

zcat is used to print a content of a compressed text file without decompressing it.

Example:

zcat /etc/busybox.conf.gz

This will dump to screen busybox.conf.a

System

free

free returns the amount of RAM in the machine, the amount of used memory in the machine and the amount of used memory in the machine.

~ # free

total used free shared buffers

Mem: 505560 47912 457648 0 1356

Swap: 0 0 0

Total: 505560 47912 457648

lshw

Lists the hardware configuration of the machine.

~ # lshw

manz

description: Computer

product: N/A

vendor: N/A

version: N/A

serial: N/A

width: 32 bits

capabilities: smbios-2.5 dmi-2.5

configuration: administrator_password=disabled boot=oem-specific frontpanel_

password=unknown keyboard_password=unknown power-on_password=disabled

  *-core

description: Motherboard

product: MODB

vendor: Kontron Embedded Modules

physical id: 0

version: 05.00

serial: YXEBK0229

  *-firmware

description: BIOS

vendor: Phoenix Technologies LTD

physical id: 0

version: MODBR131 (06/27/0808)

size: 104KiB

capacity: 960KiB

capabilities: isa pci pcmcia pnp apm upgrade shadowing escd cdboot acp

i usb agp biosbootspecification

  *-cpu

description: CPU

product: Intel(R) Celeron(R) M processor 1.50GHz

vendor: Intel Corp.

physical id: 4

bus info: cpu@0

version: 6.13.8

slot: U2E1

size: 1500MHz

capacity: 2048MHz

width: 32 bits

capabilities: fpu fpu_exception wp vme de pse tsc msr pae mce cx8 sep

mtrr pge mca cmov clflush dts acpi mmx fxsr sse sse2 ss tm pbe nx bts

  *-cache:0

description: L1 cache

physical id: 5

slot: L1 Cache

size: 64KiB

capacity: 64KiB

 

udevadm

udev is part of a linux device model. Udevadm is a tool used to query, monitor and control devices. For example, the hardisk “hda”,has a pci address, it belongs to the block device subsystem, and so on. To get this sort of information in one unified view, we do:

~ # udevadm info -a -p /sys/block/hda

Udevadm info starts with the device specified by the devpath and then

walks up the chain of parent devices. It prints for every device

found, all possible attributes in the udev rules key format.

A rule to match, can be composed by the attributes of the device

and the attributes from one single parent device.

looking at device '/block/hda':

KERNEL=="hda"

SUBSYSTEM=="block"

DRIVER==""

ATTR{range}=="64"

ATTR{ext_range}=="256"

ATTR{removable}=="0"

ATTR{ro}=="0"

ATTR{size}=="1981728"

ATTR{alignment_offset}=="0"

ATTR{discard_alignment}=="0"

ATTR{capability}=="50"

ATTR{stat}==" 342 173 15716 1119 47 25 1

1768 0 2179 2886"

ATTR{inflight}==" 0 0"

ATTR{events}==""

ATTR{events_async}==""

ATTR{events_poll_msecs}=="-1"

As one can observe, a disk called had is part of the block subsystem, there is no driver for it as I did not compile external modules, additional information appears such as its size and some statistics.

 

Reboot

To reboot the MIB use the “reboot” command.

Poweroff

To turn off the MIB, use the “poweroff” command.

hwclock

To get or set the time to/from RTC hardware clock , use the “hwclock” command. In cases where RTC is broken, “hwlock” will hang or display bad time.

 

Process

In this section I show some commands related to processes management.

Ps

Use the “ps” command to list system processes. For example, the “ps aux” outputs:

~ # ps aux

USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND

root 1 0.0 0.1 2076 516 ? Ss 08:03 0:01 init

root 2 0.0 0.0 0 0 ? S 08:03 0:00 [kthreadd]

root 3 0.1 0.0 0 0 ? S 08:03 0:02 [ksoftirqd/0]

root 5 0.0 0.0 0 0 ? S 08:03 0:00 [kworker/u:0]

root 6 0.0 0.0 0 0 ? S 08:03 0:00 [posixcputmr/0]

root 7 0.0 0.0 0 0 ? S< 08:03 0:00 [khelper]

root 8 0.0 0.0 0 0 ? S 08:03 0:00 [kworker/u:1]

root 125 0.0 0.0 0 0 ? S 08:03 0:00 [sync_supers]

root 127 0.0 0.0 0 0 ? S 08:03 0:00 [bdi-default]

root 128 0.0 0.0 0 0 ? S< 08:03 0:00 [kblockd]

root 135 0.0 0.0 0 0 ? S< 08:03 0:00 [ata_sff]

root 142 0.0 0.0 0 0 ? S 08:03 0:00 [khubd]

root 248 0.0 0.0 0 0 ? S 08:03 0:00 [kworker/0:1]

root 268 0.0 0.0 0 0 ? S 08:03 0:00 [kswapd0]

root 269 0.0 0.0 0 0 ? S 08:03 0:00 [fsnotify_mark]

root 271 0.0 0.0 0 0 ? S< 08:03 0:00 [crypto]

root 869 0.0 0.0 0 0 ? S 08:04 0:00 [irq/15-ide0]

root 906 0.0 0.0 0 0 ? S 08:04 0:00 [irq/1-i8042]

root 913 0.0 0.0 0 0 ? S 08:04 0:00 [irq/8-rtc0]

root 921 0.0 0.0 0 0 ? S 08:04 0:00 [kworker/0:2]

root 922 0.0 0.0 0 0 ? S 08:04 0:00 [irq/4-serial]

root 923 0.0 0.0 0 0 ? S 08:04 0:00 [kjournald]

root 945 0.0 0.1 1896 648 ? S<s 08:04 0:00 /sbin/udevd --d root 999 0.0 0.1 1892 608 ? S< 08:04 0:00 /sbin/udevd --d root 1002 0.0 0.1 1892 604 ? S< 08:04 0:00 /sbin/udevd --d root 1017 0.0 0.1 2992 716 ? Ss 08:04 0:00 /sbin/syslog-ng root 1025 0.0 0.1 3932 996 ? Ss 08:04 0:00 /usr/sbin/sshd

root 1045 0.0 0.0 0 0 ? S 08:04 0:00 [irq/9-eth0]

root 1056 0.0 0.0 0 0 ? S 08:04 0:00 [irq/11-srcsII]

root 1075 99.7 0.0 1528 196 ? Rs 08:04 31:12 /usr/bin/pkgd /

root 1079 0.0 0.1 2080 544 ttyS0 Ss+ 08:04 0:00 /sbin/getty -L

root 1093 0.0 0.3 6536 2004 ? Ss 08:04 0:00 sshd: root@pts/

root 1097 0.0 0.1 2080 632 pts/0 Ss+ 08:04 0:00 -sh

root 1107 0.0 0.3 6536 1988 ? Ss 08:05 0:00 sshd: root@pts/

root 1111 0.0 0.1 2080 664 pts/1 Ss 08:05 0:00 -sh

root 1146 0.0 0.0 0 0 ? S 08:25 0:00 [flush-3:0]

root 1177 0.2 0.3 6536 1988 ? Ss 08:35 0:00 sshd: root@pts/

root 1181 0.0 0.1 2080 608 pts/2 Ss 08:35 0:00 -sh

root 1182 3.2 5.1 42140 26172 pts/2 Sl+ 08:35 0:00 mc

root 1209 0.0 0.1 2228 824 pts/1 R+ 08:35 0:00 ps aux

all processes in the entire operating system along with their memory consumption, state, pid, cpu usage and so on. As one can see the next to last process is mc itself, so where are his threads. For this I created an abbreviation called threads:

~ # threads

Warning: bad ps syntax, perhaps a bogus '-'? See http://procps.sf.net/faq.html

PID TID CLS RTPRIO NI PRI PSR %CPU STAT WCHAN COMMAND

1 1 TS - 0 19 0 0.0 Ss wait init

2 2 TS - 0 19 0 0.0 S kthreadd kthreadd

3 3 RR 99 - 139 0 0.1 S run_ksoftirqd ksoftirqd/0

5 5 TS - 0 19 0 0.0 S worker_thread kworker/u:0

6 6 RR 16 - 56 0 0.0 S posix_cpu_time posixcputmr/0

7 7 TS - -20 39 0 0.0 S< rescuer_thread khelper 8 8 TS - 0 19 0 0.0 S worker_thread kworker/u:1 125 125 TS - 0 19 0 0.0 S bdi_sync_super sync_supers

127 127 TS - 0 19 0 0.0 S bdi_forker_thr bdi-default

128 128 TS - -20 39 0 0.0 S< rescuer_thread kblockd 135 135 TS - -20 39 0 0.0 S< rescuer_thread ata_sff 142 142 TS - 0 19 0 0.0 S hub_thread khubd 248 248 TS - 0 19 0 0.0 S worker_thread kworker/0:1

268 268 TS - 0 19 0 0.0 S kswapd_try_to_ kswapd0

269 269 TS - 0 19 0 0.0 S fsnotify_mark_ fsnotify_mark

271 271 TS - -20 39 0 0.0 S< rescuer_thread crypto 869 869 FF 50 - 90 0 0.0 S irq_thread irq/15-ide0 906 906 RR 16 - 56 0 0.0 S irq_thread irq/1-i8042

913 913 RR 16 - 56 0 0.0 S irq_thread irq/8-rtc0

921 921 TS - 0 19 0 0.0 S worker_thread kworker/0:2

922 922 RR 16 - 56 0 0.0 S irq_thread irq/4-serial

923 923 TS - 0 19 0 0.0 S kjournald kjournald

945 945 TS - -4 23 0 0.0 S<s poll_schedule_ udevd 999 999 TS - -2 21 0 0.0 S< poll_schedule_ udevd 1002 1002 TS - -2 21 0 0.0 S< poll_schedule_ udevd 1017 1017 TS - 0 19 0 0.0 Ss poll_schedule_ syslog-ng 1025 1025 TS - 0 19 0 0.0 Ss poll_schedule_ sshd

1045 1045 RR 16 - 56 0 0.0 S irq_thread irq/9-eth0

1056 1056 RR 99 - 139 0 0.0 S irq_thread irq/11-srcsII

1075 1075 TS - 0 19 0 99.5 Rs - pkgd

1079 1079 TS - 0 19 0 0.0 Ss+ n_tty_read getty

1093 1093 TS - 0 19 0 0.0 Ss poll_schedule_ sshd

1097 1097 TS - 0 19 0 0.0 Ss+ poll_schedule_ sh

1146 1146 TS - 0 19 0 0.0 S bdi_writeback_ flush-3:0

1177 1177 TS - 0 19 0 0.0 Ss poll_schedule_ sshd

1181 1181 TS - 0 19 0 0.0 Ss wait sh

1182 1182 TS - 0 19 0 0.0 Sl+ futex_wait_que mc

1182 1184 RR 1 - 41 0 0.0 Sl+ wq_sleep jexec

1182 1186 RR 25 - 65 0 0.0 Sl+ semtimedop tErrHndl

1182 1187 RR 16 - 56 0 0.0 Sl+ semtimedop tLogger

1182 1188 RR 16 - 56 0 0.0 Sl+ inet_csk_wait_ cli

1182 1189 RR 16 - 56 0 0.0 Sl+ inet_csk_wait_ tEthernInp

1182 1190 RR 16 - 56 0 0.0 Sl+ wait_for_packe tEthernOut

1182 1191 RR 16 - 56 0 0.0 Sl+ inet_csk_wait_ tEthernInp2

1182 1192 RR 16 - 56 0 0.0 Sl+ wait_for_packe tEthernOut2

1182 1193 RR 16 - 56 0 0.0 Sl+ inet_csk_wait_ tEthernInp0

1182 1194 RR 16 - 56 0 0.0 Sl+ wait_for_packe tEthernOut0

1182 1195 RR 16 - 56 0 0.0 Sl+ inet_csk_wait_ tEthernInp3

1182 1196 RR 16 - 56 0 0.0 Sl+ wait_for_packe tEthernOut3

1182 1197 RR 16 - 56 0 0.0 Sl+ wait_for_packe RbootPd

1182 1198 RR 16 - 56 0 0.0 Sl+ poll_schedule_ tVirtualInp

1182 1199 RR 26 - 66 0 0.0 Sl+ hrtimer_nanosl tBit

1182 1200 RR 27 - 67 0 0.4 Sl+ semtimedop tSpy

1182 1201 RR 21 - 61 0 0.1 Sl+ semtimedop tScHandler

1182 1202 RR 20 - 60 0 0.0 Sl+ semtimedop tScServer

1182 1203 RR 21 - 61 0 0.3 SNl+ sercosII_read sercosFun

1182 1204 RR 23 - 63 0 0.0 SNl+ semtimedop MotManager

1182 1207 RR 28 - 68 0 0.1 SNl+ semtimedop tRecPeriodic

1182 1208 RR 29 - 69 0 0.0 SNl+ semtimedop tEvent

1210 1210 TS - 0 19 0 0.6 Ss poll_schedule_ sshd

1214 1214 TS - 0 19 0 0.0 Ss wait sh

1215 1215 TS - 0 19 0 0.0 S+ wait sh

1216 1216 TS - 0 19 0 0.0 R+ - ps

The "threads" is actually a shortcut for the following ps command:

ps -axH -eo pid,tid,class,rtprio,ni,pri,psr,pcpu,stat,wchan:14,comm

The above command presents the following information for each task in the operating system:

pid = process id of the parent not-detached task

tid = process id of the task within parent task – what we refer as thread.

class = scheduling class. TS = OTHER, RR = round robin, FF = fifo. - = not reported

rtprio = real time priority, ranging from 99 to 0. When 99 is strongest.

ni = niceness. Ranging from -19 to 20.

pri = static priority.

psr = processor id.

pcpu = overall cpu usage

stat = process state. R for runnable or S for sleeping, Z for zombie.

wchan = kernel function where process is waiting. If process is running a dash is displayed

comm = name of process

If you wish to sort the list by the processes real time priority, use the following command:

threads | sort –k4

This command sorts the list according by the fourth column.

Kill

To terminate a running process use the kill command. Kill needs the process id , so many times you can simply type:

kill -9 $(pidof mc)

Which means, kill anyway, the mc by its process id.

Top

top is an interactive view of displaying system tasks. It refreshes the list every 1 or more second.

~ # top

top - 09:21:51 up 1:17, 4 users, load average: 1.04, 1.03, 1.01

Tasks: 42 total, 2 running, 40 sleeping, 0 stopped, 0 zombie

Cpu(s): 29.6%us, 70.3%sy, 0.1%ni, 0.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st

Mem: 505536k total, 49120k used, 456416k free, 860k buffers

Swap: 0k total, 0k used, 0k free, 12288k cached

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND

1075 root 20 0 1528 196 148 R 98.9 0.0 77:03.44 pkgd

1056 root RT 0 0 0 0 S 2.0 0.0 0:05.73 irq/11-srcsII

1 root 20 0 2076 520 460 S 0.0 0.1 0:01.17 init

2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd

3 root RT 0 0 0 0 S 0.0 0.0 0:07.44 ksoftirqd/0

5 root 20 0 0 0 0 S 0.0 0.0 0:00.01 kworker/u:0

6 root -17 0 0 0 0 S 0.0 0.0 0:00.00 posixcputmr/0

7 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 khelper

8 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kworker/u:1

125 root 20 0 0 0 0 S 0.0 0.0 0:00.00 sync_supers

127 root 20 0 0 0 0 S 0.0 0.0 0:00.00 bdi-default

128 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kblockd

135 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 ata_sff

142 root 20 0 0 0 0 S 0.0 0.0 0:00.00 khubd

248 root 20 0 0 0 0 S 0.0 0.0 0:00.02 kworker/0:1

268 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kswapd0

269 root 20 0 0 0 0 S 0.0 0.0 0:00.00 fsnotify_mark

271 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 crypto

Top displays a nice summary before the list. Memory usage, cpu usage and so on. Important information is found in this line

Cpu(s): 29.6%us, 70.3%sy, 0.1%ni, 0.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st

For example:

us is the Cpu usage in user space here is 29.6%

sy is the cpu usage in kernel space is 70%

ni is the niceness of last process

wa is io wait which is the amount of time system is waiting for IO to complete.

hi is hardware interrupt usage

si is soft irqs usage

st is virtualization usage ( always zero in mib)

htop

htop is like top but more interactive. You can asks for different sorting keys, like sort by memory usage, sort by cpu usage and so on.

[[Image:]]

Type F6 and toy with it.

Display process’s maps

To watch a process’ segmented allocation use the following commands:

~ # cat /proc/$(pidof mc)/maps

08048000-08429000 r-xp 00000000 03:01 13462 /usr/bin/mc

08429000-08558000 rwxp 003e1000 03:01 13462 /usr/bin/mc

08558000-085ed000 rwxp 00000000 00:00 0

09afd000-0b060000 rwxp 00000000 00:00 0 [heap]

b5a1c000-b5a1d000 ---p 00000000 00:00 0

b5a1d000-b5a24000 rwxp 00000000 00:00 0

b5a24000-b5a25000 ---p 00000000 00:00 0

b5a25000-b5a30000 rwxp 00000000 00:00 0

b5a30000-b5a31000 ---p 00000000 00:00 0

b5a31000-b5a3c000 rwxp 00000000 00:00 0

b5a3c000-b5a3d000 ---p 00000000 00:00 0

b5a3d000-b5a48000 rwxp 00000000 00:00 0

b5a48000-b5a49000 ---p 00000000 00:00 0

b5a49000-b5a58000 rwxp 00000000 00:00 0

b5a58000-b5a59000 ---p 00000000 00:00 0

b5a59000-b5a5c000 rwxp 00000000 00:00 0

b5a5c000-b5a5d000 ---p 00000000 00:00 0

b5a5d000-b5a64000 rwxp 00000000 00:00 0

b5a64000-b5a65000 ---p 00000000 00:00 0

b5a65000-b5a6c000 rwxp 00000000 00:00 0

b5a6c000-b5a6d000 ---p 00000000 00:00 0

b5a6d000-b5a74000 rwxp 00000000 00:00 0

b5a74000-b5a75000 ---p 00000000 00:00 0

b5a75000-b5a80000 rwxp 00000000 00:00 0

b5a81000-b5a82000 ---p 00000000 00:00 0

b5a82000-b5aa5000 rwxp 00000000 00:00 0

b5aa5000-b5aa6000 ---p 00000000 00:00 0

b5aa6000-b5ac1000 rwxp 00000000 00:00 0

b5ac1000-b5ac2000 ---p 00000000 00:00 0

b5ac2000-b5ac9000 rwxp 00000000 00:00 0

b5ac9000-b5aca000 ---p 00000000 00:00 0

b5aca000-b5aed000 rwxp 00000000 00:00 0

b5aed000-b5aee000 ---p 00000000 00:00 0

b5aee000-b5af5000 rwxp 00000000 00:00 0

b5af5000-b5af6000 ---p 00000000 00:00 0

b5af6000-b5b19000 rwxp 00000000 00:00 0

b5b19000-b5b1a000 ---p 00000000 00:00 0

b5b1a000-b5b21000 rwxp 00000000 00:00 0

b5b21000-b5b22000 ---p 00000000 00:00 0

b5b22000-b5b45000 rwxp 00000000 00:00 0

b5b45000-b5b46000 ---p 00000000 00:00 0

b5b46000-b5b4d000 rwxp 00000000 00:00 0

b5b4d000-b5b4e000 ---p 00000000 00:00 0

b5b4e000-b5c18000 rwxp 00000000 00:00 0

b5c18000-b5c19000 ---p 00000000 00:00 0

b5c19000-b6418000 rwxp 00000000 00:00 0

b6418000-b6419000 ---p 00000000 00:00 0

b6419000-b6420000 rwxp 00000000 00:00 0

b6420000-b6421000 ---p 00000000 00:00 0

b6421000-b6429000 rwxp 00000000 00:00 0

b6429000-b642a000 ---p 00000000 00:00 0

b642a000-b642d000 rwxp 00000000 00:00 0

b642d000-b742d000 rwxs fffe9000000 00:12 2311 /dev/sercosII

b742d000-b742e000 ---p 00000000 00:00 0

b742e000-b7435000 rwxp 00000000 00:00 0

b7435000-b7436000 ---p 00000000 00:00 0

b7436000-b7544000 rwxp 00000000 00:00 0

b7544000-b7679000 r-xp 00000000 03:01 10172 /lib/libc-2.13.so

b7679000-b767a000 ---p 00135000 03:01 10172 /lib/libc-2.13.so

b767a000-b767c000 r-xp 00135000 03:01 10172 /lib/libc-2.13.so

b767c000-b767d000 rwxp 00137000 03:01 10172 /lib/libc-2.13.so

b767d000-b7680000 rwxp 00000000 00:00 0

b7680000-b769b000 r-xp 00000000 03:01 12467 /lib/libgcc_s.so.1

b769b000-b769c000 rwxp 0001a000 03:01 12467 /lib/libgcc_s.so.1

b769c000-b76c1000 r-xp 00000000 03:01 14763 /lib/libm-2.13.so

b76c1000-b76c2000 r-xp 00024000 03:01 14763 /lib/libm-2.13.so

b76c2000-b76c3000 rwxp 00025000 03:01 14763 /lib/libm-2.13.so

b76c3000-b779b000 r-xp 00000000 03:01 9190 /usr/lib/libstdc++.so.6.0.14

b779b000-b779f000 r-xp 000d7000 03:01 9190 /usr/lib/libstdc++.so.6.0.14

b779f000-b77a0000 rwxp 000db000 03:01 9190 /usr/lib/libstdc++.so.6.0.14

b77a0000-b77a8000 rwxp 00000000 00:00 0

b77a8000-b77b0000 r-xp 00000000 03:01 16731 /lib/libcrypt-2.13.so

b77b0000-b77b1000 r-xp 00007000 03:01 16731 /lib/libcrypt-2.13.so

b77b1000-b77b2000 rwxp 00008000 03:01 16731 /lib/libcrypt-2.13.so

b77b2000-b77d9000 rwxp 00000000 00:00 0

b77d9000-b77ed000 r-xp 00000000 03:01 17714 /lib/libpthread-2.13.so

b77ed000-b77ee000 r-xp 00013000 03:01 17714 /lib/libpthread-2.13.so

b77ee000-b77ef000 rwxp 00014000 03:01 17714 /lib/libpthread-2.13.so

b77ef000-b77f1000 rwxp 00000000 00:00 0

b77f1000-b77f7000 r-xp 00000000 03:01 13450 /lib/librt-2.13.so

b77f7000-b77f8000 r-xp 00005000 03:01 13450 /lib/librt-2.13.so

b77f8000-b77f9000 rwxp 00006000 03:01 13450 /lib/librt-2.13.so

b77f9000-b77fb000 r-xp 00000000 03:01 17388 /lib/libdl-2.13.so

b77fb000-b77fc000 r-xp 00001000 03:01 17388 /lib/libdl-2.13.so

b77fc000-b77fd000 rwxp 00002000 03:01 17388 /lib/libdl-2.13.so

b77fd000-b7817000 r-xp 00000000 03:01 16404 /lib/ld-2.13.so

b7817000-b7818000 rwxp 00000000 00:00 0

b7818000-b7819000 r-xp 0001a000 03:01 16404 /lib/ld-2.13.so

b7819000-b781a000 rwxp 0001b000 03:01 16404 /lib/ld-2.13.so

bfd20000-bfd41000 rwxp 00000000 00:00 0 [stack]

ffffe000-fffff000 r-xp 00000000 00:00 0 [vdso]

From left to tight:

  1. The segment ( also known as vma ) memory addresses
  2. The segment permission
  3. The segment offset into the file
  4. The block device major/minor holding the file
  5. The size of the segment

chrt

change real time priority. You can control a processes scheduling class and priority level from the command line.

For example:

Ksoftirq is a kernel daemon that is widely used in the kernel.

~ # threads |grep sof

3 3 RR 99 - 139 0 0.1 S run_ksoftirqd ksoftirqd/0

ksoftirq pid is 3. Its real time priority is 99. So , let say we wish to change its priority to 19.

~ # chrt -r -p 19 3

pid 3's current scheduling policy: SCHED_RR

pid 3's current scheduling priority: 99

pid 3's new scheduling policy: SCHED_RR

pid 3's new scheduling priority: 19

and indeed priority changed.

~ # threads | grep sof

3 3 RR 19 - 59 0 0.1 S run_ksoftirqd ksoftirqd/0

 

Network

ssh sshd and scp

Secure shell is used to access remote machines. Sshd is service running in the target MIB and ssh is the client. You can login (perform ssh) to a MIB and login from a MIB to any other Linux machine. You can copy files with scp to and from Linux machines.

To login to MIB ip 10.4.20.240 from any Linux machine enter:

~ # ssh root@10.4.20.240

The authenticity of host '10.4.20.240 (10.4.20.240)' can't be established.

RSA key fingerprint is ef:f6:72:7f:64:7a:21:d4:8b:c3:b2:db:cf:a0:0f:99.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added '10.4.20.240' (RSA) to the list of known hosts.

root@10.4.20.240's password:

the first you will asked is enter yes/no. this happens only in the first time you access a remote machine. Enter “yes” and then you will be asked to enter a password, please do. Once entered, you will be in the MIB running in root privileges.

To copy files from Linux machine to another Linux machine in the command line we use scp command: for example, the command:

scp –r /tmp root@10.4.20.240:/root/

will copy tmp directory to to root directory in target machine. The “-r” means recursive copy, which is how we copy directories.

If you copy files from a windows machine to a linux machine you should use winscp.

winscp

The first window displays a list machines that were accessed previously. If this is the first time you use winscp this list is empty. To copy files to 10.4.20.240 please click on the New button.

winscp

Fill the MIB’s ip. The user name “root”, the password, and change the protocol from sftp to scp. Click on “Save” to save the new machine in the list and then click on Login.

winscp

You will windows saying that the command “group” returned error, disregard it, it is because MIB does not have group command, after that you will have the above screen. Now you can simply drag and drop files.

Route

To watch the routing tables just type “route” or “netstat –r”. Here is route output in MIB

Ip 10.4.20.240.

Kernel IP routing table

Destination Gateway Genmask Flags Metric Ref Use Iface

10.0.0.0 * 255.0.0.0 U 0 0 0 eth0 As the reader can see, there is not default route, so if we try to access a different network segment will be getting “unreachable network” . We can only access network on the 10.x.x.x. because the netmask is 255.0.0.0. The only Ethernet interface a MIB has is eth0.

 

tcpdump

tcpdump is a packet capture program. To capture packets simply type:

tcpdump

this will fill screen with traffic captures. If you use ssh to access the machine you will see ssh traffic as well. So you probably want to filter out this ssh traffic. To do that enter:

tcpdump ip –i eth0 and not port 22

Which means, capture all traffic on interface eth0, but drop any traffic on directed to port 22.

There are many other ways to capture traffic. Sometimes you need to capture the traffic and want to analize it later with better tools, like wireshark. For this please enter:

tcpdump ip –i eth0 and not port 22 –w foo.cap

This means that the captured data will be passed to a file called foo.cap.

 

ethtool

ethtool is used to query and control network interfaces.

~ # ethtool eth0

Settings for eth0:

  Supported ports: [ TP MII ]

Supported link modes: 10baseT/Half 10baseT/Full

100baseT/Half 100baseT/Full

Supports auto-negotiation: Yes

Advertised link modes: 10baseT/Half 10baseT/Full

100baseT/Half 100baseT/Full

Advertised pause frame use: Symmetric

Advertised auto-negotiation: Yes

Link partner advertised link modes: 10baseT/Half 10baseT/Full

100baseT/Half 100baseT/Full

Link partner advertised pause frame use: Symmetric

Link partner advertised auto-negotiation: Yes

Speed: 100Mb/s

Duplex: Full

Port: MII

PHYAD: 1

Transceiver: internal

Auto-negotiation: on

Supports Wake-on: g

Wake-on: g

Current message level: 0x00000007 (7)

Link detected: yes

Common use for it is checking the link type, 10/100/1000 Mbps and if the network is actually up (Last line: Link Detected).

Boot

Linux MIB boot is a two-phase boot. Once the computer passed the POST stage (Power On Self Test) it passes the control to the operating system. The first operating system is actually a boot loader. The boot loader is called grub – “grand unified boot loader”. Grub has one main purpose, to boot Linux. At the moment, the MIB hardware prevents us from seeing the grub loads. When grub loads it splashes a menu to screen (it is called splashing). This menu is kept in /boot/grub/menu.lst which is accessible through the LinuxMIB.

~ # cat /boot/grub/menu.lst

serial --unit=0 --speed=115200

terminal --timeout=0 serial console

default 0

timeout 0

color cyan/blue white/blue

title Standalone Boot

root (hd0,0)

kernel /boot/bzImage root=/dev/hda1,/dev/hdc1 console=ttyS0,115200

title Network Boot

ifconfig --server= --gateway= --mask= --address=

root (nd)

kernel (nd)/linux root=/dev/nfs console=ttyS0,115200 ip=:::::eth0: nfsroot=

~ #

The boot loader menu has two entries, the first entry boots Linux from the disk, and the second one boots Linux from the network. The first one is the default one.

Grub boots the kernel by loading the kernel file (bzImage) to the main memory and passing it some parameters. Current parameters are:

root=/dev/hda1,/dev/hdc1 console=ttyS0, 115200

This means that the kernel search for a root file system in a block device called /dev/hda1 and if it fails it tries /dev/hdc1. The “console=” means that the rs232 input and output redirected through a device file called /dev/ttyS0 in 115200 speed. These parameters are kernel parameters and do not relate to grub.

 

BSP

The board specific package I used to create the MIB is Pengutronix. Pengutronix is software builds an entire Linux distribution from scratch. Linux MIB software does not contain any binaries with the sources. So, in this section I will describe how to build the MIB bsp and MC in the virtual disk I supply for this.

Virtual Build Machine

The virtual machine I use to virtual box. Please download and install it. The virtual machine is composed from two virtual disks, mib.vdi and buildDisk.vdi. The mib.vdi is 50MB disk, and buildDisk.vdi is 2 GB disk. This is because the build objects consume a lot of storage. Both disks can be found at //domainaxy/IL/MC/linux/buildmachine . Access to virtual machine is done through the terminal or through ssh with user root , no password required.

Virtual Box Configuration

storage

vbox

Network

vbox

share

vbox

The guest gets static IP 192.168.56.101 . It is accessible only from the host. We decided to use this configuration as it simplifies things. If you wish to have the Linux connect to the network choose network card attached as bridge and choose intel PRO/1000 MT Desktop.

To have the virtual build machine access s shared folder in the host machine, please add a share name called amcs to whatever folder you wish.

The “amcs” share will mount automatically. Any other share has to be mounted manually in the guest:

mount.vboxsf <share name> <mount point>

Virtual Linux Configuration

The virtual disk containing the toolchain is called toolchain.vdi. Once you boot the virtual build machine you need to make sure build disk is mounted. So check is /opt directory contains OSELAS toolchain. Also, please check the you have network access (with ifconfig) .If all well, please check if you can connect with ssh.

 

Building MC

  1. Make sure amcs share is mounted and contains all required sources. Make sure the toolchain is mounted on /opt.

~ # df

Filesystem 1K-blocks Used Available Use% Mounted on

udev 191428 112 191316 0% /dev

tmpfs 76572 144 76428 0% /run

/dev/sda1 147415 85218 54697 61% /

none 191428 0 191428 0% /tmp

none 191428 0 191428 0% /var/log

none 191428 16 191412 0% /var/run

none 191428 0 191428 0% /var/lock

none 191428 0 191428 0% /var/tmp

tmpfs 191428 112 191316 0% /dev

'/dev/sdb 8256952 1784056 6053468 23% /opt'

none 4217028 1366328 2850700 32% /media

Change directory to mc sources (inside the amcs share) or clone them from the linux. if this is the first time you build these sources please configure the build as follows:

$ sh run_configure_all and now you can build these sources:

$ make –j2

If you wish to configure eclipse ontop of the virtual box please refer to this document: Eclipse Stand Alone Linux

Once you’re done, you need to copy the binary to the target machine if you have external networking.

scp mc root@10.4.20.240:/usr/bin/mc

else use eclipse terminal to copy.

 

Troubleshoot

run_configure_all

If run_configure_all fails with numerous errors, edit in linux, and remove all ^M signs.

Out Of memory

Incase during the build you see a message “out of memory” please remove the –j from the make and remake or increase the virtual machine RAM.

Out of disk space

You are probably building on the virtual machine disk. Change to share directory.

Toolchain

The toochain is installed in the /opt/ directory. This requirement is strict and I do not support any other configuration. The toolchain we use is:

Gcc 4.52

Glibc 2.13

Binutils 2.13

Sanitized kernel headers 2.6.36

Your /opt/ directory should contain a directory called:/opt/OSELAS.Toolchain-2011.03.1/.

 

The BSP

To build the entire bsp you need a linux ubunto server. Building the bsp on a virtual box running ubunto is possible but will take a long time.

You can find the toolchain tar ball

//domainaxy/IL/MC/linux/buildmachine/OSELAS.Toolchain-2011.03.1.tar

Copy it and extract it in the ubunto :

$ sudo tar xvf OSELAS.Toolchain-2011.03.1.tar –C /opt/

Now, clone the bsp:

git clone git@10.4.20.38:/home/git/bsp.git

to build the bsp master branch :

cd bsp/

ptxdist go

at the end of the process you will have linuximage in platform-i586/images. This is not enough as you need to build to full image , for this run the bellow command:

ptxdist images

the image is hd.img. To burn it to the sdcard please:

sudo dd if=platform-i586/images/hd.img of=/dev/sdX

when /dev/sdX is the sdcard device name. if you don’t the device name, do not bother dd’ing, you will probably destroy the build server.

Once you dd’ed, please sync and eject:

sync

eject /dev/sdX

Replicate an image

There are times where one wishes to replicate an existing image. To do that he must copy the source image as file to some Linux machine using dd and then burn the source file image to new card. Here are the steps to do that:

  1. Place in the card reader the source flash card. Linux will notice a new disk was pushed in.
  2. dmesg and look for the new disk name, like /dev/sdd or/dev/sdb.

It will appear in the bottom of the dmesg log, for example:

  [422238.883418] sd 9:0:0:0: [sdd] Assuming drive cache: write through

  [422238.883423] sd 9:0:0:0: [sdd] Attached SCSI removable disk

  [422470.346994] EXT3-fs: barriers not enabled

  [422470.735075] kjournald starting. Commit interval 5 seconds   [422470.735121] EXT3-fs (sdd1): warning: maximal mount count reached, running e2fsck is recommended

  [422470.736077] EXT3-fs (sdd1): using internal journal

  [422470.736083] EXT3-fs (sdd1): recovery complete

  [422470.737199] EXT3-fs (sdd1): mounted filesystem with ordered data mode

The device ( disk ) in my machine is /dev/sdd. It has a single partition called /dev/sdd1.

 

  1. Now copy the card to a file using dd: for example, if my disk name is /dev/sdb I enter:

$ dd if=/dev/sdb bs=1M of=/tmp/hd.img

$ sync

  1. Now pull out the source sd card, and place the new card.
  2. Push back the target flash card, and then:

$ dd if=/tmp/hd.img of=/dev/sdb

$ sync

 

How to edit files in MIB

There are cases where a user needs to edit a text file in the LinuxMIB. LinuxMIB has two editors, nano and vi.

vi is considered more powerfull than nano. Yet, I believe that the regular user should start with nano as it is more intuitive.

Upgrade Linux MIB

Linux MIB is shipped with a debian based packaging system. This means that to any update is wrapped with ipkg. Once the package is ready, simply copy the package file to the target to the inbox directory.

scp mc-4.9.0-linux.ipk 10.4.20.240:/inbox/ or by drag-and-drop through windows operating system with winscp.

Packaging is triggered automatically. I wrote a package manager daemon that listens on /inbox directory and if a new file is put there it tries to install it.

You can list the packages with the following command:

dpkg -l

Currently you cannot uninstall a package, you have to remove the files manually.I believe it is a pengutronix bug.

Control MC Start

One of the first things a programmer does when developing is disabling the automatic start of the application he is debugging. In manz case it is mostly the mc.

There are two ways to disable automatic starting:

 

  1. Each time you boot.

  # ~ /etc/init.d/mc stop

  1. Edit /etc/init.d/mc script and remark the mc launching as follows:

start)

/etc/init.d/run_config

  # nohup /bin/sh /usr/bin/mc.sh &

Add # before the nohup as depicted in the line above.

Debugging

Debugging mc can mostly with eclipse. Please refer to eclipse documentation to learn how to do that.

Logs

In addition to the log files in /RAM file system. We added a linux-like logger which can be found at /var/syslog.

 

Core files

A core file is a snapshot of the process memory when it crashed. It is a post mortem debugging method commonly used. All cores files are generated to /cores directory. There will no more than 5 cores. The 6-th core is written on the first core.

To debug a core dump you must compile the same mc with debug info and copy the core file to the ubunto ( virtual build machine is not suitable for that ). Then type:

gdb mc coredump

 

Memory Detector

To debug memory leaks you need valgrind. Valgrind is not installed as is in the bsp, simply take a package and put it in the target. If you do not know how to use valgrind I suggest you refer to valgrind web site. It is beyond the scope of this paper.

 

MC cli

MC Linux is shipped with a telnet server. This telnet server resembles the vxworks terminal.

To login please:

~ # telnet localhost:8000

Entering character mode

Escape character is '^]'.

AMCS shell

User name is root and password qwerty.

Username: root

Password:

The telnet is evolving and the command may differ from one version to another but to get help you can simply type help.

> help

Commands available:

help Show available commands

logout Disconnect

history Show a list of previously run commands

threads print all threads

stack trace print the stack of a given thread

p print a symbol

exit exit the process

>

 

Profiling

Profiling MC can be done with oprofile. To use oprofile you need to boot a kernel with oprofile support, and replace the drivers. For this you will have to install a package called kernel-oprofile.ipk and boot this kernel.

To use oprofile please:

$ opcontrol –reset

$ opcontrol –deinit

$ opcontrol –init

Now to choose type of event you should make sure your processor support this type of event – if any.

$ opcontrol –list-events

Let say you wish to check memory references.

$ opcontrol –event:DATA_MEM_REFS:30000

The above command sets the event memory references each time the a a hardware counter finish counting to 30000.

$ opcontrol –session-dir=/home/myoprofile

$ opcontrol –sparate=cpu

$ opcontrol –callgraph=10

$ opcontrol –novmlinux

$ opcontrol –start

./prog..

$ opcontrol –stop

Now copy the entire profiling results to your local machine home user.

$ opreport –session-dir=/home/raz/myprofile

CPU_CLK_UNHALT...|LLC_MISSES:466500|

samples| %| samples| %|

  ------------------------------------

943 100.000 1 100.000 prog

CPU_CLK_UNHALT...|LLC_MISSES:466500|

samples| %| samples| %|

  ------------------------------------

709 75.1856 1 100.000 prog
234 24.8144 0 0 libc-2.11.1.so

To get annotation per line use, run this from the mc directory. This way opannotate will find the source code.

$ opanotate –s session-dir=/home/raz/myprofile

Please note if you intend to use oprofile please read the tutotial as it is beyond the spec of this paper.

ftrace

I do not want to write what is ftrace in this book, please refer to the ftrace tutorials to do that:

Here are the steps to ftrace.

Boot the same kernel as the one for ftrace.

$ mount –t debugfs /sys/kernel/debug /debug

$ cd /debug/tracing/

$ echo 0 > tracing_on

$ echo function > current_tracer

$ echo 1 > tracing_on

….

$ echo 0 > tracing_on

File “trace” contains the tracing information. It a huge text file:

$ cat trace

A visual view for ftrace output is known as kernelshark.

To use it please issue the bellow command after you are done with the trace.

$ trace-cmd extract

A local file named trace.dat is created . copy it to your ubunto and launch kernelshard.

$ kernelshark trace.dat