Thursday, November 03, 2011

[Pogoplug] How to fix 'drive is not available'

I met this problem recently when trying to access an external hd driver.

After Google I got the following:

Text of fix provided by Pogoplug support:

The symptoms you are describing could be caused by a corrupted index file on your Pogoplug's drive. The good news is that this file is automatically regenerated if it isn't present, but the data corruption is not currently detected by the software. Your files are intact but please do the following to resolve this:

- Log in to http://my.pogoplug.com and safely notify the software you wish to eject your drive using the eject icon next to your drive on the left pane.

- Remove you hard drive from the USB on your pogoplug.

- Attach your hard drive to your computer and allow it to be discovered.

- Open the drive in windows explorer, and delete file named "cedb" in the folder named ".cedata"

- Safely remove your drive by clicking the Safely Remove Hardware option from the toolbar in the lower right of the screen.

- Power cycle your Pogoplug, wait for SOLID green led's

- reattach your hard drive to your Pogoplug.

What I did is some different than above:
- ssh into pogoplug, remove the index file in /tmp/.cemnt/mnt_sdb2/.cedata

However I got another problem: "cannot stat '.cedata/cedata_journal': Input/Output error"
It looks like a file system corruption. Ran 'fsck' got some error... And searched online got the following:

fsck applet is only a driver. Real checking is done by executing fsck. binary. Currently, busybox does not build fsck.ext2 (although code is still around in e2fsprogs/old_e2fsprogs/e2fsck.c).

So install e2fsprogs.

  ipkg update

  ipkg install e2fsprogs



Now, Open a browser, logged in mypogoplug.com and eject the drive.
Back to ssh window:

- check 'mount' to make sure the drive is umounted

- run 'e2fsck /dev/sdb2'. Errors on file system fixed.

- reboot. The drive is usable now.

Monday, March 28, 2011

VIM extension setting (syntax color, multiple files ...) on Mac OS

This article is about how to set configurations on Mac OS 10.6 to use extension option of vim.

Making an optimized configuration file

To allow for syntax highlighting, auto indentation, etc. in vim, open a new Terminal window and enter these commands to open vim’s configuration file:

cd /usr/share/vim

sudo vim vimrc

Press the ‘i‘ key to switch vim to Insertion Mode, then enter these lines below the ‘set backspace=2‘ line:

set ai " auto indenting
set ruler " show the cursor position
syntax on " enable syntax highlighting
set background=dark " make color suitable to dark background
set history=100
set hlsearch " highlight the last searched term
filetype plugin on " use the file type plugins

nmap <C-T> :tabprev<CR> " key mapping to move between files when open in tabs: Ctrl+T
nmap <C-B> :tabnext<CR>  " Ctrl+B


" When editing a file, always jump to the last cursor position
autocmd BufReadPost *
\ if ! exists("g:leave_my_cursor_position_alone") |
\ if line("'\"") > 0 && line ("'\"") <= line("$") |
\ exe "normal g'\"" |
\ endif |
\ endif

Press the Escape key to take vim out of Insertion Mode, then press ‘:‘ (colon) followed by ‘x‘ to save the file and exit.
Open/Create a script file with vim, for example:

vim hello.php

You’ll see that vim now automatically indents code, displays the cursor position, has syntax highlighting, etc.

To open multiple files in tabs, replace vi with vim

You can add the following line into your .profile or .bash_profile :

alias vi="vim -p"

Alias allows us to change the way of calling vim, when typing vi, bash shell will replace vi command with vim -p. Therefore, we can open multiple files in tabs.

After saving the file, run
source ~/.profile
vi file1 file2 file3

As we already added key mappings in .vimrc, you can switch between files with 'Ctrl+T' and 'Ctrl+B'.


The :tabf command allows you to search for a file in your current path and open it in a new tab. For instance, if you want to open a file called inventory.txt that's in your current path, you could run:

:tabf inven*

That will search for a file that matches the string inven and any number of characters after it. If only one file is found, Vim will open it in a new tab. If you have several files that match, Vim will complain that too many files match, and you'll have to narrow the search a little. The :tabn command will do autocompletion of file names in your path, so you can just type the first few characters of a filename and hit Tab to find the right file.

Reference to this link for more: Vim tips: Using tabs

To open multiple files in splits

If you are already editing a file in vim and want to split the screen and edit a second one, you can use either of these commands:

:sp filename Splits the screen horizontally and opens filename in the new area.
:vsp filename Splits the screen vertically and opens filename in the new area.

Any split can be further split -- you can edit as many files in a single instance of vim as you like.

Use the following commands to move back and forth through your files and manage the size of the splits.
The prefix for all the below commands is <c-w> -- that is, hold down Ctrl and type w. Press <c-w> before typing any of the below commands.

<C-W> Moves to the next split.
k Moves to the split above the current split.
Up Moves to the split above the current split.
j Moves to the split below the current split.
Down Moves to the split below the current split.
h Moves to the split on left side of the current split.
l Moves to the split on right side of the current split.
+ Increases the size of the current split by one line. (Try combining this with counts -- e.g. 5<C-W>+ will make the split five lines bigger.)
- (Minus sign) Decreases the size of the current split by one line.
_ (Underscore) Maximize the current split (that is, make it take up as much room as possible.)

