Wednesday, December 28, 2011

cpio archive creation and extraction

use the following to create archive:
find . -print|cpio -ovcBO <archive path name>

use following to extract it:
cpio -ivI <archive path name>

Monday, December 26, 2011

sata / sas conversion or drive use

converter for SATA to SAS 


SATA-SAS Converter for Hitachi Ultrastar 
2TB DK7SAA200 HUA722020ALA330 Raid HD

Detailed item info

Product Description
The Hitachi Ultrastar A7K2000 hard drive, with a storage capacity of 2 TB, allows you to store your digital world. Buffer size of 32 MB, enables this Hitachi hard drive to work at a faster pace. Having a spindle speed of 7200 rpm, this internal hard drive copies data and writes at a high speed. With 300 MBps of transfer rate, this Hitachi hard drive facilitates speedy transfer of files. The SAS 300 interface of this 2 TB Hard Drive enhances connectivity with other devices. Have your computer function smoothly with the Hitachi Ultrastar A7K2000 hard drive.
Product Identifiers
BrandHitachi
ModelHUA721075KLA33
MPNHUA722020ALA330
UPC102646201817

Key Features
EnclosureInternal
Capacity2 TB
Buffer Size32 MB
Spindle Speed7200 RPM
InterfaceSATA, SATA 2
DesignationDesktop Computer

Technical Features
PlatformPC
External Data Transfer Rate300 Mbps
Form Factor3.5"
Seek Time8.5 ms

Dimensions
Height1.02 in.
Width4.02 in.
Depth5.79 in.
Weight1.5 lbs
 

Monday, December 12, 2011

slice and dice a csv file into submission

 1943  echo First Name,Last Name,Email Address > toImport.csv
 1944  vi toImport.csv
 1945  cat 2011-1205-server3-thunderbird-contacts.csv | cut -d.,. -f1,2,5 >>toImport.csv
 1946  cat 2011-1205-server3-thunderbird-contacts.csv | cut -d"," -f1,2,5 >>toImport.csv


examples above for now

Saturday, December 10, 2011

synaptic demon on linux

the touch pad on most laptops is run by a daemon, syndaemon.  a program, synclient exists to control the daemon.

there are two problems with Ubuntu 11.10 on laptops.  One is that the

synclient TouchpadOff=0

Monday, November 21, 2011

ffmpeg, joining video files

http://ffmpeg.org/faq.html#toc-How-can-I-join-video-files_003f

A few multimedia containers (MPEG-1, MPEG-2 PS, DV) allow to join video files by merely concatenating them.
Hence you may concatenate your multimedia files by first transcoding them to these privileged formats, then using the humble cat command (or the equally humble copy under Windows), and finally transcoding back to your format of choice.
 
ffmpeg -i input1.avi -sameq intermediate1.mpg
ffmpeg -i input2.avi -sameq intermediate2.mpg
cat intermediate1.mpg intermediate2.mpg > intermediate_all.mpg
ffmpeg -i intermediate_all.mpg -sameq output.avi
Notice that you should either use -sameq or set a reasonably high bitrate for your intermediate and output files, if you want to preserve video quality.
Also notice that you may avoid the huge intermediate files by taking advantage of named pipes, should your platform support it:
 
mkfifo intermediate1.mpg
mkfifo intermediate2.mpg
ffmpeg -i input1.avi -sameq -y intermediate1.mpg < /dev/null &
ffmpeg -i input2.avi -sameq -y intermediate2.mpg < /dev/null &
cat intermediate1.mpg intermediate2.mpg |\
ffmpeg -f mpeg -i - -sameq -vcodec mpeg4 -acodec libmp3lame output.avi
Similarly, the yuv4mpegpipe format, and the raw video, raw audio codecs also allow concatenation, and the transcoding step is almost lossless. When using multiple yuv4mpegpipe(s), the first line needs to be discarded from all but the first stream. This can be accomplished by piping through tail as seen below. Note that when piping through tail you must use command grouping, { ;}, to background properly.
For example, let’s say we want to join two FLV files into an output.flv file:
 
mkfifo temp1.a
mkfifo temp1.v
mkfifo temp2.a
mkfifo temp2.v
mkfifo all.a
mkfifo all.v
ffmpeg -i input1.flv -vn -f u16le -acodec pcm_s16le -ac 2 -ar 44100 - > temp1.a < /dev/null &
ffmpeg -i input2.flv -vn -f u16le -acodec pcm_s16le -ac 2 -ar 44100 - > temp2.a < /dev/null &
ffmpeg -i input1.flv -an -f yuv4mpegpipe - > temp1.v < /dev/null &
{ ffmpeg -i input2.flv -an -f yuv4mpegpipe - < /dev/null | tail -n +2 > temp2.v ; } &
cat temp1.a temp2.a > all.a &
cat temp1.v temp2.v > all.v &
ffmpeg -f u16le -acodec pcm_s16le -ac 2 -ar 44100 -i all.a \
       -f yuv4mpegpipe -i all.v \
       -sameq -y output.flv
rm temp[12].[av] all.[av]

Thursday, November 17, 2011

redhat install notes

install a package
rpm –ivh packagename
upgrade a package
rpm –Uvh packagename

create a tar file
tar –cvf myfiles.tar mydir/
(add z if you are dealing with or creating .tgz (.tar.gz) files)

standard install from source
tar –xvzf Apackage.tar.gz
cd Apackage
./configure
make
make install

Wednesday, November 16, 2011

removing bad characters from file names

