When you create a domain with --portbase 30000 option, you get the following ports:

Using port 30048 for Admin.
Using port 30080 for HTTP Instance.
Using port 30076 for JMS.
Using port 30037 for IIOP.
Using port 30081 for HTTP_SSL.
Using port 30038 for IIOP_SSL.
Using port 30039 for IIOP_MUTUALAUTH.
Using port 30086 for JMX_ADMIN.
Using port 30066 for OSGI_SHELL.

Of course, you may use different port bases (31000, 32000…) for different domains.

I managed to flash my Speedtouch 706WL box and reconfigure it to work with Base (former Tele2, with former Tele2AllIn service) service provider, in Belgium.

Both Internet and Phone (VOIP) work fine.

Tele2/Base Speedtouch routers use a firmware that restricts configuration possibilities for their users.  It also gives them direct access to the router’s configuration.  I really don’t like such practices – they should give users a way to use standard routers and configurations, like other providers do, and permit their users to use the full power of the routers they’ve bought.

Knowing these configuration settings, users may even use other routers to connect to Tele2/Base, which in fine is really beneficial to them if they don’t need the support of Tele2/Base or need/want to use some other router, like one they already own – removing the need to acquire one from Tele2.

As Tele2/Base don’t provide their users with full configuration settings, I decided to publish them.

After having flashed the box, I configured it with the following information:

Tele2/Base connection settings

WAN connection

User: vtxxxxxxx@tele2allin.be

Password: the ADSL password

PPPoA 8/35

ntp1.versatel.be

ntp2.versatel.be

VOIP

User: phone number (for 02/234 55 44, use 22345544)

PPPoA 0/32

Password: the ADSL password

Registrar: versatel.be:5060

Proxy: 62.58.224.212:5060

Timeout: 3600

This is the line defining my bash prompt in .bashrc, using some colors:

PS1='\[\e[0;32m\][\u@\H\[\e[m\] \[\e[1;34m\]\w\[\e[m\] \[\e[0;32m\]]\[\e[1;32m\]\$\[\e[m\] \[\e[0m'

This is what my prompt looks like:

My colored bash prompt, in Yakuake

If I’m not wrong, the characters in bold give the content of the prompt, the other ones are color-codes.

I currently haven’t found out how to use this prompt by default for all users, even existing ones, without modifying each user’s .bashrc file.

For new users to use this prompt, modify /etc/skel/.bashrc.

On the web, you’ll find how to setup ArchLinux with LVM, or with RAID, or with encryption, but not with the combination of these three technologies.  This article explains the different steps I took to setup these three technologies with ArchLinux.

Required skills:

Sound understanding of Linux (ArchLinux specifics may be useful…) and raid, lvm2, partitioning, encryption.

The story

During the last days I reinstalled my server (AMD x86_64), which runs several VirtualBox VMs, with ArchLinux.

It’s a simple PC with 3 hard drives: one for the OS and two 500GB drives which hold my data and VMs.

Here’s the detail of my hard disk setup:

  • The OS hard drive: This one is encrypted using LUKS and then runs LVM for the partitioning.  There are 2 primary partitions: one for /boot, not encrypted, and one which contains the encrypted LVM partitions.  Thus, the root partition is encrypted and on LVM, which needs specific setup in Grub.
  • The 2 data hard drives: These are raided-1 (simple duplication), the raid array is encrypted, and the partitioning is done using LVM.  The array only contains 1 single primary partition, spanning the whole space and containing the LVM partitions.

I never dared install ArchLinux on top of this setup before (so I ran my server using openSUSE, and recently Fedora 13), because of the not so user friendly ArchLinux install software.  I added encryption to my setup when I installed Fedora 13, using the Fedora installer Anaconda.  But some days ago, as I encountered several issues using Fedora 13, I decided to give ArchLinux a try. Please note that I was really surprised by the Fedora 13 release (it’s quite slick and very stable), but ArchLinux (the control I have over it and the gargantuous software collection it provides) is better suited to my advanced needs.  More precisely, in Fedora 13, I’ve found nothing as easy as netcfg to setup my network interfaces like I wanted (quite complicated, not explained here).
So here are the steps:

Hard drive setup

Setup the hard drives (partitioning, RAID-1 and LVM2) with the Fedora 13 installer Anaconda.  Simply put in the Fedora 13 install disk and make a simple install with the correct disk setup you need.  The installed OS will be of no use, the purpose here is to setup the disks, not the OS.  The Fedora 13 install software is very easy to use, as the hard drive setup is visual.
openSUSE may be OK as well, as Yast is visual and easy to use as well.

ArchLinux installation

Boot using the ArchLinux Install CD.
Choose the correct keymap for your PC:

km

Load the encryption, raid1 and LVM modules:

modprobe dm-crypt
modprobe dm-mod
modprobe raid1

