Difference between revisions of "AXY:Linux MIB"

From SoftMC-Wiki
Jump to: navigation, search
 
(57 intermediate revisions by 3 users not shown)
Line 1: Line 1:
== Preface ==
 
  
# Manz developer that compiles and links c/c++ code .
+
== Introduction ==
# 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 to two types.
 
  
The first type is software Manz controls, meaning, manz build it and holds its source code. The second type os software manz has no control , like third party binaries.
+
*softMC developers who are compiling and link C/C++ code  
 +
*QA teams
 +
*Managers engaged in MIB development
  
# Linux operating system. This includes all services and utilities along with their shared objects (aka dll) which take part of maintaining the operating system.
+
= MIB Software Components =
# The Linux Kernel. The core of the operating system.
 
# mc. Manz’s mc binary and its bash scripts extensions.
 
# /FFS0 with its PRG programs.
 
# core dumper. Daemon used to redirect core files.
 
# pkgd. Package manager maintainer.
 
# sercos driver.
 
# In the future, any third party software that is added. Like pnp plugins.
 
  
All of the above software is built from source code. We do not ship any component without its source code. Binaries are passed to MIB through the aico are considered part of Linux build system.  
+
The software on a common Linux MIB has two main types.
  
Further information of each component is detailed in the rest of this paper.
+
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.
 +
 
 +
 
 +
 
 +
*<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)
 
Parity:Odd ( N)
 +
</pre>
  
Once connected a login session would appear
+
<font color="red">Once connected a login session will appear:</font>
  
manz login:
+
<font color="red">''manz login:''</font>
  
enter '''root'''
+
<font color="red">enter '''mc'''</font>
  
and then:
+
<font color="red">and then:</font>
  
Password:
+
<font color="red">''Password:''</font>
  
Enter '''1-login11'''.
+
<font color="red">Enter '''mc'''</font>
  
 +
&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 rs<div align="right">IP here</div>232 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 ==
  
~ #
+
To access the MIB from windows without direct connection use secure shell, or in short “ssh”.
  
== Access LinuxMIB through secure shell ==
+
If you login through putty, run it. A screen will appear.
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.
+
[[File:puttyconf.gif|putty]]
  
 +
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.
  
[[Image:]]
+
[[File:login.gif|putty]]
  
Act according the steps above. Once you open ( yae..yae… I know you can double click instead of open) you get to a login screen:<div align="right">5. open it</div><div align="right">4. save it</div><div align="right">3. Fill LinuxMIB ip in both feilds</div># <div align="right">Choose ssh button</div>
+
== Changing the password ==
 
 
<div align="right">2. ssh port is 22 by default</div>
 
  
[[Image:]]
+
It is common to change the login password (for developers only):
  
== Changing the password ==
+
~ # '''''passwd'''''
It is common to change the login password ( for developers only):
 
 
 
~ # passwd
 
  
 
Changing password for root
 
Changing password for root
  
New password:
+
'''''New password:'''''
  
 
Enter q
 
Enter q
  
You will have a prompt saying
+
A prompt will appear:
  
Bad password: too short.  
+
Bad password: too short.
  