this will clean bad characters (such as \1b and \1f and \7f's) from a file and convert them to underscores

for file in *
do
mv “$file” $(echo “$file” | sed ‘s/[^A-Za-z0-9_.]/_/g’)
done

svn password snafu workaround

sometimes svn will emit the following message when trying to do a write:


svn gnome keyring is locked and we are non-interactive


the workaround is to change the default config to use local svn if you are not using svn+ssh to access the svn database.


this is done by altering the default client config file in the ~/.subversion directory.


Change to add the line in the auth stanza:
[auth]
password-stores=


to get it to use the "old" way.  The current config which is shown in the config file is password-stores=gnome-keyring,kwallet.  This is actually compiled in and is the default behavior.


There is apparently no path to actually "unlock" the gnome keyring for subversion if it has not been unlocked and that credential set, so it will emit the error message forever and is a bug.  This is just a document of the workaround.


http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=553312

Monday, November 14, 2011

two gtk menu examples


menu factory and menu program for small examples

http://www.gtk.org/tutorial1.2/gtk_tut-13.html

to compile:


g++ main.cpp -Os -s `pkg-config gtk+-2.0 --cflags` `pkg-config gtk+-2.0 --libs`

create itemfactory as a .c file or you will get a huge list of deprecated error messages

here is tree example for GTK 2.0
http://scentric.net/tutorial/treeview-tutorial.html

svnserve init / startup script for ubuntu

One needs to create a script in /etc/init.d to ensure that svnserve is started at boot time.


A script with start, stop and restart (and optionally status) can be created, but a simple script which just starts the server will suffice.

#! /bin/sh
#
# svnserve
#
# start svn server
#

COMMAND="$1"
shift

case $COMMAND in
start)
svnserve -d -r /home/jws/svnserver/repository
;;
stop)
killall svnserve
;;
esac


the script can be installed into the init.d with the following:

update-rc.d svnserve defaults

Multiple repositories on same server:
http://wordaligned.org/articles/one-svnserve-multiple-repositories

make a directory called "repositories"
place all repositories in that directory.


start svnserv with that directory, rather than a pointer to a single repository.


Each repository is independent, with a separate url.


eg:
repositories
    local
    globalmt


svn://host/local is one base repo.
svn://host/globalmt is the other base repo

migrate cvs to svn:
http://cvs2svn.tigris.org/


cvs2svn can be installed on Ubuntu with apt-get


with a directly addressable copy of the cvs repository data, one can run the cvs2svn and produce an svn repository file structure with the migrated data.


cvs2svn -s <svn repo name> /cvs/cvsroot/modulename

Wednesday, November 9, 2011

microsoft xp file sharing

This addresses problems when a system is taken out of a domain and it is placed on a workgroup type network.  A number of settings won't be correct and have to be changed to share files on the machine.

turn on simple file sharing:
open folder options, make sure simple file sharing is on.


http://support.microsoft.com/kb/304040

make sure restricted anonymous access is off (if need be)

http://support.microsoft.com/kb/913628

thunderbird profiles


start->run->%appdata%  ... thunderbird->profiles

http://kb.mozillazine.org/Profile_folder_-_Thunderbird#Windows_2000_and_XP

Thursday, October 27, 2011

vmware esxi disk conversion

In order to use a disk imported from another vmware version, either use vmware converter first, then transfer the machine, or convert the disk and insert it into a new esxi vm.


to do the latter for example

 vmkfstools -i itvmgr41.vmdk -d zeroedthick itvmgr40sp1.vmdk

will convert the disk.  There are other options for the -d parameter, but this will result in a fully allocated disk image with the sparse portions of the original file filled in with zeros.



Tuesday, October 18, 2011

cute way to distribute software via tar link on web page

this gets the tar info from a web site via port 80, pipes it 
to tar which in turn expands and stores it 


wget -O- http://status.calibre-ebook.com/dist/src | tar xvz
 
Stolen from calibre installer page for linux os.
 
remainder of install if one uses the above:
 
cd calibre*
sudo python setup.py install
 

static mac address on vmware

in the vmx file, enter:

ethernetN.addressType = “static”
ethernetN.address = “<address>”


statements with desired mac address, : delimited


works on bridged and private to host, causes dictionary error if you try nat connection for some reason.
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=507

Friday, October 14, 2011

using gmailfs

umount -l <path> if the python support process dies. 

