[Linux] Ubuntu Root Server to VMWare BareMetal Recovery

I got an root server on the net hosting an important website and am doing backups on a daily base using Tartarus ( http://wiki.hetzner.de/index.php/Tartarus_Backup-Konfiguration ). But as we all know: Backups are only worth a penny if they really work and are usable after an crash. Therefor I did try to recover the "dead called" machine onto BareMetal - or at least BareAir - as it was an VMWare Machine I used.

PreWork:
- Creating VMware Machine with same background and partition structure
( 40 GB HDD: Swap, Root, Boot Partition )
- Install Ubuntu 10.04.2 LTS

Recovery:
- Boot with Linux Live CD
- mount /dev/sda2 (my Root Partition)
- Recover Tartarus Backup curl ftp://USER:PASS@YOURSERVER/home-20080411-1349.tar.bz2 | tar xpvj -C /mnt/restore
- mount /dev/sda1 (my Grub Partition) and maybe recover Tartarus Backup of the Partition (most likely that should be do more harm than good... so... maybe leave it 😉 )
- Check UUID of the Partitions with blkid
- Change blkid within /etc/fstab
- Reboot

Done... or most likely 😉

PS: Maybe you will need to remove /etc/udev/rules.d/70-net-persistent and reboot because of the broken Ethernet Card...

[ESXi4.1] Review

It has been sometime, but I still want to tell my experiences with ESXi 4.1.
In the beginning, I was very annoyed from the fact that you really need an 64 bit System and at least 2 Gigs of RAM.
But the rest just turned out fine, I have to admit.

Theres an upgrade path available, so you can upgrade your ESXi 3.5 Machine via an Upgrade to 4.1 without losing your Machines or the need to reinstall.
Actually - it worked, which did surprise myself in a good manner.

In Terms of Speed and Stabilty I did not recognize anything bad.
Especially the new features were downright awesome:
I just love the USB Virtualisation.
I really hit the top by plugin in an USB Videocard to my ESXi 4.1, and adding this Virtual Device to an Vmware Appliance: Awesome speed, had realtime video within my VM.
( I used it to virtualize a bunch of Servers, Firewalls, Routers, Asterisk and a Webcamserver... was really nice running ).

The only thing I really couldn't test and missed was the PCI Virtualization.
That feature *should* work - but you need some kind of state-of-the-Art Intel CPU / Board with Virtual I/O... and I had an old Tyan AMD Dual Core Board, only... ^^'.

So maybe sometime later.

But after all, I'm really happy with that System, I could migrate an running Windows XP Machine to the ESXi4U1 and the Converter was really doing alright...

[Player 3.0] VMware Player Network Config

To configure network you need the "Virtual Network Editor" Tool. It IS integrated within the Installer - but isn't unpacked (sadly). To get the vmnetcfg.exe you need to do following: Launch the installer with /e parameter: VMware-player-3.0.0-197124.exe /e .\extract. With this command, the complete install gets "unzipped" into the "extract" folder. Within this folder you will find the network.cab. And in this file, you find the vmnetcfg.exe. Copy it to the Program Files\VMware\VMware Player Folder.  Run the Program as Administrator.

And to add multiple bridged interfaces, do configure an interface in the VMware File vmx with following:

ethernet0.present = "TRUE"
ethernet0.virtualDev = "vmxnet"
ethernet0.startConnected = "TRUE"
ethernet0.connectionType = "custom"
ethernet0.vnet = "/dev/vmnet0"

[ESXi 3.5] ESXi 3.5 Update 5 Install CD with oem.tgz + ssh,ftp,rsync and wget (made easy)!

Hello,

It has been a while since I was really doing something new with VMWare, but as I had the need to install some new Servers, I also was looking for better ways on integrating oem.tgz and other features. For that, I stumbled upon an very cool and useful Linux Build Script for ESXi, made by the User Varazir. After this How To you're going to hold an ISO Installer with SSH, FTP, RSYNC, WGET and the Community Unified Driver Pack 1.1.0 oem.tgz in your Hands. Or an USB Stick with the same features - as Live Boot or Installer. Your choice.

Download:
VMware-VMvisor-InstallerCD-3.5.0_Update_5-207095.i386.iso: Vmware.com / ESXi 3.5 Download Section
Mkesxiiso.sh: http://varazir.mine.nu/esxi/
CommunityUnifiedDriverPack_v1.1.0_U3-123629.oem.gz: http://www.vm-help.com/esx/esx3i/Custom_oem.tgz/CommunityUnifiedDriverPack_v1.1.0_U3-123629.oem.gz

What you also need:
An english (!) speaking and recent Ubuntu Version with installed mkisofs.
You can use the VMWare Player for that ;-).