It is correct. “q” is bad password. but you’re likely to login so many times.  
+
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:'''''
  
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”.<sup><nowiki>[1]</nowiki></sup>
+
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 =
  
1. ''One to keep in mind here. A LinuxMIB is a Linux. It means your IT department will suddenly have some new machines flying around asking for dhcp IP, performing ARP queries and so on. ''
+
This section details the storage of the LinuxMIB. Storage refers to the disks and file systems.
 
 
= Storage =
 
This section details the storage of the LinuxMIB. In storage we mean, the disks and file systems.
 
  
 
== Block Devices ==
 
== Block Devices ==
A block device is a device where access to this device is done with blocks. 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 many ways to examine storage devices. I will describe some on regular Linux machine. The LinuxMIB lack the tools for that.''
+
&nbsp;
 +
<nowiki>To examine the content of another directory use ls <dir>. For example:</nowiki>
  
 +
~ # ''ls /sbin/''
  
The device file /dev/root is considered the boot device because it keeps 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.
+
adjtimex halt init modprobe setconsole udevadm
  
== File systems ==
+
blkid hdparm insmod poweroff sfdisk udevd
LinuxMIB is composed from several independent file systems. To examine the file systems please enter:
 
  
~ # df -h
+
dhclient hwclock klogd reboot start-stop-daemon udhcpc
  
Like the in bellow example:
+
fdisk ifconfig loadkmap rmmod sulogin umount.devkit
  
~ # df -h
+
fsck ifdown lsmod route syslog-ng watchdog
  
Filesystem Size Used Available Use% Mounted on<div align="right">1</div>
+
getty ifup modinfo runlevel threads
  
/dev/root 485.5M 83.8M 377.3M 18% /<div align="right">2</div>
+
~ #
  
none 246.9M 4.0K 246.9M 0% /tmp<div align="right">3</div>
+
The “ls” commands have additional flags, such as&nbsp;: “ls –al” which provides more information about the files.
  
none 246.9M 24.0K 246.8M 0% /RAM
+
=== cat ===
  
none 246.9M 44.0K 246.8M 0% /var/log
+
To examine the content of a text file use the cat. For example:
  
none 246.9M 24.0K 246.8M 0% /var/run<div align="right">4</div>
+
~ # ''cat /etc/busybox.conf''
  
none 246.9M 0 246.9M 0% /var/lock
+
you can also create new files with cat by redirecting cat’s output to a new file. For example:
  
none 246.9M 0 246.9M 0% /var/tmp
+
~ # ''cat /etc/busybox.conf > /tmp/busybox.conf''
  
tmpfs 246.9M 4.0K 246.9M 0% /dev
+
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''
  
# 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.
+
will concatenate to /tmp/busybox.conf the content of /etc/inet.conf.
  
Here the root file system is of size of 485MB, and 83MB of it are used.
+
=== echo ===
  
# /tmp directory is mounted as tmpfs file system. This is a ram file system. It does not survive boots.
+
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.
# 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 hello
== File and file system ==
+
 
=== ls ===
+
Hello
To examine the content the of current directory use ls:
 
  
~ # ls
+
&nbsp;
  
<nowiki>To examine the content of another directory use ls <dir>. For example:</nowiki>
+
=== less ===
  
~ # ls /sbin/
+
less is a textual viewer. It is used to examine text file content in read-only mode. Usage:
  
adjtimex halt init modprobe setconsole udevadm
+
&nbsp;
 +
<nowiki>~# less <file name></nowiki>
  
blkid hdparm insmod poweroff sfdisk udevd
+
=== tail/head ===
  
dhclient hwclock klogd reboot start-stop-daemon udhcpc
+
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.
  
fdisk ifconfig loadkmap rmmod sulogin umount.devkit
+
For example:
  
fsck ifdown lsmod route syslog-ng watchdog
+
~ # tail –f /var/syslog
  
getty ifup modinfo runlevel threads
+
=== 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:
  
The “ls” commands have additional flags, such as : “ls –al” which provides more information about the files.
+
''mknod /dev/hda1 b 3 1''
  
=== cat ===
+
This is because /dev/hda1 does not exist on the MIB and neither /dev/root.
To examine the content of a text file use the cat. For example:
 
  
~ # cat /etc/busybox.conf
+
Now issue the fsck command as bellow. I use –n flag to do that in read only mode.
  
<nowiki>[SUID]</nowiki>
+
''fsck.ext3 –n /dev/hda1''
  
<nowiki>#lines starting with # are comments</nowiki>
+
=== grep ===
  
<nowiki>#<applet> = [Ssx-][Ssx-][x-] (<username>|<uid>).(<groupname>|<gid>)</nowiki>
+
grep prints lines matching a pattern. Example:
  
 +
/etc # ''grep mc /usr/bin/mc.sh''
  
<nowiki>#reboot = ssx root.0 # applet reboot can be run by anyone and runs with euid=0/egid=0</nowiki>
+
/usr/bin/mc
  
 +
The above command prints each line containing the word “mc”.
  
you can also create new files with cat by redirecting cat’s output to a new file. For example:
+
or check number of mc core files in the /cores/ directory.
  
~ # cat /etc/busybox.conf > /tmp/busybox.conf
+
''nf=$(ls /cores/mc* | wc -l)''
  
you can concatenate two files to single file by using the >> sign.
+
''echo $nf''
  
For example the command
+
4
  
~ # cat /etc/inet.conf >> /tmp/busybox.conf
+
=== awk ===
  
will concatenate to /tmp/busybox.conf the content of /etc/inet.conf.
+
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:
  
=== echo ===
+
~# awk '$2 == 0 { printf $1 " " $2 " " $3 "\n"}' /proc/interrupts
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
+
NMI: 0 Non-maskable
  
Hello
+
LOC: 0 Local
  
 +
SPU: 0 Spurious
  
=== less ===
+
PMI: 0 Performance
less is a textual viewer. It is used to examine text file content in read-only mode. Usage:  
 
  
<nowiki>~# less <file name></nowiki>
+
IWI: 0 IRQ
  
=== tail/head ===
+
TRM: 0 Thermal
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:
+
THR: 0 Threshold
  
~ # tail –f /var/syslog
+
MCE: 0 Machine
  
=== fsck – check file system consistency ===
+
ERR: 0
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:
+
MIS: 0
  
mknod /dev/hda1 b 3 1
+
This command prints columns 1, 2 and 3 in the /proc/interrupts if the second column equal 0.
  
This is because /dev/hda1 does not exist on the MIB and neither /dev/root.
+
=== find ===
  
Now issue the fsck command as bellow. I use –n flag to do that in read only mode.
+
find searches for files in directory recursively. For example, if a user wants to find all files named mc in the LinuxMIB:
  
fsck.ext3 –n /dev/hda1
+
~ # find / -name mc
  
=== grep ===
+
/etc/init.d/mc
grep prints lines matching a pattern. Example:
 
 
 
/etc # grep mc /usr/bin/mc.sh
 
  
 
/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 268 0.0 0.0 0 0&nbsp;? S 08:03
 +
<nowiki>0:00 [kswapd0]</nowiki>
  
root 1 0.0 0.1 2076 516 ? Ss 08:03 0:01 init
+
root 269 0.0 0.0 0 0&nbsp;? S 08:03
 +
<nowiki>0:00 [fsnotify_mark]</nowiki>
  
root 2 0.0 0.0 0 0 ? S 08:03 <nowiki>0:00 [kthreadd]</nowiki>
+
root 271 0.0 0.0 0 0&nbsp;?
 +
<nowiki>S< </nowiki>
 +
08:03 <nowiki>0:00 [crypto]</nowiki>
  
root 3 0.1 0.0 0 0 ? S 08:03 <nowiki>0:02 [ksoftirqd/0]</nowiki>
+
root 869 0.0 0.0 0 0&nbsp;? S 08:04
 +
<nowiki>0:00 [irq/15-ide0]</nowiki>
  
root 5 0.0 0.0 0 0 ? S 08:03 <nowiki>0:00 [kworker/u:0]</nowiki>
+
root 906 0.0 0.0 0 0&nbsp;? S 08:04
 +
<nowiki>0:00 [irq/1-i8042]</nowiki>
  
root 6 0.0 0.0 0 0 ? S 08:03 <nowiki>0:00 [posixcputmr/0]</nowiki>
+
root 913 0.0 0.0 0 0&nbsp;? S 08:04
 +
<nowiki>0:00 [irq/8-rtc0]</nowiki>
  
root 7 0.0 0.0 0 0 ? <nowiki>S< </nowiki>08:03 <nowiki>0:00 [khelper]</nowiki>
+
root 921 0.0 0.0 0 0&nbsp;? S 08:04
 +
<nowiki>0:00 [kworker/0:2]</nowiki>
  
root 8 0.0 0.0 0 0 ? S 08:03 <nowiki>0:00 [kworker/u:1]</nowiki>
+
root 922 0.0 0.0 0 0&nbsp;? S 08:04
 +
<nowiki>0:00 [irq/4-serial]</nowiki>
  
root 125 0.0 0.0 0 0 ? S 08:03 <nowiki>0:00 [sync_supers]</nowiki>
+
root 923 0.0 0.0 0 0&nbsp;? S 08:04
 +
<nowiki>0:00 [kjournald]</nowiki>
  
root 127 0.0 0.0 0 0 ? S 08:03 <nowiki>0:00 [bdi-default]</nowiki>
+
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 128 0.0 0.0 0 0 ? <nowiki>S< </nowiki>08:03 <nowiki>0:00 [kblockd]</nowiki>
+
root 1045 0.0 0.0 0 0&nbsp;? S 08:04
 +
<nowiki>0:00 [irq/9-eth0]</nowiki>
  
root 135 0.0 0.0 0 0 ? <nowiki>S< </nowiki>08:03 <nowiki>0:00 [ata_sff]</nowiki>
+
root 1056 0.0 0.0 0 0&nbsp;? S 08:04
 +
<nowiki>0:00 [irq/11-srcsII]</nowiki>
  
root 142 0.0 0.0 0 0 ? S 08:03 <nowiki>0:00 [khubd]</nowiki>
+
root 1075 99.7 0.0 1528 196&nbsp;? Rs 08:04 31:12 /usr/bin/pkgd /
  
root 248 0.0 0.0 0 0 ? S 08:03 <nowiki>0:00 [kworker/0:1]</nowiki>
+
root 1079 0.0 0.1 2080 544 ttyS0 Ss+ 08:04 0:00 /sbin/getty -L
  
root 268 0.0 0.0 0 0 ? S 08:03 <nowiki>0:00 [kswapd0]</nowiki>
+
root 1093 0.0 0.3 6536 2004&nbsp;? Ss 08:04 0:00 sshd: root@pts/
  
root 269 0.0 0.0 0 0 ? S 08:03 <nowiki>0:00 [fsnotify_mark]</nowiki>
+
root 1097 0.0 0.1 2080 632 pts/0 Ss+ 08:04 0:00 -sh
  
root 271 0.0 0.0 0 0 ? <nowiki>S< </nowiki>08:03 <nowiki>0:00 [crypto]</nowiki>
+
root 1107 0.0 0.3 6536 1988&nbsp;? Ss 08:05 0:00 sshd: root@pts/
  
root 869 0.0 0.0 0 0 ? S 08:04 <nowiki>0:00 [irq/15-ide0]</nowiki>
+
root 1111 0.0 0.1 2080 664 pts/1 Ss 08:05 0:00 -sh
  
root 906 0.0 0.0 0 0 ? S 08:04 <nowiki>0:00 [irq/1-i8042]</nowiki>
+
root 1146 0.0 0.0 0 0&nbsp;? S 08:25
 +
<nowiki>0:00 [flush-3:0]</nowiki>
  
root 913 0.0 0.0 0 0 ? S 08:04 <nowiki>0:00 [irq/8-rtc0]</nowiki>
+
root 1177 0.2 0.3 6536 1988&nbsp;? Ss 08:35 0:00 sshd: root@pts/
  
root 921 0.0 0.0 0 0 ? S 08:04 <nowiki>0:00 [kworker/0:2]</nowiki>
+
root 1181 0.0 0.1 2080 608 pts/2 Ss 08:35 0:00 -sh
  
root 922 0.0 0.0 0 0 ? S 08:04 <nowiki>0:00 [irq/4-serial]</nowiki>
+
root 1182 3.2 5.1 42140 26172 pts/2 Sl+ 08:35 0:00 mc
  
root 923 0.0 0.0 0 0 ? S 08:04 <nowiki>0:00 [kjournald]</nowiki>
+
root 1209 0.0 0.1 2228 824 pts/1 R+ 08:35 0:00 ps aux
  
root 945 0.0 0.1 1896 648 ? <nowiki>S<s </nowiki>08:04 0:00 /sbin/udevd --d
+
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:
  
root 999 0.0 0.1 1892 608 ? <nowiki>S< </nowiki>08:04 0:00 /sbin/udevd --d
+
~ # threads
  
root 1002 0.0 0.1 1892 604 ? <nowiki>S< </nowiki>08:04 0:00 /sbin/udevd --d
+
Warning: bad ps syntax, perhaps a bogus '-'? See [http://procps.sf.net/faq.html http://procps.sf.net/faq.html]
  
root 1017 0.0 0.1 2992 716 ? Ss 08:04 0:00 /sbin/syslog-ng
+
PID TID CLS RTPRIO NI PRI PSR&nbsp;%CPU STAT WCHAN COMMAND
  
root 1025 0.0 0.1 3932 996 ? Ss 08:04 0:00 /usr/sbin/sshd
+
1 1 TS - 0 19 0 0.0 Ss wait init
  
root 1045 0.0 0.0 0 0 ? S 08:04 <nowiki>0:00 [irq/9-eth0]</nowiki>
+
2 2 TS - 0 19 0 0.0 S kthreadd kthreadd
  
root 1056 0.0 0.0 0 0 ? S 08:04 <nowiki>0:00 [irq/11-srcsII]</nowiki>
+
3 3 RR 99 - 139 0 0.1 S run_ksoftirqd ksoftirqd/0
  
root 1075 99.7 0.0 1528 196 ? Rs 08:04 31:12 /usr/bin/pkgd /
+
5 5 TS - 0 19 0 0.0 S worker_thread kworker/u:0
  
root 1079 0.0 0.1 2080 544 ttyS0 Ss+ 08:04 0:00 /sbin/getty -L
+
6 6 RR 16 - 56 0 0.0 S posix_cpu_time posixcputmr/0
  
root 1093 0.0 0.3 6536 2004 ? Ss 08:04 0:00 sshd: root@pts/
+
7 7 TS - -20 39 0
 +
<nowiki>0.0 S< </nowiki>
 +
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
  
root 1097 0.0 0.1 2080 632 pts/0 Ss+ 08:04 0:00 -sh
+
127 127 TS - 0 19 0 0.0 S bdi_forker_thr bdi-default
  
root 1107 0.0 0.3 6536 1988 ? Ss 08:05 0:00 sshd: root@pts/
+
128 128 TS - -20 39 0
 +
<nowiki>0.0 S< </nowiki>
 +
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
 +
248 248 TS - 0 19 0 0.0 S worker_thread kworker/0:1
  
root 1111 0.0 0.1 2080 664 pts/1 Ss 08:05 0:00 -sh
+
268 268 TS - 0 19 0 0.0 S kswapd_try_to_ kswapd0
  
root 1146 0.0 0.0 0 0 ? S 08:25 <nowiki>0:00 [flush-3:0]</nowiki>
+
269 269 TS - 0 19 0 0.0 S fsnotify_mark_ fsnotify_mark
  
root 1177 0.2 0.3 6536 1988 ? Ss 08:35 0:00 sshd: root@pts/
+
271 271 TS - -20 39 0
 +
<nowiki>0.0 S< </nowiki>
 +
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
  
root 1181 0.0 0.1 2080 608 pts/2 Ss 08:35 0:00 -sh
+
913 913 RR 16 - 56 0 0.0 S irq_thread irq/8-rtc0
  
root 1182 3.2 5.1 42140 26172 pts/2 Sl+ 08:35 0:00 mc
+
921 921 TS - 0 19 0 0.0 S worker_thread kworker/0:2
  
root 1209 0.0 0.1 2228 824 pts/1 R+ 08:35 0:00 ps aux
+
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
  
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:
+
945 945 TS - -4 23 0
 +
<nowiki>0.0 S<s </nowiki>
 +
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>
 +
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
  
~ # threads
+
1045 1045 RR 16 - 56 0 0.0 S irq_thread irq/9-eth0
  
Warning: bad ps syntax, perhaps a bogus '-'? See http://procps.sf.net/faq.html
+
1056 1056 RR 99 - 139 0 0.0 S irq_thread irq/11-srcsII
  
PID TID CLS RTPRIO NI PRI PSR %CPU STAT WCHAN COMMAND
+
1075 1075 TS - 0 19 0 99.5 Rs - pkgd
  
1 1 TS - 0 19 0 0.0 Ss wait init
+
1079 1079 TS - 0 19 0 0.0 Ss+ n_tty_read getty
  
2 2 TS - 0 19 0 0.0 S kthreadd kthreadd
+
1093 1093 TS - 0 19 0 0.0 Ss poll_schedule_ sshd
  
3 3 RR 99 - 139 0 0.1 S run_ksoftirqd ksoftirqd/0
+
1097 1097 TS - 0 19 0 0.0 Ss+ poll_schedule_ sh
  
5 5 TS - 0 19 0 0.0 S worker_thread kworker/u:0
+
1146 1146 TS - 0 19 0 0.0 S bdi_writeback_ flush-3:0
  
6 6 RR 16 - 56 0 0.0 S posix_cpu_time posixcputmr/0
+
1177 1177 TS - 0 19 0 0.0 Ss poll_schedule_ sshd
  
7 7 TS - -20 39 0 <nowiki>0.0 S< </nowiki>rescuer_thread khelper
+
1181 1181 TS - 0 19 0 0.0 Ss wait sh
  
8 8 TS - 0 19 0 0.0 S worker_thread kworker/u:1
+
1182 1182 TS - 0 19 0 0.0 Sl+ futex_wait_que mc
  
125 125 TS - 0 19 0 0.0 S bdi_sync_super sync_supers
+
1182 1184 RR 1 - 41 0 0.0 Sl+ wq_sleep jexec
  
127 127 TS - 0 19 0 0.0 S bdi_forker_thr bdi-default
+
1182 1186 RR 25 - 65 0 0.0 Sl+ semtimedop tErrHndl
  
128 128 TS - -20 39 0 <nowiki>0.0 S< </nowiki>rescuer_thread kblockd
+
1182 1187 RR 16 - 56 0 0.0 Sl+ semtimedop tLogger
  
135 135 TS - -20 39 0 <nowiki>0.0 S< </nowiki>rescuer_thread ata_sff
+
1182 1188 RR 16 - 56 0 0.0 Sl+ inet_csk_wait_ cli
  
142 142 TS - 0 19 0 0.0 S hub_thread khubd
+
1182 1189 RR 16 - 56 0 0.0 Sl+ inet_csk_wait_ tEthernInp
  
248 248 TS - 0 19 0 0.0 S worker_thread kworker/0:1
+
1182 1190 RR 16 - 56 0 0.0 Sl+ wait_for_packe tEthernOut
  
268 268 TS - 0 19 0 0.0 S kswapd_try_to_ kswapd0
+
1182 1191 RR 16 - 56 0 0.0 Sl+ inet_csk_wait_ tEthernInp2
  
269 269 TS - 0 19 0 0.0 S fsnotify_mark_ fsnotify_mark
+
1182 1192 RR 16 - 56 0 0.0 Sl+ wait_for_packe tEthernOut2
  
271 271 TS - -20 39 0 <nowiki>0.0 S< </nowiki>rescuer_thread crypto
+
1182 1193 RR 16 - 56 0 0.0 Sl+ inet_csk_wait_ tEthernInp0
  
869 869 FF 50 - 90 0 0.0 S irq_thread irq/15-ide0
+
1182 1194 RR 16 - 56 0 0.0 Sl+ wait_for_packe tEthernOut0
  
906 906 RR 16 - 56 0 0.0 S irq_thread irq/1-i8042
+
1182 1195 RR 16 - 56 0 0.0 Sl+ inet_csk_wait_ tEthernInp3
  
913 913 RR 16 - 56 0 0.0 S irq_thread irq/8-rtc0
+
1182 1196 RR 16 - 56 0 0.0 Sl+ wait_for_packe tEthernOut3
  
921 921 TS - 0 19 0 0.0 S worker_thread kworker/0:2
+
1182 1197 RR 16 - 56 0 0.0 Sl+ wait_for_packe RbootPd
  
922 922 RR 16 - 56 0 0.0 S irq_thread irq/4-serial
+
1182 1198 RR 16 - 56 0 0.0 Sl+ poll_schedule_ tVirtualInp
  
923 923 TS - 0 19 0 0.0 S kjournald kjournald
+
1182 1199 RR 26 - 66 0 0.0 Sl+ hrtimer_nanosl tBit
  
945 945 TS - -4 23 0 <nowiki>0.0 S<s </nowiki>poll_schedule_ udevd
+
1182 1200 RR 27 - 67 0 0.4 Sl+ semtimedop tSpy
  
999 999 TS - -2 21 0 <nowiki>0.0 S< </nowiki>poll_schedule_ udevd
+
1182 1201 RR 21 - 61 0 0.1 Sl+ semtimedop tScHandler
  
1002 1002 TS - -2 21 0 <nowiki>0.0 S< </nowiki>poll_schedule_ udevd
+
1182 1202 RR 20 - 60 0 0.0 Sl+ semtimedop tScServer
  
1017 1017 TS - 0 19 0 0.0 Ss poll_schedule_ syslog-ng
+
1182 1203 RR 21 - 61 0 0.3 SNl+ sercosII_read sercosFun
  
1025 1025 TS - 0 19 0 0.0 Ss poll_schedule_ sshd
+
1182 1204 RR 23 - 63 0 0.0 SNl+ semtimedop MotManager
  
1045 1045 RR 16 - 56 0 0.0 S irq_thread irq/9-eth0
+
1182 1207 RR 28 - 68 0 0.1 SNl+ semtimedop tRecPeriodic
  
1056 1056 RR 99 - 139 0 0.0 S irq_thread irq/11-srcsII
+
1182 1208 RR 29 - 69 0 0.0 SNl+ semtimedop tEvent
  
1075 1075 TS - 0 19 0 99.5 Rs - pkgd
+
1210 1210 TS - 0 19 0 0.6 Ss poll_schedule_ sshd
  
1079 1079 TS - 0 19 0 0.0 Ss+ n_tty_read getty
+
1214 1214 TS - 0 19 0 0.0 Ss wait sh
  
1093 1093 TS - 0 19 0 0.0 Ss poll_schedule_ sshd
+
1215 1215 TS - 0 19 0 0.0 S+ wait sh
  
1097 1097 TS - 0 19 0 0.0 Ss+ poll_schedule_ sh
+
1216 1216 TS - 0 19 0 0.0 R+ - ps
  
1146 1146 TS - 0 19 0 0.0 S bdi_writeback_ flush-3:0
+
The "threads" is actually a shortcut for the following ps command:
  
1177 1177 TS - 0 19 0 0.0 Ss poll_schedule_ sshd
+
''ps -axH -eo pid,tid,class,rtprio,ni,pri,psr,pcpu,stat,wchan:14,comm''
  
1181 1181 TS - 0 19 0 0.0 Ss wait sh
+
The above command presents the following information for each task in the operating system:
  
1182 1182 TS - 0 19 0 0.0 Sl+ futex_wait_que mc
+
'''pid''' = process id of the parent not-detached task
  
1182 1184 RR 1 - 41 0 0.0 Sl+ wq_sleep jexec
+
'''tid''' = process id of the task within parent task – what we refer as thread.
  
1182 1186 RR 25 - 65 0 0.0 Sl+ semtimedop tErrHndl
+
'''class''' = scheduling class. TS = OTHER, RR = round robin, FF = fifo. - = not reported
  
1182 1187 RR 16 - 56 0 0.0 Sl+ semtimedop tLogger
+
'''rtprio''' = real time priority, ranging from 99 to 0. When 99 is strongest.
  
1182 1188 RR 16 - 56 0 0.0 Sl+ inet_csk_wait_ cli
+
'''ni''' = niceness. Ranging from -19 to 20.
  
1182 1189 RR 16 - 56 0 0.0 Sl+ inet_csk_wait_ tEthernInp
+
'''pri''' = static priority.
  
1182 1190 RR 16 - 56 0 0.0 Sl+ wait_for_packe tEthernOut
+
'''psr''' = processor id.
  
1182 1191 RR 16 - 56 0 0.0 Sl+ inet_csk_wait_ tEthernInp2
+
'''pcpu''' = overall cpu usage
  
1182 1192 RR 16 - 56 0 0.0 Sl+ wait_for_packe tEthernOut2
+
'''stat''' = process state. R for runnable or S for sleeping, Z for zombie.
  
1182 1193 RR 16 - 56 0 0.0 Sl+ inet_csk_wait_ tEthernInp0
+
'''wchan''' = kernel function where process is waiting. If process is running a dash is displayed
  
1182 1194 RR 16 - 56 0 0.0 Sl+ wait_for_packe tEthernOut0
+
'''comm''' = name of process
  
1182 1195 RR 16 - 56 0 0.0 Sl+ inet_csk_wait_ tEthernInp3
+
If you wish to sort the list by the processes real time priority, use the following command:
  
1182 1196 RR 16 - 56 0 0.0 Sl+ wait_for_packe tEthernOut3
+
threads | sort –k4
  
1182 1197 RR 16 - 56 0 0.0 Sl+ wait_for_packe RbootPd
+
This command sorts the list according by the fourth column.
  
1182 1198 RR 16 - 56 0 0.0 Sl+ poll_schedule_ tVirtualInp
+
=== Kill ===
  
1182 1199 RR 26 - 66 0 0.0 Sl+ hrtimer_nanosl tBit
+
To terminate a running process use the kill command. Kill needs the process id , so many times you can simply type:
  
1182 1200 RR 27 - 67 0 0.4 Sl+ semtimedop tSpy
+
kill -9 $(pidof mc)
  
1182 1201 RR 21 - 61 0 0.1 Sl+ semtimedop tScHandler
+
Which means, kill anyway, the mc by its process id.
  
1182 1202 RR 20 - 60 0 0.0 Sl+ semtimedop tScServer
+
=== Top ===
  
1182 1203 RR 21 - 61 0 0.3 SNl+ sercosII_read sercosFun
+
top is an interactive view of displaying system tasks. It refreshes the list every 1 or more second.
  
1182 1204 RR 23 - 63 0 0.0 SNl+ semtimedop MotManager
+
~ # top
  
1182 1207 RR 28 - 68 0 0.1 SNl+ semtimedop tRecPeriodic
+
top - 09:21:51 up 1:17, 4 users, load average: 1.04, 1.03, 1.01
  
1182 1208 RR 29 - 69 0 0.0 SNl+ semtimedop tEvent
+
Tasks: 42 total, 2 running, 40 sleeping, 0 stopped, 0 zombie
  
1210 1210 TS - 0 19 0 0.6 Ss poll_schedule_ sshd
+
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
  
1214 1214 TS - 0 19 0 0.0 Ss wait sh
+
Mem: 505536k total, 49120k used, 456416k free, 860k buffers
  
1215 1215 TS - 0 19 0 0.0 S+ wait sh
+
Swap: 0k total, 0k used, 0k free, 12288k cached
  
1216 1216 TS - 0 19 0 0.0 R+ - ps
+
PID USER PR NI VIRT RES SHR S&nbsp;%CPU&nbsp;%MEM TIME+ COMMAND
  
 +
1075 root 20 0 1528 196 148 R 98.9 0.0 77:03.44 pkgd
  
Thread is a shortcut for the following ps command:
+
1056 root RT 0 0 0 0 S 2.0 0.0 0:05.73 irq/11-srcsII
  
ps -axH -eo pid,tid,class,rtprio,ni,pri,psr,pcpu,stat,wchan:14,comm
+
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
  
The above command presents the following information for each task in the operating system:
+
3 root RT 0 0 0 0 S 0.0 0.0 0:07.44 ksoftirqd/0
  
'''pid''' = process id of the parent not-detached task
+
5 root 20 0 0 0 0 S 0.0 0.0 0:00.01 kworker/u:0
  
'''tid''' = process id of the task within parent task – what we refer as thread.
+
6 root -17 0 0 0 0 S 0.0 0.0 0:00.00 posixcputmr/0
  
'''class''' = scheduling class. TS = OTHER, RR = round robin, FF = fifo. - = not reported
+
7 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 khelper
  
'''rtprio''' = real time priority, ranging from 99 to 0. When 99 is strongest.
+
8 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kworker/u:1
  
'''ni''' = niceness. Ranging from -19 to 20.  
+
125 root 20 0 0 0 0 S 0.0 0.0 0:00.00 sync_supers
  
'''pri''' = static priority.  
+
127 root 20 0 0 0 0 S 0.0 0.0 0:00.00 bdi-default
  
'''psr''' = processor id.
+
128 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kblockd
  
'''pcpu''' = overall cpu usage
+
135 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 ata_sff
  
'''stat''' = process state. R for runnable or S for sleeping, Z for zombie.  
+
142 root 20 0 0 0 0 S 0.0 0.0 0:00.00 khubd
  
'''wchan''' = kernel function where process is waiting. If process is running a dash is displayed
+
248 root 20 0 0 0 0 S 0.0 0.0 0:00.02 kworker/0:1
  
'''comm''' = name of process
+
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
  
If you wish to sort the list by the processes real time priority, use the following command:
+
271 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 crypto
  
threads | sort –k4
+
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
  
This command sorts the list according by the fourth column.
+
For example:
  
=== Kill ===
+
'''us''' is the Cpu usage in user space here is 29.6%
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)
+
'''sy''' is the cpu usage in kernel space is 70%
  
Which means, kill anyway, the mc by its process id.
+
'''ni''' is the niceness of last process
  
=== Top ===
+
'''wa''' is io wait which is the amount of time system is waiting for IO to complete.
top is an interactive view of displaying system tasks. It refreshes the list every 1 or more second.  
 
  
~ # top
+
'''hi''' is hardware interrupt usage
  
~ # top
+
'''si''' is soft irqs usage
  
top - 09:21:51 up 1:17, 4 users, load average: 1.04, 1.03, 1.01
+
'''st''' is virtualization usage ( always zero in mib)
  
Tasks: 42 total, 2 running, 40 sleeping, 0 stopped, 0 zombie
+
=== htop ===
  
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
+
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.
  
Mem: 505536k total, 49120k used, 456416k free, 860k buffers
+
[[Image:]]
  
Swap: 0k total, 0k used, 0k free, 12288k cached
+
Type F6 and toy with it.
  
 +
=== Display process’s maps ===
  
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
+
To watch a process’ segmented allocation use the following commands:
  
1075 root 20 0 1528 196 148 R 98.9 0.0 77:03.44 pkgd
+
~ # cat /proc/$(pidof mc)/maps
  
1056 root RT 0 0 0 0 S 2.0 0.0 0:05.73 irq/11-srcsII
+
08048000-08429000 r-xp 00000000 03:01 13462 /usr/bin/mc
  
1 root 20 0 2076 520 460 S 0.0 0.1 0:01.17 init
+
08429000-08558000 rwxp 003e1000 03:01 13462 /usr/bin/mc
  
2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd
+
08558000-085ed000 rwxp 00000000 00:00 0
  
3 root RT 0 0 0 0 S 0.0 0.0 0:07.44 ksoftirqd/0
+
09afd000-0b060000 rwxp 00000000 00:00 0
 +
<nowiki>[heap]</nowiki>
  
5 root 20 0 0 0 0 S 0.0 0.0 0:00.01 kworker/u:0
+
b5a1c000-b5a1d000 ---p 00000000 00:00 0
  
6 root -17 0 0 0 0 S 0.0 0.0 0:00.00 posixcputmr/0
+
b5a1d000-b5a24000 rwxp 00000000 00:00 0
  
7 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 khelper
+
b5a24000-b5a25000 ---p 00000000 00:00 0
  
8 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kworker/u:1
+
b5a25000-b5a30000 rwxp 00000000 00:00 0
  
125 root 20 0 0 0 0 S 0.0 0.0 0:00.00 sync_supers
+
b5a30000-b5a31000 ---p 00000000 00:00 0
  
127 root 20 0 0 0 0 S 0.0 0.0 0:00.00 bdi-default
+
b5a31000-b5a3c000 rwxp 00000000 00:00 0
  
128 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kblockd
+
b5a3c000-b5a3d000 ---p 00000000 00:00 0
  
135 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 ata_sff
+
b5a3d000-b5a48000 rwxp 00000000 00:00 0
  
142 root 20 0 0 0 0 S 0.0 0.0 0:00.00 khubd
+
b5a48000-b5a49000 ---p 00000000 00:00 0
  
248 root 20 0 0 0 0 S 0.0 0.0 0:00.02 kworker/0:1
+
b5a49000-b5a58000 rwxp 00000000 00:00 0
  
268 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kswapd0
+
b5a58000-b5a59000 ---p 00000000 00:00 0
  
269 root 20 0 0 0 0 S 0.0 0.0 0:00.00 fsnotify_mark
+
b5a59000-b5a5c000 rwxp 00000000 00:00 0
  
271 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 crypto
+
b5a5c000-b5a5d000 ---p 00000000 00:00 0
  
Top displays a nice summary before the list. Memory usage, cpu usage and so on. Important information is found in this line
+
b5a5d000-b5a64000 rwxp 00000000 00:00 0
  
 +
b5a64000-b5a65000 ---p 00000000 00:00 0
  
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
+
b5a65000-b5a6c000 rwxp 00000000 00:00 0
  
 +
b5a6c000-b5a6d000 ---p 00000000 00:00 0
  
For example:
+
b5a6d000-b5a74000 rwxp 00000000 00:00 0
  
'''us''' is the Cpu usage in user space here is 29.6%
+
b5a74000-b5a75000 ---p 00000000 00:00 0
  
'''sy''' is the cpu usage in kernel space is 70%
+
b5a75000-b5a80000 rwxp 00000000 00:00 0
  
'''ni''' is the niceness of last process
+
b5a81000-b5a82000 ---p 00000000 00:00 0
  
'''wa''' is io wait which is the amount of time system is waiting for IO to complete.
+
b5a82000-b5aa5000 rwxp 00000000 00:00 0
  
'''hi''' is hardware interrupt usage
+
b5aa5000-b5aa6000 ---p 00000000 00:00 0
  
'''si''' is soft irqs usage
+
b5aa6000-b5ac1000 rwxp 00000000 00:00 0
  
'''st''' is virtualization usage ( always zero in mib)
+
b5ac1000-b5ac2000 ---p 00000000 00:00 0
  
 +
b5ac2000-b5ac9000 rwxp 00000000 00:00 0
  
=== htop ===
+
b5ac9000-b5aca000 ---p 00000000 00:00 0
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:]]
+
b5aca000-b5aed000 rwxp 00000000 00:00 0
  
Type F6 and toy with it.
+
b5aed000-b5aee000 ---p 00000000 00:00 0
  
=== Display process’s maps ===
+
b5aee000-b5af5000 rwxp 00000000 00:00 0
To watch a process’ segmented allocation use the following commands:
 
  
~ # cat /proc/$(pidof mc)/maps
+
b5af5000-b5af6000 ---p 00000000 00:00 0
  
08048000-08429000 r-xp 00000000 03:01 13462 /usr/bin/mc
+
b5af6000-b5b19000 rwxp 00000000 00:00 0
  
08429000-08558000 rwxp 003e1000 03:01 13462 /usr/bin/mc
+
b5b19000-b5b1a000 ---p 00000000 00:00 0
  
08558000-085ed000 rwxp 00000000 00:00 0
+
b5b1a000-b5b21000 rwxp 00000000 00:00 0
  
09afd000-0b060000 rwxp 00000000 00:00 0 <nowiki>[heap]</nowiki>
+
b5b21000-b5b22000 ---p 00000000 00:00 0
  
b5a1c000-b5a1d000 ---p 00000000 00:00 0
+
b5b22000-b5b45000 rwxp 00000000 00:00 0
  
b5a1d000-b5a24000 rwxp 00000000 00:00 0
+
b5b45000-b5b46000 ---p 00000000 00:00 0
  
b5a24000-b5a25000 ---p 00000000 00:00 0
+
b5b46000-b5b4d000 rwxp 00000000 00:00 0
  
b5a25000-b5a30000 rwxp 00000000 00:00 0
+
b5b4d000-b5b4e000 ---p 00000000 00:00 0
  
b5a30000-b5a31000 ---p 00000000 00:00 0
+
b5b4e000-b5c18000 rwxp 00000000 00:00 0
  
b5a31000-b5a3c000 rwxp 00000000 00:00 0
+
b5c18000-b5c19000 ---p 00000000 00:00 0
  
b5a3c000-b5a3d000 ---p 00000000 00:00 0
+
b5c19000-b6418000 rwxp 00000000 00:00 0
  
b5a3d000-b5a48000 rwxp 00000000 00:00 0
+
b6418000-b6419000 ---p 00000000 00:00 0
  
b5a48000-b5a49000 ---p 00000000 00:00 0
+
b6419000-b6420000 rwxp 00000000 00:00 0
  
b5a49000-b5a58000 rwxp 00000000 00:00 0
+
b6420000-b6421000 ---p 00000000 00:00 0
  
b5a58000-b5a59000 ---p 00000000 00:00 0
+
b6421000-b6429000 rwxp 00000000 00:00 0
  
b5a59000-b5a5c000 rwxp 00000000 00:00 0
+
b6429000-b642a000 ---p 00000000 00:00 0
  
b5a5c000-b5a5d000 ---p 00000000 00:00 0
+
b642a000-b642d000 rwxp 00000000 00:00 0
  
b5a5d000-b5a64000 rwxp 00000000 00:00 0
+
b642d000-b742d000 rwxs fffe9000000 00:12 2311 /dev/sercosII
  
b5a64000-b5a65000 ---p 00000000 00:00 0
+
b742d000-b742e000 ---p 00000000 00:00 0
  
b5a65000-b5a6c000 rwxp 00000000 00:00 0
+
b742e000-b7435000 rwxp 00000000 00:00 0
  
b5a6c000-b5a6d000 ---p 00000000 00:00 0
+
b7435000-b7436000 ---p 00000000 00:00 0
  
b5a6d000-b5a74000 rwxp 00000000 00:00 0
+
b7436000-b7544000 rwxp 00000000 00:00 0
  
b5a74000-b5a75000 ---p 00000000 00:00 0
+
b7544000-b7679000 r-xp 00000000 03:01 10172 /lib/libc-2.13.so
  
b5a75000-b5a80000 rwxp 00000000 00:00 0
+
b7679000-b767a000 ---p 00135000 03:01 10172 /lib/libc-2.13.so
  
b5a81000-b5a82000 ---p 00000000 00:00 0
+
b767a000-b767c000 r-xp 00135000 03:01 10172 /lib/libc-2.13.so
  
b5a82000-b5aa5000 rwxp 00000000 00:00 0
+
b767c000-b767d000 rwxp 00137000 03:01 10172 /lib/libc-2.13.so
  
b5aa5000-b5aa6000 ---p 00000000 00:00 0
+
b767d000-b7680000 rwxp 00000000 00:00 0
  
b5aa6000-b5ac1000 rwxp 00000000 00:00 0
+
b7680000-b769b000 r-xp 00000000 03:01 12467 /lib/libgcc_s.so.1
  
b5ac1000-b5ac2000 ---p 00000000 00:00 0
+
b769b000-b769c000 rwxp 0001a000 03:01 12467 /lib/libgcc_s.so.1
  
b5ac2000-b5ac9000 rwxp 00000000 00:00 0
+
b769c000-b76c1000 r-xp 00000000 03:01 14763 /lib/libm-2.13.so
  
b5ac9000-b5aca000 ---p 00000000 00:00 0
+
b76c1000-b76c2000 r-xp 00024000 03:01 14763 /lib/libm-2.13.so
  
b5aca000-b5aed000 rwxp 00000000 00:00 0
+
b76c2000-b76c3000 rwxp 00025000 03:01 14763 /lib/libm-2.13.so
  
b5aed000-b5aee000 ---p 00000000 00:00 0
+
b76c3000-b779b000 r-xp 00000000 03:01 9190 /usr/lib/libstdc++.so.6.0.14
  
b5aee000-b5af5000 rwxp 00000000 00:00 0
+
b779b000-b779f000 r-xp 000d7000 03:01 9190 /usr/lib/libstdc++.so.6.0.14
  
b5af5000-b5af6000 ---p 00000000 00:00 0
+
b779f000-b77a0000 rwxp 000db000 03:01 9190 /usr/lib/libstdc++.so.6.0.14
  
b5af6000-b5b19000 rwxp 00000000 00:00 0
+
b77a0000-b77a8000 rwxp 00000000 00:00 0
  
b5b19000-b5b1a000 ---p 00000000 00:00 0
+
b77a8000-b77b0000 r-xp 00000000 03:01 16731 /lib/libcrypt-2.13.so
  
b5b1a000-b5b21000 rwxp 00000000 00:00 0
+
b77b0000-b77b1000 r-xp 00007000 03:01 16731 /lib/libcrypt-2.13.so
  
b5b21000-b5b22000 ---p 00000000 00:00 0
+
b77b1000-b77b2000 rwxp 00008000 03:01 16731 /lib/libcrypt-2.13.so
  
b5b22000-b5b45000 rwxp 00000000 00:00 0
+
b77b2000-b77d9000 rwxp 00000000 00:00 0
  
b5b45000-b5b46000 ---p 00000000 00:00 0
+
b77d9000-b77ed000 r-xp 00000000 03:01 17714 /lib/libpthread-2.13.so
  
b5b46000-b5b4d000 rwxp 00000000 00:00 0
+
b77ed000-b77ee000 r-xp 00013000 03:01 17714 /lib/libpthread-2.13.so
  
b5b4d000-b5b4e000 ---p 00000000 00:00 0
+
b77ee000-b77ef000 rwxp 00014000 03:01 17714 /lib/libpthread-2.13.so
  
b5b4e000-b5c18000 rwxp 00000000 00:00 0
+
b77ef000-b77f1000 rwxp 00000000 00:00 0
  
b5c18000-b5c19000 ---p 00000000 00:00 0
+
b77f1000-b77f7000 r-xp 00000000 03:01 13450 /lib/librt-2.13.so
  
b5c19000-b6418000 rwxp 00000000 00:00 0
+
b77f7000-b77f8000 r-xp 00005000 03:01 13450 /lib/librt-2.13.so
  
b6418000-b6419000 ---p 00000000 00:00 0
+
b77f8000-b77f9000 rwxp 00006000 03:01 13450 /lib/librt-2.13.so
  
b6419000-b6420000 rwxp 00000000 00:00 0
+
b77f9000-b77fb000 r-xp 00000000 03:01 17388 /lib/libdl-2.13.so
  
b6420000-b6421000 ---p 00000000 00:00 0
+
b77fb000-b77fc000 r-xp 00001000 03:01 17388 /lib/libdl-2.13.so
  
b6421000-b6429000 rwxp 00000000 00:00 0
+
b77fc000-b77fd000 rwxp 00002000 03:01 17388 /lib/libdl-2.13.so
  
b6429000-b642a000 ---p 00000000 00:00 0
+
b77fd000-b7817000 r-xp 00000000 03:01 16404 /lib/ld-2.13.so
  
b642a000-b642d000 rwxp 00000000 00:00 0
+
b7817000-b7818000 rwxp 00000000 00:00 0
  
b642d000-b742d000 rwxs fffe9000000 00:12 2311 /dev/sercosII
+
b7818000-b7819000 r-xp 0001a000 03:01 16404 /lib/ld-2.13.so
  
b742d000-b742e000 ---p 00000000 00:00 0
+
b7819000-b781a000 rwxp 0001b000 03:01 16404 /lib/ld-2.13.so
  
b742e000-b7435000 rwxp 00000000 00:00 0
+
bfd20000-bfd41000 rwxp 00000000 00:00 0
 +
<nowiki>[stack]</nowiki>
  
b7435000-b7436000 ---p 00000000 00:00 0
+
ffffe000-fffff000 r-xp 00000000 00:00 0
 +
<nowiki>[vdso]</nowiki>
  
b7436000-b7544000 rwxp 00000000 00:00 0
+
From left to tight:
  
b7544000-b7679000 r-xp 00000000 03:01 10172 /lib/libc-2.13.so
+
#The segment ( also known as vma ) memory addresses
 +
#The segment permission
 +
#The segment offset into the file
 +
#The block device major/minor holding the file
 +
#The size of the segment
  
b7679000-b767a000 ---p 00135000 03:01 10172 /lib/libc-2.13.so
+
=== chrt ===
  
b767a000-b767c000 r-xp 00135000 03:01 10172 /lib/libc-2.13.so
+
change real time priority. You can control a processes scheduling class and priority level from the command line.
  
b767c000-b767d000 rwxp 00137000 03:01 10172 /lib/libc-2.13.so
+
For example:
  
b767d000-b7680000 rwxp 00000000 00:00 0
+
Ksoftirq is a kernel daemon that is widely used in the kernel.
  
b7680000-b769b000 r-xp 00000000 03:01 12467 /lib/libgcc_s.so.1
+
~ # threads |grep sof
  
b769b000-b769c000 rwxp 0001a000 03:01 12467 /lib/libgcc_s.so.1
+
3 3 RR 99 - 139 0 0.1 S run_ksoftirqd ksoftirqd/0
  
b769c000-b76c1000 r-xp 00000000 03:01 14763 /lib/libm-2.13.so
+
ksoftirq pid is 3. Its real time priority is 99. So , let say we wish to change its priority to 19.
  
b76c1000-b76c2000 r-xp 00024000 03:01 14763 /lib/libm-2.13.so
+
~ # chrt -r -p 19 3
  
b76c2000-b76c3000 rwxp 00025000 03:01 14763 /lib/libm-2.13.so
+
pid 3's current scheduling policy: SCHED_RR
  
b76c3000-b779b000 r-xp 00000000 03:01 9190 /usr/lib/libstdc++.so.6.0.14
+
pid 3's current scheduling priority: 99
  
b779b000-b779f000 r-xp 000d7000 03:01 9190 /usr/lib/libstdc++.so.6.0.14
+
pid 3's new scheduling policy: SCHED_RR
  
b779f000-b77a0000 rwxp 000db000 03:01 9190 /usr/lib/libstdc++.so.6.0.14
+
pid 3's new scheduling priority: 19
  
b77a0000-b77a8000 rwxp 00000000 00:00 0
+
and indeed priority changed.
  
b77a8000-b77b0000 r-xp 00000000 03:01 16731 /lib/libcrypt-2.13.so
+
~ # threads | grep sof
  
b77b0000-b77b1000 r-xp 00007000 03:01 16731 /lib/libcrypt-2.13.so
+
3 3 RR 19 - 59 0 0.1 S run_ksoftirqd ksoftirqd/0
  
b77b1000-b77b2000 rwxp 00008000 03:01 16731 /lib/libcrypt-2.13.so
+
&nbsp;
  
b77b2000-b77d9000 rwxp 00000000 00:00 0
+
== Network ==
  
b77d9000-b77ed000 r-xp 00000000 03:01 17714 /lib/libpthread-2.13.so
+
=== ssh sshd and scp ===
  
b77ed000-b77ee000 r-xp 00013000 03:01 17714 /lib/libpthread-2.13.so
+
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.
  
b77ee000-b77ef000 rwxp 00014000 03:01 17714 /lib/libpthread-2.13.so
+
To login to MIB ip 10.4.20.240 from any Linux machine enter:
  
b77ef000-b77f1000 rwxp 00000000 00:00 0
+
~ # ssh root@10.4.20.240
  
b77f1000-b77f7000 r-xp 00000000 03:01 13450 /lib/librt-2.13.so
+
The authenticity of host '10.4.20.240 (10.4.20.240)' can't be established.
  
b77f7000-b77f8000 r-xp 00005000 03:01 13450 /lib/librt-2.13.so
+
RSA key fingerprint is ef:f6:72:7f:64:7a:21:d4:8b:c3:b2:db:cf:a0:0f:99.
  
b77f8000-b77f9000 rwxp 00006000 03:01 13450 /lib/librt-2.13.so
+
Are you sure you want to continue connecting (yes/no)? yes
  
b77f9000-b77fb000 r-xp 00000000 03:01 17388 /lib/libdl-2.13.so
+
Warning: Permanently added '10.4.20.240' (RSA) to the list of known hosts.
  
b77fb000-b77fc000 r-xp 00001000 03:01 17388 /lib/libdl-2.13.so
+
root@10.4.20.240's password:
  
b77fc000-b77fd000 rwxp 00002000 03:01 17388 /lib/libdl-2.13.so
+
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.
  
b77fd000-b7817000 r-xp 00000000 03:01 16404 /lib/ld-2.13.so
+
To copy files from Linux machine to another Linux machine in the command line we use scp command: for example, the command:
  
b7817000-b7818000 rwxp 00000000 00:00 0
+
scp –r /tmp root@10.4.20.240:/root/
  
b7818000-b7819000 r-xp 0001a000 03:01 16404 /lib/ld-2.13.so
+
will copy tmp directory to to root directory in target machine. The “-r” means recursive copy, which is how we copy directories.
  
b7819000-b781a000 rwxp 0001b000 03:01 16404 /lib/ld-2.13.so
+
If you copy files from a windows machine to a linux machine you should use winscp.
  
bfd20000-bfd41000 rwxp 00000000 00:00 0 <nowiki>[stack]</nowiki>
+
[[File:winscp1.png|winscp]]
  
ffffe000-fffff000 r-xp 00000000 00:00 0 <nowiki>[vdso]</nowiki>
+
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.
  
 +
[[File:winscp2.png|winscp]]
  
From left to tight:
+
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.
  
# The segment ( also known as vma ) memory addresses
+
[[File:winscp3.png|winscp]]
# The segment permission
 
# The segment offset into the file
 
# The block device major/minor holding the file
 
# The size of the segment
 
  
=== chrt ===
+
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.
change real time priority. You can control a processes scheduling class and priority level from the command line.
 
  
For example:
+
=== Route ===
  
Ksoftirq is a kernel daemon that is widely used in the kernel.
+
To watch the routing tables just type “route” or “netstat –r”. Here is route output in MIB
  
~ # threads |grep sof
+
Ip 10.4.20.240.
  
3 3 RR 99 - 139 0 0.1 S run_ksoftirqd ksoftirqd/0
+
Kernel IP routing table
  
 +
Destination Gateway Genmask Flags Metric Ref Use Iface
  
ksoftirq pid is 3. Its real time priority is 99. So , let say we wish to change its priority to 19.
+
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.
 +
The only Ethernet interface a MIB has is eth0.
  
~ # chrt -r -p 19 3
+
&nbsp;
  
pid 3's current scheduling policy: SCHED_RR
+
=== tcpdump ===
  
pid 3's current scheduling priority: 99
+
tcpdump is a packet capture program. To capture packets simply type:
  
pid 3's new scheduling policy: SCHED_RR
+
tcpdump
  
pid 3's new scheduling priority: 19
+
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:
  
and indeed priority changed.
+
tcpdump ip –i eth0 and not port 22
  
~ # threads | grep sof
+
Which means, capture all traffic on interface eth0, but drop any traffic on directed to port 22.
  
3 3 RR 19 - 59 0 0.1 S run_ksoftirqd ksoftirqd/0
+
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
  
== Network ==
+
This means that the captured data will be passed to a file called foo.cap.
=== 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:
+
&nbsp;
  
ssh [mailto:root@10.4.20.240 root@10.4.20.240]
+
=== ethtool ===
  
~ # ssh root@10.4.20.240
+
ethtool is used to query and control network interfaces.
  
The authenticity of host '10.4.20.240 (10.4.20.240)' can't be established.
+
~ # ethtool eth0
  
RSA key fingerprint is ef:f6:72:7f:64:7a:21:d4:8b:c3:b2:db:cf:a0:0f:99.
+
Settings for eth0:
  
Are you sure you want to continue connecting (yes/no)? yes
+
&nbsp;
 +
<nowiki>Supported ports: [ TP MII ]</nowiki>
  
Warning: Permanently added '10.4.20.240' (RSA) to the list of known hosts.
+
Supported link modes: 10baseT/Half 10baseT/Full
  
root@10.4.20.240's password:
+
100baseT/Half 100baseT/Full
  
 +
Supports auto-negotiation: Yes
  
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.
+
Advertised link modes: 10baseT/Half 10baseT/Full
  
To copy files from Linux machine to another Linux machine in the command line we use scp command: for example, the command:
+
100baseT/Half 100baseT/Full
  
scp –r /tmp root@10.4.20.240:/root/
+
Advertised pause frame use: Symmetric
  
will copy tmp directory to to root directory in target machine. The “-r” means recursive copy, which is how we copy directories.
+
Advertised auto-negotiation: Yes
  
If you copy files from a windows machine to a linux machine you should use winscp.
+
Link partner advertised link modes: 10baseT/Half 10baseT/Full
  
 +
100baseT/Half 100baseT/Full
  
[[Image:]]
+
Link partner advertised pause frame use: Symmetric
  
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.
+
Link partner advertised auto-negotiation: Yes
  
[[Image:]]
+
Speed: 100Mb/s
  
 +
Duplex: Full
  
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.
+
Port: MII
  
[[Image:]]
+
PHYAD: 1
  
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.
+
Transceiver: internal
  
=== Route ===
+
Auto-negotiation: on
To watch the routing tables just type “route” or “netstat –r”. Here is route output in MIB
 
  
Ip 10.4.20.240.
+
Supports Wake-on: g
  
Kernel IP routing table
+
Wake-on: g
  
Destination Gateway Genmask Flags Metric Ref Use Iface
+
Current message level: 0x00000007 (7)
  
10.0.0.0 <nowiki>* </nowiki>255.0.0.0 U 0 0 0 eth0
+
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).
  
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.
+
= Boot =
  
The only Ethernet interface a MIB has is eth0.
+
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
  
=== tcpdump ===
+
serial --unit=0 --speed=115200
tcpdump is a packet capture program. To capture packets simply type:
 
  
tcpdump
+
terminal --timeout=0 serial console
  
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:
+
default 0
  
tcpdump ip –i eth0 and not port 22
+
timeout 0
  
Which means, capture all traffic on interface eth0, but drop any traffic on directed to port 22.
+
color cyan/blue white/blue
  
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:
+
title Standalone Boot
  
tcpdump ip –i eth0 and not port 22 –w foo.cap
+
root (hd0,0)
  
This means that the captured data will be passed to a file called foo.cap.
+
kernel /boot/bzImage root=/dev/hda1,/dev/hdc1 console=ttyS0,115200
  
 +
title Network Boot
  
=== ethtool ===
+
ifconfig --server= --gateway= --mask= --address=
ethtool is used to query and control network interfaces.
 
  
~ # ethtool eth0
+
root (nd)
  
Settings for eth0:
+
kernel (nd)/linux root=/dev/nfs console=ttyS0,115200 ip=:::::eth0: nfsroot=
  
<nowiki>Supported ports: [ TP MII ]</nowiki>
+
~ #
  
Supported link modes: 10baseT/Half 10baseT/Full
+
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.
  
100baseT/Half 100baseT/Full
+
Grub boots the kernel by loading the kernel file (bzImage) to the main memory and passing it some parameters. Current parameters are:
  
Supports auto-negotiation: Yes
+
root=/dev/hda1,/dev/hdc1 console=ttyS0, 115200
  
Advertised link modes: 10baseT/Half 10baseT/Full
+
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.
  
100baseT/Half 100baseT/Full
+
&nbsp;
  
Advertised pause frame use: Symmetric
+
= BSP =
  
Advertised auto-negotiation: Yes
+
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.
  
Link partner advertised link modes: 10baseT/Half 10baseT/Full
+
== Virtual Build Machine ==
  
100baseT/Half 100baseT/Full
+
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.
  
Link partner advertised pause frame use: Symmetric
+
'''Virtual Box Configuration'''
  
Link partner advertised auto-negotiation: Yes
+
storage
  
Speed: 100Mb/s
+
[[File:vbox1.png|vbox]]
  
Duplex: Full
+
Network
  
Port: MII
+
[[File:vbox2.png|vbox]]
  
PHYAD: 1
+
share
  
Transceiver: internal
+
[[File:vbox3.png|vbox]]
  
Auto-negotiation: on
+
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.
  
Supports Wake-on: g
+
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.
  
Wake-on: g
+
The “amcs” share will mount automatically. Any other share has to be mounted manually in the guest:
  
Current message level: 0x00000007 (7)
+
mount.vboxsf
 +
<nowiki><share name> </nowiki>
 +
<nowiki><mount point> </nowiki>
  
Link detected: yes
+
'''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.
  