fuser file system will give you "Transport endpoint is not connected" if you try to umount any other way (fusermount -u doesn't work either).

still hunting for a graceful way to make it go away.

links:

http://www.commandlinefu.com/commands/view/1763/use-a-gmail-virtual-disk-gmailfs-on-ubuntu
http://sr71.net/projects/gmailfs/
http://code.google.com/p/gmailfs/issues/detail?id=1#c2  has a fix to problem with env variable
http://blog.philippklaus.de/2010/04/mount-a-gmail-account-as-filesystem-using-gmailfs/

Wednesday, October 12, 2011

autoconf / automake / pkgconfig

The library package uses configure.ac files to build a configure file when autoconf and automake are run.

a pkgconfig file is usually generate in the form of a .pc.in file

the resulting .pc file should be installed when one runs make install.

subsequent references to the library will find the library information using pkgconfig

Thursday, October 6, 2011

flight notes

seat utility:   http://seatexpert.com/
flightaware:    http://flightaware.com/
flytecomm:      http://www.flytecomm.com/
flightwise:     http://flightwise.com/default.aspx
satellites:     http://www.n2yo.com/satellite/?s=25544

Mainframe Assembler references

cbt / Jim Morrison page    http://cbttape.org/~jmorrison/
Assembler connection       http://www.simotime.com/indexasm.htm
opcode list                http://www.hlasm.com/english/oplist.htm
green card                 http://www.garlic.com/~lynn/gcard.html 

postscript, pdf tools command line linux

from:  http://www.physics.usyd.edu.au/~rennie/ps_notes.html

Central to all PostScript and PDF manipulations is the program GhostScript. This interprets files in any of these formats, and it can then output the document or image after applying various operations: rotation, scaling, cropping, and rasterization. GhostScript is rather user-hostile. Fortunately there are various less hostile wrapper programs, which shield users from GhostScript. The most important one is
gv            displays ps, eps or pdf files
display       displays, manipulates and converts image files
Gnome and KDE have their own variants of gv.
Other utilities, specific to .ps and .eps, are:
psbook        rearrange pages in PostScript file into signatures
psselect      selects pages from a PostScript file
pstops        Ghostscript's PostScript distiller for PS and EPS
epsffit       fit encapsulated PostScript file (EPSF) into constrained size
ps2epsi       embeds a thumbnail image within a PS or EPS file
psnup         multiple pages per sheet
psresize      multiple pages per sheet
psmerge       filter to merge several PostScript files into one
ps2ps         optimizer for PS files
eps2eps       optimizer for EPS files
ps2ascii      extract text from PS file
ps2pdf        translator from PS to PDF
fig2ps        translator from FIG, via Latex, to PS/EPS
Utilities specific to .pdf are:
pdf2ps        translator from PDF to PS
pdfimages     extracts images from PDF documents
pdftotext     extracts text from PDF documents
pdftops       converts PDF to PS
pdftopbm      converts each page to a PBM image
pdftoppm      converts each page to a PPM image
pdfcrop       reduces/increases margins

Monday, October 3, 2011

set vim or vi as default editor

useful for setting editor from "nano" for such as crontab -e and svn commit command line commands which require using editor to prepare a parameter file. 

In defense of Nano, you can do an control O and then control X, but my fingers like vi


sudo update-alternatives –config editor 
There are 3 choices for the alternative editor (providing /usr/bin/editor).

  Selection    Path               Priority   Status
------------------------------------------------------------
  0            /bin/nano           40        auto mode
  1            /bin/ed            -100       manual mode
  2            /bin/nano           40        manual mode
* 3            /usr/bin/vim.tiny   10        manual mode


select desired editor from the list

Friday, September 30, 2011

VMware esxi on a memory stick

http://www.vladan.fr/how-to-install-esxi-40-on-usb-memory-key/

Written in the past (some time ago…) , I published a how-to called “Howto install ESXi 3.5 update 3 on USB memory key“. The things has changed today a bit. The how-to is about the same but ESXi 4.0 and vSphere is new and it rocks…. We are in the ESX 4 Era… With ESX Server (vSphere) and more than 150 new features packed inside….
If you found this website useful and want to comeback for more, consider subscribing for FREE via RSS. If you don’t know what is RSS, don’t worry, I wrote a little guide what is RSS and how it saves your daily time.
VMware with vSphere are distancing even more the competition with the performances of vSphere greatly improved. Microsoft’s Hyper-V R2 is still in Beta….. Clearly, the time for an investment into a Virtual Infrastructure with VMware was never been more advantageous. Prices for the SMB market are starting from $166 per CPU. Each physical server may contain up to two phycial processors with up to 6 cores per processor.
Ok, here is the how-to:

01.) Get this 2 tools to acomplish the task.  IZArc, and also WinImage. (trial)
02.) Head to VMware Website and download the ESXi 4.0 vSphere – register for the free for the download. Here is the link.
03.) Save the file to the C drive for example.

ESXi 4 vSphere on USB Memory Key
ESXi 4 vSphere on USB Memory Key

04.) Open the ISO file with IZArc and extract the whole content to c:\Vmware-VMvisor-Installer-4.0.0-164009.x86_64 folder .
ESXi 4 vSphere on USB Memory Key
05.) Browse to “\image.tgz.temptar\usr\lib\vmware\installer\VMware-VMvisor-big-164009-x86_64.dd.bz2\
Extract the “VMware-VMvisor-big-164009-x86_64.dd” file. You’ll have to extract the “image.tgz.temptar” file first…

ESXi 4 vSphere on USB Memory Key


ESXi 4 vSphere on USB Memory Key 

ESXi 4 vSphere on USB Memory Key

06.) From just open Winimage, and goto file menu:  Disk > “Restore Virtual Harddisk Image on physical drive”

ESXi 4.0 vSphere on USB Memory Stick
07.) Select your USB drive
ESXi 4 vSphere on USB Memory Key
08.) Select The file “VMware-VMvisor-big-164009-x86_64.dd” that you extracted earlier.
ESXi 4 vSphere on USB Memory Key
09.) Click Yes to write the image to the USB Memory Stick. (ooups… I’m running on French Windows here…… -:) ? It’s because I have 3 different language versions on my Desktop at home… Where I use VMware Workstation as a Virtual Lab. I hope that you don’t mind, the tuto is quite easy to follow…) . If you got any trouble, just comment below and I’ll try to help.. -:)
ESXi 4 vSphere on USB Memory Key
10.) And the result of your effort should look like this.
ESXi 4.0 vSphere on USB Memory Stick

Tuesday, September 20, 2011

script to monitor a particular process & memory usage

#!/bin/bash



while [ 1 ]; do
   export phpcount=`ps -ef|grep php-cgi|wc| awk '{print $1}'`
   memtotal=`free | awk '/Mem/ { print }' | awk '{ print $2 }'`
   memused=`free | awk '/Mem/ { print }' | awk '{ print $3 }'`
   memfree=`free | awk '/Mem/ { print }' | awk '{ print $4 }'`
   echo "there are $phpcount php-cgi processes at `date` mem $memtotal used $memused free $memfree"
   #free
   sleep 2
done

virtualbox

Install virtualbox 4.0 in ubuntu 10.10
Edit /etc/apt/sources.list file

  deb http://download.virtualbox.org/virtualbox/debian maverick contrib
Add gpg key

  wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | sudo apt-key add -
Update source list

 sudo apt-get update

Install virtualbox 4.0

  sudo apt-get install virtualbox-4.0

may need:
sudo apt-get install dkms


from:
http://www.ubuntugeek.com/virtualbox-4-0-released-and-ubuntu-10-1010-049-10-installation-instructions-included.html

Wednesday, September 14, 2011

wine with office 2007 tips

