get list of most recently installed packages with dpkg log

# zcat -f /var/log/dpkg.log*|grep 'status installed'|awk '{print $1" "$5}'|sort -u |less
2015-05-04 ffmpeg
2015-05-04 libavcodec52
2015-05-04 libavdevice52
2015-05-04 libavfilter0
2015-05-04 libavformat52
2015-05-04 libavutil49
2015-05-04 libdc1394-22
2015-05-04 libdirac-encoder0
2015-05-04 libdirectfb-1.2-9
2015-05-04 libfaad2
2015-05-04 libgsm1
2015-05-04 libogg0
2015-05-04 libopenjpeg2
2015-05-04 liborc-0.4-0
2015-05-04 libpostproc51
2015-05-04 libraw1394-11
2015-05-04 libschroedinger-1.0-0
2015-05-04 libsdl1.2debian
2015-05-04 libsdl1.2debian-alsa
2015-05-04 libspeex1
2015-05-04 libsvga1
2015-05-04 libswscale0
2015-05-04 libtheora0
2015-05-04 libusb-1.0-0
2015-05-04 libvorbis0a
2015-05-04 libvorbisenc2
2015-05-04 libx86-1
2015-05-04 man-db

IRQBALANCE_BANNED_CPUS explained and working on Ubuntu 14.04

Despite the explanation and examples in the manual, there is still some confusion on how to use irqbalance to move interrupts to a specific set of CPUs. (For the sake of simplicity, I use the words CPUs in the same way Linux sees them; it doesn’t care whether they are physical, or cores, or threads.)

Let’s start with a box that has 8 CPUs

# grep processor /proc/cpuinfo 
processor       : 0
processor       : 1
processor       : 2
processor       : 3
processor       : 4
processor       : 5
processor       : 6
processor       : 7

irqbalance uses a variable set at runtime ( IRQBALANCE_BANNED_CPUS ) to make decisions which CPUs should not receive interrupts. IRQBALANCE_BANNED_CPUS is a hexidecimal representation of a “bitmask” to ignore certain CPUs when deciding which CPU to use for a specific interrupt. If we have a box with 8 cpus we will need to start with a binary string 8 digits long: “00000000”

0 means “allow interrupts on this CPU”
1 means “prevent interrupts on this CPU”

In the case of “00000000” we are allowing interrupts on all 8 CPUs. In binary numbers the least significant bit is on the right, mapping the CPUs like this:
“CPU7 CPU6 CPU5 CPU4 CPU3 CPU2 CPU1 CPU0″

Let’s say we want to allow interrupts on the 6th and 7th CPU, and exclude the 1st, 2nd, 3rd, 4th, 5th, and 8th CPU from interrupts. Our bitmask in this case would look like this”

   1    0    0    1    1    1    1    1
"CPU7 CPU6 CPU5 CPU4 CPU3 CPU2 CPU1 CPU0"

This can get tricky. Most humans start counting from 1 but computers start counting at 0. So be careful: the 7th CPU is CPU6 in this case.

Now that we have our bitmask of “10011111” we need to convert it to hexadecimal. You could use this handy bash function:

#
bin2hex() {
   echo "obase=16;ibase=2;$1"|bc
}
# bin2hex 10011111
9F
#

So now we can edit /etc/default/irqbalance and set the variable:

export IRQBALANCE_BANNED_CPUS="9F" 

NOTE: I have been able to get irqbalance working on Ubuntu 14.04 trusty only by exporting the IRQBALANCE_BANNED_CPUS variable using “export” in /etc/default/irqbalance AND using the latest (at the time of this writing) irqbalance 1.0.9

Once you understand how the CPUs translate to the bitmask you can extrapolate out from there and come up with a way to ban specific CPUs from irqbalance for any number of CPUs.

identify hard drive serial number

# hdparm -I /dev/sda | grep Serial
        Serial Number:      WD-WCAL71856931
#
# smartctl -a /dev/sda | grep 'Serial Number'
Serial Number:    WD-WCAL71856931
#

These utilities are from the hdparm and smartmontools packages:

# dpkg -l | grep hdparm
ii  hdparm                              9.32-1                       tune hard disk parameters for high performance
# dpkg -l | grep smart
ii  smartmontools                       5.39.1+svn3124-2             control and monitor storage systems using S.M.A.R.T.
# 

