hype-o-thetic?com

my notes

andyleonard.com – zfs-snapshot.sh

leave a comment

Here’s a nice script found on thinking sysadmin. I slightly modified it to use the real mount point instead of assuming “/”, my changes are highlighted below:

#!/usr/local/bin/bash

# FROM: http://andyleonard.com/2010/04/07/automatic-zfs-snapshot-rotation-on-freebsd/

# Path to ZFS executable:
ZFS=/sbin/zfs

# Parse arguments:
TARGET=$1
SNAP=$2
COUNT=$3

# Function to display usage:
usage() {
    scriptname=`/usr/bin/basename $0`
    echo "$scriptname: Take and rotate snapshots on a ZFS file system"
    echo
    echo "  Usage:"
    echo "  $scriptname target snap_name count"
    echo
    echo "  target:    ZFS file system to act on"
    echo "  snap_name: Base name for snapshots, to be followed by a '.' and"
    echo "             an integer indicating relative age of the snapshot"
    echo "  count:     Number of snapshots in the snap_name.number format to"
    echo "             keep at one time.  Newest snapshot ends in '.0'."
    echo
    exit
}

# Basic argument checks:
if [ -z $COUNT ] ; then
    usage
fi

if [ ! -z $4 ] ; then
    usage
fi

# Get the TARGET mountpoint
TARGET_MOUNT=$($ZFS get -H -o value mountpoint $TARGET)

# Snapshots are number starting at 0; $max_snap is the highest numbered
# snapshot that will be kept.
max_snap=$(($COUNT -1))

# Clean up oldest snapshot:
if [ -d ${TARGET_MOUNT}/.zfs/snapshot/${SNAP}.${max_snap} ] ; then
    $ZFS destroy -r ${TARGET}@${SNAP}.${max_snap}
fi

# Rename existing snapshots:
dest=$max_snap
while [ $dest -gt 0 ] ; do
    src=$(($dest - 1))
    if [ -d ${TARGET_MOUNT}/.zfs/snapshot/${SNAP}.${src} ] ; then
        $ZFS rename -r ${TARGET}@${SNAP}.${src} ${TARGET}@${SNAP}.${dest}
    fi
    dest=$(($dest - 1))
done

# Create new snapshot:
$ZFS snapshot -r ${TARGET}@${SNAP}.0

Thanks Andy!

Fork me on GitHub

Written by gimpe

March 22nd, 2011 at 10:16 pm

Posted in bash,FreeBSD,FreeNAS

Tagged with , , ,

Steam: Install a single game on a different hard drive

leave a comment

I have a small ssd (c:\) so I installed my Steam client on my hdd (d:\). But there is a game I wanted to be on my ssd (c:\), here are the steps to do it:

  1. Close Steam
  2. Move the game to the new location
    e.g.: from “d:\Steam\steamapps\common\fallout new vegas” to “c:\Program Files (x86)\Steam\steamapps\common\fallout new vegas”
  3. Open a command prompt
    go in –> “Start Menu” –> “Run..” –> type “cmd”
  4. Create a Windows symlink
    type: mklink /J “d:\Steam\steamapps\common\fallout new vegas” “c:\Program Files (x86)\Steam\steamapps\common\fallout new vegas”
    output: Junction created for d:\Steam\steamapps\common\fallout new vegas <==> c:\Program Files (x86)\Steam\steamapps\common\fallout new vegas

Now start your Steam client and the game will run from its new location.

NOTE: Dead Money DLC didn’t install while using a symlink, I had to move the game back in its original location to download and install the DLC.

Written by gimpe

February 27th, 2011 at 6:32 pm

Posted in Uncategorized

How to Install Virtualbox 3.1.6 on NexentaStor 3.0.4

3 comments

Get: VirtualBox-3.1.6-59338-SunOS.tar.gz
Get: VBoz.zip

Unzip and RENAME python-lib-3.1.8.tar.bz2 TO python-lib.tar.bz2

Put everything in the same dir.

VirtualBox-3.1.6-59338-SunOS.tar.gz
solaris-lib.tar.bz2
sunwvbox-1.0-20100217.diff.gz
python-lib.tar.bz2

And now:

# add required packages
aptitude install alien g11n-minimal-uiu8 lib64gcc1 lib64stdc++6 lib64z1 libfontconfig1 libfreetype6 libgcc1 libice6 libpng12-0 libsm6 libstdc++6 libxau6 libxdmcp6 libxmuu1 libxrender1 python python-dev sunwcsl sunwcslr sunwlibm zlib1g

# untar & prepare VirtualBox
tar -xzf VirtualBox-3.1.6-59338-SunOS.tar.gz
alien -d -s -c --reloc_root=/ VirtualBox-3.1.6-SunOS-r59338.pkg

# patch it
gzip -d -c sunwvbox-1.0-20100217.diff.gz | patch -p0