apply "overrides" on this page:  http://appdb.winehq.org/objectManager.php?sClass=version&iId=4992


wine->wineconfig->libraries usp10 'native,builtin'
wine->wineconfig->libraries riched20 'Native (Windows)'  
wine->wineconfig->graphics 'emulate a virtual desktop'

Tuesday, September 13, 2011

bash notes

http://tldp.org/LDP/abs/html/fto.html

if [ -<opt> "$str" ]
then
     ...
else
     ...
fi

-e exists
-f is a file
-s is not 0 bytes
-d is directory
-b is block device
-c is char device
-p is pipe
-b is symlink
-L is symlink
-S is socket
-t  is terminal
-r has read perm
-w has write
-x has execute
-g has sgid flag
-u has suid flag
-k sticky bit
-O owner
-G gid same as yours
-N modifed since last read
f1 -nt f2 f1 newer than f2
f1 -ot f2 f2 older than f2
! nots above compares

ffmpeg conversion of 3gp to mp4 files

http://ffmpeg-users.933282.n4.nabble.com/3gp-to-mp4-td942632.html

ffmpeg -i test.3gp -sameq -ab 64k -ar 44100 test.mp4

-ab audio bitrage 
-ar audio resample


info from file ffmpeg -i video.avi
images to file ffmpeg -f image2 -i image%d.jpg video.mpg
file to images ffmpeg -i video.mpg image%d.jpg
sound to mp3   ffmpeg -i source_video.avi -vn -ar 44100 -ac 2 -ab 192 -f mp3 sound.mp3
 
* Source video : source_video.avi
* Audio bitrate : 192kb/s
* output format : mp3
* Generated sound : sound.mp3





avi to giff    ffmpeg -i source_video.avi animated_gif.gif
avi to ntsc    ffmpeg -i source_video.avi -target ntsc-svcd final_video.mpg 
 




cheatsheets:
http://www.webupd8.org/2009/08/ffmpeg-cheat-sheet-19-best-practices.html
http://rodrigopolo.com/ffmpeg/cheats.html

windows command line install:
http://www.arachneweb.co.uk/software/windows/avchdview/ffmpeg.html

Sunday, September 11, 2011

Raid configuration example

http://ascend4.org/Installing_Raid_1_on_Existing_Ubuntu_Server

copied from above:

Useful web sites

* how to set up a raid disk - really good instructions * benchmarks comparing fstype options * how to set up fstab entries * what mount and umount are really all about

(NOTE: I have used these instructions for Ubuntu 7.04 and 8.04 also, and they work without any problems. AWW)
 
(NOTE April 27, 2009: I attempted to use these instructions when updating the operating system on my computer to Ubuntu 9.04 from 8.10. The raid 1 disk already existed, and the install process found it and set it up automatically. It called the raid disk md_d0 rather than md0, however. I had to mount it. I also looked into /etc/fstab and corrected the automount instruction that was there.)
 
The first web site above is really excellent. It points you to the tool mdadm, which is for setting up raid disks in linux. I basically followed the instructions on this web site. May God bless Mário, its creator. As you encounter each computer instruction in his guide, it should pay handsomely if you looked at the man pages for it. If the instruction was complex or a term confusing, I also did a search on the web for better explanations (giving rise to those above for fstype, fstab and mount)).

Background

I am a real novice at doing all this so I shall put in my thoughts as we go along. I purchased a PowerEdge 2950 rack mounted server computer from Dell in February, 2007. I bought it without any OS installed and without a hardware Raid controller. It shipped with a single 160 GB SATA disk but with slots for several more disks. I installed the Ubuntu 6.10 (Edgy) linux OS from a disk downloaded from the Ubuntu web site. We later ordered from Dell and received two additional 250 GB SATA disks, which I wished to install in a Raid 1 configuration AFTER having an "up and running" server. We could not obtain only the rails to install the disks into the front slots; we had to purchase the disks, too, from Dell. 


Before starting, and with the computer running, execute the following instruction:


cat /proc/diskstats 
and note the disks that are detected. I detected sda and its partitions only - i.e., my 160 GB disk. 


To install the disks, we halted the computer and installed them by simply slipping them into two slots on the front of the computer. We powered up the computer.



Creating the Raid 1 configuration

Go to the heading "The hard work" in the guiding web page. From a remote computer via ssh, it was my intention now to configure these disks to be in a Raid 1 configuration. The first instruction told me to check if the system identified the disks, which I checked by again running 

cat /proc/diskstats 
At the bottom of the output were the two new disks: sdb and sdc.
The next instruction tells us to format these two disks. If you are using disks that were previously in a Raid configuration, they are already formatted, and you can skip this step. Mine were new. I formatted the first one using 


sudo fdisk /dev/sdb 
The fdisk instruction expects you to "run it" interactively. Typing in m will give you the menu. As noted in the guiding web page, first type in n to establish a logic partition (I wrote down the number of cylinders as told to do). Then I typed in t and was presented with a list of options. I selected fd as this was to be part of a Raid 1 disk. I typed w as instructed to save this information.
I repeated the formatting for the second disk, sbc. 


The guiding web page now instructed me to use mdadm, which I did have to install 


sudo apt-get install mdadm 
I then read the man pages for this instruction carefully. Doing so one realizes this package is the secret behind setting up a Raid disk system. I wonder how anyone would do it without it. In the version of the man pages I read, the instruction has the form: 


mdadm [mode] <raiddevice> [options] <component-devices> 
The mode part is really meant to be the place to put the mode selection options. In the following instruction --create is such an option.
I then ran the instruction as advised 


