- create the lvm on the second disk
- dd data onto the lvm disk
- detach the old disk
- reboot with rescue cd and chown into the lvm root
- grub-install /dev/sda
- update-grub
Monday, May 12, 2014
debian squeeze change root disk to lvm
Wednesday, April 30, 2014
X11 forwarding for other users
1. in Your session do xauth list and find your correct auth (the one matching $DISPLAY), and copy the whole line
2. do your sudo or su and then do xauth add<the line copied in step one>
Big Thanks to http://blog.cyphermox.net/2008/05/ssh-x11-forwarding-for-other-users.html
2. do your sudo or su and then do xauth add
Big Thanks to http://blog.cyphermox.net/2008/05/ssh-x11-forwarding-for-other-users.html
Thursday, April 10, 2014
add remove dynamic bind dns records
IF ZONES EXIST
nsupdate -k $keyfile
> server 127.0.0.1
> update add server1.example.com 3600 A 10.0.0.1
> send
> update add 1.0.0.10.in-addr.arpa 3600 in ptr server1.example.com.
> send
nsupdate -k $keyfile
> server 127.0.0.1
> update add server1.example.com 3600 A 10.0.0.1
> send
> update add 1.0.0.10.in-addr.arpa 3600 in ptr server1.example.com.
> send
Wednesday, April 09, 2014
Friday, February 07, 2014
remove a line from a file
sed -i '22d' /root/.ssh/known_hosts
or better is to do ssh-keygen -R hostname/IP
or better is to do ssh-keygen -R hostname/IP
linux change root disk grub-install
redetect disks by grub-install in case dd ing 446 bytes from one disk to the other did not work, /boot/grub/devices.map needs to be fixed
Wednesday, February 05, 2014
perl command line arguments
#!/usr/bin/perl -w
use strict;
use Getopt::Long;
use utils qw( &usage );
my($host,$port,$user,$password,$file,$opt_w,$opt_c) = ("",22,"","","","","","","","");
Getopt::Long::Configure('bundling', 'no_ignore_case');
GetOptions
("H|host=s" => \$host,
"p|port=s" => \$port,
"U|user=s" => \$user,
"P|password=s" => \$password,
"F|file=s" => \$file,
"w|warning=s" => \$opt_w,
"c|critical=s" => \$opt_c,
);
($host) || usage("Host not specified\n");
($user) || usage("SFTP Username not specified\n");
($password) || usage("SFTP password not specified\n");
($file) || usage("File to upload and download not specified\n");
($opt_w) || usage("Warning threshold not specified\n");
($opt_c) || usage("Critical threshold not specified\n");
use strict;
use Getopt::Long;
use utils qw( &usage );
my($host,$port,$user,$password,$file,$opt_w,$opt_c) = ("",22,"","","","","","","","");
Getopt::Long::Configure('bundling', 'no_ignore_case');
GetOptions
("H|host=s" => \$host,
"p|port=s" => \$port,
"U|user=s" => \$user,
"P|password=s" => \$password,
"F|file=s" => \$file,
"w|warning=s" => \$opt_w,
"c|critical=s" => \$opt_c,
);
($host) || usage("Host not specified\n");
($user) || usage("SFTP Username not specified\n");
($password) || usage("SFTP password not specified\n");
($file) || usage("File to upload and download not specified\n");
($opt_w) || usage("Warning threshold not specified\n");
($opt_c) || usage("Critical threshold not specified\n");
Tuesday, February 04, 2014
rvm install ruby specific version
\curl -k -sSL https://get.rvm.io | bash -s stable --ruby=1.9.3-p362
Monday, February 03, 2014
replace root with lvm
In rescue mode::
KER=`ls /lib/modules` #if single kernel
initrd -v -f /boot/initrd-$KER.img $KER
DAAA :::: make sure you do not have rd_NO_LVM in the options passed to vmlinuz
KER=`ls /lib/modules` #if single kernel
initrd -v -f /boot/initrd-$KER.img $KER
DAAA :::: make sure you do not have rd_NO_LVM in the options passed to vmlinuz
Friday, December 20, 2013
linux remove sata disk
echo 1 > /sys/block/(whatever)/device/delete
thanks to http://unix.stackexchange.com/questions/43413/how-can-i-safely-remove-a-sata-disk-from-a-running-system
thanks to http://unix.stackexchange.com/questions/43413/how-can-i-safely-remove-a-sata-disk-from-a-running-system
Friday, October 25, 2013
centos enable LVM for root disk
1. do vgchange -a y /dev/vg1/lv_root
this enables you to see the logical volume from the rescue/gparted disk
1. do mkinitrd -f /boot/initrd-2.6.xxxxxx 2.6.xxxxxxx
this enables you to see the logical volume from the rescue/gparted disk
1. do mkinitrd -f /boot/initrd-2.6.xxxxxx 2.6.xxxxxxx
Tuesday, October 01, 2013
extend an lvm with a file on another partition
if resizing another lvm and file system is not an option (time consuming) a temp solution will be
dd if=/dev/zero of=/var/disk1_2.dsk bs=1M count=100
losetup /dev/loop0 /var/disk1_2.dsk
pvcreate /dev/loop0
vgextend /dev/VG1/lv_disk1
lvextend -L+100M /dev/VG1/lv_disk1
vim /etc/rc.local
losetup /dev/loop0 /var/disk1_2.dsk
dd if=/dev/zero of=/var/disk1_2.dsk bs=1M count=100
losetup /dev/loop0 /var/disk1_2.dsk
pvcreate /dev/loop0
vgextend /dev/VG1/lv_disk1
lvextend -L+100M /dev/VG1/lv_disk1
vim /etc/rc.local
losetup /dev/loop0 /var/disk1_2.dsk
Monday, September 16, 2013
awk gsub for regular expression modification of strings
Use gsub like this
ping -c1 10.10.27.5 > /dev/null;arp 10.10.27.5 | awk '/ether/ {gsub(/:/,"",$3);print $3}'
ping -c1 10.10.27.5 > /dev/null;arp 10.10.27.5 | awk '/ether/ {gsub(/:/,"",$3);print $3}'
Thursday, June 27, 2013
remove unkown device from VG
add a new disk and assign the missing uuid to it
pvcreate --uuid 56ogEk-OzLS-cKBc-z9vJ-kP65-DUBI-hwZPSu /dev/sdc1
then remove it from the VG and PVs
pvcreate --uuid 56ogEk-OzLS-cKBc-z9vJ-kP65-DUBI-hwZPSu /dev/sdc1
then remove it from the VG and PVs
Thursday, June 20, 2013
comm - join like utility on linux
Compare sorted files FILE1 and FILE2 line by line.
With no options, produce three-column output. Column one contains lines unique to FILE1, column two contains lines unique to FILE2, and column
three contains lines common to both files.
With no options, produce three-column output. Column one contains lines unique to FILE1, column two contains lines unique to FILE2, and column
three contains lines common to both files.
Wednesday, June 05, 2013
ssh disable host authenticity checking
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -l user 10.10.1.70
thanks to http://linuxcommando.blogspot.com/2008/10/how-to-disable-ssh-host-key-checking.html
thanks to http://linuxcommando.blogspot.com/2008/10/how-to-disable-ssh-host-key-checking.html
Monday, April 08, 2013
Friday, April 05, 2013
basic nagios bash service check
#!/bin/bash
CMD=`some command with a numerical output`
# Sanity check
if [ $# -ne 4 ]; then
echo "Usage: $0 -w WARNING -c CRITICAL"
exit
fi
while getopts ":w:c:" optname
do
case "$optname" in
"w")
WARNING=$OPTARG
;;
"c")
CRITICAL=$OPTARG
;;
"?")
echo -e "Unknown option $OPTARG\nUsage: $0 -w WARNING -c CRITICAL"
;;
":")
echo "No argument value for option $OPTARG"
;;
*)
# Should not occur
echo "Unknown error while processing options"
;;
esac
done
E_SUCCESS="0"
E_WARNING="1"
E_CRITICAL="2"
E_UNKNOWN="3"
if [ "$CMD" -gt "$CRITICAL" ]; then
echo -n "CRITICAL"
RETCODE=$E_CRITICAL
elif [ "$CMD" -gt "$WARNING" ];then
echo -n "WARNING"
RETCODE=$E_WARNING
else
echo -n "OK"
RETCODE=$E_SUCCESS
fi
echo "|RESULT=$CMD"
exit $RETCODE
CMD=`some command with a numerical output`
# Sanity check
if [ $# -ne 4 ]; then
echo "Usage: $0 -w WARNING -c CRITICAL"
exit
fi
while getopts ":w:c:" optname
do
case "$optname" in
"w")
WARNING=$OPTARG
;;
"c")
CRITICAL=$OPTARG
;;
"?")
echo -e "Unknown option $OPTARG\nUsage: $0 -w WARNING -c CRITICAL"
;;
":")
echo "No argument value for option $OPTARG"
;;
*)
# Should not occur
echo "Unknown error while processing options"
;;
esac
done
E_SUCCESS="0"
E_WARNING="1"
E_CRITICAL="2"
E_UNKNOWN="3"
if [ "$CMD" -gt "$CRITICAL" ]; then
echo -n "CRITICAL"
RETCODE=$E_CRITICAL
elif [ "$CMD" -gt "$WARNING" ];then
echo -n "WARNING"
RETCODE=$E_WARNING
else
echo -n "OK"
RETCODE=$E_SUCCESS
fi
echo "|RESULT=$CMD"
exit $RETCODE
Subscribe to:
Posts (Atom)