How To:
Copy all the files into the /tmp Folder of the Ubuntu Installation.
Rename the CommunityUnifiedDriverPack_v1.1.0_U3-123629.oem.gz to oem.tgz
Give chmod +x to the latest Mkesxiiso.sh (in my case: chmod +x mkesxiaio_3.9.1.sh).
Run sudo ./mkesxiaio_3.9.1.sh
Now the Script is going to walk you through the build of the ESXi System.

Thanks to Varazir and www.vm-help.com its finally very easy to build an custom system!

Addition: Add User to installed ESXi:
If you got an installed ESXi 3.5 and want to have an second User to use ssh and ftp instead of "root only", do this:
userdelete the old additional VMWare User you created. Create it a new with: useradd Username -M -d /
Wit that command you create the new user and put its root folder into "/" (root).
Problem why an normal user can't access ssh is, that VMWare does erase the home Folder on every boot.
You should also change the User Password on creation with passwd Username...

Quick'n Dirty Moodle Learning Platform Setup

Download and Install TurnKey LAMP (Vmware Appliance)
http://www.turnkeylinux.org/redir.php?url=http%3A%2F%2Fswitch.dl.sourceforge.net%2Fproject%2Fturnkeylinux%2Fturnkey-lamp%2F2009.10-hardy-x86%2Fturnkey-lamp-2009.10-hardy-x86.zip

go to http://IP