Common use for it is checking the link type, 10/100/1000 Mbps and if the network is actually up (Last line: Link Detected).
+
&nbsp;
  
 +
=== Building MC ===
  
= Boot =
+
#Make sure amcs share is mounted and contains all required sources. Make sure the toolchain is mounted on /opt.  
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.
 
  
 +
~ # df
  
~ # cat /boot/grub/menu.lst
+
Filesystem 1K-blocks Used Available Use% Mounted on
  
serial --unit=0 --speed=115200
+
udev 191428 112 191316 0% /dev
  
terminal --timeout=0 serial console
+
tmpfs 76572 144 76428 0% /run
  
 +
/dev/sda1 147415 85218 54697 61% /
  
default 0
+
none 191428 0 191428 0% /tmp
  
timeout 0
+
none 191428 0 191428 0% /var/log
  
color cyan/blue white/blue
+
none 191428 16 191412 0% /var/run
  
 +
none 191428 0 191428 0% /var/lock
  
title Standalone Boot
+
none 191428 0 191428 0% /var/tmp
  
root (hd0,0)
+
tmpfs 191428 112 191316 0% /dev
  
kernel /boot/bzImage root=/dev/hda1,/dev/hdc1 console=ttyS0,115200
+
''''/dev/sdb 8256952 1784056 6053468 23% /opt''''
  
 +
