Nick's Tech Blog

Pages

Wednesday, December 17, 2014

ZFS folders on Ubuntu 14.04 LTS not mounting after reboot

Problem

On Ubuntu 14.04 LTS, I installed a ZFS ZPOOL following these instructions.

After a restarting my machine however, the zpools failed to mount. I couldn't see any apparent errors from checking the logs.

Solution


Attempt #1


Executing the following command actually mounts the zpool as desired. We could execute this script on startup (but we shouldn't have to).
zpool import -a

Attempt #2


Apparently setting/adding the following properties automatically mounts the zpool. This didn't work for me (my version of zfs).

File: /etc/default/zfs
ZFS_MOUNT='yes'
ZFS_UNMOUNT='yes'

Attempt #3


Other solutions suggest adding a sleep to the following file:

File: /etc/init/mountall.conf

I didn't even bother trying this though.

Attempt #4 (Success)


I came across the following zpool config file, and tried changing the value for zfs_autoimport_disable from 1 to 0.

File: /etc/init/zpool-import.conf
modprobe zfs zfs_autoimport_disable=0

After a restart, my zpools were imported (success!). Then, to automatically mount the zfs mounts, I had to add the following line:

File: /etc/rc.local
zfs mount -a
Not sure why this value is defaulted to 1, but changing it to 0 worked for me.

Tuesday, December 24, 2013

Installing Tomcat8 as a service on Window7

Install it!

  1. Download Tomcat8 zip for your operating system. -> http://tomcat.apache.org/download-80.cgi (I grabbed the Windows 64bit version)
  2. Unzip it to the directory where you want it to live.

Check your Config

  1. Check your config by running <tomcat_home>\bin\configtest.bat

Error1: JVM & JDK had a space in the name.
Fix1: Fixed by setting JAVA_HOME and JRE_HOME Environment Variables to use C:\Progra~1\Java\<java_version>

Error2: JVM was 32bit, needed to be 64bit
Fix2: Changed JAVA_HOME and JRE_HOME to use correct 64bit Java install. 

Install Tomcat8 as a service

  1. Run: <tomcat_home>\bin\service.bat install
When starting, it failed with "Error Code 4".
I had a look in the Windows System Logs, and found this: "The Tomcat8 service terminated with service-specific error The system cannot open the file."

Enable logging:

  1. Run <tomcat_home>\bin\tomcat8w.exe (a window will open)
  2. Under the "Logging" tab, set the logging directory
  3. Set the STDOUT and STDERR files
  4. Set the logging to DEBUG (turn this back to INFO when app starts up successfully).
  5. Attempt to start the app again, and check the logs:

Error3: stderr.log
2013-12-24 13:18:43 Commons Daemon procrun stderr initialized
java.lang.NoClassDefFoundError: org/apache/catalina/startup/Bootstrap
Caused by: java.lang.ClassNotFoundException: org.apache.catalina.startup.Bootstrap
Fix3: Using tomcat8w.exe
  1. Run <tomcat_home>\bin\tomcat8w.exe (a window will open)
  2. Under the "Java" tab, set the classpath (which was empty) to the following:
C:\devtools\apache-tomcat-8.0.0-RC5\lib\*;C:\devtools\apache-tomcat-8.0.0-RC5\bin\*;

After that, I was able to start up Tomcat8 successfully -> http://localhost:8080/

After installing some apps, I got:
Error4: java.lang.OutOfMemoryError: PermGen space
Fix4: 
  1. Run <tomcat_home>\bin\tomcat8w.exe (a window will open)
  2. Under the "Java" tab, I changed the "Java Options" to:
-Dcatalina.base=C:\devtools\apache-tomcat-8.0.0-RC5
-Dcatalina.home=C:\devtools\apache-tomcat-8.0.0-RC5
-Djava.endorsed.dirs=C:\devtools\apache-tomcat-8.0.0-RC5\endorsed
-Djava.io.tmpdir=C:\devtools\apache-tomcat-8.0.0-RC5\temp
-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
-Djava.util.logging.config.file=C:\devtools\apache-tomcat-8.0.0-RC5\conf\logging.properties
-Xms256M
-Xmx1024M
-XX:MaxPermSize=1024M
-XX:MaxHeapSize=256M
-XX:PermSize=256M
-XX:+CMSClassUnloadingEnabled
-XX:+CMSPermGenSweepingEnabled

Everthing's now working smoothly!

Additional Notes:

1) I had to add <tomcat_home>/bin/tomcat7.exe and <tomcat_home>/bin/tomcat7w.exe to Windows Firewall.

2) When uploading a new application, I got the following error:
java.lang.IllegalStateException: org.apache.tomcat.util.http.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because its size (53706238) exceeds the configured maximum (52428800)
Simply modify the following section in <tomcat_home>/webapps/manager/WEB-INF/web.xml
    <multipart-config>
      <!-- 50MB max -->
      <max-file-size>52428800</max-file-size>
      <max-request-size>52428800</max-request-size>
      <file-size-threshold>0</file-size-threshold>
    </multipart-config>