extract Debian package

To extract a Debian package and view it’s contents first make a temporary directory to work in, move the .deb file to that location, and extract it:

# mkdir /tmp/rssh
# mv rssh_2.3.2-13squeeze3_i386.deb /tmp/rssh
# cd /tmp/rssh
# ar vx rssh_2.3.2-13squeeze3_i386.deb 
# ls -l
total 128
-rw-r--r-- 1 root root  5094 Jun  5 09:13 control.tar.gz
-rw-r--r-- 1 root root 54142 Jun  5 09:13 data.tar.gz
-rw-r--r-- 1 root root     4 Jun  5 09:13 debian-binary
-rw-r--r-- 1 root root 59428 Nov 27  2012 rssh_2.3.2-13squeeze3_i386.deb

As you can see, the contents have been extracted, and we see the typical 3 files, that are needed for a proper Debian package. The debian-binary file contains information about the version of the package. The control.tar.gz file contains configuration scripts, and tells dpkg about how to install and configure the package. data.tar.gz is the one we are interested in. It contains the actual files that will be set in place at time of installation. The contents of data.tar.gz mirror the typical Linux filesystem tree. Make a directory for the contents of data.tar.gz and extract the tarball into it.


# mkdir debroot
# tar -C debroot -xzf data.tar.gz 
# find debroot/ -ls
   950    4 drwxr-xr-x   4 root     root         4096 Nov 22  2012 debroot/
   956    4 drwxr-xr-x   3 root     root         4096 Nov 22  2012 debroot/etc
   960    4 -rw-r--r--   1 root     root         1867 Nov 22  2012 debroot/etc/rssh.conf
   957    4 drwxr-xr-x   3 root     root         4096 Nov 22  2012 debroot/etc/logcheck
   958    4 drwxr-xr-x   2 root     root         4096 Nov 22  2012 debroot/etc/logcheck/ignore.d.server
   959    4 -rw-r--r--   1 root     root          455 Nov 22  2012 debroot/etc/logcheck/ignore.d.server/rssh
   961    4 drwxr-xr-x   5 root     root         4096 Nov 22  2012 debroot/usr
   965    4 drwxr-xr-x   5 root     root         4096 Nov 22  2012 debroot/usr/share
   971    4 drwxr-xr-x   3 root     root         4096 Nov 22  2012 debroot/usr/share/doc
   972    4 drwxr-xr-x   3 root     root         4096 Nov 22  2012 debroot/usr/share/doc/rssh
   977    8 -rw-r--r--   1 root     root         4162 Nov 27  2005 debroot/usr/share/doc/rssh/SECURITY.gz
   975    4 -rw-r--r--   1 root     root         2207 Nov 22  2012 debroot/usr/share/doc/rssh/README.Debian
   981    4 -rw-r--r--   1 root     root           46 Jul 21  2003 debroot/usr/share/doc/rssh/TODO
   976    8 -rw-r--r--   1 root     root         6297 Nov 22  2012 debroot/usr/share/doc/rssh/changelog.Debian.gz
   983    4 -rw-r--r--   1 root     root          680 Nov 22  2012 debroot/usr/share/doc/rssh/NEWS.Debian.gz
   973    4 -rw-r--r--   1 root     root         2575 Nov 22  2012 debroot/usr/share/doc/rssh/copyright
   979    4 drwxr-xr-x   2 root     root         4096 Nov 22  2012 debroot/usr/share/doc/rssh/examples
   980    8 -rwxr-xr-x   1 root     root         6479 Nov 22  2012 debroot/usr/share/doc/rssh/examples/mkchroot.sh
   974    8 -rw-r--r--   1 root     root         4409 Nov 27  2005 debroot/usr/share/doc/rssh/CHROOT.gz
   982    4 -rw-r--r--   1 root     root         1488 Jan  3  2006 debroot/usr/share/doc/rssh/changelog.gz
   978    4 -rw-r--r--   1 root     root         1636 Dec 29  2004 debroot/usr/share/doc/rssh/README
   984    4 drwxr-xr-x   2 root     root         4096 Nov 22  2012 debroot/usr/share/rssh
   985    4 -rwxr-xr-x   1 root     root         1321 Nov 22  2012 debroot/usr/share/rssh/conf_convert
   966    4 drwxr-xr-x   4 root     root         4096 Nov 22  2012 debroot/usr/share/man
   969    4 drwxr-xr-x   2 root     root         4096 Nov 22  2012 debroot/usr/share/man/man1
   970    8 -rw-r--r--   1 root     root         5771 Nov 22  2012 debroot/usr/share/man/man1/rssh.1.gz
   967    4 drwxr-xr-x   2 root     root         4096 Nov 22  2012 debroot/usr/share/man/man5
   968    4 -rw-r--r--   1 root     root         2277 Nov 22  2012 debroot/usr/share/man/man5/rssh.conf.5.gz
   986    4 drwxr-xr-x   2 root     root         4096 Nov 22  2012 debroot/usr/bin
   987   24 -rwxr-xr-x   1 root     root        22288 Nov 22  2012 debroot/usr/bin/rssh
   962    4 drwxr-xr-x   3 root     root         4096 Nov 22  2012 debroot/usr/lib
   963    4 drwxr-xr-x   2 root     root         4096 Nov 22  2012 debroot/usr/lib/rssh
   964   24 -rwxr-xr-x   1 root     root        21184 Nov 22  2012 debroot/usr/lib/rssh/rssh_chroot_helper

