Friday, August 12, 2016

MacOS X: Problem with accessing SMB-Shares on your Synology with "El Capitan"

Objective


I wanted to access my smb shares on my Synology from my MacBook Air that I recently updated to "El Capitan".

Motivation


As I my Synology DS209+II as my central data store where I never had problem so share files via the smb protocol with my MacBook Air as a client, I recently recognized that I can't establish a connection to the shares on my Synology after updating my MacBook Air to "El Capitan".


Prerequisites


  • DS209+II
  • MacBook Air (or any other Mac) with "El Capitan"

Solution


Explanation


Apparently Apple change it's security policy regarding smb-shares in "El Capitan". Those changes can lead to significant speed reduction with smb connection and even prevent you to mount a share at all. Ususally a login via the Finder menu "Go to server" is not successful whereas in the previous version of MacOS X "Mavericks" there where no problem and nothing has changed meanwhile on the server.

Solution


You can quickly fix the problem without downgrading to MacOS 10.11.4.

Open a Terminal an execute the following command:

sudo sh -c 'echo "[default]\nsigning_required=no" > /etc/nsmb.conf'

Now, restart your MacBook and you should be able to mount a shared drive from you Synology as ususal.

References:

  1. http://www.heise.de/mac-and-i/meldung/OS-X-10-11-5-Abhilfe-fuer-SMB-Probleme-3222725.html (German)

Sunday, April 17, 2016

Manage your local scripts via git on a shared directory of your NAS

Objective


I want to store all my scripts in a central place on my Synology NAS. I want to be able to easily add or alter any script on any computer within may local network. I want to be able to synchronize all my computer to have always the most recent version of any of my scripts installed. I don't want to use a public repository like GitHub or BitBucket for privacy reasons.

Motivation


At the moment, I use several computers to develop software. Those include a MacBookAir, a Linux workstation with several Virtual-Machines on it and a Laptop. On all those machines, virtual or physical I have a separate homeaccount with a bin folder where my scripts for daily work are located. I have a Synology NAS in my network where I backup all those scripts manually in a so called reference folder. I also synchronize my scripts manually, which is time consuming and kind a painful, because sometimes I even don't remember which of my local machines has the most recent version of a script stored at a certain point of time.

Prerequisites


  • Linux Mint 17.3 Rose
  • Synology DS209+II
  • git v1.9.1
  • nfs-shared directory on NAS

Solution


Create a new bare git repository


On my client machine (laptop with Linux Mint) I changed to the mounted directory (automount) from my NAS wher I want to create the bare git repository:

$> cd /mnt/DiskStation/data/home/cschmidt/

At the moment I have my reference directory containing all my scripts already in the bin folder there.

$> ls -la

drwxr-xr-x 3 cschmidt users 4096 Apr 16 22:54 .
drwxr-xr-x 3 cschmidt users 4096 Apr 16 22:54 ..
drwxrwxrwx 2 cschmidt users 4096 Apr 16 22:54 bin

Now I create the bare git repository named bin.git

$> git init --bare bin.git

Initialized empty Git repository in /mnt/DiskStation/data/home/cschmidt/bin.git/

Create a non-bare git repository in the folder where the reference scripts are actually stored.


Now I change back to the folder where my scripts are currently stored

$> cd bin
$> ls -la

drwxrwxrwx 2 cschmidt users 4096 Apr 16 22:54 .
drwxr-xr-x 4 cschmidt users 4096 Apr 17 2016 ..
-rwxrwxrwx 1 cschmidt users 82 Jul 20 2008 listfoldersize.sh
-rwxr-xr-x 1 cschmidt users 2193 Apr 16 18:20 mkscript.sh
-rwxr--r-- 1 cschmidt users 886 Sep 5 2015 renfiles.rb
-rwxrwxrwx 1 cschmidt users 671 Dez 3 2009 synapticsOnOff.sh
-rwxr--r-- 1 cschmidt users 1626 Jul 12 2015 wav2mp3.sh

Here I create a non-bare repository

$> git init

Initialized empty Git repository in /mnt/DiskStation/data/home/cschmidt/bin/.git/