none 4217028 1366328 2850700 32% /media
  
title Network Boot
+
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:
  
ifconfig --server= --gateway= --mask= --address=
+
$ sh run_configure_all and now you can build these sources:
  
root (nd)
+
$ make –j2
  
kernel (nd)/linux root=/dev/nfs console=ttyS0,115200 ip=:::::eth0: nfsroot=
+
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.
  
~ #
+
scp mc root@10.4.20.240:/usr/bin/mc
  
 +
else use eclipse terminal to copy.
  
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.
+
&nbsp;
  
Grub boots the kernel by loading the kernel file (bzImage) to the main memory and passing it some parameters. Current parameters are:
+
==== Troubleshoot ====
  
root=/dev/hda1,/dev/hdc1 console=ttyS0, 115200
+
'''run_configure_all'''
  
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.
+
If run_configure_all fails with numerous errors, edit in linux, and remove all ^M signs.
  
 +
'''Out Of memory'''
  
= BSP =
+
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.
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 ==
+
'''Out of disk space'''
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.
 
  
 +
You are probably building on the virtual machine disk. Change to share directory.
  
'''Virtual Box Configuration'''
+
== Toolchain ==
  
storage
+
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:
  
[[Image:]]
+
Gcc 4.52
  
Network
+
Glibc 2.13
  