sudo mdadm --create --verbose /dev/md0 --level=1 --raid-devices=2 /dev/sdb1 /dev/sdc1 
and expected a miracle would occur, and it would work. It did not. The error message said something about md0 not existing. Of course it did not exist. I was "creating" it. Well, back to the web and a lot of not-too-helpful "help me" messages and their responses, until I came across a response that said "use the --auto option." I had read about that and had wondered about using it but lacked the courage. The response said that the --auto option is there to break the circle of md0 not being there but the mdadm instruction not functioning if it is not yet defined. They did not suggest which value to give that option so I ran the above instruction again with --auto=yes, as follows: 


sudo mdadm --create --verbose --auto=yes /dev/md0 --level=1 --raid-devices=2 /dev/sdb1 /dev/sdc1 
and now the miracle did occur. It worked. 


Our next instruction is to restart the computer and then to wait until the disks sync. Mário suggested getting a cup of coffee. Good idea, except you can do a lot more than that in the one to two hours you will be waiting. That they are syncing will not be obvious so you should monitor it, as noted by Mario, by issuing the command 


watch cat /proc/mdstat 

After it has synced, we are now told to format md0 with the instruction (if you are reinstalling disks that were in a previous Raid 1 configuration and you do not wish to destroy their content, skip this step): 


sudo mkfs -t reiserfs /dev/md0 
Okay, so what is the option -t reiserfs all about? On to the man pages for mkfs. Ah, reiserfs is an fstype. It tell us there are lots of different types of formating from which we can choose. Questions that occur: what are the options and which should I choose? Using google again on mkfs, I found Q&A pages noting that the types are indicated by choosing among installed programs of the form mkfs.fstype so I ran 


sudo locate mkfs\. 
to see what was in my system of that form. A list popped up that included ext2, ext3, and so forth but no reiserfs. Back to google. The best page I found to give me clues as to which to choose is in the useful web pages at the start of this page. First of all one wants a type that has journaling. Journaling says that if the system powers down suddenly and not nicely, one can power up and the system can directly recover the disk without me having to ask it to fix up all the inconsistencies it is finding. Yes, I want that. ext3 and reiserfs have journaling. I finally found a statement that said feiserfs is a good choice and a newer type than ext3. So, I chose reiserfs. Now does it exists?


I ran the instruction as advised


sudo mkfs -t reiserfs /dev/md0 
and sure enough reiserfs existed and ran successfully. Okay, I could have just done what I was advised, but I felt better about knowing why. 


The next instruction is to edit the /etc/fstab file with the apology that he was not going to tell us how to do that. Okay, his instructions have been great, and I can figure this out myself. Back again to google and up pops a really excellent website on fstab (see above). It directed me to a page on mount which I also read (I read it first, as advised). I found these two pages to be to the point and very easy to follow. All of a sudden I understood the mount instruction, and fstab no longer seemed a mystery. Basically, for our needs here you can mount a partition on a disk at a mount point that is any existing directory in your system (apparently even a directory that has things in it - not tested). That directory will be the root of the mounted partition, and, while mounted, the previous content of the directory is hiding from view. md0 is a partition. sdb1 is a partition on the hard disk sdb, and so forth. 


To check out my understanding, I decided to mount md0 manually at /back (I have my reasons for this name, but they are irrelevant here). /back has to exist so I first ran 


sudo mkdir /back 
and then I mounted md0 with the instruction 


sudo mount /dev/md0 /back 
Running the instruction 


df 
listed md0 as having the mount point /back, so everything seems to have worked. Armed with this general feeling of success, I added the following line to my /etc/fstab. You need to read about fstab in the above web page to see what auto, defaults and the two zeros are all about. The first two arguments are those for running the mount instruction. 


/dev/md0        /back           auto    defaults        0       0 
fstab is a file that tells the operating system which disks to mount automatically when restarting the system. The mount instruction it will run is 


sudo mount /dev/md0 /back 
So, if you are really curious that this restarting works and if you will not spoil it for anyone else who may be on your computer at this time, you could restart your computer and then run 


df 

again.  md0 should be there at the mount point called /back.


Putting things on your Raid disk

Now it up to you to put things on md0 that you wish to be on your raid 1 disk. It seems most people put /home there (which makes complete sense). You can do this easily by tarring up the contents inside /home as the superuser (you need to be, and doing so guarantees file and directory ownership stays unchanged), umounting md0, remounting md0 to the mount point called /home, and untarring the contents of /home inside this directory. 

As we are running a server with MySQL running, it made sense to grab the files in /var/lib/mysql and put them there, too. But a word of warning. DO NOT put the whole directory /var onto the Raid disk. The sudo instruction that you need to move things around as the superuser first looks in /var for information, and it also writes back in there. You will almost certainly "mv" it to put it aside for a moment, and /var will no longer exist. sudo will no longer work. Ouch!! And you need to be the superuser to "mv" it back while attempting in full panic to rescue yourself from your not-so-clever misstep. Yes, I got bitten, and I had to take my install disk for ubuntu 6.10 to the machine and use the rescue facilities on it to put /var back in place. 

Note, I did not partition the raid 1 disk so I could have several mount points. As I have not played with this option (I did not want it), I offer no comments on how to do that.

Friday, September 9, 2011

duplicating devices via dd or via nc

using dd and gzip
Backup the drive
# dd if=/dev/hda conv=sync,noerror bs=64K | gzip -c  > /mnt/sda1/hda.img.gz
To restore your system
# gunzip -c /mnt/sda1/hda.img.gz | dd of=/dev/hda conv=sync,noerror bs=64K
view partitions in the image (once uncompressed)
# fdisk -l hda.img > /mnt/sda1/hda_fdisk.info 
 
netcat chatserver
create the chat server on this machine and set it to listen to 3333 TCP port:
$ nc -l 3333
On the other end, connect to the server with the following:
$ nc 192.168.0.1 3333

creating a partition image and sending it to a remote machine on-the-fly:
$ dd if=/dev/hdb5 | gzip -9 | nc -l 3333
On the remote machine, connect to the server and receive the partition image with the following command:
$ nc 192.168.0.1 3333 | pv -b > myhdb5partition.img.gz
This might not be as classy as the partition backups using partimage, but it is efficient.