# build it
cd sunwvbox-1.0
./debian/rules binary

# install the .deb package
cd ..
dpkg -i sunwvbox_1.0-1_solaris-i386.deb

That’s it! Many thanks to Ernst Gill!

SOURCES:
http://www.nexenta.org/boards/1/topics/142

Written by gimpe

August 6th, 2010 at 12:05 am

Posted in NexentaStor

Tagged with , , ,

VirtualBox useful commands (VBoxManage/VBoxHeadless)

leave a comment

# change VirtualBox disk and machine default location
VBoxManage setproperty hdfolder /volumes/data/vbox
VBoxManage setproperty machinefolder /volumes/data/vbox

# create a VM
VBoxManage createvm --name "U10.4-base" --ostype Ubuntu --register
# add some ram, network card, DVD-ROM
VBoxManage modifyvm "U10.4-base" --memory 128 --acpi on --boot1 dvd --nic1 bridged
# create a HDD
VBoxManage createhd --filename U10.4-base.vdi --size 10000 --register

# attach storage controllers to it
VBoxManage storagectl "U10.4-base" --name "IDE Controller" --add ide
VBoxManage storageattach "U10.4-base" --storagectl "IDE Controller" --port 1 --device 0 --type dvddrive --medium none

# remove .iso
VBoxManage closemedium dvd /volumes/data/exchange/mini-ubuntu-10.04-server-i386.iso

# start VM
VBoxHeadless --startvm "U10.4-base"

# stop VM (requires package acpid)
VBoxManage controlvm "U10.4-base" acpipowerbutton

# view VM information
VBoxManage showvminfo "U10.4-base"

Written by gimpe

July 25th, 2010 at 6:42 pm

Posted in bash,tips,VirtualBox

Tagged with , ,

How to Install Transmission 2.01 on NexentaStor 3.0.3

leave a comment

Install required packages

aptitude install libssl-dev libcurl4-openssl-dev intltool

Install libevent

wget http://monkey.org/~provos/libevent-1.4.13-stable.tar.gz
tar -xzf libevent-1.4.13-stable.tar.gz
cd libevent-1.4.13-stable
./configure
make && make install

Install Transmission

wget http://mirrors.m0k.org/transmission/files/transmission-2.01.tar.bz2
tar -xjf transmission-2.01.tar.bz2
cd transmission-2.01
./configure LIBEVENT_LIBS="-L/usr/local/lib -levent"
make && make install

Read the rest of this entry »

Written by gimpe

July 24th, 2010 at 12:02 am

Posted in NexentaStor

Tagged with , ,

Zotact IONITX-G-E Wake On USB with Ubuntu/XBMC (working)

leave a comment

  1. Edit /etc/default/grub and add:
    GRUB_CMDLINE_LINUX="usbcore.autosuspend=-1"
  2. Run update-grub
  3. Edit /etc/crontab add:
    @reboot root echo -n USB0 > /proc/acpi/wakeup
  4. Plug the USB Receiver into the lowest port under the PS/2 connector
  5. Reboot

I am using Ubuntu 9.10 and XBMC 9.11.

SOURCE: http://www.minimyth.org/forum/viewtopic.php?f=6&t=2524

Written by gimpe

May 7th, 2010 at 9:32 pm

Posted in htpc,Uncategorized

Tagged with , , ,

Ping Ubuntu hostname from Windows (winbind+samba)

leave a comment

Here’s a procedure I found on taesch.com to ping a Ubuntu machine by the hostname from a Windows PC:

  1. sudo vi /etc/nsswitch.conf
    hosts: files wins dns
  2. sudo aptitude install winbind
  3. sudo aptitude install samba

SOURCE: http://taesch.com/my-digital-life/cant-ping-ubuntu-hostname-from-windows-xp-setup-winbind

Written by gimpe

February 19th, 2010 at 8:17 pm

Posted in linux,network,tips

Tagged with , ,

Acer EasyStore H340, the perfect FreeNAS box?

4 comments

The Acer EasyStore H340 comes with 1 x 1TB HDD and room for three more drives (SATA-II). A low power Atom 230, 2 GB of Ram and an internal 256M flash storage to install FreeNAS 64 bits. This comes in a nice 7.9″ (200mm) W x 7.1″ (180mm) D x 8.3″ (212mm) H casing.

Easystore

I am curious to see if the Atom 230 is enough horsepower for ZFS, anybody tried it?

SOURCE: HappyBison.com

Written by gimpe

January 19th, 2010 at 10:18 am

Posted in Uncategorized

FreeNAS CIFS/Samba changing Guest Account ‘FTP’ not working

leave a comment

Using FreeNAS 0.7 Khasadar (revision 4919) with CIFS/SMB Authentication Anonymous, I changed the Guest account for but it is not actually applying it to the configuration, it is a trivial bug and here’s a small dirty workaround.