[[Image:]]
+
Binutils 2.13
  
 +
Sanitized kernel headers 2.6.36
  
share
+
Your /opt/ directory should contain a directory called:/opt/OSELAS.Toolchain-2011.03.1/.
  
[[Image:]]
+
&nbsp;
  
 +
== The BSP ==
  
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 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 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.
+
You can find the toolchain tar ball
  
The “amcs” share will mount automatically. Any other share has to be mounted manually in the guest:
+
//domainaxy/IL/MC/linux/buildmachine/OSELAS.Toolchain-2011.03.1.tar
  
mount.vboxsf <nowiki><share name> </nowiki><nowiki><mount point> </nowiki>
+
Copy it and extract it in the ubunto&nbsp;:
  
 +
$ sudo tar xvf OSELAS.Toolchain-2011.03.1.tar –C /opt/
  
'''Virtual Linux Configuration'''
+
Now, clone the bsp:
  
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.
+
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&nbsp;:
  
=== Building MC ===
+
cd bsp/
# Make sure amcs share is mounted and contains all required sources. Make sure the toolchain is mounted on /opt.
 
  
+
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:
  
~ # df
+
ptxdist images
  
Filesystem 1K-blocks Used Available Use% Mounted on
+
the image is hd.img. To burn it to the sdcard please:
  