We can add the below key maps to .vimrc file to make working with splits easier:

map <C-J> <C-W>j<C-W> "go to the split below the current one
map <C-K> <C-W>k<C-W> "go to the split above the current one
map <C-H> <C-W>h<C-W> "go to the split on left of the current one
map <C-L> <C-W>l<C-W> "go to the split on right of the current one


Saving and quitting

When working with multiple files, each tab / split acts something like an individual instance of vim -- so :w and :q work on the current file. If you want those commands to apply to all the files instead of just the current one, add 'a' to them -- for instance, :wa saves all the open files, :qa quits all open files (and exits vim), and :wqa saves and then closes all open files.

Friday, January 07, 2011

Pogoplug and WDTV sharing via NFS

Finally I get Pogoplug and WDTV linked. Yahoo!!

NFS Server (Pogoplug)
Reference to 'Running an NFS Server' in http://openpogo.tumblr.com/

ipkg install nfs-server
vi /opt/etc/exports
# add following line 
/tmp/.cemnt/mnt_sdb1/download 192.168.1.0/255.255.255.0(rw,async,no_root_squash) 
 
Because nfs-server depends on the portmapper, we must verify that portmapper is running before start nfs-server.

# start nfs server
/opt/etc/init.d/S56nfsd

# make sure nfsd started
ps -w


NFS Client (WDTV)
Devices I have:
* WDTV: gen 1 with B-Rad's unofficial firmware WDLXTV 0.5.8.1
* Wireless adapter: Rosewill RNX-EasyN1 (Chipset Ralink 3070)
* USB drive: a very old timer -- Apacer 32M. Yes, and don't laugh. It is 32M. You read it correctly. It came back to life again. :)

- Config network with Wireless adaptor

Fortunately Pogoplug has web interface wireless support in my.pogoplug.com. So I first plug RNX-EasyN1 into pogoplug and set it up in the web interface. Then simply copy /etc/Wireless/RT2870STA/RT2870STA.dat out from pogoplug to root of the start up USB drive.

Download wireless app wireless-mod-rt.app.bin (search in WDTV Forum) and put in root of usb drive.

- Add NFS app
download nfs.app.bin-0.3 and copy to root of USB drive.

-Config NFS Client
Edit net.mounts and put into usb drive root.
xmount 192.168.1.3:/tmp/.cemnt/mnt_sdb1/download Pogo nfs udp,soft,rsize=32768,wsize=32768


Evertything is ready now. 'Restart' WDTV.
There are 2 ways to restart WDTV:
- Pull out power adaptor and wait a while (let's say 20 sec) and plug in
or
- Telnet/SSH into WDTV if you have network setup successfully already. Run reboot.

Check if NFS share is success from your WDTV GUI. If there is problem, telnet/ssh into wdtv and check mount, /etc/fstab... My link is not stable at first, after several reboot, it's there finally. Cheers!

Thursday, January 06, 2011

[Pogoplug] Install Transmission

Based on Installing OpenPogo + Transmission on dockstar

- SSH into Pogoplug.
        
    # makes filesystem read-write
    mount -o rw,remount / 
    ipkg install nano transmission
    # Run the following 2 commands to generate a configuration file for Transmission
    transmission-daemon --config-dir /opt/etc/transmission-daemon 
    killall transmission-daemon
    # modify the settings.json file
    # go to line 44 and make “rpc-whitelist-enabled”: false, save it
    vi /opt/etc/transmission-daemon/settings.json
    transmission-daemon --config-dir /opt/etc/transmission-daemon 
    mount -o r,remount /


Now you should be able to browse the web interface with http://pogoplug_ip-addr:9091 and change settings in the preference page. You can also go into the setting.json and modify any of the other settings.

To set an init script to make transmission run on boot create a script:

vi /opt/etc/init.d/S88transmission 

#!/bin/bash
# Starts up transmission
#

start() {

 echo -n "starting up transmission:"
 if [ -n "`pidof transmission-daemon`" ]; then
  killall `pidof transmission-daemon`
 fi

 /opt/bin/transmission-daemon --config-dir /opt/etc/transmission-daemon --blocklist

}

stop () {

   echo -n "stopping transmission:"
   killall transmission-daemon

}

restart () {

   stop
   start
}

case "$1" in

   start)
   start
   ;;

   stop)
   stop
   ;;

   restart)
   restart
   ;;

   *)
   echo "usage: $0 {start|stop|restart)"
   exit 1
   ;;

 esac


Be sure to set the downloads directory from the interface to the real directory identified by the pogoplug ie. '/tmp/.cemnt/mnt_sdb1/downloads' you should see the field getting populated in the setting.json file, now whenever you reboot transmission should start up too.

[Pogoplug] Install/Uninstall PlugApps to a USB flash drive

- Make sure all the wires are linked ( network, power, usb )
- Get IP address of pogoplug from router/modem
- Log into my.pogoplug.com to enable SSH access and set a password.
- SSH into pogoplug as root with putty.

