"And earthquakes are to a girls guitar they're just another good vibration"
InSAR Processing and more
Wednesday, January 6, 2016
Real-Time Kernel for RaspberryPi 2
Tuesday, November 26, 2013
Real-Time Kernel for RaspberryPi (Take II)
I encountered a very good guide describing how to compile a Debian Linux-rt kernel with Xenomai for the RaspberryPi. and a completing page for creating the RPI image.
I can't say I understand it completely, but I managed to combine to two guides and compile my own RaspberryPi Linux-rt kernel.
I'm sure some of the steps are missing and things change very quickly (e.g. links, kernel versions and patches) so anyone following my steps should take that into consideration and adapt to changes.
I started by installing a fresh Debian 32bit x86 on a virtual box.
Follow the picnc guides but remember to adapt the patches and kernel version differences.
I'll try to redo the process and give here a complete guide at a later stage.
Thursday, August 1, 2013
Machinoid Real-Time Linux for RaspberryPi
apt-get install libtool gfortran
apt-get install libusb-1.0
install xenomai following the instructions in the link above.
sysctl vm.min_free_kbytes=8192
vi /etc/ld.so.conf.d/xenomai.conf
add 2 lines:
# xenomai default configuration
/usr/xenomai/lib
ldconfig
install wifi drivers (after I got problems with rt2800usb driver):
apt-get install firmware-ralink
create new file /etc/modprobe.d/8192cu.conf
add:
# Disable power saving
options 8192cu rtw_power_mgnt=0 rtw_enusbss=1 rtw_ips_mode=1
Sunday, July 7, 2013
LSM303 accelerometer on RaspberryPi
Connecting LSM303 pins 1 (SCL), 2 (SDA), 6 (GND) and 8 (V3V) to pins 5 (SCL), 3 (SDA), 6 (GND) and 1 (V3V) on the Pi board.
On my ArchlinuxARM OS I had to install i2c-tools:
> pacman -S i2c-tools
And add i2c modules:
> echo i2c-dev > /etc/modules-load.d/ i2c.conf
> echo i2c-bcm2708 >> /etc/modules-load.d/ i2c.conf
> reboot
now to check it works:
> i2cdetect -y 1
got a message like this:
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- 19 -- -- -- -- 1e --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
Now, following this, I test it and it works. Now I'm up for creating my own code.
Made some changes to the code:
main.cpp
#include<stdio.h>
#include <unistd.h>
/*
getHeading() calculates a tilt-compensated heading.
A float between 0 and 360 degrees is returned. You need
to pass this function both a magneto and acceleration array.
Headings are calculated as specified in AN3192:
http://www.sparkfun.com/datasheets/Sensors/Magneto/Tilt%20Compensated%20Compass.pdf
*/
float getHeading(LSM303& lsm303dlhc);
#define PI 3.141592654
int main(void)
{
uint8_t bajt;
const char *fileN = "/dev/i2c-1";
LSM303 lsm303dlhc(fileN);
lsm303dlhc.enalbe();
while(1)
{
lsm303dlhc.readAccelerationRaw();
lsm303dlhc.readMagnetometerRaw();
printf("acc [m/s^2]: \e[27;1;31m %f \e[m \e[27;1;32m %f \e[m \e[27;1;34m %f \e[m mag: \e[27;1;31m %d \e[m \e[27;1;32m %d \e[m \e[27;1;34m %d\e[m %fdeg\n",
(int16_t)lsm303dlhc.acc_x_raw*0.00957,(int16_t)lsm303dlhc.acc_y_raw*0.00957,-(int16_t)lsm303dlhc.acc_z_raw*0.00957,
(int16_t)lsm303dlhc.mag_x_raw, (int16_t)lsm303dlhc.mag_y_raw, (int16_t)lsm303dlhc.mag_z_raw,getHeading(lsm303dlhc));
usleep(10);
}
}
float getHeading(LSM303& lsm303dlhc)
{
float heading,pitch,roll,xh,yh,zh;
// see section 1.2 in app note AN3192
int magValue[3];
float accelValue[3];
magValue[0] = (int16_t)lsm303dlhc.mag_x_raw;
magValue[1] = (int16_t)lsm303dlhc.mag_y_raw;
magValue[2] = (int16_t)lsm303dlhc.mag_z_raw;
accelValue[0] = (int16_t)lsm303dlhc.acc_x_raw*0.000976531;
accelValue[1] = (int16_t)lsm303dlhc.acc_y_raw*0.000976531;
accelValue[2] = -(int16_t)lsm303dlhc.acc_z_raw*0.000976531;
// see appendix A in app note AN3192
pitch = asin(-accelValue[0]);
roll = asin(accelValue[1]/cos(pitch));
xh = magValue[0] * cos(pitch) + magValue[2] * sin(pitch);
yh = magValue[0] * sin(roll) * sin(pitch) + magValue[1] * cos(roll) - magValue[2] * sin(roll) * cos(pitch);
zh = -magValue[0] * cos(roll) * sin(pitch) + magValue[1] * sin(roll) + magValue[2] * cos(roll) * cos(pitch);
heading = 180*atan2(yh,xh)/PI;
if (heading <0)
heading += 360;
return heading;
}
LSM303DLHC.cpp:
#include<math.h>
#include<stdio.h>
/*Conection to Raspberry PI:
LSM303 Raspberry PI
VDD -> 3V3(PIN 1)
SDA -> SDA(PIN 3)
SCL -> SCL(PIN 5)
GND -> GND(PIN 6)
*/
#define LSM303DLHC_MAG_ADDRESS (0x3C >> 1)
#define LSM303DLHC_ACC_ADDRESS (0x32 >> 1)
LSM303::LSM303(const char * i2cDeviceName) : i2c_lsm303(i2cDeviceName)
{
}
uint8_t LSM303::readAccRegister(uint8_t regAddr)
{
i2c_lsm303.addrSet(LSM303DLHC_ACC_ADDRESS);
return i2c_lsm303.readByte(regAddr);
}
uint8_t LSM303::readMagRegister(uint8_t regAddr)
{
i2c_lsm303.addrSet(LSM303DLHC_MAG_ADDRESS);
return i2c_lsm303.readByte(regAddr);
}
void LSM303::writeAccRegister(uint8_t regAddr,uint8_t byte)
{
i2c_lsm303.addrSet(LSM303DLHC_ACC_ADDRESS);
i2c_lsm303.writeByte(regAddr, byte);
}
void LSM303::writeMagRegister(uint8_t regAddr, uint8_t byte)
{
i2c_lsm303.addrSet(LSM303DLHC_MAG_ADDRESS);
i2c_lsm303.writeByte(regAddr, byte);
}
void LSM303::enalbe(void)
{
writeAccRegister(LSM303_CTRL_REG1, 0b10010111);
writeAccRegister(LSM303_CTRL_REG4, 0b00001000);
writeMagRegister(LSM303_MR_REG, 0x00);
}
void LSM303::readAccelerationRaw(void)
{
uint8_t block[6];
i2c_lsm303.addrSet(LSM303DLHC_ACC_ADDRESS);
i2c_lsm303.readBlock(0x80 | LSM303_OUT_X_L_A, sizeof(block), block);
acc_x_raw = (int16_t)(block[0] | (block[1] << 8)) >> 4;
acc_y_raw = (int16_t)(block[2] | block[3] << 8) >> 4;
acc_z_raw = (int16_t)(block[4] | block[5] << 8) >> 4;
}
void LSM303::readMagnetometerRaw(void)
{
uint8_t block[6];
i2c_lsm303.addrSet(LSM303DLHC_MAG_ADDRESS);
i2c_lsm303.readBlock(0x80 | LSM303_OUT_X_H_M, sizeof(block), block);
mag_x_raw = (int16_t)(block[1] | block[0] << 8);
mag_y_raw = (int16_t)(block[5] | block[4] << 8);
mag_z_raw = (int16_t)(block[3] | block[2] << 8);
}
void LSM303::readAcceleration(void)
{
readAccelerationRaw();
}
Wednesday, January 16, 2013
Fedora 17 Linux packges
1. Add rpmfusion to yum repo list:
> sudo yum localinstall --nogpgcheck http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm
2.
sudo yum install -y yumex tcsh gmt ImageMagick ipython scipy scitools spyder gthumb nautilus-open-terminal bluecurve-icon-theme gnome-applets gnome-themes bluecurve-gnome-theme filezilla gimp swig lshw lshw-gui gnome-tweak-tool libreoffice gv gcc gcc-gfortran gcc-c++ dconf-editor tigervnc-server
install chrome from google
install virtualbox from oracle site.
copy panels:
on old machine: dconf dump /org/gnome/gnome-panel/ > panels
on new machine: dconf load /org/gnome/gnome-panel/ < panels
change with dconf-editor:
/org/gnome/desktop/interface/icon-theme to Bluecurve
/org/gnome/desktop/wm/preferences/theme Clearlooks
/org/gnome/desktop/background/show-desktop-icons True
change user shell to tcsh: sudo usermod -s /bin/tcsh USERNAME
install microsoft fonts:
wget http://www.my-guides.net/en/images/stories/fedora12/msttcore-fonts-2.0-3.noarch.rpm
sudo rpm -ivh msttcore-fonts-2.0-3.noarch.rpm
6.Install obspy as root:
sudo easy_install -N obspy.core obspy.mseed obspy.sac obspy.gse2 obspy.imaging obspy.signal obspy.arclink obspy.datamark obspy.db obspy.earthworm obspy.fissures obspy.iris obspy.neries obspy.realtime obspy.segy obspy.seg2 obspy.seisan obspy.seishub obspy.sh obspy.taup obspy.wav obspy.xseed
Sunday, December 16, 2012
JoyWarrior24F14 Udev rules
issue the command:
> sudo vi /etc/udev/rules.d/10-JoyWarrior24F14.rules
and when in editing mode (i) add:
SUBSYSTEM=="usb", ATTRS{idVendor}=="07C0", ATTRS{idProduct}=="0140", MODE:="666", GROUP="users"
SUBSYSTEM=="usb", ATTRS{idVendor}=="07c0", ATTRS{idProduct}=="1116", MODE:="666", GROUP="users"
Monday, September 24, 2012
Installing SeisComp3 on fedora 17
first, install MySQL (following this):
> sudo yum install -y mysql mysql-server
enable and start MySQL service:
> sudo systemctl enable mysqld.service
> sudo systemctl start mysqld.service
Next, secure the server:
> sudo /usr/bin/mysql_secure_installation
(answer yes to all questions and change the MySQL root password)
If you need to change the database location from the default follow this (source):
Stop the service:
> systemctl stop mysqld.service
Copy from default to new location:
> cp -R -p /var/lib/mysql /path/to/new/datadir
Clean unneeded files:
> rm /path/to/new/datadir
(don't worry about error messages - the undeleted files are the databases)
Edit the configuration file:
> gedit /etc/mysql/my.cnf
(change keyword value of datadir to the new location)
Restart the service:
> systemctl restart mysqld.service
Now to the SeisComp3 install (Zurich version for fedora16 modified for fedora 17):
Add needed packages:
> sudo yum install -y boost-filesystem boost-iostreams boost-program-options boost-serialization boost-signals
boost-thread boost-wave boost-regex boost-devel ncurses python-numeric numpy alsa-utils festival
Link installed libraries (so.1.48) to the needed packages (so.1.47):
> sudo ln -s /usr/lib64/libboost_iostreams.so.1.48.0 /usr/lib64/libboost_iostreams.so.1.47.0
> sudo ln -s /usr/lib64/libboost_filesystem.so.1.48.0 /usr/lib64/libboost_filesystem.so.1.47.0
> sudo ln -s /usr/lib64/libboost_system.so.1.48.0 /usr/lib64/libboost_system.so.1.47.0
> sudo ln -s /usr/lib64/libboost_regex.so.1.48.0 /usr/lib64/libboost_regex.so.1.47.0
> sudo ln -s /usr/lib64/libboost_thread-mt.so.1.48.0 /usr/lib64/libboost_thread-mt.so.1.47.0
> sudo ln -s /usr/lib64/libboost_program_options.so.1.48.0 /usr/lib64/libboost_program_options.so.1.47.0
> sudo ln -s /usr/lib64/libboost_signals.so.1.48.0 /usr/lib64/libboost_signals.so.1.47.0
Put key files in ~/.seiscomp3/key/ directory
Install using the setup and seiscomp config procedures described in the SeisComp3 documentations
add a source to env.sh file in your .bashrc:
source ~/seiscomp3/lib/env.sh
For the seattle release use:
>sudo yum install -y boost boost-devel python-numeric
Don't forget to download and extract to the seiscomp directory, the correct fedora seiscomp package (e.g. seiscomp3-zurich-xxxx.xxx.xx-fedora16-x86_64.tar.gz), the maps (e.g. seiscomp3-maps.tar.gz) and the methadata of GE network (e.g. seiscomp3-metadata-GE-2010.tar.gz).
Tuesday, August 28, 2012
Howto write to stdout XY
import sys
def print_there(x, y, text):
sys.stdout.write("\x1b7\x1b[%d;%df%s\x1b8" % (x, y, text))
sys.stdout.flush()
Creating a software raid
or with parted (for 3TB disks):
> parted /dev/sdx
(parted) mklabel gpt
(parted) unit TB
(parted) mkpart primary 0 3001G
(parted) print
(parted) quit
2. Create the raid device (change level and devices as needed):
mdadm --create --level=1 --raid-devices=2 /dev/md0 /dev/sd[bc]1
3. format the file system of the new device:
mkfs.ext4 /dev/md0
4. create the mdadm.conf file:
mdadm --detail --scan > /etc/mdadm.conf
5. add mail alert:
echo "MAILADDR your_mail@somthing.com" >> /etc/mdadm.conf
echo "MAILFROM your_server" >> /etc/mdadm.conf
6. test mail alert:
mdadm --monitor --scan --test --oneshot
7. start mail alert deamon:
systemctl enable mdmonitor.service
systemctl start mdmonitor.service
8. edit the mail aliases file to forward root messages to your email:
vi /etc/aliases
add your mail under the line: # Person who should get root's mail
http://www.iceteks.com/articles.php/linuxmdadmraid/
* after name change, create the /etc/mdadm.conf file and run:
sudo update-initramfs -u
or
sudo dracut -f /boot/initramfs-[current].img
Thursday, May 10, 2012
Howto run a process automatically when a certain mail is downloaded by Thunderbird
/usr/bin/python,/home/UserName/code.py,-a
The line is a comma separated 3 parts line. The first part is the python interperter, the second is the script name to run and the last part is an argument needed for the script to run. Omitting the first part and the filter wont work.
Saturday, July 30, 2011
Create a photo collage using a single command-line
Thursday, July 28, 2011
HowTo use a computer without a screen attached
I have a Linux machine (Fedora 14) with no screen attached. I view the graphics via VNC server. I had to adjust the system to use the Nvidia driver and tweak it for no screen.
The solution:
First we need to install the Nvidia driver. Then, we need to adjust the X configuration for no screen and our preferred resolution.
for more details see: http://forums.fedoraforum.org/showthread.php?t=204752
1. Update the kernel:
su yum update kernel* reboot
2. Add rpmfusion to your repository.
su rpm -Uvh http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm
3. Depending on your card add nvidia akmod to the kernel and the proper driver. for a Gforce 9500GT on my 64bit machine:
yum install akmod-nvidia-260.19.36-1.fc14.x86_64 xorg-x11-drv-nvidia-libs-260.19.36-1.fc14.x86_64
4. Edit the xorg.conf file. don't forget to adjust the Nvidia card for no screen attached by adding:
Option "ConnectedMonitor" "CRT"
to the device section and adjust the screen resolution under the Screen section:
Section "Device"
Identifier "Card0"
Driver "nvidia"
Option "ConnectedMonitor" "CRT"
EndSection
Section "Screen"
Identifier "Screen0"
Device "Card0"
Monitor "Monitor0"
SubSection "Display"
Viewport 0 0
Modes "1280x1024"
EndSubSection
EndSection
Thursday, March 31, 2011
Installing Linux Fedora Core 14
Here I'll detail the steps I used for the installation.
I generally follow my Fedora 10 installation guide with some changes of course.
LiveCD:
I use a liveCD (download page) to install.
after loading the system via cd,
I use the "Install to Hard Drive" icon.
next,next,next.
Giving the Hostname, setting location, giving a good root password.
File System:
Since I use several hard drives I need to configure the file system. I use one 1.5TB disk as my home, another one for data and processing and one for the system so all the installation will only deal with the last one. later I'll mount all the rest of the disks.
so the type of installation for me is "Replace Existing Linux System(s)", but with "Review and modify layout" switch on and I select the system disk as "Install Target Devices".
Next I change the partitions and mount points of all disks as needed.
Finally, The boot loader is set up and the system is installed on the hard drive.
Updates and softwares:
As a first step few softwares should be installed and update (this might take forever):
yumex
gconf-editor
gedit-plugins
gthumb
nautilus0open-terminal
tango-icon-theme
tango-icon-extras
fonts for Hebrew
all stix fonts
cm-lgc fonts
blender
gimp
gv
ImageMagick
inkscape
filezilla
thunderbird
emacs
open office
vim-enhanced
gcc
gmt
grace
HDF
HDF5
lapack
netcdf
numpy
python support for open office
compat-gcc
glade3
ipython
pango-devel
wget
tcsh
system-config-samba
system-config-users
system-config-nfs
dos2unix
selinux configuration gui
matplotlib
scipy
scitools
kdocker
numlockx
bluecurve icons
ssmtp
Customizing:
remove SElinux policy
disable filrewall
configure remote desktop
add user to sudo:
su --login -c 'visudo'
Now go below the line:
root ALL=(ALL) ALL
press a, and type the following
username ALL=(ALL) ALL
where username is the username you use to login. Next press Escape.
Now, if you want to be prompted for your root password each time you use the sudo command go to this line:
# %wheel ALL=(ALL) ALL
and with your cursor pointing on # press x
If you don't want to be prompted for your root password each time you use the sudo command go to this line:
# %wheel ALL=(ALL) NOPASSWD: ALL
and with your cursor pointing on # press x
Next, press :wq to save and exit. (type the : as well)
* Adding your user to the wheel group
Just type:
su -c 'gpasswd -a username wheel'
* Testing sudo
To test if you have done it correctly as a simple user type:
$ sudo whoami
If everything is working properly the command should return the word 'root'.
change autologin for user:
sudo vi /etc/gdm/custom.conf
under [daemon], add:
AutomaticLoginEnable=true
AutomaticLogin=yourUserName
edit /etc/fstab for mounting external HD (LAN):
//XXX.XX.XX.XX/DATA /mountpoint cifs auto,owner,rw,username=XXX,uid=XXX,gid=XXX 0 0
NOTE! - it will not mount on startup. need to do: "sudo mount mountpoint" to mount. one can add password=[user-passwd] after username=[username] or instead username and password : credentials=[path to a file containing user and password]
the file should contain the remote system properties:
username=[username]
password=[userpassword]
Enable Num Lock on GNOME startup:
su -c 'yum install numlockx'
su -c 'cp /etc/gdm/Init/Default /etc/gdm/Init/Default_backup'
su -c 'gedit /etc/gdm/Init/Default'
And add the following lines at the end of the file before the exit 0.
if [ -x /usr/bin/numlockx ]; then
/usr/bin/numlockx on
fi
set the samba server
set the mail server:
sudo vi /etc/ssmtp/ssmtp.conf
change the line:
mailhub=mail
to:
mailhub=[your outgoing mail server]
Set the screen resolution for vnc and no monitor:
create xorg.conf file
sudo Xorg :1 -configure
sudo cp /root/xorg.conf.new /etc/X11/xorg.conf
and add lines to the xorg.conf file:
Section "Monitor"
Identifier "Monitor0"
ModelName "LCD Panel 1280x1024"
HorizSync 31.5 - 64.0
VertRefresh 56.0 - 65.0
Option "dpms"
EndSection
Section "Device"
### Available Driver options are:-
### Values: <i>: integer, <f>: float, <bool>: "True"/"False",
### <string>: "String", <freq>: "<f> Hz/kHz/MHz",
### <percent>: "<f>%"
### [arg]: arg optional
#Option "SWcursor" # [<bool>]
#Option "HWcursor" # [<bool>]
#Option "NoAccel" # [<bool>]
#Option "ShadowFB" # [<bool>]
#Option "UseFBDev" # [<bool>]
#Option "Rotate" # [<str>]
#Option "VideoKey" # <i>
#Option "FlatPanel" # [<bool>]
#Option "FPDither" # [<bool>]
#Option "CrtcNumber" # <i>
#Option "FPScale" # [<bool>]
#Option "FPTweak" # <i>
#Option "DualHead" # [<bool>]
Identifier "Card0"
Driver "vesa"
BusID "PCI:1:0:0"
EndSection
Section "Screen"
Identifier "Screen0"
Device "Card0"
Monitor "Monitor0"
SubSection "Display"
Viewport 0 0
Depth 24
Modes "1280x1024"
EndSubSection
EndSection
set the panels and desktop background as you like it.
Install RPMfusion repositories following: www.rpmfusion.org/Configuration
add true type fonts from windows
Sunday, July 18, 2010
SSH with no password
first you'll need to produce the key in the local computer:
ssh-keygen -t dsa -b 1024 -P ""
press Enter on the questions followed by the command.
the output will be something like:
Your identification has been saved in /home/yourname/.ssh/id_dsa.
Your public key has been saved in /home/yourname/.ssh/id_dsa.pub.
The key fingerprint is:
4f:9e:4c:17:8f:19:37:32:bc:45:4f:2a:a2:8e:1c:15 yourname@your.loacl.machine
The key's randomart image is:
+--[ DSA 1024]----+
| .o |
| .oo. |
| . o+ |
| o *.+. .|
| .E . + . |
| o .+.. . .|
| +o.o. + |
| o+E |
| o=. |
+-----------------+
change mod to 600:
chmod 600 ~/.ssh/authorized_keys
Wednesday, June 2, 2010
How to format a hard drive on Linux
How to format a hard drive on Linux.
The Solution:
in order to format a HD on Linux you'll need super user privileges.
you can use sudo if you have sudo privilages or in the terminal
switch to super user:
>su
(give super user pwd)
and ignore the sudo in the following commands. if you're system can't find the commands while in su mode, try to add /sbin/ before the command.
follow the steps below: marked with •
run commnads marked with >
commands output looks like this.
Warning: formatting your HD will erase all data on it!
- Connect the HD to the computer, make sure it's on.
- get the hard drive's (device) name on your system:
Now lets say our HD is sdb1.
- lets build it's partition:
Command (m for help):
- pressing m will get this menu:
- pressing p will print the current partition:
- pressing d will delete the current partition. depending on the partition you want to delete (this case 1) press the number of the partition to be deleted. if all the disk should be formatted and there are several partitions repeat pressing d and the number of the partitions until you delete them all.
- pressing n will create a new partition.
- pressing p will create a primary partition. select 1 as the number of the partition. use the defaults (just press Enter) for the start and end cylinders.
- pressing t will set the file system type.
- pressing l will list the available file systems.
- select 83 if you want a Linux file system
- pressing w will write and exit to shell.
> sudo mkfs -t ext2 /dev/hdb1
remember to change the number at the end if your HD device number is different.
if your using different fs than ext2 (newer Linux systems have ext3 and fc11 has ext4) replace the ext2 in the command with the correct fc name.
the mkfs may take some time to run (depending on the computer and HD size).
To add a label to the partition use:
e2label /dev/sdb1 NEWLABEL
where sdb should be changed to the correct device and NEWLABEL changed to the new label.
Now add the device to the fstab file in order to mount it:
> sudo vi /etc/fstab
and add a line like:
LABEL=NEWLABEL MOUNTPOINT ext3 defaults 1 2
where NEWLABEL is the disk labe and MOUNTPOINT is where you want to mount the disk.
mount it using:
> sudo mount -a
Note you might need to change permissions and owner of the mount point:
> sudo chown username:usergroop MOUNTPOINT
when finnished - reboot.
Wednesday, April 28, 2010
Moving memory from swap (page) to RAM
more details and a nice script to do is are available at: Ubuntu Community Documentation Swap FAQ page.
sudo swapoff -a
sudo swapon -a
The commands simply shut off swap and turning it on back again.
You'll have to make sure there is enough space on the RAM to accommodate the Swap data, this can be done using:
free
the output will show you the used space of Swap and free space of RAM:
total used free shared buffers cached Mem: 8047896 772268 7275628 0 19540 129372 -/+ buffers/cache: 623356 7424540 Swap: 10108920 0 10108920
The example above show that no data (0) is stored on Swap.
Thursday, May 7, 2009
Using HighLearn & Linux
Can't use HighLearn on Linux with firefox.
This e-learning system of some of the academic institutions in Israel is Microsoft explorer based. It is a very unfortunate setting for linux users. I hope they will change the system soon. Probably they won't...
The Solution:
Thanks to a tip from a friend, I google it up and discovered this thread (Hebrew) which suggest using konqueror.
Just install Greasemonkey on your firefox, restart firefox and click "Install" Here.
Note! not all the features are working yet.
Monday, May 4, 2009
Howto view an image in Google Earth
I have an image I wish to view on Google Earth.
The Solution:
I assume you have an image in jpg or tiff or gif format. and you have a world file for it or can create one. Then, all you need to do is to run the image2kml.csh script.
just download (~1kb), apply execution privilege (chmod +x [ScriptFileName])
and run it. or visit my scripts page
Tip:
gif format image can support transparency you can use GIMP or other image manipulation program to turn unwanted parts of the image to be transparent so you can see the Google Earth layover under the image.
Howto share folders from windows to Linux
The Problem:
I use two machines, one is a Linux based and one windows based. I need to share files between them.
The Solution:
One option is to use a network hard drive. It might be quite slow though.
Other option is to use windows share documents option. It is not the safest methods, but surely one of the easiest.
On Windows:
- Right click on the folder to be shared and select “sharing and Security...”
- mark “Share this folder on the network”
- give a network name – best if only one word (it is not case sensitive)
- if you will need to change the files and not only to view them mark also “Allow network users to change my files”

On Linux:
Gui solution:
- go to “Places” -> “Connect
to Server..."
- switch to “Widows Share” on service type
- On “Server:” enter the windows machine IP number
- On “Share:” enter the name of the shared folder as was entered on the Windows sharing options
- if you use a different user name enter your windows user name on “User Name:”
- You can use an alias for this folder on the Linux machine by entering a new name at “Bookmark name:”
Now you can see and use the folder and files.
Or using mount (not Gui):
- create a new mount point (e.g. /mnt/windowsshare)
- Use mount command:
mount -t cifs //serverIP/shareName -o username=WindowsUserName,password=WindowsPassword /mnt/windowsshare
Or edit /etc/fstab file:
mounting windows share:
//XXX.XX.XX.XX/shareName /mountpoint cifs auto,owner,rw,username=XXX,uid=XXX,gid=XXX 0 0NOTE! - it will not mount on startup. need to do: "sudo mount mountpoint" to mount. one can add password=[user-passwd] after username=[username] or instead username and password : credentials=[path to a file containing user and password]the file should contain the remote system properties:username=[username]password=[userpassword]
Tuesday, April 28, 2009
Whoto know if a long process is done?
I sometimes run a very long process which can even reach up to few days.
Instead of looking and checking if the process has done, I needed a solution to get a message from the process itself.
One way to do it is by using mail like this:
echo "some message" | mail -s "subject of mail" yourmail@wherever
Unfortunately, for some reason it doesn't work for me.
if you have any solution - let me know. I used a workaround...
The Solution (Option I):
Using Thunderbird and cshell and a tip from here (look at the comments), I built a script that can be added to a command line or another script which run's the process.
needed ingredients:
- Thunderbird
- xdotools
usage: simply copy the command below, edit where needed and run:
mail_script.csh [few message body words]
mail_script.csh:
#!/bin/cshThe Solution (Option II):
# this will send a mail with subject:"mission accomplished"
# and command line variables (argv) as the message body
# the script require Thunderbird and xdotool installed
# Just change the "to" field in the command below and
# set a program to run it at the end of process
# by Ran Novitsky Nof 2009 @ BGU
set body = `echo $argv`
thunderbird -compose "to='yourmail@wherever',subject='Mission Accomplished',body=$body" & ; sleep 5 ; set WID=`xdotool search --title
"Compose" head -1`; xdotool windowfocus $WID;xdotool key ctrl+Return
Option I needs Thunderbird to be installed and it uses gui so somtimes there are conflicts with user activity. an alternative solution is to install ssmtp (most Linux distros has it as a package). after installing edit /etc/ssmtp/ssmtp.conf file:
most importent lines to edit:
Mailhub - you smtp server (e.g smtp.gmail.com or any other smtp server)
AuthUser - see conf file link above
AuthPass - see conf file link above
AuthMethod - see conf file link above
FromLineOverride - remove the # at the start of line
edit /etc/ssmtp/revaliases:
add a line:
root:[user]@[mailaccount]:[smtpserver]:[port]
and run the script mail_script.csh:
# this will send a mail with subject:"mission accomplished"
# and command line varibles (argv) as the message body
# the script requier ssmtp installed
# Just change the -F , SendTo and "To" fields in the command below and set a program to run it at the end of process
#
# by Ran Novitsky Nof 2010 @ BGU
set body = `echo $argv`
sudo ssmtp -F"name of sender" recipient@mailserver << END
To:recipient@mailserver
Subject:Mission accomplished
$body
END