Now we can browse, and take a look at the contents of the files.

download currently installed Debian package without reinstalling

Sometimes it’s necessary to download a Debian package from a repository without actually intsalling or reinstalling it.

# apt-get -d --reinstall -o=dir::cache=/tmp install rssh
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Suggested packages:
  cvs rdist subversion makejail
The following NEW packages will be installed:
  rssh
0 upgraded, 1 newly installed, 0 to remove and 102 not upgraded.
Need to get 59.4 kB of archives.
After this operation, 225 kB of additional disk space will be used.
Get:1 http://ftp.us.debian.org/debian/ squeeze/main rssh i386 2.3.2-13squeeze3 [59.4 kB]
Fetched 59.4 kB in 0s (178 kB/s)
Download complete and in download only mode
#

This downloaded the rssh .deb package to /tmp/archives without reinstalling over the existing version.

# ls -l /tmp/archives
total 64
-rw-r----- 1 root root     0 Jun  5 09:05 lock
drwxr-xr-x 2 root root  4096 Jun  5 09:05 partial
-rw-r--r-- 1 root root 59428 Nov 27  2012 rssh_2.3.2-13squeeze3_i386.deb

get drive serial numbers from NetApp DS4243 shelves strapped to Linux server

When doing data recovery on a failed 3Ware RAID group, I utilized a couple spare NetApp DS4243 shelves. I put all the SATA drives into brackets, popped a quad port SAS card into a 1U server, and booted my rescue image from the network. The Debian OS was able to see each individual drive, at which point I could make ddrescue copies, and edit the 3Ware DCB metadata using hexedit. Keeping everything straight was quite a challenge. This one liner helped me find all the serials, and get the copies sorted out:

