[XEN] Shrink / Reduce Windows Guest Filesystem

1) Shrink the filesystem via windows as needed.

2) Extract the corresponding VDI at the hypervisor (xenserver):
2.1) First look up the VDI UUID

xe vbd-list 

2.2) Export VDI – Format default: raw -> Set with format=…

xe vdi-export uuid=VDI_UUID filename=fs.vdi

3.) Mount VDI on another Maschine (e.g. VM via XenServer (recommended))

apt-get install qemu-utils kpartx
modprobe nbd
qemu-nbd -c /dev/nbd0 /path/to/file.vdi

3.1) Create device maps from partition tables -> Typical for windows guests: nbd0p1 (system-reserved) and nbd0p2 (data)

kpartx -a /dev/nbd0

4) Add a new virtual disk image to your VM and create corresponding partition tables on the target device -> HowTo:Fdisk

5.1) Copy boot partition with dd:

dd if=/dev/nbd0p1 of=/dev/xvdX1

5.2) Copy data partition with dd:

dd if=/dev/nbd0p2 of=/dev/xvdX2

Export our new small vdi at the hypervisor (xenserver):

xe vdi-export uuid=VDI_UUID filename=fs.vdi

Create new VBD (Connector between VM and VDI)

xe vdb-create vm-uuid=WINDOWS_GUEST_VM_UUID device=0 bootable=yes mode=RW type=Disk

Plug new VDB to VM

xe vdb-plug uuid=UUID_OUTPUT_FROM_LAST_STEP

[Debian]: Create NTFS Filesystem

fdisk /dev/sdX

If required delete old partition table (DATA LOSS!!!):

for i in partitionNumber; do d + ENTER; done

Create new DOS partition table:

g + ENTER

Create new Partition:

n + ENTER + Follow instructions

Set Partition Type NTFS:

t + ENTER + 7 + ENTER

Write changes:

w + ENTER

Create NTFS Partiton:

mkfs.ntfs /dev/sdX

[Postfix]: Block Spam with Helo Restrictions

/etc/postfix/main.cf:

###Block HELO Wildcards
smtpd_delay_reject = yes
smtpd_helo_required = yes
smtpd_helo_restrictions = permit_mynetworks, check_helo_access hash:/etc/postfix/helo_access, permit

Example Syntax for mailminion:

/etc/postfix/helo_access:

.mailminion.net REJECT Fuck off - I hate spam like this!
mailminion.net REJECT Fuck off - I hate spam like this!
mmsvr.net REJECT Fuck off - I hate spam like this!
.mmsvr.net REJECT Fuck off - I hate spam like this!

Build readable database for postfix:

postmap helo_access

Restart Postfix:

/etc/init.d/postfix restart
or
service postfix restart

~Faulwurf

[Script]: Simple Kimsufi KS-1 Notification Script

Hey,

just a little script to check if a KS-1 is available:

#!/bin/bash
#Simple KS-1 Notification Script
#Alexander Krischan - http://krischan.eu
#16.10.2015

#API abrufen und verarbeiten
curl https://ws.ovh.com/dedicated/r2/ws.dispatcher/getAvailability2 -o api -silent
cat api | tr "," "\n" > out
num=`grep -A 31 150sk10 out | grep -c 1H-high`

#Mail erstellen
echo "KS-1 Available" > mail
echo "Buy here: http://www.kimsufi.com/de/index.xml" >> mail
echo "or here: http://kimsufi.com/en/order/kimsufi.cgi?hard=142sk1&dedicatedQuantity=1" >> mail
echo "" >> mail
echo "Output:" >> mail
grep -A 31 150sk10 out >> mail

#Auf Verfuegbarkeit pruefen
if [ $num = 0 ]; then
exit
else
mail -s "Kimsufi KS-1 Available!" sample@domain.com < mail
fi
exit

Faulwurf

[Script] Hitleap Viewer with CentOS

To simplify the process of installing wine and tightvnc I wrote a little script. You’ll be asked for an userpass and vncpass during the installation. The User is hardcoded to “hitvnc” and you just need to login via vnc and install hitleap via the msi-file and you will be done 😉 (just check my normal howto if you don’t know how to install hitleap)

OS: CentOS 6 32bit (tested) / CentOS 7 32bit (not tested – please give me some feedback if you try it with CentOS7)

Usage:

cd /home && wget http://repo.krischan.eu/hitvnc/install.sh && wget http://repo.krischan.eu/hitvnc/vncuser.sh && chmod +x install.sh && chmod 777 vncuser.sh && bash install.sh 

Regards,
Faulwurf