udev 191428 112 191316 0% /dev
+
sudo dd if=platform-i586/images/hd.img of=/dev/sdX
  
tmpfs 76572 144 76428 0% /run
+
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.
  
/dev/sda1 147415 85218 54697 61% /
+
Once you dd’ed, please sync and eject:
  
none 191428 0 191428 0% /tmp
+
sync
  
none 191428 0 191428 0% /var/log
+
eject /dev/sdX
  
none 191428 16 191412 0% /var/run
+
=== Replicate an image ===
  
none 191428 0 191428 0% /var/lock
+
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:
  
none 191428 0 191428 0% /var/tmp
+
#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.
  
tmpfs 191428 112 191316 0% /dev
+
It will appear in the bottom of the dmesg log, for example:
  
/dev/sdb 8256952 1784056 6053468 23% /opt
+
&nbsp;
 +
<nowiki>[422238.883418] sd 9:0:0:0: [sdd] Assuming drive cache: write through</nowiki>
  
none 4217028 1366328 2850700 32% /media
+
&nbsp;
 +
<nowiki>[422238.883423] sd 9:0:0:0: [sdd] Attached SCSI removable disk</nowiki>
  
 +
&nbsp;
 +
<nowiki>[422470.346994] EXT3-fs: barriers not enabled</nowiki>
  
