December 08, 2014

ZFS Notes

   28  zpool create -f 2TB-RAIDZ raidz /dev/sdc /dev/sdh /dev/sdi
   29  zpool status datastore
   30  mkdir /media/zfs
   31  zfs create -o mountpoint=/media/zfs/ datastore/zfs
   32  zfs list

Scan for new Hard Disks

ls /sys/class/scsi_host/ | while read host ; do echo "- - -" > /sys/class/scsi_host/$host/scan ; done


zpool status -x datastore
  647  zpool status -v datastore
  667  zpool status -f datastore
  833  zpool health
  834  zpool list
  835  zpool history
 zfs get compressration
 zfs list

August 25, 2014

Raspberry Pi SeedBox

Installed Deluge 1.3.6 as per this post:

http://www.onepitwopi.com/raspberry-pi/installing-deluge-1-3-6-on-a-raspberry-pi/

Find External Hard Drive:

  •  dmesg | grep sd
  • [    4.487833] sd 0:0:0:0: [sda] 488397168 512-byte logical blocks: (250 GB/232 GiB)

Delete existing partitions with cfdisk 
  • cfdisk /dev/sda
and create a single primary partition. Then format:
  • mkfs.ext4 /dev/sda1
Mount it and setup automount:
  1. mkdir /media/usbhdd
  2. mount /dev/sda1 /media/usbhdd/
  3. echo "/dev/sda1       /media/usbhdd   ext4    defaults     0       0" >>/etc/fstab
Move /var/log to external HDD

  1.  /etc/init.d/rsyslog stop
  2. mv log /media/usbhdd/
  3. ln -s /media/usbhdd/log
  4.  /etc/init.d/rsyslog start
Script to update Deluge Interface IP (/etc/network/if-up.d):

#! /bin/sh
/etc/init.d/deluge-daemon stop
oldIP=`cat /etc/network/eth0.ip`
newIP=$(ip -f inet -o addr show eth0|cut -d\  -f 7 | cut -d/ -f 1)
logger "DELUGE Updating Deluge IP Address, $oldIP -> $newIP"
sed -i -e 's/listen_interface": "'$oldIP'"/listen_interface": "'$newIP'"/g'  /root/.config/deluge/core.conf
if [ $? = 0 ]; then
    echo $newIP >/etc/network/eth0.ip
    logger "DELUGE IP BINDING SUCCESS"
    /etc/init.d/deluge-daemon start
else
    logger "DELUGE IP BINDING FAILUE"
fi
Setup folder for Deluge stuff:
  1. mkdir /media/usbhdd/media
  2. ln -s /media/usbhdd/media/
Install FlexGet

  1. apt-get install python-pip
  2. pip install flexget

July 02, 2014

Rasplex - Restricting section access at certain times

In case anyone is interested, as this is rasplex and I want to keep the auto updates, I wrote a script that runs on a different box:

sshpass -p 'rasplex' ssh -v root@192.168.1.120 'sed -i -e s/OLDTOKEN/NEWTOKEN/g /storage/.plexht/userdata/guisettings.xml' 
sshpass -p 'rasplex' ssh -v root@192.168.1.120 'sed -i -e "s/Signed in (OLDUSERNAME)/Signed in (NEWUSERNAME)/g" /storage/.plexht/userdata/guisettings.xml'
sshpass -p 'rasplex' ssh -v root@192.168.1.120 'reboot'


I have enabled 'Require authentication on local networks" on the local media server. Would be nice to restart services instead of reboot, but will work on that later.

GPS on Pi

AdaFruit Ultimate GPS Module v3
Wiring:
GPS   RPi GIOP
VIN   5V
GND   GND
RX       TX
TX       RX
——-
nano /boot/cmdline.txt
# Remove these in cmdline.txt:
# `console=ttyAMA0,115200`
# and `kgdboc=ttyAMA0,115200`.
# Mine looks like this:
dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
—–
Comment out the line “T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100″ at the end of /etc/inittab
nano /etc/inittab
#Spawn a getty on Raspberry Pi serial line
#T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
—-
apt-get install gpsd gpsd-clients
gpsd /dev/ttyAMA0 -F /var/run/gpsd.sock
cgps

