The Developer's Tidbit

September 1, 2009

How to manually transfer large directories from an external device to your QNAP device

Filed under: linux, qnap — Ben @ 3:22 pm

Recently I was forced to format my QNAP TS-109 and reinstall the firmware. For some reason the file partition holding all the data became so corrupt that the QNAP firmware would refuse to even mount the drive. No amount of partition fixing or recovering would enable it to mount. Eventually I gave up and restarted from scratch.

Lucky I had all the QNAP data stored on a secondary, dumb USB hard drive so no data was lost. This is something I would recommend to everyone do, even those with NAS devices which run with multiple drives.

One of the problems though was trying to work out an easy away to transfer the 750 GB of data from the USB device over to the NAS server without using the QNAP Backup feature. In the past I have found it unreliable and I also preferred the manual control of using the Linux command line.

Fortunately the QNAP server comes with the handy command known as rsync. This utility covered all my needs quite well and so below I will explain how to use it with an external USB device and a QNAP NAS server.

Part I, Telnet

  • Turn on your QNAS server and wait for it to boot.
  • Plug in your external USB device into a USB socket at the back of the QNAS server and turn the USB device on (if needed).
  • Web browse to your QNAP administration page, by default it is at http://169.254.100.100:8080. Login using your administrator (admin) account.
  • Go to External Device and then select USB Disk.
  • If everything is okay your USB disk should be shown in the web form.

QNAP USB Disk

  • Now we are going to turn on the Telnet remote log-in of the QNAP server. If you already are familiar with using Telnet or SSH to connect to your QNAP server you can skip this and go to Part II of this article.
  • In the QNAP administrator webpage select Network Services > Remote Login.
  • On the Remote Login make sure the Telnet connection is selected.

Remote Login

  • Now we will need to connect to your QNAP server using a Telnet client. I recommend the very popular client known as Putty (http://www.chiark.greenend.org.uk/~sgtatham/putty/). So if you don’t have a client, download Putty and install it. From now on I will assume that is what you are using.
  • In Putty setup your Putty Configuration to look like this, but obviously replace the IP address with that of your QNAP server. Once you have setup Putty, open the session.

Putty Configuration

  • Once connected you should be prompted for a login in a screen that is not unlike the Windows Command Prompt. Login using your QNAP ‘admin‘ account, as this is the only account accepted by QNAP under Telnet.

Putty Login

Part II Rsync

Rsync is a Linux tool that allows you to synchronise directories together. Your QNAP device keeps symbolic links to all the folders within the /share/ directory. The external USB device will be located in the /share/USBDisk1/ directory.

Rsync comes with a number of option attributes but we will only list the ones of interest to our task.

Command: rsync [OPTIONS...] SOURCE… [DESTINATION]

OPTIONS
-v verbose output – displays syncing information
-vv verbose output with additional information
-r recursive scanning and copying – scans and copies all sub-directories
-h human readable output – recommended
–size-only – recommended otherwise rsync will use dates to check for file differences. If you have to abort and later resume your synchronisation, this option will enable you to skip the files that have already been copied to your QNAP server.
–progress displays live transfer details such as the percentage copied and the speed of the transfer
-n dry run – simulates the copy without actually transferring any files. This is good if you wish to play around with the options.

If you wished for example to copy the backed up /MyMedia/ folder onto your QNAP server under the /Qmultimedia/ folder you would run the following command. Remember Linux is caps sensitive.

rsync –v –r –h –size-only –progress /share/USBDisk1/MyMedia/ /share/Qmultimedia/

With this information you should be able to copy large amounts of data from external USB devices onto your QNAP server without any troubles. If you need to cancel your session during mid-transfer, simply abort the synchronisation using the Ctrl-C key combination or exit Putty. When you are ready to resume, reconnect using Putty and run the same command again and rsync will resume from the last copied file saving you valuable time and duplication.

Once you have completed all the file transfers you need to conduct, make sure you disable Telnet access from your QNAP administration.

May 21, 2009

Disable Ubuntu/Gnome PC Speaker, Beeper Emulation

Filed under: linux — Ben @ 6:45 am

I recently installed Ubuntu 9.4 onto my fairly new Dell XPS laptop. Everything has been fine until I encountered one of the more annoying things I find about Linux, its sound and audio set-up. The operating system depends on multiple sound interfaces that essentially compete to do the same functions. It reminded me of PC audio back in my youth under MS-DOS.

The annoying thing is a driver that literally emulates the beeping, squeaking and downright horrible noise of PC speaker. This 1981 budget sound device emulation can at times ignore all your audio and mute settings. Worse because it is emulated, removing the Linux pc speaker audio driver does not work. After hours of being driven crazy by random speak alert prompts I discovered what was causing this and more importantly how to disable it. Simply…

  1. On the Gnome panel right click the volume control (should be a speaker icon)
  2. Open Volume Control
  3. Select the Alsa Mixer
  4. Then click Preferences
  5. In the Volume Control Preferences select the PC Beep playback and then close the dialogue
  6. Now you should see the PC Beep volume control in the Volume Control dialogue
  7. Press the mute button and you should be done, blissful quietness
PC Beep muted, thank goodness!

PC Beep muted, thank goodness!

April 18, 2009

Railo on Linux, CFEXECUTE bug

Filed under: linux, railo — Ben @ 6:12 am

I stumbled upon this bug today that drove me nuts trying to figure out what was wrong. I was using the Linux FILE program within the Railo <CFEXECUTE /> tag  to extract MIME type data from a large collection of files,  so it could be inserted into a database. The problem was Railo kept on getting stuck in a prolonged loop. After much troubleshooting I realised the affected files all contained spaces within their file names.

A search on the Internet revealed this bug was recently submitted by Andy Carmichael at https://jira.jboss.org/jira/browse/RAILO-163. Essentially I am guessing Railo’s <CFEXECUTINE /> incorrectly converts spaces into newline characters. Combining the bug with the Linux FILE program causes the active CFM application to be caught in a very prolonged process.

Unfortunately until the bug is fixed, the only work around I came to was to scan and skip any file names containing spaces, or to automatically rename them to names with under scores.

Below is the error message when using the Linux VDIR command on a file containing spaces within legal quotes.

vdir: cannot access '/home/A: No such file or directory
vdir: cannot access test: No such file or directory
vdir: cannot access file.text': No such file or directory
Next Page »

Blog at WordPress.com.