Now I add all the scripts I already have, to the working copy and commit them all.

$> git add .
$> git status

On branch master

Initial commit

Changes to be committed:
(use "git rm --cached ..." to unstage)

new file: listfoldersize.sh
new file: mkscript.sh
new file: renfiles.rb
new file: synapticsOnOff.sh
new file: wav2mp3.sh

$> git commit -m "initial bunch of scripts"

[master (root-commit) 17879d2] initial bunch of scripts
5 files changed, 805 insertions(+)
create mode 100755 listfoldersize.sh
create mode 100755 mkscript.sh
create mode 100755 renfiles.rb
create mode 100755 synapticsOnOff.sh
create mode 100755 wav2mp3.sh

Push the commited scripts into the bare repository


So, now I tried to push the committed scripts into my bare host repository

$> git push

fatal: No configured push destination.
Either specify the URL from the command-line or configure a remote repository using

git remote add

and then push using the remote name

git push

Ok, I admit ... I forgot to add the remote repository to push into, so do so now

$> git remote add origin /mnt/DiskStation/data/home/cschmidt/bin.git

and again

$> git push

oops ...


fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use

git push --set-upstream origin master

Ok, I see I could name the repository every time I want to push something into or I'll add it as a upstream.
Let's do the latter ...

$> git push --set-upstream origin master

Counting objects: 7, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (7/7), done.
Writing objects: 100% (7/7), 32.23 KiB | 0 bytes/s, done.
Total 7 (delta 2), reused 0 (delta 0)
To /mnt/DiskStation/data/home/cschmidt/bin.git
* [new branch] master -> master
Branch master set up to track remote branch master from origin.

Synchronize your script repository with your client


So, I want to have my recently commited scripts synchronized to my client

I go to my home account on my laptop and clone the remote repository into my bin.
(If you have already a bin folder in your home account, delete it first.)

$> cd ~
$> git clone /mnt/DiskStation/data/home/cschmidt/bin.git bin

Cloning into 'bin'...
done.

$> cd bin
$> ls -la

drwxrwxrwx 2 cschmidt users 4096 Apr 16 22:54 .
drwxr-xr-x 4 cschmidt users 4096 Apr 17 2016 ..
-rwxrwxrwx 1 cschmidt users 82 Jul 20 2008 listfoldersize.sh
-rwxr-xr-x 1 cschmidt users 2193 Apr 16 18:20 mkscript.sh
-rwxr--r-- 1 cschmidt users 886 Sep 5 2015 renfiles.rb
-rwxrwxrwx 1 cschmidt users 671 Dez 3 2009 synapticsOnOff.sh
-rwxr--r-- 1 cschmidt users 1626 Jul 12 2015 wav2mp3.sh

Yeah, everything worked fine!

Friday, June 19, 2015

Blogger: Setup "SyntaxHighlighter" for your blog

Objective


Install "SyntaxHighlighter" on Google-Drive to make it easy to format your source-code on your blog on Blogger. This is needed, because the original hosting service of "SyntaxHighlighter" only supports "http" which Google does not like anymore for security reasons. Installing the needed files on Google-Drive will solve the problem and will serve the needed Javascript and CSS files via "https".

Motivation


This time I wanted to write a new blog article containing C++ code. I was not very keen of manually highlighting the code-snippets like I did in my first blog article about implementing a Java "synchronized" keyword in C++. Therefore I searched the web for a Syntax-Highlighter. I found many online solutions where you can copy&paste your code into a textarea to get html-code for your source-code that can be copied into your blogs source-text. Unfortunatelly this is not very practical nor flexible if you change or edit of your code while writing the blog article or even later. I needed a solution where you just copy&paste your raw-source-code into your blogs text. Ok, maybe you need to assign some specific style, but that's ok. In the end, I found "SyntaxHighlighter" a Javascript and CSS framework written by Alex Gorbatchev. I tried it in my Test-Blog and unfortunatelly noticed that the default hosting that Mr. Gorbatchev provided on his homepage is only "http" and not "https". Since a few weeks ago, links with only "http" do not work anymore with Blogger and Google-Chrome. Therefore I had to find an easy solution, to host the "SyntaxHighlighter" scripts myself via "https". I found out, that I very neat solution herefore is, to copy the needed files to your Google-Drive and make them publically accessible. This was the solution of my choice, because I already use the blogging service that Google provides.