January 24, 2013

Dynamic DNS on Raspberry Pi

With Ni-IP.org and inadyn



  1. Register for an account at no-ip.org.
  2. Install inadyn "apt-get install inadyn"
  3. create a config file in etc called inadyn.conf:
--username xxxx 
--password xxxx
update_period 60000
alias carpi.no-ip.org
dyndns_system default@no-ip.com

Raspberry Pi with 3G and WiFi


Aim: To have a Wireless hotspot in the truck with 3G internet and vehicle tracking
Kit:
  • Raspberry Pi running Raspbian
  • Powered USB Hub
  • Huawei E170 3G Dongle
  • TP-Link TL-WN722N
After several false starts and 10's of hours trying to get various hardware working I settled on the above.

Wireless Setup

apt-get install hostapd dhcpd
nano /etc/hostapd/hostapd.conf

interface=wlan0
driver=nl80211
ssid=3GPi
hw_mode=g
channel=11
wpa=2
wpa_passphrase=xxxxxx
wpa_key_mgmt=WPA-PSK
wpa_pairwise=CCMP
rsn_pairwise=CCMP
auth_algs=3
wmm_enabled=1
nano /etc/dhcp3/dhcpd.conf

subnet 10.10.0.0 netmask 255.255.255.0 {
        range 10.10.0.25 10.10.0.50;
        option domain-name-servers 202.37.101.1, 202.37.101.2;
        option routers 10.10.0.1;}
nano /etc/network/interfaces

auto lo

iface lo inet loopback

iface eth0 inet dhcp
 post-up iptables-restore </etc/network/iptables

allow-hotplug wlan0

iface wlan0 inet static 
  address 10.10.0.1 
  netmask 255.255.255.0 

  post-up /etc/init.d/hostapd start ; /etc/init.d/isc-dhcp-server start 
  down /etc/init.d/hostapd stop ; /etc/init.d/isc-dhcp-server stop
Permanently enable IP forwarding in /etc/sysctl.conf:
net.ipv4.ip_forward=1
nano /etc/network/iptables
*nat
:PREROUTING ACCEPT [2:208]
:INPUT DROP [2:208]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -i eth0 -j ACCEPT
-A INPUT -i wlan0 -j ACCEPT
-A INPUT -p icmp -m icmp --icmp-type 3 -j ACCEPT
-A INPUT -p icmp -m icmp --icmp-type 4 -j ACCEPT
-A INPUT -p icmp -m icmp --icmp-type 11 -j ACCEPT
-A INPUT -p icmp -m icmp --icmp-type 12 -j ACCEPT
-A INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT
-A INPUT -s [MY IP AT HOME] -j ACCEPT
:OUTPUT ACCEPT [1:108]
-A OUTPUT -o lo -j ACCEPT
-A OUTPUT -o ppp0 -j ACCEPT
-A OUTPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
:POSTROUTING ACCEPT [0:0]
-A POSTROUTING -o ppp0 -j MASQUERADE
COMMIT

Managed to get 2MB/s running through it using Plex on the iPad

Setting up 3G



wget "http://www.sakis3g.org/versions/latest/$ARCH/sakis3g.gz" # where $ARCH is either i386 or amd64
gunzip sakis3g.gz
chmod +x sakis3g
./sakis3g --interactive

I have had to make alot of changes to this since I added the GPS as the GPS module moves all the serial ports around. Here is the working config:


USBINTERFACE="0"
USBDRIVER="option"
USBMODEM="12d1:140c"
OTHER="USBMODEM"
MODEM="OTHER"
# Bus 001 Device 006: ID 12d1:140c Huawei Technologies Co., Ltd.
APN=CUSTOM_APN
#2degrees
CUSTOM_APN="direct"
APN_USER="vodafone"
APN_PASS="vodafone"

January 02, 2013

VMWare Server vmdk to ESX

vmkfstools -i <src> <dst>

http://www.corelan.be:8800/index.php/2007/09/11/moving-vmware-serverworkstation-vmdk-to-esx-server/

http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1028943