# for i in `ls /dev | grep sd | sed -e 's/[0-9]//' | sort -u`; do echo -n "/dev/$i " ; smartctl --all /dev/$i | grep "Serial number" | awk '{print " --- " $3}'; done;
/dev/sdaa  --- 9VS0R3T4
/dev/sdab  --- 9VS3SSJE
/dev/sdac  --- 9VS2K1DY
/dev/sdad  --- 9VS07FMW
/dev/sdae  --- 9VS402AA
/dev/sdaf  --- 9VS3V74N
/dev/sdag  --- 9VS388JX
/dev/sdah  --- 9VS2AQ9A
/dev/sdai  --- 9VS3THY9
/dev/sdaj  --- 9VS4EE3T
/dev/sdak  --- 9VS0FXWA
/dev/sdal  --- 9VS34DAD
/dev/sdam  --- 9VS45C9J
/dev/sdan  --- 9VS4L45S
/dev/sdao  --- 9VS2K9K1
/dev/sdap  --- 9VS2D631
/dev/sdaq  --- 9VS2L1BK
/dev/sdar  --- 9VS4DYDB
/dev/sdas  --- 9VS3T33R
/dev/sdat  --- 9VS3YE1K
/dev/sdc  --- 9VS1HWAM
/dev/sdd  --- 9VS1J9F3
/dev/sde  --- 9VS1L0FY
/dev/sdf  --- 9VS1H3RB
/dev/sdg  --- 9VS1JNPW
/dev/sdh  --- 9VS1GWGK
/dev/sdi  --- 9VS1DLZZ
/dev/sdj  --- 9VS1FSRD
/dev/sdk  --- 9VS3A8GZ
/dev/sdl  --- 9VS1L8ZZ
/dev/sdm  --- 9VS1JE7E
/dev/sdn  --- 9VS1CHE1
/dev/sdo  --- 9VS295R5
/dev/sdp  --- 9VS1HR8P
/dev/sdq  --- 9VS1EJQW
/dev/sdr  --- 9VS1A4V5
/dev/sds  --- 9VS1JGP8
/dev/sdt  --- 9VS1HPGB
/dev/sdu  --- 9VS1JAWZ
/dev/sdv  --- 9VS1JG8K
/dev/sdw  --- 9VS1JA51
/dev/sdx  --- WD-WMATV4441330
/dev/sdy  --- 9VS38GT3
/dev/sdz  --- 9VS4SQJX
#

chkconfig –list for Debian using sysv-rc-conf

In Redhat based distros you can use chkconfig to see what daemons are supposed to run at what run levels. In Debian you can use the sysv-rc-conf package.

Install it:

# apt-get install --yes sysv-rc-conf

Run it:



# sysv-rc-conf