Assemble the raid (as it was created with the Fedora 13 installer, there is no need to create it):

mdadm -A /dev/md0 /dev/sdc1 /dev/sdb1

Setup encryption on the OS hard drive and the data array (again, as the encrypted drives already exist, there is no need to create them, simply open them with your passphrases):

cryptsetup luksOpen /dev/sda2 system
cryptsetup luksOpen /dev/md0 data

Scan for LVM volume groups and keep them in memory:

vgscan
vgchange -ay

Then run the ArchLinux install software:

/arch/setup

Configure your installation (use the existing partitions!) until when packages were installed.
Immediately after package installation, change to another terminal with the key combination CTRL-ALT-F2, and login as root.
Now, replace the mdadm.conf file by the one corresponding to your setup (this step is needed, as this file is used to generate the initrd image with mkinitcpio):

rm /mnt/etc/mdadm.conf
mdadm --examine --scan >> /mnt/etc/mdadm.conf

Come back to the install software with the key combination CTRL-ALT-F1.
Now, in the install software, edit your configuration files:

rc.conf

USELVM=yes
KEYMAP=be-latin1

You may replace be-latin1 with your keymap.

mkinitcpio.conf

MODULES=(... dm-mod dm-crypt aes_x86_64 raid1 ...)
HOOKS=(... mdadm keymap encrypt lvm2 filesystems...)

The order in the HOOKS array is very important:

  • keymap permits to set the keymap before the encryption password for the drives is required.
  • encrypt is necessary to decrypt the drives, which allows content access to lvm2
  • lvm2 provides partitions, which are needed to mount the filesystems

I think the mdadm hook is not needed, as the root partition is not on top of a raid.  But if it was, it would be required!
Based on your setup (lvm2 over encryption over raid, encryption of single lvm2 drives,…), the order may change, so your understanding of how these technologies are set up on your drives really is relevant.

locale.gen

