http://www.sicherheitstacho.eu/?lang=en
giovedì 28 marzo 2013
mercoledì 13 febbraio 2013
Physical to virtual (P2V) GNU/Linux step by step
Hi,
I'm trying to migrate from physical machine to virtual machine GNU/Linux with KVM, continuing keeping running the physical machine during the virtualization (and thus minimization the downtime).
(still working in progress, but...)
I'm trying to migrate from physical machine to virtual machine GNU/Linux with KVM, continuing keeping running the physical machine during the virtualization (and thus minimization the downtime).
(still working in progress, but...)
Script to create the virtual disk with 2 partitions:
#!/bin/bash
set -e
if [ ! $UID -eq 0 ] ; then
echo "You are not root"
exit 1
fi
DEFAULT=5 # GB
ROOTSIZEGB=${1:-$DEFAULT}
ROOTSIZEB=$((ROOTSIZEGB * 1024 * 1024 * 1024 )) # bytes
ROOTSIZEs=$((ROOTSIZEB / 512 )) # sector
SWAPSIZEGB=4 # GB
SWAPSIZEB=$((SWAPSIZEGB * 1024 * 1024 * 1024 )) # bytes
SWAPSIZEs=$((SWAPSIZEB / 512 )) # sector
# 4K alignment:
#OFFSETKB=64 # KB
OFFSETKB=1024 # KB
OFFSETB=$((OFFSETKB * 1024 )) # bytes
OFFSETs=$((OFFSETB / 512 )) # sector
DEFAULT=1
N=${2:-$DEFAULT}
LOOP=/dev/loop$N
VDISK=disk-0$N.bin
LOGFILE=$VDISK.log
if [ -f $VDISK ] ; then
echo "$VDISK already exists!"
echo "usage: $0 GBsize LOOPdevice"
ls -lh $VDISK
mount | grep $LOOP
echo "# umount /mnt/$VDISK"
losetup -a
echo "# losetup -d $LOOP"
exit 1
fi
echo "Virtual file system : $VDISK : $ROOTSIZEGB GB / + $SWAPSIZEGB swap mounted on $LOOP"
echo "Ok? (CTRL-C to quit, ENTER to continue)"
read ANSWER
CMD="qemu-img create -f raw $VDISK $((OFFSETB + ROOTSIZEB + SWAPSIZEB))"
echo "--------" | tee -a $LOGFILE
echo $CMD | tee -a $LOGFILE
echo "--------" | tee -a $LOGFILE
$CMD
#CMD="$OFFSETs,$ROOTSIZEs,83\n$((OFFSETs + ROOTSIZEs)),$((SWAPSIZEs - OFFSETs)),82"
CMD="$OFFSETs,$ROOTSIZEs,83\n$((OFFSETs + ROOTSIZEs)),,82"
echo "--------" | tee -a $LOGFILE
echo -e "$CMD | sfdisk -S 32 -uS $VDISK" | tee -a $LOGFILE
echo "--------" | tee -a $LOGFILE
echo -e "$CMD" | sfdisk -S 32 -uS $VDISK > /dev/null 2>&1
# check:
echo "--------" | tee -a $LOGFILE
sfdisk -l -S 32 -uS $VDISK | tee -a $LOGFILE
echo "--------" | tee -a $LOGFILE
LOOPSWAP=/dev/loop7
CMD="losetup --offset $(( OFFSETB + ROOTSIZEB )) $LOOPSWAP $VDISK"
echo -e "--------\n$CMD\n--------" | tee -a $LOGFILE
$CMD
mkswap $LOOPSWAP
sleep 1
losetup -d $LOOPSWAP
mkdir -p /mnt/$VDISK
CMD="losetup --offset $OFFSETB $LOOP $VDISK"
echo -e "--------\n$CMD\n--------" | tee -a $LOGFILE
$CMD
CMD="mkfs.ext4 -O uninit_bg,filetype,extent,dir_index -L KVM $LOOP"
echo -e "--------\n$CMD\n--------" | tee -a $LOGFILE
$CMD > /dev/null 2>&1
CMD="mount $LOOP /mnt/$VDISK"
echo -e "--------\n$CMD\n--------" | tee -a $LOGFILE
$CMD
#grub-install --force --boot-directory=/mnt/test-sda/ --no-floppy $LOOP
echo "At the end...:"
echo "umount $LOOP ; losetup -d $LOOP" | tee -a $LOGFILE
Clone physical machine:
cd /mnt/$VDISK rsync -e ssh -au -numeric-ids --stats -h --exclude /proc --exclude /tmp --exclude /dev --exclude /sys root@REMOTEHOST:/ /mnt/$VDISK/
Chroot to VM:
mount --bind /dev/ /mnt/$VDISK/dev/ mount -t devpts pts /mnt/$VDISK/dev/pts/ mount -t tmpfs none /mnt/$VDISK/dev/shm/ mount -t proc none /mnt/$VDISK/proc/ mount -t sysfs sys /mnt/$VDISK/sys/ chroot /mnt/test/sda
Fix mtab and fstab:
vim /etc/mtab vim /etc/fstab
Rebuild initramdisk:
mkinitrd ...
Install grub:
grub-install $LOOP
Umounting virtual image:
exit cd .. umount /mnt/$VDISK/sys/ umount /mnt/$VDISK/proc/ umount /mnt/$VDISK/dev/shm umount /mnt/$VDISK/dev/pts umount /mnt/$VDISK/dev/ umount /mnt/$VDISK/ losetup -d $LOOP
Run virtual machine:
kvm -name VMclone -m 4096 -cpu kvm32 -monitor stdio -kernel boot/vmlinuz -append "root=/dev/sda1" -initrd initrd.img $VDISK
grub:
linux /boot/vmlinux... root=/dev/sda1 initrd /boot/initrd.... boot
venerdì 9 marzo 2012
Brevetti, un punto di vista storico
Articoli contro i brevetti:
http://torrentfreak.com/history-shows-that-copyright-monopolies-prevent-creativity-and-innovation-120205/
http://christianengstrom.wordpress.com/2011/03/09/an-alternative-to-pharmaceutical-patents/
http://torrentfreak.com/history-shows-that-copyright-monopolies-prevent-creativity-and-innovation-120205/
http://christianengstrom.wordpress.com/2011/03/09/an-alternative-to-pharmaceutical-patents/
domenica 29 gennaio 2012
Bash tips
Bash tips:
http://www.quora.com/Linux/What-are-some-time-saving-tips-that-every-Linux-user-should-know
http://www.quora.com/Linux/What-are-some-time-saving-tips-that-every-Linux-user-should-know
giovedì 5 gennaio 2012
No such file or directory but file exists SOLVED
At least I have resolved the problem:
:[~]$ LANGUAGE=C ./lmgrd
-bash: ./lmgrd: No such file or directory
:[~]$ LANGUAGE=C ./lmgrd
-bash: ./lmgrd: No such file or directory
:[~]$ file ./lmgrd
./lmgrd: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.9, stripped
:[~]$ ls -l ./lmgrd
-rwxrwxrwx ./lmgrd*
:[~]$ strace ./lmgrd
execve("./lmgrd", ["./lmgrd"], [/* 100 vars */]) = -1 ENOENT (No such file or directory)
dup(2) = 3
fcntl(3, F_GETFL) = 0x8002 (flags O_RDWR|O_LARGEFILE)
fstat(3, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 5), ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f9082bf3000
lseek(3, 0, SEEK_CUR) = -1 ESPIPE (Illegal seek)
write(3, "strace: exec: No such file or di"..., 40strace: exec: No such file or directory
) = 40
close(3) = 0
munmap(0x7f9082bf3000, 4096) = 0
exit_group(1) = ?
:[~]$ ldd ./lmgrd
linux-gate.so.1 => (0xf7710000)
libpthread.so.0 => /lib32/libpthread.so.0 (0xf76be000)
libm.so.6 => /lib32/libm.so.6 (0xf7694000)
libgcc_s.so.1 => /usr/lib32/libgcc_s.so.1 (0xf7675000)
libc.so.6 => /lib32/libc.so.6 (0xf74fb000)
libdl.so.2 => /lib32/libdl.so.2 (0xf74f6000)
/lib/ld-lsb.so.3 => /lib/ld-linux.so.2 (0xf7711000)
:[~]$ LANGUAGE=C ls -l /lib/ld-lsb.so.3
ls: cannot access /lib/ld-lsb.so.3: No such file or directory
root@niels:/lib# ln -s ld-linux.so.2 ld-lsb.so.3
:[~]$ ./lmgrd
20:53:22 (lmgrd) -----------------------------------------------
20:53:22 (lmgrd) Please Note:
20:53:22 (lmgrd)
20:53:22 (lmgrd) This log is intended for debug purposes only.
IT WORKS!
But why ldd lie?
martedì 3 gennaio 2012
tcpdump
tcpdump -l -s0 -w - tcp dst port 80 | strings | egrep "(Host:|Referer:)" | tee -a website-tracing.txt
lunedì 2 gennaio 2012
Calendario 2012
pcal -S -B -p -P a4 -o calendario-2012.ps -M -F Monday -E -J -a IT 12 ; evince calendario-2012.ps
Iscriviti a:
Post (Atom)