┌ SysV Runlevel Config   -: stop service  =/+: start service  h: help  q: quit ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│                                                                                                                                                                                                                                           │
│ service      1       2       3       4       5       0       6       S                                                                                                                                                                    │
│ ----------------------------------------------------------------------------                                                                                                                                                              │
│ acpid       [ ]     [X]     [X]     [X]     [X]     [ ]     [ ]     [ ]                                                                                                                                                                   │
│ bootlogd    [ ]     [ ]     [ ]     [ ]     [ ]     [ ]     [ ]     [X]                                                                                                                                                                   │
│ bootlogs    [X]     [X]     [X]     [X]     [X]     [ ]     [ ]     [ ]                                                                                                                                                                   │
│ console-s$  [ ]     [ ]     [ ]     [ ]     [ ]     [ ]     [ ]     [X]                                                                                                                                                                   │
│ cron        [ ]     [X]     [X]     [X]     [X]     [ ]     [ ]     [ ]                                                                                                                                                                   │
│ fancontrol  [ ]     [X]     [X]     [X]     [X]     [ ]     [ ]     [ ]                                                                                                                                                                   │
│ halt        [ ]     [ ]     [ ]     [ ]     [ ]     [ ]     [ ]     [ ]                                                                                                                                                                   │
│ hdparm      [ ]     [ ]     [ ]     [ ]     [ ]     [ ]     [ ]     [X]                                                                                                                                                                   │
│ ifupdown    [ ]     [ ]     [ ]     [ ]     [ ]     [ ]     [ ]     [X]                                                                                                                                                                   │
│ ifupdown-$  [ ]     [ ]     [ ]     [ ]     [ ]     [ ]     [ ]     [X]                                                                                                                                                                   │
│ kbd         [ ]     [ ]     [ ]     [ ]     [ ]     [ ]     [ ]     [X]                                                                                                                                                                   │
│ keyboard-$  [ ]     [ ]     [ ]     [ ]     [ ]     [ ]     [ ]     [X]                                                                                                                                                                   │
│ killprocs   [X]     [ ]     [ ]     [ ]     [ ]     [ ]     [ ]     [ ]                                                                                                                                                                   │
│ lm-sensors  [ ]     [ ]     [ ]     [ ]     [ ]     [ ]     [ ]     [X]                                                                                                                                                                   │
│ lvm2        [ ]     [ ]     [ ]     [ ]     [ ]     [ ]     [ ]     [X]                                                                                                                                                                   │
│ mdadm       [ ]     [X]     [X]     [X]     [X]     [ ]     [ ]     [ ]                                                                                                                                                                   │
│ mdadm-raid  [ ]     [ ]     [ ]     [ ]     [ ]     [ ]     [ ]     [X]                                                                                                                                                                   │
│ module-in$  [ ]     [ ]     [ ]     [ ]     [ ]     [ ]     [ ]     [X]                                                                                                                                                                   │
│ mountover$  [ ]     [ ]     [ ]     [ ]     [ ]     [ ]     [ ]     [X]                                                                                                                                                                   │
│ multipath$  [ ]     [X]     [X]     [X]     [X]     [ ]     [ ]     [ ]                                                                                                                                                                   │
│ multipath$  [ ]     [ ]     [ ]     [ ]     [ ]     [ ]     [ ]     [X]                                                                                                                                                                   │
│ mysql       [ ]     [ ]     [ ]     [ ]     [ ]     [ ]     [ ]     [ ]                                                                                                                                                                   │
│ ndbd        [ ]     [ ]     [ ]     [ ]     [ ]     [ ]     [ ]     [ ]                                                                                                                                                                   │
│ networking  [ ]     [ ]     [ ]     [ ]     [ ]     [ ]     [ ]     [X]                                                                                                                                                                   │
│ nfs-common  [ ]     [X]     [X]     [X]     [X]     [ ]     [ ]     [X]                                                                                                                                                                   │
│ ntp         [ ]     [X]     [X]     [X]     [X]     [ ]     [ ]     [ ]                                                                                                                                                                   │
│ open-iscsi  [ ]     [ ]     [ ]     [ ]     [ ]     [ ]     [ ]     [X]                                                                                                                                                                   │
│ portmap     [ ]     [X]     [X]     [X]     [X]     [ ]     [ ]     [X]                                                                                                                                                                   │
│ postfix     [ ]     [X]     [X]     [X]     [X]     [ ]     [ ]     [ ]                                                                                                                                                                   │
│ procps      [ ]     [ ]     [ ]     [ ]     [ ]     [ ]     [ ]     [X]                                                                                                                                                                   │
│ rc.local    [ ]     [X]     [X]     [X]     [X]     [ ]     [ ]     [ ]                                                                                                                                                                   │
│ reboot      [ ]     [ ]     [ ]     [ ]     [ ]     [ ]     [ ]     [ ]                                                                                                                                                                   │
│ rmnologin   [ ]     [X]     [X]     [X]     [X]     [ ]     [ ]     [ ]                                                                                                                                                                   │
│ rsyslog     [ ]     [X]     [X]     [X]     [X]     [ ]     [ ]     [ ]                                                                                                                                                                   │
│ sendsigs    [ ]     [ ]     [ ]     [ ]     [ ]     [ ]     [ ]     [ ]                                                                                                                                                                   │
│ single      [X]     [ ]     [ ]     [ ]     [ ]     [ ]     [ ]     [ ]                                                                                                                                                                   │
│ snmpd       [ ]     [X]     [X]     [X]     [X]     [ ]     [ ]     [ ]                                                                                                                                                                   │
│ ssh         [ ]     [X]     [X]     [X]     [X]     [ ]     [ ]     [ ]                                                                                                                                                                   │
│ stop-boot$  [ ]     [X]     [X]     [X]     [X]     [ ]     [ ]     [ ]                                                                                                                                                                   │
│ stop-boot$  [ ]     [ ]     [ ]     [ ]     [ ]     [ ]     [ ]     [X]                                                                                                                                                                   │
│ udev        [ ]     [ ]     [ ]     [ ]     [ ]     [ ]     [ ]     [X]                                                                                                                                                                   │
│ udev-mtab   [ ]     [ ]     [ ]     [ ]     [ ]     [ ]     [ ]     [X]                                                                                                                                                                   │
│ umountfs    [ ]     [ ]     [ ]     [ ]     [ ]     [ ]     [ ]     [ ]                                                                                                                                                                   │
│ umountroot  [ ]     [ ]     [ ]     [ ]     [ ]     [ ]     [ ]     [ ]                                                                                                                                                                   │
│ urandom     [ ]     [ ]     [ ]     [ ]     [ ]     [ ]     [ ]     [X]  

This shows a list of Runlevel configuration for daemons. For most user land stuff, you will just want 2, 3, 4, and 5. You can edit the list, and changes will be made when you exit. This is a graphical alternative to update-rc.d