Remove the leading dashes (#) in front of your locale.

pacman.conf

Strictly speaking, this is not needed at all for this setup, but I can’t imagine using ArchLinux without this repository, so I always enable it:

[archlinuxfr]
Server = http://repo.archlinux.fr/x86_64

Now validate your config files.  The system launches mkinitcpio, which generates initrd images.
Now edit your menu.lst file.  Add cryptdevice=/dev/sda2:vg_system to the kernel line (adapt it to your config, replace sda2 by your encrypted partition and vg_system by your LVM2 volume group’s name).  Following are my configurations:

# (0) Arch Linux
title  Arch Linux
root   (hd0,0)
kernel /vmlinuz26 root=/dev/mapper/vg_system-root cryptdevice=/dev/sda2:vg_system ro
initrd /kernel26.img

# (1) Arch Linux
title  Arch Linux Fallback
root   (hd0,0)
kernel /vmlinuz26 root=/dev/mapper/vg_system-root cryptdevice=/dev/sda2:vg_system ro
initrd /kernel26-fallback.img

Save the file, install grub to your MBR.
Now, to automatically mount the encrypted data partitions (those on the raid1), the system must know your passphrase.  That’s the purpose of the /etc/crypttab file.

nano /mnt/etc/crypttab

Add the line:

data /dev/md0 PASSPHRASE
  • The device /dev/md0 should be the same as the one in /etc/mdadm.conf.
  • Replace PASSPHRASE with the one you chose for your system.
  • Make sure /etc/crypttab is only readable by root, or maybe someone else may read your passphrase!

The use of /etc/crypttab conveniently avoids asking the user for two passphrases, one for the OS encrypted drive and one for the data encrypted drive.  At boot, you enter your OS-encrypted-partition passphrase, and then the system reads /etc/crypttab to decrypt the data-encrypted-partition.

Enjoy!

Now, if everything went fine, you may reboot and enjoy using your fresh ArchLinux system.
Should there be some steps you don’t understand or with errors, feel free to leave a comment, I’ll do the corrections.

File locks control access to a file or a range of bytes within a file.  This is necessary in situations where multiple simultaneously executing programs need to modify the same file.

File locking functionalities are provided within the NIO API, or more specifically in the java.nio.channels package.

The two most important classes for file locking are java.nio.channels.FileChannel and java.nio.channels.FileLock.

Several methods provide file locking:

lock() acquires an exclusive lock on the entire file, and blocks until the lock is acquired, tryLock() is identical but returns null if the lock cannot be acquired.
The methods with parameters lock only regions of a file, the shared parameter is true for a shared lock and false for an exclusive lock.

A shared lock prevents other concurrently-running programs from acquiring an overlapping exclusive lock, but does allow them to acquire overlapping shared locks. An exclusive lock prevents other programs from acquiring an overlapping lock of either type.

Once you don’t need the lock anymore, release it with FileLock.release().

That seems to be a great solution, but there are limitations, related to the operating system the JVM runs on:

  • Some systems only provide advisory file locking: applications that don’t acquire locks may still write the file.
  • Some systems make it impossible to lock a file and map it into memory.  On those, you won’t be able to use a MappedByteBuffer to access file.
  • File locks are held by the Java Virtual Machine, not by individual programs. Two programs in the same JVM won’t be able to simultaneously acquire a lock on the same file.
  • Opening multiple channels on the same locked file should be avoided, as on some systems, closing a channel on a file releases all locks on the file held by the same JVM.
  • On networked file systems, file locking should be avoided – or at least, relying on file locking mechanisms should be avoided, as it’s dependent on the networked file system implementation.

My laptop currently runs the 64-bit version of Arch Linux.

The last time (some years ago, I must admit) I tried to run a 64-bit Linux distribution, I was disappointed by the issues that existed with some Firefox plugins, Skype and some other 32-bit applications.

Some weeks ago, as I had to reinstall my laptop and thought it’s time again to give a try to a 64-bit distro.  So I installed Arch Linux 64-bit.

And well, after some weeks of use as a desktop distro, I must say that in the end there is no single significant difference between the 64-bit and the 32-bit versions of Arch Linux.  Flash works, Skype works.  The set-up of Skype is not straightforward, but after I manually installed 32-bit libraries which are needed by Skype but not automatically installed, Skype now runs flawlessly, on top of Pulseaudio.

On server-side, I’ve already been using Arch64 for sime time now (virtualized on a openSUSE 64-bit host) and it runs flawlessly, but that’s no big challenge for a modern Linux distro…

I still don’t know what the 64-bit desktop versions of Ubuntu, openSUSE or Fedora are worth, but I’m very happy to see that Arch64 is rock-solid, and I would definitely recommend it to anybody who has some basic command-line knowledge.

To be more complete, I should also try running some 32-bit closed source games on Arch64, but I really don’t have much time to try, as I’m not really interested in computer games.

As most of you probably don’t know, my prefered Linux distro is Arch Linux.  I use it on almost every computer I have:

  • On my desktop computer (Intel Core 2 Duo with embedded Intel Graphics Card)
  • On my laptop (Acer 5920G)
  • On my server (AMD Athlon X2) – a virtualized instance of Arch Linux
  • On my girlfriend’s laptop (Asus M51SE) (OK, I must admit that I’m responsible for installing software and configuring the laptop – and in the end, that’s quite the best solution, she avoids issues with Linux and I’m sure she has a well configured laptop, but she’s the one who uses this and she’s accustomed to it now, I would even bet she wouldn’t switch back to Windows if she could…)

In this article, I’ll explain how I configure my Arch Linux PCs.

/etc/pacman.d/mirrorlist

Here I uncomment the Belnet lines (as I’m in Belgium) and some other German- and French-based servers.

/etc/pacman.conf

Here I only add the archlinuxfr repository:

[archlinuxfr]
Server = http://repo.archlinux.fr/x86_64

/etc/mkinitcpio.conf

As I already use btrfs (but unfortunately I still haven’t figured out how to use it as root), I’ve modified the modules list to:

MODULES="crc32c libcrc32c btrfs zlib_deflate"

This is my HOOKS list:

HOOKS="base udev autodetect pata scsi sata filesystems btrfs resume consolefont"

And finally I uncommented the line:

COMPRESSION="lzma"

/etc/makepkg.conf

Here I optimized the compilation flags to:

CFLAGS="-march=native -mtune=native -O3 -pipe"
CXXFLAGS="-march=native -mtune=native -O3 -pipe"
LDFLAGS="-Wl,--hash-style=gnu -Wl,--as-needed"
MAKEFLAGS="-j3"

These optimizations are useful in two cases: when I install packages from AUR which are built from source and when I use srcpac instead of pacman, to compile the packages myself instead of installing precompiled binaries.

I usually use srcpac when I install software that is often used, like the kernel (package kernel26), the QT 4 libraries (I always use the latest KDE), hal, vlc, kdebase-workspace, konsole, chromium (that has become my favourite web browser) and so on.  This recompiles and optimizes software for my PC architecture thus I’m sure the performance is high.

/etc/rc.conf

In this file I’ve made little changes.  I won’t show the modules and daemons lists, as they depend on the software one installs on a PC.

I use terminus-font as the console font:

CONSOLEFONT=”ter-v16b”

This post is a reply to Kent Tong’s post about scala’s getters and setters: http://agileskills2.org/blog/2010/01/applying_scala_to_solving_real_1.html:
You may also use the @BeanProperty annotation to generate Java-compatible getters and setters instead of weird methods with space and equal signs:

http://www.scala-lang.org/docu/files/api/scala/reflect/BeanProperty.html