http://www.g-loaded.eu/2006/11/06/netcat-a-couple-of-useful-examples/ 

audio examples, and named fifo examples here:
http://www.debian-administration.org/articles/145

file transfer:
tar cz /etc | ssh user@host -c ‘cd /bak ; cat > etc.tgz’

On the localhost, this will create an archive of /etc, which is piped into an ssh connection. On the remote host, the snippet enclosed in ” is executed: Change to the backup directory, and pipe the content of the connection into a file. If I wanted to extract the files again on the receiving side, I could do:

tar cz /etc | ssh user@host -c ‘cd /bak ; cat tar xz’

Note that the ‘-f -’ given in the article is redundant. If tar is not given a file, it uses STDIN/OUT. The advantage over recursive scp is that this method preserves device nodes and file permissions. The advantage over rsync is that it is using familiar tar semantics on both sides (of course, if you want diffing, you need rsync, which works just fine over SSH).

Of course, the other direction (pulling files from a host) is equally possible:

ssh user@host -c ‘tar cz /etc’ > /bak/etc.tgz

webmin notes

How do I change my Webmin password if I can't login?
/usr/local/webmin-1.150/changepass.pl /etc/webmin admin foo 

mounting images with kpartx or losetup + fdisk

http://madduck.net/blog/2006.10.20:loop-mounting-partitions-from-a-disk-image/

