Friday, December 19, 2014

HowTo Install Sun-Java on Debian Wheezy


For Debian Wheezy and later releases, Sun Java is no longer available in the repositories. However, java-package can be used to generate Debian packages from the upstream distributables of the JDK as provided by Oracle.

To create packages for DebianWheezy and later, do the following.

Process

1. Install the java-package package from contrib:

Add a "contrib" component to /etc/apt/sources.list, for example:

# Debian 7 "Wheezy"
deb http://http.debian.net/debian/ wheezy main contrib

Update the list of available packages and install the java-package package:
apt-get update && apt-get install java-package && exit

3. Download the appropriate JDK from http://www.oracle.com/technetwork/java/javase/downloads/index.html or chose an older version if your needs require you to run an insecure version

Download the desired Java JDK/JRE binary distribution (Oracle). Choose tar.gz archives or self-extracting archives, do not choose the RPM!

4. Use java-package to create a Debian package, for example:
make-jpkg jdk-7u45-linux-x64.tar.gz

5. Install the binary package created:
dpkg -i oracle-j2sdk1.7_1.7.0+update45_amd64.deb

Configuration

By default the Debian Alternatives will automatically install the best version of Java as the default version. If the symlinks have been manually set they will be preserved by the tools. The update-alternatives tools try hard to respect explicit configuration from the local admin. Local manual symlinks appear to be an explicit configuration. In order to reset the alternative symlinks to their default value use the --auto option.
update-alternatives --auto java

If you'd like to override the default to perhaps use a specific version then use --config and manually select the desired version.
update-alternatives --display java
update-alternatives --config java

Choose the appropriate number for the desired alternative.

The appropriate java binary will automatically be in PATH by virtue of the /usr/bin/java alternative symlink.

You may as well use the update-alternatives tool from java-common package which let you update all alternatives belonging to one runtime or development kit at a time.
update-java-alternatives -l
update-java-alternatives -s j2sdk1.7-oracle

Monday, December 15, 2014

HOWTO Convert a KVM Disk from RAW to QCOW2

The qemu-img convert command can do conversion between multiple formats, including raw, qcow2, VDI (VirtualBox), VMDK (VMware) and VHD (Hyper-V).

Why qcow2? QEMU copy-on-write format have a range of special features, including the ability to take multiple snapshots, smaller images on filesystems that don't support sparse files, optional AES encryption, and optional zlib compression)

Image format Argument to qemu-img
raw            raw
qcow2          qcow2
VDI (VirtualBox)vdi
VMDK (VMware) vmdk
VHD (Hyper-V) vpc

The following command will convert a KVM image from RAW to qcow2:
qemu-img convert -f raw -O qcow2 /home/vservers/server1/server1.img /home/vservers/server1/server1.qcow2

After the conversion, we can check the image with the following command:
ximena@xdev:~$ qemu-img info server1.qcow2
image: server1.qcow2
file format: qcow2
virtual size: 10G (10737418240 bytes)
disk size: 1.5G
cluster_size: 65536