1 – Create an excutable file containing this:

#!/bin/sh

# find and replace 'ftp' by 'transmission'
sed -i. 's/ftp/transmission/g' /etc/rc.d/samba

# restart samba to use the new config
/etc/rc.d/samba restart

2 – Go in System|Advanced|Command scripts and add an entry for your script in “PostInit”

For those who are interested, I am doing this because my network is not accessible from the outside and I didn’t want to bother with user privileges. I am using my FreeNAS box to share media files downloaded using Transmission and I wanted everybody to be able to access/modify/delete them, so I change the guest account to be “transmission” :)

Written by gimpe

December 18th, 2009 at 2:55 pm

Posted in FreeNAS,tips

Tagged with

A PHP script to start a torrent and download it where the .torrent was located using Transmission JSON-RPC

one comment

I wrote this script because I never found a Transmission remote GUI that permits to start downloading a torrent in a specific directory.

Read the rest of this entry »

Written by gimpe

November 7th, 2009 at 1:25 pm

Posted in Uncategorized

FreeNAS: Services|UPS –> what to use as “Port”

leave a comment

I’m writing a note to myself as I don’t have a UPS yet :)

The Port value can be set to “auto” as metionned here: http://jonathanbrown.me/my-freenas-project-part-5-the-config

Found another rerefence that confirms this:
- For newhidups: “auto” or whatever value as newhidups automagically probe for USB UPS.

SOURCE: http://people.freebsd.org/~thierry/nut_FreeBSD_HowTo.txt

Written by gimpe

October 13th, 2009 at 11:29 am

Posted in FreeNAS

Tagged with

Diskless HTPC using DD-WRT (PXE), Ubuntu/XBMC and FreeNAS (TFTP, NFS)

6 comments

Given that I spent time and money on my FeeNAS node, I want to maximize its usage, so when a friend told me that I can use PXE and NFS to boot a diskless computer from the network, I thought it was the perfect opportunity to try somehing new and activate some more services under FreeNAS!

Read the rest of this entry »

Written by gimpe

September 20th, 2009 at 2:46 pm

Posted in FreeNAS,htpc,hype,linux,network

Tagged with , , ,

Tip: use rsync to convert filenames from/to UTF-8 <–> latin-1/ISO-8859-1

leave a comment

This will copy files with UTF-8 encoded characters filenames to new files with a ISO-8859-1 encoded filenames and, when everything is completed, will delete the old (UTF-8) files.

BE CAREFUL THIS IS NOT FOOL PROOF :) YOU MUST KNOW WHAT YOU ARE DOING TO NOT DOUBLE ENCODE THE CHARACTERS FILENAMES.

rsync SOURCE SAMEFORDESTINATION --recursive --human-readable --stats --times --progress --iconv=utf8,iso88591 --delete-after

To do the opposite change the iconv switch to: --iconv=iso88591,utf8

Note: If you run rsync as root, you can use --owner --group to keep the same user.group for the copied files.

Written by gimpe

September 13th, 2009 at 8:03 pm

Posted in tips

Tagged with

FreeNAS (embedded) iconv command

one comment

To install iconv on a “data” parition:

export PKG_TMPDIR=/mnt/usb-data/temp
pkg_add -r iconv -P /mnt/usb-data/pkg

And execute this at boot time:
ln -s /mnt/usb-data/pkg/bin/iconv /bin/iconv

Written by gimpe

September 8th, 2009 at 8:31 pm

Posted in Uncategorized

FreeNAS Bash script to start a ZFS scrub on each pool (scrub.sh)

7 comments

This script will start a scrub on each ZFS pool (one at a time) and will send an e-mail or display the result when everyting is completed. I wrote this script to launch each scrub one after the other and a summary by e-mail that can tell me how much time it took to each ZFS scrub.

Read the rest of this entry »

Written by gimpe

August 28th, 2009 at 9:48 am

Posted in bash,FreeNAS

Tagged with ,

Useful tools in an “embedded” FreeNAS: wget and bash

one comment

wget

To install wget on a “data” parition:

export PKG_TMPDIR=/mnt/usb-data/temp
pkg_add -r wget -P /mnt/usb-data/pkg

Now we need a script to create the symlinks to the wget binaries in the “pkg” directory:

nano /mnt/usb-data/hooks.sh

Here’s the content:

#!/bin/sh

ln -s /mnt/usb-data/pkg/bin/wget /bin/wget

Now make it run at boot time, go in System —> Advanced —> Command scripts and enter:

/mnt/usb-data/hooks.sh

Select PostInit and that’s it! Everytime you reboot your FreeNAS server the symlinks will be re-created!

bash

For bash, add this in the “hooks.sh” script:

# .bashrc for root
ln -s /mnt/usb-data/bashrc /root/.bashrc