Loop-mounting partitions from a disk image
    Update: it seems that kpartx pretty much does all of the below. Thanks to Faidon Liambotis for the pointer.


    Every now and then, I have a disk image (as produced by cat, pv, or dd) and I need to access separate partitions. Unfortunately, the patch allowing partitions on loop devices to be accessed via their own device nodes does not appear to be in the latest (Debian) 2.6.18 kernels — the loop module does not have a max_partmodinfo. parameter, according to


    So this time I sat down to come up with a recipe on how to access the partitions, and after some arithmetic and much swearing at disk manufacturers, and especially the designers of the msdos partition table type, I think I have found the solution, and the urge to document it for posterity.


    It’s all about the -o parameter to losetup, which specifies how many bytes into the disk a given partition starts. Getting this number isn’t straight forward. Well, it is, if you know how, which is why I am writing this.


    Let’s take a look at a partition table, with sectors as units:
    $ /sbin/fdisk -lu disk.img
    You must set cylinders.
    You can do this from the extra functions menu.
    
    Disk disk.img: 0 MB, 0 bytes
    255 heads, 63 sectors/track, 0 cylinders, total 0 sectors
    Units = sectors of 1 * 512 = 512 bytes
    
          Device Boot      Start         End      Blocks   Id  System
    disk.imgp1   *          63       96389       48163+  83  Linux
    disk.imgp2           96390     2056319      979965   82  Linux swap / Solaris
    disk.imgp3         2056320    78140159    38041920    5  Extended
    disk.imgp5         2056383     3052349      497983+  83  Linux
    disk.imgp6         3052413    10859939     3903763+  83  Linux
    disk.imgp7        10860003    68372639    28756318+  83  Linux
    disk.imgp8        68372703    76180229     3903763+  83  Linux
    disk.imgp9        76180293    78140159      979933+  83  Linux
    The first few lines is fdisk complaining not being able to extract the number of cylinders, since it has to operate on a file which does not provide an ioctl interface.


    The first important data are the units, which are stated to be 512 bytes per sector. We take note of this value as the factor for use in the next operation.
    Let’s say we want to access the 7th partition, which is 10860003 sectors into the disk, according to the fdisk output. We know that each sector is 512 bytes, so:
    10860003 * 512 = 5560321536
    Passing this number to losetup produces the desired result:
    # losetup /dev/loop0 disk.img -o $((10860003 * 512))
    # file -s /dev/loop0
    /dev/loop0: Linux rev 1.0 ext3 filesystem data
    # mount /dev/loop0 /mnt
    [...]
    # umount /mnt
    # losetup -d /dev/loop0
    If the partition really holds a normal filesystem, you can also let mount set up the loop device, and manage it automatically:
    # mount -o loop,offset=$((10860003 * 512)) disk.img /mnt
    [...]
    # umount /mnt
    And since there’s aparently no means to automate the whole process for an entire disk, I hacked up plosetup. Enjoy:
    # plosetup lapse.hda .
    I: partition 1 of lapse.hda will become ./lapse.hda_p1 (/dev/loop0)...
    I: plosetup: skipping partition 2 of type 82...
    I: plosetup: skipping partition 3 of type 5...
    I: partition 5 of lapse.hda will become ./lapse.hda_p5 (/dev/loop1)...
    I: partition 6 of lapse.hda will become ./lapse.hda_p6 (/dev/loop2)...
    I: partition 7 of lapse.hda will become ./lapse.hda_p7 (/dev/loop3)...
    I: partition 8 of lapse.hda will become ./lapse.hda_p8 (/dev/loop4)...
    I: partition 9 of lapse.hda will become ./lapse.hda_p9 (/dev/loop5)...
    # ls -l
    total 0
    lrwxrwxrwx 1 root root 10 2006-10-20 13:25 lapse.hda_p1 -> /dev/loop0
    lrwxrwxrwx 1 root root 10 2006-10-20 13:25 lapse.hda_p5 -> /dev/loop1
    lrwxrwxrwx 1 root root 10 2006-10-20 13:25 lapse.hda_p6 -> /dev/loop2
    lrwxrwxrwx 1 root root 10 2006-10-20 13:25 lapse.hda_p7 -> /dev/loop3
    lrwxrwxrwx 1 root root 10 2006-10-20 13:25 lapse.hda_p8 -> /dev/loop4
    lrwxrwxrwx 1 root root 10 2006-10-20 13:25 lapse.hda_p9 -> /dev/loop5
    # plosetup -c .
    # ls -l
    total 0
     
    Kpartx:
     
    Kpartx can be used to set up device mappings for the partitions of any 
    partitioned block device. It is part of the Linux multipath-tools. With 
    kpartx -l imagefile you get an overview of the partitions in the image 
    file and with kpartx -a imagefile the partitions will accessible 
    via /dev/mapper/loop0pX (X is the number of the partition). 
     
    You can mount it now with mount /dev/mapper/loop0pX /mnt/ -o loop,ro
    After unmounting you can disconnect the mapper devices with kpartx -d 
    imagefile. 
     

    Monday, September 5, 2011

    Sunday, September 4, 2011

    Set Backspace’s Firefox behavior

    set the backspace to be a back page (page up) or to match Windows / Mac behaviour (more useful) to go back a page in browser history:

    default is now 2


    Set "browser.backspace_action" to either 0 or 1
    0 - Pressing backspace button will go back a page in the session history
    1 - Pressing backspace button will scroll up a page in the current document and
    (other) unmap function.  so new default value of 2 disables either of the above.

    set it to 0 to match the WinMac action.

    about:config browser.backspace_action;0

    Wednesday, August 31, 2011

    home webcam motion stuff

    http://tech.shantanugoel.com/2008/05/14/keep-tab-on-home-security-with-a-webcam-and-twitter.html

    install motion to poll for activity and create movies

    etch archive

    updated debian system sources.list to work with old etch.  Need to get a local repository clone next.

    index here:
    http://www.debian.org/distrib/archive

    sources.list example:

    # deb cdrom:[Debian GNU/Linux 4.0 r6 _Etch_ - Official amd64 DVD Binary-1 20081219-16:30]/ etch contrib main

    # deb cdrom:[Debian GNU/Linux 4.0 r6 _Etch_ - Official amd64 DVD Binary-1 20081219-16:30]/ etch contrib main

    # regular updates for etch
    deb http://debian.advalem.net/debian-archive/debian/ etch main contrib non-free
    deb-src http://debian.advalem.net/debian-archive/debian/ etch main contrib non-free

    # security updates for etch
    #deb http://security.debian.org/ etch/updates main contrib non-free
    #deb-src http://security.debian.org/ etch/updates main contrib non-free

    # multimedia       Christian Marillat (was: ftp.nerim.net)
    #deb http://www.debian-multimedia.org etch main
    #deb-src http://www.debian-multimedia.org etch main

    # unofficial      http://www.debian-unofficial.org
    #deb http://ftp.debian-unofficial.org/debian etch main contrib non-free restricted
    #deb-src http://ftp.debian-unofficial.org/debian etch main contrib non-free restricted


    Thursday, August 18, 2011

    sscanf example

     http://support.microsoft.com/kb/38335

    from microsoft of all places:


    /* The following sample illustrates the use of brackets and the
       caret (^) with sscanf().
       Compile options needed: none
    */ 
    
    #include <math.h>
    #include <stdio.h>
    #include <stdlib.h>
    
    char *tokenstring = "first,25.5,second,15";
    int result, i;
    double fp;
    char o[10], f[10], s[10], t[10];
    
    void main()
    {
       result = sscanf(tokenstring, "%[^','],%[^','],%[^','],%s", o, s, t, f);
       fp = atof(s);
       i  = atoi(f);
       printf("%s\n %lf\n %s\n %d\n", o, fp, t, i);
    }

    Wednesday, August 10, 2011

    slickedit tabs vs. space

    slickedit tabs
    Document->Tabs                            set tab stops here
    Document->Intent with tabs          turn on or off to suit style

    Styles:
    Tools->Options
       Languages>All Languages>Indent
           Syntax Indent (set)
           Tabs (set)

    Monday, August 1, 2011

    setting vncserver to start at ubuntu boot (5901 session)

    full original article:
    http://www.abdevelopment.ca/blog/start-vnc-server-ubuntu-boot


    update to correct update-rc hint:
    http://www.debuntu.org/how-to-manage-services-with-update-rc.d

    To set it up, follow these steps:
    1. First, install the TightVNC server. This VNC server has excellent compatibility with clients, and provides reasonable compression for slow networks. It can be installed with Synaptic, or with sudo aptitude install tightvncserver.
    2. Set up the VNC server for the user you wish to log in as. When you run "vncserver" for the first time, it will ask you to set a password. VNC authentication is not the strongest encryption available, so be sure to firewall your server from all but trusted machines. Better yet, deny direct access to VNC and only allow SSH tunnelled or VPN connections. To launch programs or a session when your VNC session starts, modify ~/.vnc/xstartup. Here is my copy of xstartup: it runs an icewm session, Azureus, and K3B. For Gnome, try running "gnome-session", and for KDE, try "startkde".
      #!/bin/sh xrdb $HOME/.Xresources
      xsetroot -solid black
      /opt/azureus/azureus &
      k3b &
      icewm-session &
    3. Copy the following into /etc/init.d/vncserver. The easiest way to do it is to copy it to your clipboard, run sudo -i && cat > /etc/init.d/vncserve && exit in a terminal, paste it in, and type CTRL-D. Be sure to change the USER variable to whatever user you want the VNC server to run under.
      #!/bin/sh -e
      ### BEGIN INIT INFO
      # Provides:          vncserver
      # Required-Start:    networking
      # Default-Start:     3 4 5
      # Default-Stop:      0 6
      ### END INIT INFO
      PATH="$PATH:/usr/X11R6/bin/"
      # The Username:Group that will run VNC
      export USER="mythtv"
      #${RUNAS}
      # The display that VNC will use
      DISPLAY="1"
      # Color depth (between 8 and 32)
      DEPTH="16"
      # The Desktop geometry to use.
      #GEOMETRY="<WIDTH>x<HEIGHT>"
      #GEOMETRY="800x600"
      GEOMETRY="1024x768"
      #GEOMETRY="1280x1024"
      # The name that the VNC Desktop will have.
      NAME="my-vnc-server"
      OPTIONS="-name ${NAME} -depth ${DEPTH} -geometry ${GEOMETRY} :${DISPLAY}"
      . /lib/lsb/init-functions
      case "$1" in
      start)
      log_action_begin_msg "Starting vncserver for user '${USER}' on localhost:${DISPLAY}"
      su ${USER} -c "/usr/bin/vncserver ${OPTIONS}"
      ;;
      stop)
      log_action_begin_msg "Stoping vncserver for user '${USER}' on localhost:${DISPLAY}"
      su ${USER} -c "/usr/bin/vncserver -kill :${DISPLAY}"
      ;;
      restart)
      $0 stop
      $0 start
      ;;
      esac
      exit 0
    4. Make the script executable with sudo chmod +x /etc/init.d/vncserver.
    5. Then, run sudo update-rc.d vncserver defaults. This adds the appropriate symlinks to the vncserver script so that it is sent the start and stop commands at the appropriate time. Update: jpb writes that you may need to use sudo update-rc.d vncserver default 99 instead if the job is running too early in the boot process.
    6. To start the server without rebooting, run sudo /etc/init.d/vncserver start
    7. Finally, connect to your server with a VNC client on port 590X, where X is the value of "DISPLAY" in the vncserver script. On OS X, I like to use Chicken of the VNC. On Windows and Linux, the TightVNC client works nicely.
    Of course, this script should work as expected on any Debian-based distribution. If you have problems with performance, try lowering the screen resolution. 800x600 is much faster than 1024x768 over slow connections.

    Monday, July 25, 2011

    bash vs dash as /bin/sh

    to change from dash, use dpkg-reconfigure dash


    dash need not be installed, however if it is, dpkg has an install time option question to ask whether to redirect /bin/sh at it.

    Friday, July 22, 2011

    tftp server demon for Ubuntu

    pinched from another blogger:
    http://pjpramod.blogspot.com/2009/08/setting-up-tftp-server-on-ubuntu-904.html

    Tftp is a server/client implementation which supports the Internet Trivial File Transfer Protocol. TFTP is a file transfer protocol, with the functionality of a very basic form of File Transfer Protocol (FTP).

    Advantages of the protocol

    • simple design
    • implemented in a very small amount of memory
    Usage
    • Booting devices such as routers which did not have any data storage devices
    • transfer small amounts of data between hosts on a network
    • initial stages of some network based installation systems to load a basic kernel that performs the actual installation.
    TFTP Details
    • It uses UDP port 69 as its transport protocol (unlike FTP which uses TCP port 21)
    • It cannot list directory contents.
    • It has no authentication or encryption mechanisms.
    • It is used to read files from, or write files to, a remote server.
    • Supports three different transfer modes, "netascii", "octet" and "mail" (Obsolete)
    • Generally used on private, local networks - Due to lack of security

    For further details on the protocol refer: http://en.wikipedia.org/wiki/Trivial_File_Transfer_Protocol

    For setting up TFTP server on Ubuntu you can use either tftpd, atftpd or tftpd-hpa.

    tftpd Setup

    Install tftpd on your system.

    #sudo apt-get install tftpd
    Configuring the tftpd directory:

    #sudo mkdir /tftpboot ; if directory is not yet created
    #sudo chmod -R 777 /tftpboot
    #sudo chown -R username:username /tftpboot ;replace 'username' with your actual username


    Create /etc/xinetd.d/tftp and insert the following:
    service tftp
    {
    socket_type = dgram
    protocol = udp
    wait = yes
    user = username ; Enter your user name
    server = /usr/sbin/in.tftpd
    server_args = -s /tftpboot
    per_source = 11
    cps = 100 2
    disable = no
    }

    Now restart the tftpd server

    #sudo /etc/init.d/xinetd start



    advanced TFTP server (atftpd) setup
    atftp is a client/server implementation of the TFTP protocol that implements RFCs 1350, 2090, 2347, 2348, and 2349. The server is multi-threaded. & also supports multicast protocol known as mtftp, defined in the PXE specification.

    Install the server using the command:

    #sudo apt-get install atftpd

    Configuring the directory:

    #sudo mkdir /tftpboot ; if directory is not yet created
    #sudo chmod -R 777 /tftpboot
    #sudo chown -R username:username /tftpboot ;replace 'username' with your actual username
    #sudo /etc/init.d/atftpd restart

    If you want ATFTP to be run as a server directly than through inetd, try the following

    #sudo vim /etc/default/atftpd

    Change the 'USE_INETD=true' line to 'USE_INETD=false'.... save and quit.

    Use the following command to start atftpd:

    #sudo invoke-rc.d atftpd start


    tftpd-hpa setup

    This is a tftp server derived from OpenBSD tftp with some extra options added. Like atftpd It is useful if you want to use the PXE protocol which has some non-standard requirements for tftp.
    Install tftpd on your system.

    #sudo apt-get install tftpd-hpa

    While installation it will ask whether you need to configure the server or not. Enter yes to do a default configuration. By default the system will consider "/var/lib/tftpboot" as the default directory.

    If you need to change the default directory to '/tftpboot', then create a directory as mentioned earlier, give the necessary permissions and then edit
    '/etc/default/tftp-hpa'.


    Modify 'OPTIONS="-l -s /var/lib/tftpboot" to
    'OPTIONS="-l -s /tftpboot"
    and restart the server
    # sudo /etc/init.d/tftpd-hpa restart


    To run the tftpd-hpa as a daemon, set in '/etc/default/tftp-hpa' the following:

    RUN_DAEMON="yes"
    and restart the server
    # sudo /etc/init.d/tftpd-hpa restart


    *************************
    net install ubuntu
    https://help.ubuntu.com/community/Installation/WindowsServerNetboot