I doubled the values from 52428800 to 104857600.

Friday, May 10, 2013

Groovy > Bidirectional binding using SwingBuilder

Problem

I was trying to setup "two-way" binding (e.g. model can update the ui, and vice versa), in a single bind{} statement.

For example, the below code is exhibiting the "two-way" binding behaviour that I want (i.e. toggleButton <-> model.toggleButtonValue). I was wondering if there was a more succinct way to get the same behaviour, but without having two statements (i.e. without the need to have the actionPerformed)?
toggleButton('Test',
  selected: bind { model.toggleButtonValue }, // model->button
  actionPerformed: { model.toggleButtonValue = button.selected }) // button->model

So I posted on the Groovy forums, and got the following answer from Ed Clark (Thanks Ed!)

Solution

Just use the "mutual" flag, like in the following examples:

toggleButton('Test',
  selected: bind (source: model, 'toggleButtonValue', mutual: true))

// Fyi, the following also works, but the button will ignore the
// model's value on initialisation.
toggleButton('Test', selected: bind (target: model, 'toggleButtonValue', mutual: true))

As far as I know, it's an undocumented feature at the moment. I couldn't find it on the SwingBuilder.bind site/docs.

See Also:
My Original Problem on the Groovy Forums

Thursday, February 28, 2013

Plex on Ubuntu > can't access home directory

Problem

After installing plex media server, I went to add some media libraries. I couldn't see any directories under my home directory.

Solution - Difficulty: Very Easy

The "plex" user account doesn't have permission to view any directories under your home directory. In addition, if there are any subdirectories it can't view, rather than show the directories it can, it shows nothing.


First of all, lets give it access to your home directory:

nick@pc:~$ ll -d ~
drwx------ 89 nick nick 28672 Feb 28 19:21 /home/nick/
nick@pc:~$ sudo chmod 755 ~
nick@pc:~$ ll -d ~
drwxr-xr-x 89 nick nick 28672 Feb 28 19:21 /home/nick/

Because I still can't add my media library plex, I'm going to "pull out" just the folders I want plex to use, into it's own home directory (using symbolic links).

nick@pc:~$ sudo mkdir /home/plex
nick@pc:~$ sudo chown plex:plex /home/plex
nick@pc:~$ sudo ln -s /home/nick/Music /home/plex/Music
nick@pc:~$ ll /home/plex
total 8
drwxr-xr-x 2 plex plex 4096 Feb 28 20:23 ./
drwxr-xr-x 5 root root 4096 Feb 28 20:22 ../
lrwxrwxrwx 1 root root   16 Feb 28 20:23 Music --> /home/nick/Music/

And there you have it. You should now be able to add "/home/plex/Music".


Additional Troubleshooting:

If you want to test what directories the "plex" user account can access, you can become the "plex" user by typing:

nick@pc:~$ sudo su plex

Navigate around, do some troubleshooting. To exit back to your own account, just type "exit".

Friday, August 31, 2012

ANT > default 'help' target

Problem

I want the default target for ant™, to display the project help.

Solution

Add the following default target:
<?xml version="1.0" encoding="UTF-8"?>
<project default="help" name="test" xmlns="antlib:org.apache.tools.ant">
         
  <target name="help" description="print the help">
    <exec executable="${ant.home}/bin/ant">
      <arg value="-projecthelp"/>
      <arg value="-buildfile"/>
      <arg value="${ant.file}"/>
    </exec>
  </target>
  
</project> 

This allows us to display the help using the following commands.
ant
ant help
ant -buildfile somefile.xml

Improved from the following website:
http://amazing-development.com/archives/2005/01/28/ant-help-target/

Tuesday, August 21, 2012

Ubuntu lightdm login screen!

Problem

You want to customise your login screen.

Solution

Checkout lightdm "greeters". Below is an example of "crowd-greeter".



Instructions to install it can be found here:
http://www.iloveubuntu.net/lightdm-receives-new-experimental-3d-character-based-greeter-ubuntu-1110

I haven't found a single site which lists available greeters. Thanks go to Robert Ancell for this list of greeters:

See also:
"SO YOU WANT TO WRITE A LIGHTDM GREETER…" - http://www.mattfischer.com/blog/?p=5

Friday, August 17, 2012

Use sed to remove '^M' characters from a file

Simple stuff, this post is here more as a reference than anything.

Problem

Windows puts '^M' characters throughout text files. I want to remove them.

Solution

The following commands will strip out the '^M' characters, and put the contents into a new file, then overwrite the original file.
sed -e s/^M//g oldfile.txt > newfile.txt
mv newfile.txt oldfile.txt
To get the '^M' character, type Ctrl+V,Ctrl+M