- Partition/format the USB Drive on which you will install PlugApps
cd /tmp
wget http://plugapps.com/os/pogoplug/mke2fs
chmod 755 mke2fs
killall hbwd # This will turn off my.pogoplug.com functionality temporarily and unlock the USB drive for PlugApps installation.
/sbin/fdisk /dev/sda # delete all existing partitions and create a new one
./mke2fs /dev/sda1
/sbin/reboot


- Unplug usb and reboot and plugin usb when restarted

- Install PlugApps

On your PC navigate to the Pogoplugged Development download page http://www.pogoplugged.com/download/list?cat=36 and download the "opt.tar.gz" file to your computer. Then upload it into the root of usb drive via my.pogoplug.com.

SSH again.

cd /tmp/.cemnt/mnt_sda1
# wget http://openpogo.com/base/openpogo-usb.tar.gz
# tar -xzvf openpogo-usb.tar.gz
tar -xzvf opt.tar.gz
mount -o rw,remount /
ln -s /tmp/mnt_opt/.opt /opt

# When booting the mount_opt script looks for openpogo on any of the 4 usb ports and then creates another link to the physical device as /tmp/mount_opt/.opt. So a link pointing to a link pointing to a physical disk because we do not know what order the drives get mounted after reboot.

cp /etc/init.d/rcS /etc/init.d/rcS.original
echo '# code added below for OpenPogo /opt on USB with init on boot' >>  /etc/init.d/rcS
echo '/etc/init.d/mount_opt' >>  /etc/init.d/rcS
echo '/opt/etc/init' >>  /etc/init.d/rcS

echo '#!/bin/bash' > /etc/profile
echo '# New profile added for OpenPogo /opt on USB' >> /etc/profile
echo '#' >> /etc/profile
echo 'export PATH=/opt/bin:/opt/sbin:/usr/bin:/usr/sbin:/bin:/sbin' >> /etc/profile

cp /tmp/.cemnt/mnt_sda1/.opt/mount_opt /etc/init.d/
rm /tmp/.cemnt/mnt_sda1/openpogo-usb.tar.gz
chmod 755 /etc/init.d/mount_opt

/sbin/reboot


- SSH again after restart

Change to the original repository


Since OpenPogo is no longer maintained you should change to the original repository:

Change to the ipkg configuration directory
cd /opt/etc/ipkg

Check the name of the conf file
ls

You should see some filename with .conf in the ending, then edit this file
vi or nano filename.conf (probable armel-feed.conf)

Comment out current repo
"src cross http://openpogo.com/repo" 
to 
"#src cross http://openpogo.com/repo"

Then add the new repo underneath
src cross http://ipkg.nslu2-linux.org/feeds/optware/cs08q1armel/cross/stable

Exit from your editor, then reboot your system
sync
sync
reboot

Once rebooted, log back in to your system and do an update
ipkg update


Congratulations! OpenPogo should now be successfully installed and you are all ready to go. Just log back in using ssh again.

UNINSTALL

In case you need to uninstall PlugApps, SSH into pogoplug first:
mount -o rw,remount /
mv /etc/init.d/rcS.original /etc/init.d/rcS
rm /etc/profile
rm /etc/mount_opt
rm /opt
mount -o r,remount /
rm -r  /tmp/.cemnt/mnt_sda1/.opt
/sbin/reboot

Reference:
How-to-Install-or-remove-OpenPogo-on-Your-Pogoplug-Attached-USB-Drive/

[Pogoplug] Hacking Pogoplug Gray version

Around 2 months ago, I got a Pogoplug gray version when BB had it on sale.

The exciting thing about this box is:
- It's linux based which means you can hack in it and add on packages you want.
- It's small, low noise, energy saving.

I've been looking for a low budget NAS for a long time. So the chance is here.

The software with this box provides online access and Windows/Mac/Linux drive driver. But it's not enough for me. I also need it to be able to download, and link to my WDTV as a media center. To modify this pogoplug into my ideal NAS, I searched online and read a lot articles about it. PlugApps is the most complete and successful one I found so far. Here is what I did.

First I installed PlugApps to a USB flash drive based on
OpenPogo:Installing Base Package - USB
and
How to Install (or remove) OpenPogo on Your Pogoplug-Attached USB Drive.

It provides additional features to the existing Pogoplug software by creating an opt folder on the USB drive that allows installation of Optware ipkg applications.

** Since Pogoplug disabled ssh by default, ssh must be enabled from the settings page of my.pogoplug.com before starting this installation.

What I used:
- I downloaded putty to my Asus EeePC (Windows XP) to SSH into pogoplug and execute all the commands;
- a 8GB Kingston USB flash drive formatted to ext2 attached to pogoplug.

When the basic stuff are in place, I added more packages such as: Samba (file sharing), Transmission(BT download), Lighttpd Web Server with PHP , MySQL and PHPMyAdmin ...

Then the most important part, install NFS server to share media to WDTV.

OK. That's it. I'll put more details in later posts.