go to Webmin (https://IP:12321)
change root pw
change root pw in mysql
create mysql table utf8-unicode "moodle"
mkdir /var/moodledata
chown nobody /var/moodledata
chmod 777 /var/moodledata

root@lamp:/var# apt-get update
root@lamp:/var# apt-get install wget
root@lamp:/var# apt-get install php5-gd
root@lamp:/var# apt-get install php5-curl
root@lamp:/var# apt-get install php5-xmlrpc

cd /var/www
wget http://download.moodle.org/download.php/direct/stable19/moodle-weekly-19.zip
unzip moodle-weekly-19.zip

Access http://ip/moodle

(create config.php in /var/www/moodle)

change pwd,
user admin, pw admin

upload user.csv as iso8859-1 (if you're using öüä!) batch import

setting up firewall
setting up nat
setting up dyndns server for dyndns adress

with phpmyadmin moodle`.`mdl_mnet_host` change to:
Bearbeiten       Löschen       1      0      http://DYNDNSADRESS/moodle      CORRECTDNSADRESS.COM                    0      0      0      0      0      0      NULL      1

$ apt-cache search php | grep gd
php5-gd - GD module for php5

[ESXi 3.5] Dell Optiplex G620 ESXi 3.5 U5 & Problems with Ubuntu 9.10 and Vmware Tools

So, we happend to get an new ESXi 3.5 Server, using an Dell Optiplex G620 for that.

To install ESXi 3.5 U5 onto that Desktop Machine, you NEED to upgrade to Bios A11 and Shutdown CPU Limit ID - and do the Install in SATA Normal Mode (not Compability!). You also need to use the Tipps to install to an IDE Drive (so changing TYPE_IDE to TYPE_ISCSI in the TargetFilter.py) - than it will work flawlessly... (As long as you get the Bios updated, we had the "orignial" A01 Bios and it refused to use an Boot CD for the Update (did load but then always did disable Keyboard - you couldn't enter anything...). We solved the Problem by using an REAL Floppy Disk... Yeah, was hard to get one. That worked! Ah and by the way, the ESXi install did load then, but the Keyboard got Stuck again - we plugged in an USB Keyboard and that one worked, the PS2 didn't wanted to.. well, it always an Adventure setting up ESXi on non-listed Hardware - especially with Dell Bios ;-)...

So - the other Problem is the new and very cool Ubuntu 9.10 - which we did install on the ESXi with latest Software Upgraded. Both Ubuntu 9.10 and ESXi 3.5 U5 (and latest Update by Infrastructure Update Client...). So Problem was: You installed everything, installed VMWare Tools and everything worked - rebooted and your Network was fried... Actually non DNS Lookup did work at all - and everything else neither. DHCP and such worked but it looked like something on the "Hardware" (lol?) / Kernel Level screwed up.

My Co Worker Sebastian came up with one Post, giving an Solution to the Problem:

Unplug the Network from your Ubuntu (by going into the Infrastructure Client, choose Settings of the Machine, choose the NICs and unklick both "Connected" Buttons, press Enter)

sudo rmmod pcnet32
sudo rmmod vmxnet
sudo modprobe vmxnet

Replug the Network

And now it works again!

.....until the next reboot.... T_T'''... >.<'

So.. no final solution here but NOT installing VMWare Tools.

And thats my recommandation after the 5th reinstall of Ubuntu.

Will try again on the next Ubuntu and ESXi Upgrade.

SCP with Plain Password

My altered Version:

Call it with ./scp_bkp.sh User Password BKPPath ServerIP

#!/usr/bin/expect -f

set USER [lrange $argv 0 0]
set PW [lrange $argv 1 1]
set BKPPath [lrange $argv 2 2]
set IP [lrange $argv 3 3]

# 1 User, 2 PW, 3 BkpPath, 4 IP

# trick to pass in command-line args to spawn
#eval spawn scp $argv
eval spawn scp $USER@$IP:/bootbank/state.tgz $BKPPath

expect "password: $"
send "$PW\n"

# wait for regular shell prompt before quitting
# probably a better way using 'wait'
expect "$ $"

Orginally taken from: http://tiebing.blogspot.com/2009/01/scp-with-automatic-password-input.html

[VMWare] How to shrink Virtual Harddrives?

You want to shrink an too big harddrive on your VM?
Ok, lets go:

1.) Create an Harddrive in your VM which does have the desired size as second Drive
2.) Boot the VM with an Parted Magic ISO (http://partedmagic.com)
3.) Choose GParted and size your existing Harddrive down so that it will fit into the new Drive
4.) Choose Clonezilla, start for Local Disk, Local Disk to Local Disk, choose your old Disk as Source and the new as Destitination and Expert Modus.
4b.) Don't change anything in Expert, just klick through and accept the new MBR and Co.
5.) After thats done, you're done! Shut down, remove the first Harddrive (just remove from VM, NOT ERASE FROM ESXi!) and select the "new" Drive and set it to the SCSI Path the old one was (0:0:0) or so - fire it up! It should boot.

If it doesn't, get the new drive again to second with the second scsi path, insert the old drive as first again, and try again. Mostly works on second trial.

PS: If you got an Windows VM, try to use Acronis True Image Home 11 and its harddrive clone function. Works better on MS Products.

[ESXi 3.5] Output Bootup / Working Logs to Serial Connections

Very cool feature which you can enable by using the Viclient.

Go to
Configuration,
Advanced Settings,
VMKernel,
Boot,
VMkernel.Boot.serialPort

There you can set your wanted Serial Port.
0 means "no Output", 1 "Com1", 2 "Com2", etc...

Just enter you wanted Serial Port, Ok, Close, Shutdown the Server, hook up to the Serial Port with an Console Cable, get your Console open (115200er Speed, you can change that aswell!) and boot up the Server... Tada! Ok, thats only the log for Bootup!

If you want an Output for "Working ESXi", you need to go to
Configuration,
Advanced Settings,
Misc,
Misc.SerialPort

Settings are the same as above.

Enjoy