Prerequisites



Solution


Get SyntaxHighlighter


Download SyntaxHighlighter from http://alexgorbatchev.com/SyntaxHighlighter/download/ and unzip it (in my case version 3.0.83):

$> unzip syntaxhighlighter_3.0.83.zip


Archive: syntaxhighlighter_3.0.83.zip
creating: syntaxhighlighter_3.0.83/
...
inflating: syntaxhighlighter_3.0.83/index.html
inflating: syntaxhighlighter_3.0.83/LGPL-LICENSE
inflating: syntaxhighlighter_3.0.83/MIT-LICENSE
creating: syntaxhighlighter_3.0.83/scripts/
inflating: syntaxhighlighter_3.0.83/scripts/shAutoloader.js
...
inflating: syntaxhighlighter_3.0.83/scripts/shBrushCpp.js
...
inflating: syntaxhighlighter_3.0.83/styles/shThemeRDark.css
creating: syntaxhighlighter_3.0.83/tests/
...

DEPRECATED SECTION : Setup your Hosting of SyntaxHighlighter on Google-Drive

The following section is deprecated. Due to the fact that Google deprecated web-hosting support in Google-Drive as of 31. August 2015 (Reference: https://gsuiteupdates.googleblog.com/2015/08/deprecating-web-hosting-support-in.html).
However, the web-hosting via Google-Drive stopped working only a year later as of 31. August 2016.

An alterative to host your javascript files is using github-pages.
So skip this section or jump directly to Blogger: Host "SyntaxHighlighter" on GitHub-Pages

Setup your Hosting of SyntaxHighlighter on Google-Drive


1. Create your folder

Log into your Google Drive account. Create a folder, by clicking "New" and then "Folder". Choose where you want to store your SyntaxHighlighter files. I named the root folder "Blog" and even created a subfolder named "SyntaxHighlighter" to create kind of a directory hierarchy in case I want also to host other packages in future.



Within the folder "SyntaxHighlighter" create 2 subfolders "scripts" and "styles".

2. Share your folder

Select the folder and then click the Share button.



Click on advanced and choose "change..."



then choose "On - Public on the web" in the next dialog



and click "Save".

3. Upload the necessary files from SyntaxHighlighter

Navigate back into your "Blog/SyntaxHighligter/scripts" folder and choose "File upload".



Now, navigate to the local folder where you unzipped the source of syntaxhighlighter_3.0.83.zip and go into the subfolder "scripts". Here you have to select at least "shCore.js" and minimum a "shBrushXX.js" file. The "shBrushXX.js" files specify which languages will be highlighted later on on your blog. I only have choosen "shBrushCpp.js" for the moment.

Navigate into "styles" folder and choose "File upload" again. Upload at least "shCore.css" and "shThemeDefault.css" from the "styles" folder of your local Hightlighter sources.

Prepare your template to support code formatting


Go to your Blogger's blog online editor and choose "Template" from the menu at the left.




Click on "Edit HTML".

Within the code search for the closing head-tag

</b:template-skin>
    <b:include data='blog' name='google-analytics'/>
  </head>

  <body expr:class='&quot;loading&quot; + data:blog.mobileClass'>
  <b:section class='navbar' id='navbar' maxwidgets='1' name='Navbar' showaddelement='no'>

And copy the following code (only the links to the files you prepared for hosting) right before the end head-tag

<!-- Begin SyntaxHighlighter-->
    <link href='https://googledrive.com/host/xxxxx/styles/shCore.css' rel='stylesheet' type='text/css'/> 
    <link href='https://googledrive.com/host/xxxxx/styles/shThemeDefault.css' rel='stylesheet' type='text/css'/> 
    <script src='https://googledrive.com/host/xxxxx/scripts/shCore.js' type='text/javascript'/> 
 <script src='https://googledrive.com/host/xxxxx/scripts/shBrushCpp.js' type='text/javascript'/> 
    <!--script src='https://googledrive.com/host/xxxxx/scripts/shBrushCpp.js' type='text/javascript'/--> 
    <!--script src='https://googledrive.com/host/xxxxx/scripts/shBrushCSharp.js' type='text/javascript'/> 
    <script src='https://googledrive.com/host/xxxxx/scripts/shBrushCss.js' type='text/javascript'/> 
    <script src='https://googledrive.com/host/xxxxx/scripts/shBrushJava.js' type='text/javascript'/> 
    <script src='https://googledrive.com/host/xxxxx/scripts/shBrushJScript.js' type='text/javascript'/> 
    <script src='https://googledrive.com/host/xxxxx/scripts/shBrushPhp.js' type='text/javascript'/> 
    <script src='https://googledrive.com/host/xxxxx/scripts/shBrushPython.js' type='text/javascript'/> 
    <script src='https://googledrive.com/host/xxxxx/scripts/shBrushRuby.js' type='text/javascript'/> 
    <script src='https://googledrive.com/host/xxxxx/scripts/shBrushSql.js' type='text/javascript'/> 
    <script src='https://googledrive.com/host/xxxxx/scripts/shBrushVb.js' type='text/javascript'/> 
    <script src='https://googledrive.com/host/xxxxx/scripts/shBrushXml.js' type='text/javascript'/> 
    <script src='https://googledrive.com/host/xxxxx/scripts/shBrushPerl.js' type='text/javascript'/--> 
    <script type='text/javascript'>
    window.setTimeout(function() {
        SyntaxHighlighter.config.bloggerMode = true;
        SyntaxHighlighter.all();
    }, 20);
    </script>
<!-- End SyntaxHighlighter-->
</head>

The strange "xxxxx" is the placeholder for your very own share id. You can find your share-id, when you choose again the folder "SyntaxHighlighter" on your Google-Drive. Exchange all "xxxxx" in the code above by your share-id, e.g. "ZsTjl4Sjl0YmQ4SmNTh6WavThstZbGR0Mm1ydQAfm9oWlhkQlNRJSm9wQ3Z0Bxn0jvqYuNlU".



Test it


Let's put some source-code into a blog article to check if it shows up correctly. There are 2 possibilities how to do this:

Method 1:

<script type="syntaxhighlighter" class="brush: cpp"><![CDATA[
// 'Hello World!' program 
 
#include <iostream>
 
int main()
{
  std::cout << "Hello World!" << std::endl;
  return 0;
}
]]></script>

Result:



Method 2:

<pre class="brush: cpp">
// 'Hello World!' program 
 
#include &lt;iostream&gt;
 
int main()
{
  std::cout << "Hello World!" << std::endl;
  return 0;
}
</pre>

Result:

// 'Hello World!' program 
 
#include <iostream>
 
int main()
{
  std::cout << "Hello World!" << std::endl;
  return 0;
}
Great! It works! Have fun!

References:

  1. http://alexgorbatchev.com/SyntaxHighlighter/
  2. Embed Code Syntax Highlighting in Blog
  3. How to Host JavaScript or CSS Files on Google Drive

Friday, May 15, 2015

Install multiple versions of gcc at the same time

Objective


Install gcc/g++ version 4.9 and 5.1 on my current Linux Mint 17.1 Rebecca distribution. Use gcc 4.9 to compile the VirtualBox kernel driver.

Motivation


Recently I upgraded my gcc to version 5.1 via the Synaptic package manager as an suggested update. By doing this, my already installed version of gcc version 4.9 got lost. Few days later I updated my VirtualBox 4.3.26 to version 4.3.28. As a consequence of the update, all VirtualBox guest-systems refused to start, by claiming that I have update also the kernel drivers for virtualbox. Ok, no problem, as it gave me the command to do so ... but wait, I am running on an yet not officially supported kernel (as I explained in a previous post). The command updating or let's say compiling the kernel driver for VirtualBox miserably failed, due to a missing header file in gcc 5.1.

Prerequisites


  • Linux Mint 17.1 Rebecca
  • Kernel version 3.17.1
  • VirtualBox 4.3.28

Problem


The command to update the kernel driver for VirtualBox 4.3.26 was:

$> sudo /etc/init.d/vboxdrv setup

I still just had gcc 5.1 installed and unfortunatelly got the following error:

Stopping VirtualBox kernel modules ...done.
Uninstalling old VirtualBox DKMS kernel modules ...done.
Trying to register the VirtualBox kernel modules using DKMSError! Bad return status for module build on kernel: 3.17.1-031701-generic (x86_64)
Consult /var/lib/dkms/vboxhost/4.3.28/build/make.log for more information.
...failed!
(Failed, trying without DKMS)
Recompiling VirtualBox kernel modules ...failed!
(Look at /var/log/vbox-install.log to find out what went wrong)

The error in the log "/var/lib/dkms/vboxhost/4.3.28/build/make.log" mentioned above was ...

LD /var/lib/dkms/vboxhost/4.3.28/build/built-in.o
LD /var/lib/dkms/vboxhost/4.3.28/build/vboxdrv/built-in.o
CC [M] /var/lib/dkms/vboxhost/4.3.28/build/vboxdrv/linux/SUPDrv-linux.o
In file included from include/linux/compiler.h:54:0,
from /var/lib/dkms/vboxhost/4.3.28/build/vboxdrv/include/iprt/types.h:116,
from /var/lib/dkms/vboxhost/4.3.28/build/vboxdrv/include/VBox/types.h:30,
from /var/lib/dkms/vboxhost/4.3.28/build/vboxdrv/linux/../SUPDrvInternal.h:35,
from /var/lib/dkms/vboxhost/4.3.28/build/vboxdrv/linux/SUPDrv-linux.c:31:
include/linux/compiler-gcc.h:106:30: fatal error: linux/compiler-gcc5.h: No such file or directory
compilation terminated.
make[2]: *** [/var/lib/dkms/vboxhost/4.3.28/build/vboxdrv/linux/SUPDrv-linux.o] Error 1
make[1]: *** [/var/lib/dkms/vboxhost/4.3.28/build/vboxdrv] Error 2
make: *** [_module_/var/lib/dkms/vboxhost/4.3.28/build] Error 2

Solution


Install multiple versions of gcc


There is a very convenient package called update-alternatives to do the job of installing multiple versions of gcc and select the proper version for your current compile tasks.

To install just gcc/g++ 4.9 and gcc/g++ 5.1, first get rid of any other version by cleaning up the system:

$> sudo update-alternatives --remove-all gcc && sudo update-alternatives --remove-all g++

After the command returned you can install your required versions of gcc/g++:

$> sudo apt-get install gcc-4.9 gcc-5 g++-4.9 g++-5

Be patient because this may take a while if your don't have the packages allready installed.

If you get an error message like:

Paketlisten werden gelesen... Fertig
Abhängigkeitsbaum wird aufgebaut.
Statusinformationen werden eingelesen.... Fertig
Note, selecting 'gcc-4.9-base' for regex 'gcc-4.9'
E: Paket gcc-5 kann nicht gefunden werden.
E: Paket g++-4.9 kann nicht gefunden werden.
E: Mittels regulärem Ausdruck »g++-4.9« konnte kein Paket gefunden werden.
E: Paket g++-5 kann nicht gefunden werden.
E: Mittels regulärem Ausdruck »g++-5« konnte kein Paket gefunden werden.

You have to add a new repository "ppa:ubuntu-toolchain-r/test"
source first by exexuting:

$> sudo add-apt-repository ppa:ubuntu-toolchain-r/test
$> sudo apt-get update

Install the gcc versions in update-alternatives


To make update-alternatives aware of your installed compilers you have to execute the following additional installer commands:

$> sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 10
$> sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 20

$> sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.9 10
$> sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-5 20

$> sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 30
$> sudo update-alternatives --set cc /usr/bin/gcc

$> sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 30
$> sudo update-alternatives --set c++ /usr/bin/g++

Configure update-alternatives


As a last step you have to configure the default commands for gcc, g++:
$> sudo update-alternatives --config gcc

If everything went well, you should be able to interactively choose which C-Compiler version you want to activate:

There are 2 choices for the alternative gcc (providing /usr/bin/gcc).

Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/bin/gcc-5 20 auto mode
1 /usr/bin/gcc-4.9 10 manual mode
2 /usr/bin/gcc-5 20 manual mode

Press enter to keep the current choice[*], or type selection number: _


The same can be done for the C++-Compiler g++:

$> sudo update-alternatives --config g++

I've choosen gcc-4.9 and g++-4.9 for the moment.

Recompile the kernel module for VirtualBox with gcc 4.9


Finally, I typed again:

$> sudo /etc/init.d/vboxdrv setup

... and this time the update was successful:

Stopping VirtualBox kernel modules ...done.
Uninstalling old VirtualBox DKMS kernel modules ...done.
Trying to register the VirtualBox kernel modules using DKMS
...done.
Starting VirtualBox kernel modules ...done.
cschmidt@pippin:~$
cschmidt@pippin:~$ sudo /etc/init.d/vboxdrv setup
Stopping VirtualBox kernel modules ...done.
Uninstalling old VirtualBox DKMS kernel modules ...done.
Trying to register the VirtualBox kernel modules using DKMS ...done.
Starting VirtualBox kernel modules ...done.

As a last step I switched back to gcc/g++ 5.1 by the commands given above.

Have fun!

Thursday, April 16, 2015

Install Bash-Shell in favour of Ash-Shell on your Synology

Objective


I wanted to use the bash-shell on my Synology DS209+II. There are no official packages from Synology provided, but I knew there is a way to install custom and optional packages via ipkg.

Motivation


As my Synology is mostly running 24/7, I wanted establish a custom download-script which is started and stopped as a cron-job at certain periods of time. The script itself uses some commands relying on a bash-shell, but the Synology default command shell is just the less powerful ash-shell.


Prerequisites



Solution


Open a ssh-connection to your Synology


Log into your Synology as root using ssh (e.g "ssh -l root DiskStation").

Install the Bash-Shell-Package:

DiskStation$> ipkg install -A bash

You should see something like this:

DiskStation> ipkg install bash
Installing bash (3.2.54-1) to root...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/syno-e500/cross/unstable/bash_3.2.54-1_powerpc.ipk
Installing readline (6.1-2) to root...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/syno-e500/cross/unstable/readline_6.1-2_powerpc.ipk
Installing ncurses (5.7-3) to root...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/syno-e500/cross/unstable/ncurses_5.7-3_powerpc.ipk
Configuring bash
Configuring ncurses
update-alternatives: Linking //opt/bin/clear to /opt/bin/ncurses-clear
Configuring readline
Successfully terminated.

Now, Bash-Shell is installed, but when you log into your Synology it's not yet automatically started. You are still with Ash-Shell.

Activate automatic log-in with Bash


You could exchange the shell type for log-in in your /etc/passwd on your Synology, by exchanging the line (here it's done for user: root):

root:x:0:0:root:/root:/bin/ash

by

root:x:0:0:root:/root:/bin/bash

Unfortunatelly doing so, has the disadvantage, that you might loose the ability to log into your Synology at all from remote after an upgrade of your Firmware. Because optional packages like Bash are installed into /opt may be inavailable after a system-update. To prevent this accidental lock-out, it's preferred to continue to log-in with Ash-Shell, but start Bash automatically at once after you're successfully logged in.

To achive this you have to create/edit the file .profile in the homeaccount of the user the should be able to log-in on your Synology. Go to your homeaccount (e.g. /root/ for the user: root) and type the following as the proper user on you Synology:

DiskStation$> vi .profile

If the file has content, just add this lines to it:

# ...

if [[ -x /opt/bin/bash ]]; then
    exec /opt/bin/bash
fi

That's it. Next time, when root logs into your Synology, he is on a Bash-Shell.

Refine Configuration


If you want to use a different command prompt or to have some alias-commands, or at least the proper shell name in your "SHELL" environment variable, it's advisable also to create a .bashrc in the homeaccount, with the following example content (feel free to alter it to your convenience):

DiskStation$> vi .bashrc

PS1='\u@\h:\w \$ '
export SHELL=/opt/bin/bash

The first line gives you a nice bash prompt. The second explicitly sets the "SHELL" variable to your correct shell.

If you want also other scripts automatically using Bash instead of Ash, additionally create a symbolic link to it in /bin/:

DiskStation$> ln -s /opt/bin/bash /bin/bash

ADVICE: Keep a separate root shell window open until you have confirmed all of the changes work.

Sunday, April 12, 2015

Prepare your Synology NAS to install custom packages via ipkg

Objective


I wanted to use the bash-shell and a newer wget on my Synology DS209+II. There are no official packages from Synology provided, but I knew there is a way to install custom and optional packages via ipkg. Unfortunatelly ipkg must be so called bootstrapped, because it is already a custom package itself.

Motivation


As my Synology is mostly running 24/7, I wanted establish a custom download-script which is started and stopped as a cron-job at certain periods of time. The script itself uses some commands relying on a bash-shell, but the Synology default command shell is just the less powerful ash-shell. Also some of the wget-options I use in that script seem to be broken in the version of wget that my Synology has installed.

Prerequisites


  • DS209+II
  • Proper bootstrap script for your Synology NAS

Solution


Download the proper boostrap script


First you have to find out which processor is used on your specific Synology NAS.

Log into your Synology as root using ssh (e.g "ssh -l root DiskStation") and type the following command:

DiskStation$> cat /proc/cpuinfo

Doing so on my DS209+II printed the following information:

processor : 0
cpu : e500v2
clock : 1066.560000MHz
revision : 2.2 (pvr 8021 0022)
bogomips : 133.32
timebase : 66660000
platform : MPC8544 DS
model : MPC8544DS
Vendor : Freescale Semiconductor
PVR : 0x80210022
SVR : 0x80340011
PLL setting : 0x4
Memory : 512 MB
Memory : 512 MB

Now I know I have a Freescale PowerPC (e500v*), I can download the proper boostrap script here:

You can find a list of all bootstrap scripts here (column: "Optware-Pfad/IPKG"):
Processors used in Synology NAS Systems (German)

Now download the proper script and copy it to your Synology.

On the (still open) ssh connection "cd" into the folder where you stored the script and type (script name for your Synology type may differ!):

DiskStation$> sh syno-e500-bootstrap_1.2-7_powerpc.xsh

After you hit enter and you see something like this:

Optware Bootstrap for syno-e500.
Extracting archive... please wait
bootstrap/
bootstrap/bootstrap.sh
bootstrap/ipkg-opt.ipk
bootstrap/ipkg.sh
bootstrap/optware-bootstrap.ipk
bootstrap/wget.ipk
1330+1 records in
1330+1 records out

you already have installed an older version of ipkg.

Now you first have to remove this version, before installing the new one.

Backup your old ipkg configuration (only if you already have ipkg on your system)


If you have already installed ipkg and other custom packages via ipkg then make a backup of the following folders on you Synology:

  • /volume1/@optware
  • /usr/lib/ipkg

then remove all existing optware packages:

DiskStation$> rm -rf /volume1/@optware && rm -rf /usr/lib/ipkg

Afterwards, you must *reboot your Synology* and then restart the bootstrap script.

Re-Install ipkg


Again, log-into your Synology via ssh as root and type:

DiskStation$> sh syno-e500-bootstrap_1.2-7_powerpc.xsh

Now you should see a full install log:

Optware Bootstrap for syno-e500.
Extracting archive... please wait
bootstrap/
bootstrap/bootstrap.sh
bootstrap/ipkg-opt.ipk
bootstrap/ipkg.sh
bootstrap/optware-bootstrap.ipk
bootstrap/wget.ipk
1330+1 records in
1330+1 records out
Creating temporary ipkg repository...
Installing optware-bootstrap package...
Unpacking optware-bootstrap.ipk...Done.
Configuring optware-bootstrap.ipk...Setting up ipkg arch-file
Done.
Installing ipkg...
Unpacking ipkg-opt.ipk...Done.
Configuring ipkg-opt.ipk...WARNING: can't open config file: /usr/syno/ssl/openssl.cnf
Done.
Removing temporary ipkg repository...
Installing wget...
Installing wget (1.12-2) to root...
Configuring wget
Successfully terminated.
Creating /opt/etc/ipkg/cross-feed.conf...
Setup complete.

Update your $PATH variable, so that the ipkg can be found after reboot.
Therefore open the file $HOME/.profile and edit the line with your PATH:

PATH=/opt/bin:/opt/sbin:[the content that was already there]

Finally it's recommended to update your ipkg-package to ensure to use the newest version:

DiskStation$> ipkg update

Downloading http://ipkg.nslu2-linux.org/feeds/optware/syno-e500/cross/unstable/Packages.gz
Inflating http://ipkg.nslu2-linux.org/feeds/optware/syno-e500/cross/unstable/Packages.gz
Updated list of available packages in /opt/lib/ipkg/lists/cross
Successfully terminated.

If you use "ipkg upgrade" instead of "ipkg update", also all already installed custom packages are upgraded, too.

Boostrap done. Now you can install optional packages via the ipkg command on your Synology.

References:

  1. https://www.naschenweng.info/2012/01/17/synology-dsm-4-0-beta-breaks-ipkg/

Saturday, March 7, 2015

Linux Mint: Install new kernel version and update Virtual Box kernel module

Objective


I want to install the latest Linux Kernel available for my system. I also want still to work with my already installed VirtualBox which needs to install a kernel module after a kernel switch.

Motivation


There was no real resaon behind my plans to install the Linux Kernel 3.17.1. I just thought it's time for an upgrade. My current kernel is 3.13.

Prerequisites


  • Linux Mint 17.1 Rebecca
  • Oracle VM VirtualBox Manager 4.3.24

Solution


Install the Linux Kernel packages


To check which kernel packages are currently available you can do a search like (filtered by version "3.17"):

$> apt-cache search linux- | grep 3.17

you'll see some output like this:

linux-headers-3.17.1-031701 - Header files related to Linux kernel version 3.17.1
linux-headers-3.17.1-031701-generic - Linux kernel headers for version 3.17.1 on 64 bit x86 SMP
linux-image-3.17.1-031701-generic - Linux kernel image for version 3.17.1 on 64 bit x86 SMP

For 64-Bit systems download the following packages ...

$> wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.17.1-utopic/linux-headers-3.17.1-031701_3.17.1-031701.201410150735_all.deb

$> wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.17.1-utopic/linux-headers-3.17.1-031701-generic_3.17.1-031701.201410150735_amd64.deb

$> wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.17.1-utopic/linux-image-3.17.1-031701-generic_3.17.1-031701.201410150735_amd64.deb

and for 32-Bit systems download the following ...

$> wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.17.1-utopic/linux-headers-3.17.1-031701_3.17.1-031701.201410150735_all.deb

$> wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.17.1-utopic/linux-headers-3.17.1-031701-generic_3.17.1-031701.201410150735_i386.deb

$> wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v3.17.1-utopic/linux-image-3.17.1-031701-generic_3.17.1-031701.201410150735_i386.deb

Now install the packages:

$> sudo dpkg -i linux-headers-3.17.1*.deb linux-image-3.17.1*.deb

Reboot the system.

$> sudo reboot

After a successful reboot, you can delete the *.deb packages again:

$> rm linux-*


Uninstall the Linux Kernel again (if you don't like it anymore)


You can uninstall the new kernel with the following command, be aware that this may make your system unusable.

$> sudo apt-get remove 'linux-headers-3.17.1*' 'linux-image-3.17.1*'

Setup the VirtualBox Kernel module


$> sudo /etc/init.d/vboxdrv setup

You'll see output similar to:

Stopping VirtualBox kernel modules ...done.
Uninstalling old VirtualBox DKMS kernel modules ...done.
Trying to register the VirtualBox kernel modules using DKMS ...done.
Starting VirtualBox kernel modules ...done.

Now you are done!