Showing posts with label Linux Tips Hacks and Guides. Show all posts
Showing posts with label Linux Tips Hacks and Guides. Show all posts

Friday, September 24, 2021

Gnome Terminal failed to run after upgrading default Python 3 interpreter to Python 3.7 in Ubuntu 18.04

Ubuntu 18.04 comes with Python 3.6 by default. You might be inclined to do a sid-by-side installation with Python 3.7 as explained at: https://blog.globaletraining.com/2020/06/09/how-to-upgrade-to-python-3-7-on-ubuntu-18-x/ Then you might try to switch the default Python3 interpreter from Python 3.6 to Python 3.7 by using $ sudo update-alternatives --config python3 . However, this could result in unwanted side effect which made Gnome Terminal failed to open/run. 

You can fix this issue by editing this file: /usr/bin/gnome-terminal. This file by default uses /usr/bin/python3 as the python interpreter. You need to change the gnome-terminal script to use /usr/bin/python3.6 as its python interpreter, as explained over at: https://askubuntu.com/questions/1132349/terminal-not-opening-up-after-upgrading-python-to-3-7, i.e. change the #!/usr/bin/python3 line to #!/usr/bin/python3.6 and you should be OK afterward.

Sunday, September 12, 2021

Installing TensorRT 7.2.1, cuDNN 8.0.4 and Cuda 11.0 update 1 in Ubuntu 18.04 (x86_64)

  1. Make sure you have up-to-date Nvidia display driver. You need v4.50.x or newer for Cuda 11 to work (I'm using v4.70.x). You can update it using standard Ubuntu repository or via Nvidia Ubuntu ppa if it's not yet up-to-date, as explained over at: https://linuxconfig.org/how-to-install-the-nvidia-drivers-on-ubuntu-18-04-bionic-beaver-linux. In my case, I'm using standard Ubuntu repository without any problem. Make sure to follow the driver installation steps correctly if your machine is using UEFI secure boot and Nvidia PPA driver. Especially in the step that asks for password; make sure you remember the password that you entered because you will be asked the same password once you restart your machine to complete the driver installation.   
  2. Follow Cuda 11 update 1 installation guide at: https://docs.nvidia.com/cuda/archive/11.0/cuda-installation-guide-linux/index.html. Note: You can install certain version of Cuda in Ubuntu 18.04 as follows (we are using Cuda 11.1 as an example here):
    wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-ubuntu1804.pin
    sudo mv cuda-ubuntu1804.pin /etc/apt/preferences.d/cuda-repository-pin-600
    wget https://developer.download.nvidia.com/compute/cuda/11.1.0/local_installers/cuda-repo-ubuntu1804-11-1-local_11.1.0-455.23.05-1_amd64.deb
    sudo dpkg -i cuda-repo-ubuntu1804-11-1-local_11.1.0-455.23.05-1_amd64.deb
    sudo apt-key add /var/cuda-repo-ubuntu1804-11-1-local/7fa2af80.pub
    sudo apt-get update
    sudo apt-get install cuda-11.1
    
    by using "cuda-11.1" parameter in the last command, that specific version of cuda will be installed instead of newest version.
  3. Follow cuDNN 8.0.4 installation guide at: https://docs.nvidia.com/deeplearning/cudnn/archives/cudnn-804/install-guide/index.html#installlinux-deb
  4. Follow TensorRT 7.2.1 installation guide at https://docs.nvidia.com/deeplearning/tensorrt/archives/tensorrt-721/install-guide/index.html#installing-debian up-to the "sudo apt-get update" step (before the "sudo apt-get install tensorrt" step). Then, disable nvidia compute deb sources (https://developer.download.nvidia.com/compute/*) from your ubuntu sources list file(s), except the ones in the tensorrt deb sources file. The tensorrt deb source file is usually named: /etc/apt/sources.list.d/nv-tensorrt-cudaXX.x*.list. You can disable the "nvidia compute" deb sources by commenting the line(s), i.e. adding a "#" (without the quotes) to the beginning of each line in the deb sources file (/etc/apt/sources.list.d/cuda.list, etc.) that points to https://developer.download.nvidia.com/compute/* URL.  Then, install tensorrt along with its components normally ("sudo apt-get install tensorrt", etc.). Once tensorrt installation finished, make sure to enable nvidia compute deb sources as before, i.e. by deleting the comments (#) that you add in the beginning of the line(s) of the deb sources file that points to https://developer.download.nvidia.com/compute/*. This TensorRT 7.2.1 installation fix is explained over at: https://github.com/NVIDIA/TensorRT/issues/792. This is the excerpt:    
    For those who tried this approach, and yet the problem didn't get solved, it seems like there are more than one place storing nvidia deb-src links (https://developer.download.nvidia.com/compute/*) and these links overshadowed the actual deb link of dependencies corresponding with your tensorrt version.
Just comment out these links in every possible place inside /etc/apt directory at your system (for instance: /etc/apt/sources.list , /etc/apt/sources.list.d/cuda.list , /etc/apt/sources.list.d/cuda_learn.list , /etc/apt/sources.list.d/nvidia-ml.list (except your nv-tensorrt deb-src link)) before running "apt install tensorrt" then everything works like a charm (uncomment these links after installation completes).

Bonus Fix 1: Python onnx library error

You might encounter onnx data type error shown below after your tensorrt is successfully installed in python:

TypeError: 1.0 has type numpy.float32, but expected one of: int, long, float

The error very probably caused by old protobuf version. You need to update it with pip3 via this command: pip3 install protobuf -U. For more details, see: https://github.com/onnx/onnx/issues/2534


Bonus Fix 2: Cuda 11.0 missing libcusolver.so.10

You might encounter this error in tensorflow 2.4+ application:

Could not load dynamic library 'libcusolver.so.10'

It says you have missing libcusolver.so.10.Well, actually the library is non-existent in Cuda 11 and the solution is to create symbolic link to libcusolver.so.11 which is named libcusolver.so.10 in your Cuda 11 installation. It should work, as explained over at: https://github.com/tensorflow/tensorflow/issues/45263. As for where you could find libcusolver.so.11, it depends on the Cuda 11.0 version installed in your machine. In Cuda 11.0 update 1, libcusolver.so.11 is located at /usr/local/cuda-11.4/lib64. The directory is referred to indirectly by /usr/local/cuda and /usr/local/cuda-11 symbolic links. It's a bit hairy and you need to create the libcusolver.10.so symbolic link at /usr/local/cuda-11.4/lib64 that points to libcusolver.so.11.

Sunday, September 5, 2021

Fixing "RTL8822CE wireless adapter doesn't work" on Ubuntu 18.04

 RTL8822CE wifi adapter doesn't work out of the box in Ubuntu 18.04 due to missing firmware, not because the driver is not included in Ubuntu 18.04. The fix requires you to be able to download the required firmware from kernel.org and copying the firmware to your Ubuntu 18.04 firmware directory.  To do that, first, you have to make sure the machine have an internet connection before you do the steps below, either via the machine ethernet connector or some other means, in my case I have a spare USB WiFi adapter that works out of the box in Ubuntu 18.04 to do this. Then, configure the Wifi firmware like this:

sudo apt install git
git clone git://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git
sudo cp linux-firmware/rtw88/rtw8822c_wow_fw.bin /lib/firmware/rtw88 
Another approach would be to copy the file manually via USB thumbdrive, if you can't connect the connect the machine to the internet via some other means. 
This fix is elaborated over at: https://askubuntu.com/questions/1309905/rtl8822ce-wireless-adapter-doesnt-work-on-ubuntu-18-04 
 

Tuesday, March 14, 2017

Free "Remote Desktop" Setup for Windows Home Editions

As you might already know, all Windows Home Edition variants don't support Microsoft Remote Desktop Protocol (RDP) https://en.wikipedia.org/wiki/Remote_Desktop_Protocol. Therefore, you need different software stack as a solution to the problem.

Enter VNC (https://en.wikipedia.org/wiki/Virtual_Network_Computing). VNC is another protocol to remotely control Windows desktop. VNC can be used as RDP replacement, especially, if you want to control Windows Home desktop from Linux. This is a verified setup that I have tested:

  • The VNC client, i.e. the machine that will be used to control the Windows Home desktop, runs Linux. In my case it's a XFCE4 window manager. I'm using Vinagre (https://wiki.gnome.org/Apps/Vinagre/) as the client application to access the remote VNC server. 
  • The VNC server, i.e. the machine that runs Windows Home OS, is running TigerVNC(http://tigervnc.org) as the application that implements VNC server functionality. TigerVNC is very well maintained as you can see in their github page: https://github.com/TigerVNC/tigervnc.
Hopefully, this is helpful for those thinking about remotely controlling a Windows Home desktop machine.

Monday, February 13, 2017

Fix for systemd v232 build failure when using GNU gperf 3.1

You might encounter the build failure in this post title if you're the kind that roll your own Linux Systemd. I encountered it while building Systemd package for my Arch Linux SELinux variant.

The culprit is mismatch in lookup functions declaration--hash functions--generated by GNU gperf version 3.1 and the function declaration in Systemd version 232. I managed to complete the build after creating and using this patch:https://github.com/pinczakko/systemd-gperf-3.1-patch. As for whether the patch is working or not, well, it works without problems in my machine. Nonetheless, it's just a very minor patch.

UPDATE:
------------
This issue has been fixed just now in systemd v232. See: https://github.com/systemd/systemd/commit/c9f7b4d356a453a01aa77a6bb74ca7ef49732c08

UPDATE 2:
---------------
You can add the change as cherry-picked git change to the PKGBUILD to fix this issue in Arch Linux SELinux package. This is the diff (or patch):
diff --git a/PKGBUILD b/PKGBUILD
index 47d82d1..1e57ec7 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -61,6 +61,7 @@ _backports=(
   'cfed63f60dd7412c199652825ed172c319b02b3c'  # nspawn: fix exit code for --help and --version (#4609)
   '3099caf2b5bb9498b1d0227c40926435ca81f26f'  # journal: make sure to initially populate the space info cache (#4807)
   '3d4cf7de48a74726694abbaa09f9804b845ff3ba'  # build-sys: check for lz4 in the old and new numbering scheme (#4717)
+  'c9f7b4d356a453a01aa77a6bb74ca7ef49732c08'  # build-sys: add check for gperf lookup function signature (#5055)
 )
  _validate_tag() {
Hopefully, this temporary fix could help before the official fix is included in the main Arch Linux package.

Monday, June 6, 2016

Arch Linux cpupower Missing Library Temporary Fix

If you are experiencing the issue described at https://bbs.archlinux.org/viewtopic.php?id=213404 (copied here for your convenience--courtesy of bartbkr):
After a recent upgrade, when I attempt to use cpupower, I get the following
message:
    cpupower: /usr/lib/libpci.so.3: verion `LIBPCI_3.5' not found (required by cpupower)
I haven't changed any of the setting for cpupower recently and everything was
running smoothly before. Now I can't query the cpu settings any longer.
$ ls /usr/lib/libpci.so*
        /usr/lib/libpci.so
        /usr/lib/libpci.so.3
        /usr/lib/libpci.so.3.4.1

Then, the temporary solution is to downgrade cpupower to version 4.6.1. Follow the general downgrade guide at https://wiki.archlinux.org/index.php/Downgrading_packages. For comparison sake, this is the log of failed cpupower at start-up in my machine:
root@jeez /var/cache/pacman/pkg
 # systemctl status cpupower.service
— cpupower.service - Apply cpupower configuration
   Loaded: loaded (/usr/lib/systemd/system/cpupower.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Mon 2016-06-06 22:07:38 SGT; 44min ago
  Process: 328 ExecStart=/usr/lib/systemd/scripts/cpupower (code=exited, status=1/FAILURE)
 Main PID: 328 (code=exited, status=1/FAILURE)

Jun 06 22:07:37 jeez systemd[1]: Starting Apply cpupower configuration...
Jun 06 22:07:37 jeez cpupower[328]: cpupower: /usr/lib/libpci.so.3: version `LIBPCI_3.5'
Jun 06 22:07:38 jeez systemd[1]: cpupower.service: Main process exited, code=exited, sta
Jun 06 22:07:38 jeez systemd[1]: Failed to start Apply cpupower configuration.
Jun 06 22:07:38 jeez systemd[1]: cpupower.service: Unit entered failed state.
Jun 06 22:07:38 jeez systemd[1]: cpupower.service: Failed with result 'exit-code'.

This is the excerpt the steps that I did to fix the issue via package downgrade:
root@jeez /var/cache/pacman/pkg
 # pacman -U cpupower-4.6-1-x86_64.pkg.tar.xz
loading packages...
warning: downgrading package cpupower (4.6-2 => 4.6-1)
resolving dependencies...
looking for conflicting packages...

Packages (1) cpupower-4.6-1

Total Installed Size:   0.41 MiB
Net Upgrade Size:      -0.10 MiB

:: Proceed with installation? [Y/n] Y
(1/1) checking keys in keyring                            [###############################] 100%
(1/1) checking package integrity                          [###############################] 100%
(1/1) loading package files                               [###############################] 100%
(1/1) checking for file conflicts                         [###############################] 100%
(1/1) checking available disk space                       [###############################] 100%
:: Processing package changes...
(1/1) downgrading cpupower                                [###############################] 100%
:: Running post-transaction hooks...
(1/1) Updating manpage index...
root@jeez /var/cache/pacman/pkg
 # systemctl restart cpupower.service
root@jeez /var/cache/pacman/pkg
 # journalctl -xe
Jun 06 22:51:51 jeez systemd[1]: Starting Apply cpupower configuration...
-- Subject: Unit cpupower.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit cpupower.service has begun starting up.
Jun 06 22:51:52 jeez systemd[1]: Started Apply cpupower configuration.
-- Subject: Unit cpupower.service has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit cpupower.service has finished starting up.
--
-- The start-up result is done.
pinczakko@jeez Mon Jun 06 10:52:07pm
~/ systemctl status cpupower.service
— cpupower.service - Apply cpupower configuration
   Loaded: loaded (/usr/lib/systemd/system/cpupower.service; enabled; vendor preset: disabled)
   Active: active (exited) since Mon 2016-06-06 22:51:52 SGT; 26s ago
  Process: 2672 ExecStart=/usr/lib/systemd/scripts/cpupower (code=exited, status=0/SUCCESS)
 Main PID: 2672 (code=exited, status=0/SUCCESS)

Jun 06 22:51:51 jeez systemd[1]: Starting Apply cpupower configuration...
Jun 06 22:51:52 jeez systemd[1]: Started Apply cpupower configuration.

As you see in the shell log above, after downgrading cpupower to version 4.6.1, everything went back to normal. This is only temporary fix until libpci 3.5 promoted from testing to stable. We can go back to cpupower version 4.6.2 by then.

Sunday, March 20, 2016

[How-to] Copy Contents of Tmux Pane to File

There are many cases where you might want to copy part of (or the entire) contents of a tmux pane into file for further usage. This post explains how to that. Before we proceed, you need to be aware that my tmux key binding is probably different from yours, see: http://darmawan-salihun.blogspot.co.id/2015/02/zsh-tmux-configuration-for-arch-linux.html. I'm using vi mode-keys.

The steps to copy contents of a tmux pane are as follows:
  1. Enter copy mode. The key combo to enter copy mode depends on your tmux configuration, but the principle never change: press your tmux prefix key combo--in my case, this is Ctrl+A--and then press your tmux copy mode key-in my case the key is Escape. If you look at my tmux configuration file linked above, I should press: Ctrl+A, then Escape to enter tmux copy mode. 
  2. Select the text that you want to copy. I'm using the v key to select the text because that's how my tmux key binding is configured (~/.tmux.conf: bind -t vi-copy 'v' begin-selection). This is how it looks like once I have selected some text in copy mode with vi-like keys (the selected text is in yellow background):
    tmux copy mode
  3. Copy the selected text into tmux buffer. I'm using y (yank) key to select the text because that's how my tmux key binding is configured (~/.tmux.conf: bind -t vi-copy 'y' copy-selection). Now the selected text is in tmux buffer.
You can "save" contents of the tmux buffer to a file with this command:
$ tmux save-buffer -b [the_buffer_yo_want_to_save] -a [name_of_the_file_you_want_to_append_the_buffer_to]
If you want to just overwrite the contents of the "target" file with the tmux buffer contents, you can omit the -a flag. You can select your "source" tmux buffer before saving the tmux buffer contents by using the command completion key in your shell (in my case TAB -- I'm using zsh). Tmux buffer possibly contains more than one buffer if you previously "copy" something into the buffer, either inadvertently or on-purpose. This is how tmux buffer looks like in my shell as I'm trying to save one of its entries:
Tmux "copy buffer" number 0 to number 10

Anyway, you can also bind keys to the tmux save buffer command in order to make the text available for GUI application as in my tmux.conf shown in the link above. This is the configuration snippet (I'm using icccm clipboard for that):
# extra commands for interacting with the ICCCM clipboard
bind C-c run "tmux save-buffer - | xclip -i -sel clipboard"
bind C-v run "tmux set-buffer \"$(xclip -o -sel clipboard)\"; tmux paste-buffer"
That's it. I hope the explanation is clear enough because there are many explanation on the web that's not quite well-suited for newbie.

Friday, November 20, 2015

Openssh Hiccups and Fix on IBM System i (AS/400)

Let me start with the symptoms:
  • Logging in to the AS/400 (PASE) via openssh always failed despite the username, password and all directory/file permission has been triple-checked and confirmed to be OK.
  • From SSH log, it seems that the login is successful but the connection immediately "kicked out" for some reason. 
This is how I fix this problem:
  1. Run ssh client with most verbose flag.
  2. Run the shell (default shell) invoked by sshd in the server upon login.
  3. Look for clues from 1 and 2.
  4. Fix the problem based on the clue.
Running ssh -vvv in the ssh client machine produces this log:
debug3: no such identity: /home/pinczakko/.ssh/id_ecdsa: No such file or directory
debug1: Trying private key: /home/pinczakko/.ssh/id_ed25519
debug3: no such identity: /home/pinczakko/.ssh/id_ed25519: No such file or directory
debug2: we did not send a packet, disable method
debug3: authmethod_lookup keyboard-interactive
debug3: remaining preferred: password
debug3: authmethod_is_enabled keyboard-interactive
debug1: Next authentication method: keyboard-interactive
debug2: userauth_kbdint
debug2: we sent a keyboard-interactive packet, wait for reply
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug3: userauth_kbdint: disable: no info_req_seen
debug2: we did not send a packet, disable method
debug3: authmethod_lookup password
debug3: remaining preferred: 
debug3: authmethod_is_enabled password
debug1: Next authentication method: password
xxx@10.10.10.10's password: 
debug2: we sent a password packet, wait for reply
debug1: Authentication succeeded (password).
Authenticated to 10.10.10.10 ([10.10.10.10]:22).
debug1: channel 0: new [client-session]
debug3: ssh_session2_open: channel_new: 0
debug2: channel 0: send open
debug1: Entering interactive session.
debug2: callback start
debug2: fd 3 setting TCP_NODELAY
debug3: ssh_packet_set_tos: set IP_TOS 0x08
debug2: client_session2_setup: id 0
debug2: channel 0: request shell confirm 1
debug2: callback done
debug2: channel 0: open confirm rwindow 0 rmax 32768
debug2: channel 0: rcvd adjust 2097152
debug2: channel_input_status_confirm: type 99 id 0
debug2: shell request accepted on channel 0
debug1: client_input_channel_req: channel 0 rtype exit-signal reply 0
debug2: channel 0: rcvd eof
debug2: channel 0: output open -> drain
debug2: channel 0: obuf empty
debug2: channel 0: close_write
debug2: channel 0: output drain -> closed
debug2: channel 0: rcvd close
debug2: channel 0: close_read
debug2: channel 0: input open -> closed
debug3: channel 0: will not send data after close
debug2: channel 0: almost dead
debug2: channel 0: gc: notify user
debug2: channel 0: gc: user detached
debug2: channel 0: send close
debug2: channel 0: is dead
debug2: channel 0: garbage collecting
debug1: channel 0: free: client-session, nchannels 1
debug3: channel 0: status: The following connections are open:
  #0 client-session (t4 r0 i3/0 o3/0 fd -1/-1 cc -1)

Transferred: sent 3328, received 2568 bytes, in 0.5 seconds
Bytes per second: sent 6346.9, received 4897.5
debug1: Exit status -1

As you can see in the log, nothing particularly revealing. You need to run it in real time to see the connection immediately disconnected (starting at debug1: client_input_channel_req: channel 0 rtype exit-signal reply 0). This makes it clear that the client has successfully authenticated but somehow the shell on the server "died" or some permission problem on the user default login directory or other kinds of permission problem. I have triple checked the permission on all related paths without clear leads.

The next step I did was to check which shell executable is the default shell, i.e. which shell is invoked by openssh when you finished logging in to the machine running openssh. In System i version 6.1 (its AS400 PASE), openssh configuration file is located in QOpenSys/QIBM/UserData/SC1/OpenSSH/openssh-3.8.1p1/etc/sshd_config. Unfortunately, there is no default shell variable set in there. However, I have other System i machine that runs openssh with all default settings just fine. Cross-checking the latter machine I found out the default shell is QOpenSys/usr/bin/bsh. Therefore, I need to check whether bsh is working fine in the problematic System i machine.

I found out the bsh executable in the problematic System i machine is somehow broken. When I run bsh from PASE shell via 5250 terminal (via CALL QP2TERM command), bsh immediately stopped. Basically, the shell said bsh is "killed". I tried other shell, i.e. csh (QOpenSys/usr/bin/csh) and this shell worked. Therefore, what I need to fix the problem is a way to force openssh to use csh as the login shell.

Now, we arrived to the FIX. Forcing openssh to use certain shell when logging in via openssh in System i (at least in version 6.1) can be done via the ibmpaseforishell "magic" keyword (see: http://www-01.ibm.com/support/docview.wss?uid=nas8N1011555). These are the steps:
  1. Login to the System i machine via 5250 terminal application. 
  2. Open QOpenSys/QIBM/UserData/SC1/OpenSSH/openssh-3.8.1p1/etc/sshd_config via EDTF. This is the command: EDTF 'QOpenSys/QIBM/UserData/SC1/OpenSSH/openssh-3.8.1p1/etc/sshd_config'
  3. Add the ibmpaseforishell "magic" keyword near the end of the configuration file. This is the result for me:
    #no default banner path 
    #Banner /some/path 
    
    #ibm pase for IBM i shell 
    ibmpaseforishell /QOpenSys/usr/bin/csh 
    
    #override default of no subsystems 
    Subsystem sftp /QOpenSys/QIBM/ProdData/SC1/OpenSSH/openssh-3.8.1p1/libexec/sftp-server 
    
    
    As you can see, I changed the default shell to csh via the ibmpaseforishell keyword.
  4. Check that ssh client can now connect to the ssh server (daemon) in AS400. When I carried out this step, I finally get a working shell, i.e. the csh shell. 
The key point here is you must run ssh in full verbose (via the -vvv switch) to help debug the connection problem. When I was sure that openssh is just fine, then I moved up the chain by checking the default shell. It turns out the default shell is the culprit.

NOTE:
----------
- It seems that not all System i machine supports ibmpaseforishell keyword. It seems that the machine has to have this PTF. However, the keyword works in the problematic System i machine that I worked with.

Saturday, October 31, 2015

Fixing Tmux Mouse Issue

Checkout your tmux version if you've been experiencing mouse-related issue in tmux recently. This is the command:
me@machine $  tmux -V
That should show your tmux version. If you're using Tmux version 2.1, your old mouse configuration in .tmux.conf is no longer valid. The following shows the valid .tmux.conf configuration lines for mouse support in Tmux version 2.1:
#Mouse works as expected
set -g mouse on
#setw -g mode-mouse on #tmux version < 2.1
#set -g mouse-select-pane on  #tmux version < 2.1
#set -g mouse-resize-pane on  #tmux version < 2.1
#set -g mouse-select-window on  #tmux version < 2.1
The commented-out lines are from tmux version < 2.1. There is only one mouse setting in Tmux v2.1, that is "mouse". I got my tmux working as before after this change.

Note:
Primary source of information: [SOLVED] Tmux 2.1 new mouse config issues - can't scroll (It helps despite failing to show the use of the new option in tmux.conf).

Friday, October 30, 2015

Modifying Memcached Configuration in Arch Linux

It's not quite trivial to modify Memcached server configuration in Arch Linux because it's entirely managed via systemd, at least for those not well-versed with systemd. This is the command to modify Memcached server configuration in Arch Linux via systemd's systemctl:
root@darkstar # systemctl edit memcached.service --full
The command should spawn the default text editor configured to be used by systemctl. You can make your changes in the editor and save it. Systemd will apply your changes accordingly.

Wednesday, September 30, 2015

Compiling and Using Custom Arch Linux Kernel

In my previous post, I have the need to downgrade my Arch Linux kernel version in order to alleviate ACPI bug in Linux kernel 4.X. After a bit of searching through AUR, I stumbled upon a still maintained kernel 3.X, at least until 2017. This kernel is Linux kernel 3.18. Because it resides in AUR, you must compile this kernel version yourself and install it with pacman. In this post, I will explain the process of compiling and installing custom kernel 3.18 from AUR. These are the steps I carried out to do that:
  1. Clone the kernel git repository with: git clone https://aur.archlinux.org/linux-lts318.git to directory where you're going to build the kernel.
  2. Add Linus Torvalds and Greg KH keys to list of trusted keys in pacman "database" of trusted keys:
    $ sudo pacman-key -r  00411886
    $ sudo pacman-key -r  6092693E
    
  3. Import Linus Torvalds and Greg KH public key to your machine if you haven't done that already.
    $ gpg --recv-keys 79BE3E4300411886
    $ gpg --recv-keys 38DBBDC86092693E
    
    Be patient, as it could take a while searching and importing the keys.
  4. Now, you can proceed to build the kernel in the git-cloned directory in step 1. cd into the directory and makepkg:
    $ makepkg -s
    
    The -s flag is to make sure that all dependencies are downloaded while building the custom kernel package.
  5. Assuming the kernel package build is finished, you can proceed to install the kernel headers and the kernel itself:
    # pacman -U linux-lts318-headers-3.18.20-1-x86_64.pkg.tar.xz
    # pacman -U linux-lts318-3.18.20-1-x86_64.pkg.tar.xz
    
    You are advised to install kernel header first before installing the kernel as mentioned in https://wiki.archlinux.org/index.php/Kernels/Compilation/Arch_Build_System#Installing
  6. Once the kernel is installed, the remaining step is to update your machine bootloader. If you are using systemd bootloader (a.k.a gummiboot), all you need to do is modify /boot/loader/entries directory to include entry for the new kernel. For example: Create a new arch-lts.conf file in /boot/loader/entries with the following contents:
    title  Arch Linux 3.18 LTS AUR
    linux  /vmlinuz-linux-lts318
    initrd  /initramfs-linux-lts318.img
    options  root=PARTUUID=[your_root_partition_UUID] rw
    
That's all you need to do to compile and install custom kernel from AUR. If you want to create your own custom kernel, you need to build your own Arch Linux package. The compilation and installation steps should be similar to what's explained above.

NOTE:
  • If you have dirmngr problem showing up in your shell, it's probably because you haven't run it yet. You should run it as root:
    # dirmngr < /dev/null
    See: Pacman-key#gpg:_keyserver_receive_failed:_No_dirmngr
  • See also GnuPG section in Arch Wiki for more details.
  • If you'd rather prevent future kernel upgrade when upgrading packages via pacman -Syu, you can add this line to /etc/pacman.conf:
    IgnorePkg   = linux
    
    The line will prevent pacman from upgrading the linux kernel (linux package).



Sunday, August 30, 2015

Arch Linux Brightness Button Problem in Kernel 4.X

Ever since I updated my Arch Linux installation to version using kernel 4.X series, the brightness button in my Lenovo laptop (Ideapad Flex 14) is not working properly anymore. At first, I thought it's merely a configuration problem, but it turns out there's more to it than that. Let's break it down..
  • First and foremost, the laptop uses Nvidia Optimus configuration, i.e. Intel integrated graphics + NVidia discrete GPU. However, this doesn't preclude the (ACPI) brightness buttons from working just fine under Linux kernel 3.X. 
  • Upon boot, only intel_backlight is loaded. In kernel 3.X both intel_backlight and acpi_backlight "modules" are loaded. However, after trying this workaround, it's still not working as expected. Note: I used this to modify the kernel boot parameter. 
  • The symptoms of the brightness button malfunction as follows: The button is not exactly not working, it's merely the response time for a button press to be registered in the kernel takes a few seconds. As for the brightness-level setting in /sys/class/backlight/intel_backlight is just fine. 
This bug is not entirely a bad thing, but it's irritating. For the time being, I stay away from using bleeding-edge Arch Linux with kernel 4.X and uses LTS kernel instead (https://www.archlinux.org/packages/core/x86_64/linux-lts/). However, Greg KH mentioned that the LTS kernel will ceases support next year. We'll see what option I have by then. Maybe, I'll just remap other Laptop keys or find some other work around.

------UPDATE-----

Arch Linux LTS Kernel has moved to kernel 4.1.X over the weekend. I tried to use this recommended kernel version. But it turns out the ACPI-related problem I mentioned above also exists in this kernel version. I've been thinking to use one of the kernels from from AUR, but then ultimately decided to just downgrade the kernel. It turns out that it's much easier than what I thought before. This is what I did (in chronological order):
  1. I have upgraded my Arch Linux to kernel 4.1.X LTS. Therefore, I boot into this LTS kernel version. 
  2. Log in as root and then carry-out the downgrade procedure as explained at https://wiki.archlinux.org/index.php/Downgrading_packages#Downgrading_the_kernel. There are only two packages that I need to downgrade, i.e. the Linux kernel and the Linux kernel headers. Therefore, I use this command:
    pacman -U linux-lts-3.14.52-1-x86_64.pkg.tar.xz linux-lts-headers-3.14.52-1-x86_64.pkg.tar.xz
    
    and everything went without a hitch. The machine works just like before the upgrade. The ACPI hot-keys which were not functioning properly in kernel 4.X are now working like it used to be. I'm a bit worried about systemd compatibility at this point but it seems that everything works as they should.
------UPDATE 2-----
I finally decided to use one of the custom kernel from AUR because it's a stable release that will go through maintenance period at least up-to 2017. See: Compiling and Using Custom Arch Linux Kernel

Saturday, July 25, 2015

Modifying Gummiboot Configuration

Modifying gummiboot configuration (at least in Arch Linux) is quite easy. Upon gummiboot execution (when boot menu is displayed), you can press h to show the gummiboot configuration "help" as shown below.
The screen shot above shows the gummiboot help menu in the lower center of my laptop display. These are the key bindings:

  • d (lower case) sets the currently highlighted menu entry as the default boot OS (or UEFI application) on boot.
  • h (lower case) shows the help menu in the bottom part of the display. Just like shown in the screen shot above.
  • t (lower case) increments the timeout to execute the default boot menu.
  • T (upper case) decrements the timeout to execute the default boot menu.
  • p (lower case) prints "something?". I haven't test what "print" exactly means here.
Therefore, to change the default OS/UEFI application to be automatically executed on timeout, you just need to select the menu entry you want and then press d in gummiboot. The newly set default menu should be effective immediately and preserved upon reboot/shutdown. Anyway, this post is further elaboration from: Modifying Gummiboot Configuration.

Sunday, March 8, 2015

Using Windows Key in Fluxbox

It's easy to add Windows-specific key to Fluxbox. All you have to do is as follows:
  1. Find out how Xorg server recognizes the key. You can use xev for this. You can run xev from xterm or other terminal and observe the name of the specific-key shown in xev log. For example, the Windows key in my laptop is recognized as Super_L by Xorg.
  2. Add the key to ~/.fluxbox/keys file. 
Let me give you an example. Let's add Windows key (Super_L) to my Fluxbox keys configuration file and let the key invokes Fluxbox "root" menu when pressed. This is the snippet from ~/.fluxbox/keys file for this function to work.
#  Windows Key -- show root menu
Super_L :RootMenu

That's it. That's all you need to make Windows key to work as you expected (analog to how the Windows key work in Windows).

Wednesday, March 4, 2015

Adding Lock Screen to Fluxbox

It's easy to add lock screen to Fluxbox. You have many options but I'll stick to xscreensaver because it's the most bug free and standardized. For those using Arch Linux, just "pacman -S xscreensaver" and you get all that you need to run xscreensaver.

Adding the menu to Fluxbox is easy. I added the lock screen menu to ~/.fluxbox/usermenu. The additional menu entry as follows:
[separator]      
[exec] (Lock Screen) {xscreensaver-command -lock} 
[separator]      
I added the separator to make the menu entry stand-out, to reduce the possibility to inadvertently click it. This is how it looks like in my Fluxbox "root" menu (the lock screen menu entry color is inverted for emphasis):

You have to start the xscreensaver "server" upon starting Xorg. In my case, I add the following line to ~/.xprofile:
xscreensaver -no-splash &
Pay attention that you have to make sure that ~/.xprofile is parsed by ~/.xinitrc when you start Xorg. This is my ~/.xinitrc:
#!/bin/sh

# Make sure this is before the 'exec' command or it won't be sourced.
[ -f /etc/xprofile ] && source /etc/xprofile
[ -f ~/.xprofile ] && source ~/.xprofile

# Parse .Xresources
[[ -f ~/.Xresources ]] && xrdb -merge ~/.Xresources

exec startfluxbox
Hopefully this is useful for others using Fluxbox out there.

Monday, March 2, 2015

Adding New Menu Entries to Fluxbox

In this post I assume that you're using Fluxbox 1.3.7 or newer. In this version of Fluxbox, adding new menu entries to the "root menu" (the one shown when you right click on the desktop) consists of these steps:
  1. Add the menu entries in ~/.fluxbox/usermenu
  2. Run fluxbox-generate_menu
Editing ~/.fluxbox/menu directly is not recommended. However, I recommend you to read the file to get an idea about the syntax to create menu entries and submenus. Therefore, we would just add the new menu entries in usermenu file. This is an example:
      [exec] (Evince Reader) {evince} 
      [exec] (File Manager) {pcmanfm} 
Usually, usermenu is empy, unless you have alter it previously. The configuration above means I added two entries, i.e. Evince Reader and pcmanfm file manager to the root menu. Once usermenu file is ready as shown in the configuration file above, I run fluxbox_generate-menu to create the new root menu in Fluxbox. This is the result:

As you can see, the new menu entries are now integrated into fluxbox root menu.

Saturday, February 28, 2015

Fullscreen Urxvt in Arch Linux (Fluxbox)

Contrary to those mentioned at https://bbs.archlinux.org/viewtopic.php?pid=1155345#p1155345 and https://wiki.archlinux.org/index.php/rxvt-unicode#Fullscreen, you don't need the package from AUR (urxvt-fullscreen) to run Urxvt in fullscreen mode if you are using Fluxbox as your window manager.

In Fluxbox, you can use Alt+F11 to make all X applications to switch to "fullscreen". Therefore, just press Alt+F11 and your Urxvt should switch to fullscreen. I found this inadvertently while trying to switch another application to fullscreen. I didn't realize that Urxvt was under the "focus" at that point. Nonetheless, it's very useful because I don't need additional package to make it work.

The "fullscreen" moniker here is rather tentative because what happens is Fluxbox switch the window that's currently in focus to occupy the entire screen (a.k.a maximized) and at the same time disabling its window decoration. This is effectively the same as what you would expect from a "fullscreen-ed" application, i.e. applications that supports fullscreen mode such as video player.

As a bonus, this is my .Xresources snippet that shows how to make Urxvt "transparent" and at the sametime removes the scrollbar (which you won't need if you're using tmux or screen):
URxvt.depth: 32
URxvt.foreground: rgba:eeee/eeee/eeee/ffff
URxvt.background: rgba:0000/0000/0000/cccc
URxvt.cursorBlink: True 
URxvt.cursorUnderline: True 
URxvt.scrollBar: False 
Well, you might want to see the result. The screen-shot is shown below.

Urxvt (+tmux) in its glory

As you can see, the result is quite entertaining to see :-)

Sunday, February 22, 2015

Intel PCH (Haswell) Sound (ALSA) Problem and Fix for Arch Linux

The main problem fixed by the method explained here as follows: 
1. The kernel sound modules loaded just fine and able to recognize all sound-related chips just fine.
2. The Intel PCH platform (in my case Haswell) seems to be perfectly fine in loading modules. Moreover, checks via alsautils programs seems to work as well.
3. There's no sound coming out of the analog output. The analog output is usually the ones which a laptop speaker is connected and the one which you put earphone jack into. If you are using HDMI output from your Intel platform. You might not need this fix.

The "hint" that problem exists is usually failure when running:
$ speaker-test
with rather cryptic error message akin to "unable to open XXXX file"

This fix is focused on my Haswell Laptop but it could also work on other Intel systems with PCH as well. The basic idea comes from this post: https://bbs.archlinux.org/viewtopic.php?id=180102. The only different thing is details of the hardware. The basic idea of the fix is: to force ALSA to reorder the module loading so as to make the sound chip controlling the analog output becomes the default output.
This fix ensures that the sound coming out of the default sound device is coming out of the analog output instead of the HDMI output. Anyway, you should have a sort of hint on which PCI device in your machine that controls the analog audio output. Usually, in Intel PCH platform (at least in Haswell), the ones that controls the analog output doesn't connect to the CPU directly, but rather to the PCH because the CPU (i.e. the HDMI device in the CPU chip) only connects to HDMI output. You should consult the system block diagram to ensure about this.

The fix consists of a *.conf file in /etc/modprobe.d. This file instructs the kernel module loader, i.e. the ALSA subsystem to reorder the sound modules so as to make the PCH audio device the "default" one (having index 0). In my case, I name the *.conf file: /etc/modprobe.d/alsa-base.conf. This is the contents of my /etc/modprobe.d/alsa-base.conf:
# Intel PCH
options snd-hda-intel index=0  model=auto vid=8086 pid=9c20
# Intel HDMI 
options snd-hda-intel index=1  model=auto vid=8086 pid=0a0c

The meaning of the module configuration file above is to set PCI device with Vendor IDentifier (VID) 8086 and PID 9C20, i.e. Intel PCH  as the default sound device (with index value set 0). You can find your specific vid and pid with this following command:
$ lspci -nn | grep -i audio
00:03.0 Audio device [0403]: Intel Corporation Haswell-ULT HD Audio Controller [8086:0a0c] (rev 09)
00:1b.0 Audio device [0403]: Intel Corporation 8 Series HD Audio Controller [8086:9c20] (rev 04)

This is the output of aplay -l in my system after I applied the fix:
$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC3239 Analog [ALC3239 Analog]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
card 1: HDMI [HDA Intel HDMI], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
As you can see, the PCH audio device has become the "default" audio device (card 0). With the fix, speaker-test no longer stops with "unable to open XXXX file" but outputs noise sounds from the speaker. This is an excerpt of speaker-test log from my terminal:
$ speaker-test

speaker-test 1.0.28

Playback device is default
Stream parameters are 48000Hz, S16_LE, 1 channels
Using 16 octaves of pink noise
Rate set to 48000Hz (requested 48000Hz)
Buffer size range from 2048 to 16384
Period size range from 1024 to 1024
Using max buffer size 16384
Periods = 4
was set period_size = 1024
was set buffer_size = 16384
 0 - Front Left
Time per period = 2.657561
 0 - Front Left
Time per period = 2.986723
 0 - Front Left
I hope this also helps those experiencing similar problems out there. Ciao.

Sunday, February 15, 2015

Zsh-Tmux Configuration for (Arch) Linux

I've been doing some testing in order to migrate to use tmux and zsh for my daily work on Linux. This post will show my configuration on both of them. First up is .zshrc:
autoload -U compinit promptinit
compinit
promptinit

# This will set the default prompt to the walters theme
prompt walters

zstyle ':completion:*' menu select
setopt completealiases
setopt HIST_IGNORE_DUPS

alias tmux='tmux -u'

# create a zkbd compatible hash;
# to add other keys to this hash, see: man 5 terminfo
typeset -A key

key[Home]=${terminfo[khome]}
key[End]=${terminfo[kend]}
key[Insert]=${terminfo[kich1]}
key[Delete]=${terminfo[kdch1]}
key[Up]=${terminfo[kcuu1]}
key[Down]=${terminfo[kcud1]}
key[Left]=${terminfo[kcub1]}
key[Right]=${terminfo[kcuf1]}
key[PageUp]=${terminfo[kpp]}
key[PageDown]=${terminfo[knp]}

# setup key accordingly
[[ -n "${key[Home]}"     ]]  && bindkey  "${key[Home]}"     beginning-of-line
[[ -n "${key[End]}"      ]]  && bindkey  "${key[End]}"      end-of-line
[[ -n "${key[Insert]}"   ]]  && bindkey  "${key[Insert]}"   overwrite-mode
[[ -n "${key[Delete]}"   ]]  && bindkey  "${key[Delete]}"   delete-char
[[ -n "${key[Up]}"       ]]  && bindkey  "${key[Up]}"       up-line-or-history
[[ -n "${key[Down]}"     ]]  && bindkey  "${key[Down]}"     down-line-or-history
[[ -n "${key[Left]}"     ]]  && bindkey  "${key[Left]}"     backward-char
[[ -n "${key[Right]}"    ]]  && bindkey  "${key[Right]}"    forward-char
[[ -n "${key[PageUp]}"   ]]  && bindkey  "${key[PageUp]}"   beginning-of-buffer-or-history
[[ -n "${key[PageDown]}" ]]  && bindkey  "${key[PageDown]}" end-of-buffer-or-history


# Finally, make sure the terminal is in application mode, when zle is
# active. Only then are the values from $terminfo valid.
if (( ${+terminfo[smkx]} )) && (( ${+terminfo[rmkx]} )); then
    function zle-line-init () {
  printf '%s' "${terminfo[smkx]}"
 }

 function zle-line-finish () {
  printf '%s' "${terminfo[rmkx]}"
 }
 zle -N zle-line-init
 zle -N zle-line-finish
fi

I lay no claims on this configuration because it's a mix-and-match result of several configuration. Mainly from Arch Linux wiki. It worked without problems though. Next up is .zshenv:
typeset -U path
path=(~/bin $path)
So. Now hopefully you get working zsh configuration. The comments in the config files are self-explanatory. Next up is my .tmux.conf:
#Prefix is Ctrl-a
set -g prefix C-a
bind C-a send-prefix
unbind C-b

# set shell
set -g default-shell /bin/zsh

set -sg escape-time 1
set -g base-index 1
setw -g pane-base-index 1

#Mouse works as expected
setw -g mode-mouse on
set -g mouse-select-pane on
set -g mouse-resize-pane on
set -g mouse-select-window on

setw -g monitor-activity on
set -g visual-activity on

set -g mode-keys vi
set -g history-limit 10000

# y and p as in vim
bind Escape copy-mode
unbind p
bind p paste-buffer
bind -t vi-copy 'v' begin-selection
bind -t vi-copy 'y' copy-selection
bind -t vi-copy 'Space' halfpage-down
bind -t vi-copy 'Bspace' halfpage-up

# extra commands for interacting with the ICCCM clipboard
bind C-c run "tmux save-buffer - | xclip -i -sel clipboard"
bind C-v run "tmux set-buffer \"$(xclip -o -sel clipboard)\"; tmux paste-buffer"

# easy-to-remember split pane commands
bind | split-window -h
bind - split-window -v
unbind '"'
unbind %

# moving between panes with vim movement keys
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R

# moving between windows with vim movement keys
bind -r C-h select-window -t :-
bind -r C-l select-window -t :+

# resize panes with vim movement keys
bind -r H resize-pane -L 5
bind -r J resize-pane -D 5
bind -r K resize-pane -U 5
bind -r L resize-pane -R 5
Well, this one is also quite self-explanatory. At the very least this provides you with basic command completion among others and tmux that recognize zsh. Also, it remaps C-b to C-a so that it's easier to reach in QWERTY keyboard.
This is how they look like at work:
A bit of explanation on the 'tmux -u' alias. The terminal application that I'm using somehow cannot recognize the vertical line delimiter correctly in tmux unless I force it to assume that it know UTF-8 encoding. If not forced, it will use 'x' as the delimiter which was annoying.

Sunday, May 11, 2014

Raspberry Pi 3G-Ethernet Router

In this post, I'm going to explain a DIY 3G-ethernet router based on Raspberry Pi. The configuration of this DIY "router" is simple:

Internet <--> USB 3G modem <-->powered USB hub <--> Raspberry Pi <--> Ethernet <--> user machine (PC/Laptop)

The purpose of this kind of router varied, depending on your needs. However, I have a very specific need in one of my setup where providing Internet connection directly from the 3G modem is not possible and only Ethernet interface can be used by the user (physical/virtual) machine.

These are what you need:
  1. A Raspberry Pi (I'm using the B revision), with Raspbian distro.
  2. A powered USB hub. This is required because most USB 3G modems are power hungry and cannot be operated reliably only via the USB connector on the Pi.
  3. A USB 3G modem. Use whatever you have, hopefully Raspbian kernel already support it. I'm using Huawei E153 USB modem which is rather not so friendly in terms of operation in Raspbian, but it works reliably nonetheless, once you know how to "switch" it into modem "mode".
  4. Ethernet cable.
  5. A user machine to test the interconnection.
  6. Internet/data plan subscription to your mobile operator or whatever works for you.
Let's start with installing the software needed for the USB 3G modem to work on Raspbian. I'm basically using the steps mentioned at The Fan Club, but modify them a bit because I'm not using wvdial. These are my modified steps:
  1. Update your Raspbian with "sudo apt-get update"
  2. Install the needed packages with "sudo apt-get install ppp usb-modeswitch"
  3. Configure the pppd configuration file according to your needs.
Now, the software installation steps to setup the DHCP server and Network Address Translation (NAT) are mostly similar to the one at Adafruit: https://learn.adafruit.com/setting-up-a-raspberry-pi-as-a-wifi-access-point/install-software, except that you should remember that the "outgoing" interface in our case is eth0, instead of wlan0 and the "incoming" interface is ppp0 instead of eth0. Therefore, I believe you can adjust the steps accordingly. Also, I found that Adafruit step to make the NAT setting permanent is not working for me. I have to modify the configuration line in /etc/network/interfaces to:

pre-up iptables-restore < /etc/iptables.ipv4.nat

instead of the one explained by Adafruit to make the NAT work permanently across reboots and shutdowns.

The next step is to connect to the Internet. These are my steps:
  1. Power on the Raspberry Pi.
  2. Unplug the 3G USB modem from the USB hub, and then plug it back again if it's previously plugged in before Raspberry Pi finished booting. This is a compatibility hack because sometimes it is required, and sometimes not.
  3. Wait until the 3G USB modem is recognized (watch syslog, i.e. tail -f /var/log/messages)
  4. Run usb_modeswitch on the modem
  5. Run pppd
  6. Watch syslog to find out whether the data connection succeeded or not, i.e. tail -f /var/log/messages 
  7. Test the connection with your user machine connected through Raspberry Pi Ethernet.
Note that step 1 to 5 must be carried out exactly as mentioned above, otherwise pppd will always fail to initialize data connection with pppd. I'm not so sure what causes it, but it seems that the modem cannot respond to the AT command(s) sent by pppd correctly, at least the command to establish data connection. I saw that through syslog.

I also run a DHCP server in my Raspberry Pi, the isc-dhcp server. The configuration files for isc-dhcp are /etc/init.d/isc-dhcp-server, /etc/default/isc-dhcp-server and /etc/dhcp/dhcpd.conf. You only need to deal with the last two config files. /etc/default/isc-dhcp-server determines which network interface(s) used to listen for DHCP client requests. /etc/dhcp/dhcpd.conf determines the network configuration, such as the IP addresses to assign to the client, DNS servers, gateway, etc. Let's have a look at my configuration files.
This is how my /etc/default/isc-dhcp-server looks like.

# Defaults for isc-dhcp-server initscript
# sourced by /etc/init.d/isc-dhcp-server
# installed at /etc/default/isc-dhcp-server by the maintainer scripts

#
# This is a POSIX shell fragment
#

# Path to dhcpd's config file (default: /etc/dhcp/dhcpd.conf).
DHCPD_CONF=/etc/dhcp/dhcpd.conf

# Path to dhcpd's PID file (default: /var/run/dhcpd.pid).
#DHCPD_PID=/var/run/dhcpd.pid

# Additional options to start dhcpd with.
#       Don't use options -cf or -pf here; use DHCPD_CONF/ DHCPD_PID instead
#OPTIONS=""

# On what interfaces should the DHCP server (dhcpd) serve DHCP requests?
#       Separate multiple interfaces with spaces, e.g. "eth0 eth1".
INTERFACES="eth0"
As you can see, isc-dhcp listens to client on the ethernet interface and the dhcpd configuration file to use is set to /etc/dhcp/dhcpd.conf. Now, let's have a look at /etc/dhcp/dhcpd.conf.
#
# Sample configuration file for ISC dhcpd for Debian
#
#

# The ddns-updates-style parameter controls whether or not the server will
# attempt to do a DNS update when a lease is confirmed. We default to the
# behavior of the version 2 packages ('none', since DHCP v2 didn't
# have support for DDNS.)
ddns-update-style none;

# option definitions common to all supported networks...
#option domain-name "example.org";
#option domain-name-servers ns1.example.org, ns2.example.org;

default-lease-time 7200;
max-lease-time 86400;

# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
authoritative;

# Use this to send dhcp log messages to a different log file (you also
# have to hack syslog.conf to complete the redirection).
log-facility local7;

# .. irrelevant commented config omitted for brevity ..

# Raspberry Pi subnet - note: this is the subnet of M$ Internet Connection Sharing
# TODO: Make sure the router configuration is correct
subnet 192.168.137.0 netmask 255.255.255.0 {
  range 192.168.137.3 192.168.137.21;
  option broadcast-address 192.168.137.255;
  option routers 192.168.137.2;
  default-lease-time 7200;
  max-lease-time 86400;
  option domain-name "local";
  option domain-name-servers 8.8.8.8, 8.8.4.4;
}
As you can see, the lease time and maximum lease time configuration are consistent. I found that inconsistencies in these parameters sometimes causes isc-dhcp fails to provide valid IP addresses to the DHCP clients. So, watch-out to those parameters values.

Well, there are some more details regarding pppd, usb_modeswitch and iptables which are missing. This post is still considered beta and I'm going to update it in the not so distant future..