# Change directory to mc sources (inside the amcs share) or clone them from the linux.
+
&nbsp;
# If this is first time you build these sources please:
+
<nowiki>[422470.735075] kjournald starting. </nowiki>
 +
Commit interval 5 seconds &nbsp; <nowiki>[422470.735121] EXT3-fs (sdd1): warning: maximal mount count reached, running e2fsck is recommended</nowiki>
  
$ sh run_configure_all
+
&nbsp;
 +
<nowiki>[422470.736077] EXT3-fs (sdd1): using internal journal</nowiki>
  
# build
+
&nbsp;
 +
<nowiki>[422470.736083] EXT3-fs (sdd1): recovery complete</nowiki>
  
$ make –j2
+
&nbsp;
 +
<nowiki>[422470.737199] EXT3-fs (sdd1): mounted filesystem with ordered data mode</nowiki>
  
Or through the eclipse choose the virtual machine configuration and have eclipse build it for you.
+
The device ( disk ) in my machine is /dev/sdd. It has a single partition called /dev/sdd1.
  
 +
&nbsp;
  
Once you’re done, you need to copy the binary to the target machine if you have external networking.
+
#Now copy the card to a file using dd: for example, if my disk name is /dev/sdb I enter:
  
scp mc root@10.4.20.240:/usr/bin/mc
+
$ dd if=/dev/sdb bs=1M of=/tmp/hd.img
  