# .bashrc for regular user
ln -s /mnt/usb-data/bashrc /mnt/.bashrc

# automatically load bash for root on login (not clean but works)
echo "bash --init-file /mnt/usb-data/bashrc" >> /root/.cshrc

# automatically load bash for regular user on login (not clean but works)
echo "bash --init-file /mnt/usb-data/bashrc" >> /mnt/.cshrc

Written by gimpe

August 4th, 2009 at 7:38 am

Posted in bash,FreeNAS

Tagged with ,

Vim (Vi IMproved) in an “embedded” FreeNAS

3 comments

You need an embedded install with a data partition. My FreeNAS server runs from a 1GB usb stick and the data partition is mounted as “/mnt/usb-data”. To install Vim on the usb stick:

# using csh
setenv PKG_TMPDIR /mnt/usb-data/temp

# install package
pkg_add -r vim-lite -P /mnt/usb-data/pkg

Now we need a script to create the symlinks to the Vim binaries in the “pkg” directory:

nano /mnt/usb-data/hooks.sh

Here’s the content:

#!/bin/sh

# Vim symlinks to binaries
ln -s /mnt/usb-data/pkg/bin/vim /bin/vi
ln -s /mnt/usb-data/pkg/bin/vim /bin/vim

# .vimrc for root
ln -s /mnt/usb-data/pkg/share/vim/vim72/vimrc_example.vim /root/.vimrc
# .vimrc for regular user
ln -s /mnt/usb-data/pkg/share/vim/vim72/vimrc_example.vim /mnt/.vimrc

# syntax file
mkdir  /usr/local/share/vim/
mkdir  /usr/local/share/vim/syntax/
ln -s /mnt/usb-data/pkg/share/vim/vim72/syntax/syntax.vim /usr/local/share/vim/syntax/syntax.vim

Now make it run at boot time, go in System —> Advanced —> Command scripts and enter:

/mnt/usb-data/hooks.sh

Select PostInit and that’s it! Everytime you reboot your FreeNAS server the symlinks will be re-created!

Written by gimpe

August 3rd, 2009 at 8:38 am

Posted in bash,FreeNAS

Tagged with ,

Ubuntu: ethtool permanent 1000baseTX full-duplex

leave a comment

vi /etc/init.d/1000Mbs
#!/bin/sh

ETHTOOL=&quot;/usr/sbin/ethtool&quot;
DEV=&quot;eth0&quot;

case &quot;$1&quot; in
    start)
        echo -n &quot;Setting eth0 speed 1000 full-duplex...&quot;;
        $ETHTOOL -s $DEV speed 1000 duplex full autoneg on;
        echo &quot; done.&quot;
        ;;
    stop)
        ;;
esac

exit 0
update-rc.d 1000Mbs defaults

SOURCE: http://www.cyberciti.biz/tips/howto-linux-add-ethtool-duplex-settings-permanent.html

Written by gimpe

August 1st, 2009 at 1:15 pm

Posted in bash,linux,network

Tagged with , ,

Ubuntu Jaunty: ATI Radeon HD 2400 XT working in dual head with compiz! (Catalyst 9.7)

leave a comment

1 – Compile and install driver:
Source: http://wiki.cchtml.com/

sudo aptitude install build-essential cdbs fakeroot dh-make debhelper debconf libstdc++5 dkms

sh ati-driver-installer-9-7-x86.x86_64.run --buildpkg Ubuntu/jaunty

sudo dpkg -i xorg-driver-fglrx_*.deb fglrx-kernel-source_*.deb fglrx-amdcccle_*.deb

2 – Generate base xorg.conf:

sudo aticonfig --initial=dual-head

sudo aticonfig --dtop=horizontal

Note: you can do “dpkg-reconfigure xserver-xorg” to reset you xorg.conf to default values.

3 – Log out and log in to use the new xorg.conf

4 – Activate multi-screen & compiz:

Source: http://www.uluga.ubuntuforums.org/showthread.php?p=7552538

Start ATI Catalyst Control Center as root:

sudo amdcccle

Now, go in Display Manager -> Multi-Display -> Big Desktop right fo display 1

Then start compiz: System -> Preferences -> Appearence -> Visual Effects

Written by gimpe

July 29th, 2009 at 1:13 pm

Posted in linux

Tagged with

FreeBSD: lighttpd + php5 + fastcgi

leave a comment

mkdir /var/log/lighttpd.access.log
mkdir /var/log/lighttpd.error.log
chown www:www /var/log/lighttpd.access.log
chown www:www /var/log/lighttpd.error.log

http://redmine.lighttpd.net/boards/2/topics/144

mkdir /var/run/lighttpd/
and chown it to the user you configured in lighttpd

Written by gimpe

July 16th, 2009 at 8:40 pm

Posted in FreeBSD

Tagged with

Performance Optimization WordPress Plugins by W3 EDGE