else use eclipse terminal to copy.
+
$ sync
  
 +
#Now pull out the source sd card, and place the new card.
 +
#Push back the target flash card, and then:
  
Troubleshoot
+
$ dd if=/tmp/hd.img of=/dev/sdb
  
'''run_configure_all '''
+
$ sync
  
If run_configure_all fails with numerous errors, edit in linux, and remove all ^M signs.
+
&nbsp;
  
 +
= How to edit files in MIB =
  
'''Machine Name'''
+
There are cases where a user needs to edit a text file in the LinuxMIB. LinuxMIB has two editors, nano and vi.
  
If you want to change the machine name, please:
+
vi is considered more powerfull than nano. Yet, I believe that the regular user should start with nano as it is more intuitive.
  
'''Out Of memory'''
+
= Upgrade Linux MIB =
  
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.
+
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.
  
'''Out of disk space'''
+
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 are probably building on the virtual machine disk. Change to share directory.
+
You can list the packages with the following command:
  
 +
dpkg -l
  
== Toolchain ==
+
Currently you cannot uninstall a package, you have to remove the files manually.I believe it is a pengutronix bug.
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
+
== Control MC Start ==
  
Glibc 2.13
+
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.
  
Binutils 2.13
+
There are two ways to disable automatic starting:
  
Sanitized kernel headers 2.6.36
+
&nbsp;
  
Your /opt/ directory should contain a directory called:/opt/OSELAS.Toolchain-2011.03.1/.  
+
#Each time you boot.  
  
 +
&nbsp;
 +
<nowiki># ~ /etc/init.d/mc stop</nowiki>
  
== The BSP ==
+
#Edit /etc/init.d/mc script and remark the mc launching as follows:
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
+
start)
  
Copy it and extract it in the ubunto :
+
/etc/init.d/run_config
  
$ sudo tar xvf OSELAS.Toolchain-2011.03.1.tar –C /opt/
+
&nbsp;
 +
<nowiki># nohup /bin/sh /usr/bin/mc.sh &</nowiki>
  
 +
Add # before the nohup as depicted in the line above.
  
Now, clone the bsp:
+
= Debugging =
  
git clone [mailto:git@10.4.20.38:/home/git/bsp.git git@10.4.20.38:/home/git/bsp.git]
+
Debugging mc can mostly with eclipse. Please refer to eclipse documentation to learn how to do that.
  
to build the bsp master branch :
+
== Logs ==
  
cd bsp/
+
In addition to the log files in /RAM file system. We added a linux-like logger which can be found at /var/syslog.
  
ptxdist go
+
&nbsp;
  
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:
+
== Core files ==
  
ptxdist images
+
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.
  
the image is hd.img. To burn it to the sdcard please:
+
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:
  
sudo dd if=platform-i586/images/hd.img of=/dev/sdX
+
gdb mc coredump
  
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.
+
&nbsp;
  
Once you dd’ed, please sync and eject:
+
== Memory Detector ==
  
sync
+
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.
  
eject /dev/sdX
+
&nbsp;
  
=== Replicate an image ===
+
== MC cli ==
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.
+
MC Linux is shipped with a telnet server. This telnet server resembles the vxworks terminal.
# 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:
+
To login please:
  
<nowiki>[422238.883418] sd 9:0:0:0: [sdd] Assuming drive cache: write through</nowiki>
+
~ # telnet localhost:8000
  
<nowiki>[422238.883423] sd 9:0:0:0: [sdd] Attached SCSI removable disk</nowiki>
+
Entering character mode
  
<nowiki>[422470.346994] EXT3-fs: barriers not enabled</nowiki>
+
Escape character is '^]'.
  
<nowiki>[422470.735075] kjournald starting. </nowiki>Commit interval 5 seconds
+
AMCS shell
  
<nowiki>[422470.735121] EXT3-fs (sdd1): warning: maximal mount count reached, running e2fsck is recommended</nowiki>
+
User name is root and password qwerty.
  
<nowiki>[422470.736077] EXT3-fs (sdd1): using internal journal</nowiki>
+
Username: root
  
<nowiki>[422470.736083] EXT3-fs (sdd1): recovery complete</nowiki>
+
Password:
  
<nowiki>[422470.737199] EXT3-fs (sdd1): mounted filesystem with ordered data mode</nowiki>
+
The telnet is evolving and the command may differ from one version to another but to get help you can simply type help.
  
 +
> help
  
The device ( disk ) in my machine is /dev/sdd. It has a single partition called /dev/sdd1.
+
Commands available:
  
 +
help Show available commands
  
# Now copy the card to a file using dd: for example, if my disk name is /dev/sdb I enter:
+
logout Disconnect
  
$ dd if=/dev/sdb bs=1M of=/tmp/hd.img
+
history Show a list of previously run commands
  
$ sync
+
threads print all threads
  
# Now pull out the source sd card, and place the new card.
+
stack trace print the stack of a given thread
# Push back the target flash card, and then:
 
  
$ dd if=/tmp/hd.img of=/dev/sdb
+
p print a symbol
  
$ sync
+
exit exit the process
  
 +
>
  
= How to edit files in MIB =
+
&nbsp;
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.
+
== Profiling ==
  
= Upgrade Linux MIB =
+
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.
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.
+
To use oprofile please:
  
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.
+
$ opcontrol –reset
  
You can list the packages with the following command:
+
$ opcontrol –deinit
  
dpkg -l
+
$ opcontrol –init
  
Currently you cannot uninstall a package, you have to remove the files manually.I believe it is a pengutronix bug.
+
Now to choose type of event you should make sure your processor support this type of event – if any.
  
== Control MC Start  ==
+
$ opcontrol –list-events
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:
+
Let say you wish to check memory references.
  
 +
$ opcontrol –event:DATA_MEM_REFS:30000
  
# Each time you boot.
+
The above command sets the event memory references each time the a a hardware counter finish counting to 30000.
  
<nowiki># ~ /etc/init.d/mc stop</nowiki>
+
$ opcontrol –session-dir=/home/myoprofile
  
# Edit /etc/init.d/mc script and remark the mc launching as follows:
+
$ opcontrol –sparate=cpu
  
+
$ opcontrol –callgraph=10
  
start)
+
$ opcontrol –novmlinux
  
/etc/init.d/run_config
+
$ opcontrol –start
  
<nowiki># nohup /bin/sh /usr/bin/mc.sh &</nowiki>
+
./prog..
  
 +
$ opcontrol –stop
  
Add # before the nohup as depicted in the line above.
+
Now copy the entire profiling results to your local machine home user.
  
= Debugging =
+
$ opreport –session-dir=/home/raz/myprofile
Debugging mc can mostly with eclipse. Please refer to eclipse documentation to learn how to do that.
 
  
== Logs ==
+
CPU_CLK_UNHALT...|LLC_MISSES:466500|
In addition to the log files in /RAM file system. We added a linux-like logger which can be found at /var/syslog.
 
  
 +
samples|&nbsp;%| samples|&nbsp;%|
  
== Core files ==
+
&nbsp;
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.
+
<nowiki>------------------------------------</nowiki>
  
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:
+
943 100.000 1 100.000 prog
  
gdb mc coredump
+
CPU_CLK_UNHALT...|LLC_MISSES:466500|
  
 +
samples|&nbsp;%| samples|&nbsp;%|
  
== Memory Detector ==
+
&nbsp;
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.
+
<nowiki>------------------------------------</nowiki>
 
 
 
 
== 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| %|
 
 
 
<nowiki>------------------------------------</nowiki>
 
 
 
943 100.000 1 100.000 prog
 
 
 
CPU_CLK_UNHALT...|LLC_MISSES:466500|
 
 
 
samples| %| samples| %|
 
 
 
<nowiki>------------------------------------</nowiki>
 
  
 
  709 75.1856 1 100.000 prog
 
  709 75.1856 1 100.000 prog
  
 
  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