среда, 26 июня 2013 г.

Arch Linux with Awesome wm

Weeks ago i've switched from Ubuntu to Arch Linux. Why? I don't want to depend from some commercialized way of Ubuntu, also close to me Arch principles "... elegance, code correctness, minimalism, and simplicity ..." (see https://en.wikipedia.org/wiki/Arch_Linux and https://en.wikipedia.org/wiki/KISS_principle). Why not gentoo? ha,ha, it is to hardcore for me. Arch has a very useful wiki. You could start from this guide.

Let's try to install Arch with Awesome window manager.

WARN: Please try it on Virtual machine first.

Installing base system

1. Create bootable USB (https://wiki.archlinux.org/index.php/USB_Installation_Media)



wget http://mirror.yandex.ru/archlinux/iso/2013.06.01/archlinux-2013.06.01-dual.iso
dd bs=4M if=archlinux-2013.06.01-dual.iso of=/dev/sdx

Where "/dev/sdx" NOT mounted USB stick.

2. Boot from this stick. It prompts you into root console.

3. Partitioning with LVM.

Use "lsblk" to find target block device (i.e. /dev/sda). I prefer fdisk for partitioning. Command below will create two partitions (200M and all remain space).

echo -e "o\nn\n\n\n\n+200M\nn\n\n\n\n\nw\n"|fdisk /dev/sda

mkfs.ext2 /dev/sda1
pvcreate /dev/sda2
vgcreate vgroot /dev/sda2
lvcreate -n root -L 10G vgroot
lvcreate -n swap -L 1G vgroot
lvcreate -n home -L 5G vgroot
mkfs.ext4 /dev/vgroot/root
mkfs.ext4 /dev/vgroot/home
mkswap /dev/vgroot/swap
mount /dev/vgroot/root /mnt
mkdir /mnt/{boot,home}
mount /dev/vgroot/home /mnt/home
mount /dev/sda1 /mnt/boot
swapon /dev/vgroot/swap

4. Connect to the Internet. 

By default DHCP service is enabled, but if you need some other network settings (i.e. static or wireless) read this. To check Internet:

ping -c 3 www.google.com


5. Install base system.

Enable preferred mirror in /etc/pacman.d/mirrorlist and

pacstrap /mnt base base-devel


6. Configure system.

genfstab -p /mnt >> /mnt/etc/fstab
arch-chroot /mnt
echo "myhostname" > /etc/hostname
ln -s /usr/share/zoneinfo/Europe/Moscow /etc/localtime
sed -i -e 's/#ru_RU.UTF-8/ru_RU.UTF-8/' -e 's/#en_US.UTF-8/en_US.UTF-8/' /etc/locale.gen
locale-gen
echo 'LANG="en_US.UTF-8"' > /etc/locale.conf

Edit /etc/mkinitcpio.conf. Add "lvm2" hook between "block" and "filesystems".

...
HOOKS="base udev autodetect modconf block lvm2 filesystems keyboard fsck"
...

mkinitcpio -p linux

Set root password with "passwd" and create regular user:

useradd -m -s /bin/bash user1
passwd user1

Enable DHCP service:

systemctl enable dhcpcd.service


7. Installing GRUB.

See also https://wiki.archlinux.org/index.php/GRUB

grub-install --recheck /dev/sda
grub-mkconfig -o /boot/grub/grub.cfg


8. Umount and reboot

exit
umount /mnt/{boot,home,}

Installing Awesome wm

This is cool tiling window manager. Official page http://awesome.naquadah.org/.

Execute commands below from root.

1. Install video driver.

Detailed instruction here.

pacman -S xf86-video-vesa

For nvidia "xf86-video-nv", ATI "xf86-video-ati"

2. Install X server, awesome wm and slim dm.

pacman -S xorg-server xorg-server-utils xorg-xinit xterm awesome slim
systemctl enable slim.service

3. Configure xinitrc.

su - user1
echo "exec awesome" > .xinitrc
mkdir -p .config/awesome
cp /etc/xdg/awesome/rc.lua .config/awesome/
reboot

4. Using awesome.

For advanced usage should read official wiki

Keys:

win+{1, 2, 3,.., left, right} - switch between tags (like screens in gnome)
win+r - execute command (i.e. "firefox")
win+enter - open terminal
win+{j, k} - switch between windows
win+tab - switch to prev. window
win+w - open awesome menu

rc.lua:

In internet a lot of info about customizing rc.lua. Here is only simple example. This will set capslock key to switch keyboard layout.

echo 'awful.util.spawn_with_shell("setxkbmap -layout 'us,ru' -option 'grp:caps_toggle,grp_led:scroll'")' >> .config/awesome/rc.lua

Check syntax:

awesome -k .config/awesome/rc.lua

Then type "ctrl+win+r" to restart awesome.

Now you are free to install necessary software with "pacman", customize awesome with "rc.lua", etc. ,etc. ,etc.

понедельник, 10 июня 2013 г.

Rebuild CirrOS tiny cloud image for VMware

We've faced problems when tried to boot CirrOS tiny cloud image as guest OS on VMware ESXi managed by OpenStack.

Problem description: It boots up without any storage disk or NIC. By default OpenStack (with VMwareESXDriver) uses LSILogic SCSI controler (Fusion MPT) for VMware guests. Seems like there is no drivers(modules) for this type of SCSI controler. Let's try to add it.

To add this additional drivers we need to rebuild CirrOS as described in official README . I've done all stuff on Ubuntu 12.04 LTS.

* Get build dependencies, clone source code repo.

sudo apt-get -y install bison flex texinfo build-essential gettext ncurses-dev unzip bzr qemu-kvm cvs quilt
bzr branch lp:cirros
cd cirros

* Download buildroot and setup environment and apply local cirros patches to it.

br_ver="2012.05"
mkdir -p ../download
ln -snf ../download download
( cd download && wget http://buildroot.uclibc.org/downloads/buildroot-${br_ver}.tar.gz )
tar -xvf download/buildroot-${br_ver}.tar.gz
ln -snf buildroot-${br_ver} buildroot
./bin/mkcabundle > src/etc/ssl/certs/ca-certificates.crt
( cd buildroot && QUILT_PATCHES=$PWD/../patches-buildroot quilt push -a )
make ARCH=i386 br-source

 * Build buildroot for a given arch. ARCH should be set to 'i386', 'x86_64' or 'arm'.
make ARCH=i386 OUT_D=$PWD/output/i386

This will do a full buildroot build, which will take a while. The output that CirrOS is interested in is output/i386/rootfs.tar. That file is the full buildroot filesystem, and is used as input for subsequent steps here.

 * Download a kernel to use. I've used ubuntu virtual i386 kernel.

wget https://launchpad.net/ubuntu/+archive/primary/+files/linux-image-3.2.0-41-virtual_3.2.0-41.66_i386.deb -O download/linux-image-3.2.0-41-virtual_3.2.0-41.66_i386.deb

* Patch cirros bundle script. In simple, this script used to rebuild rootfs.tar with custom kernel. It creates two initramfs files: "standart" and "smaller" w/o kernel modules. By default it uses second one. To prevent it and use standart initramfs do:
sed -i 's/cp "${initramfs}.smaller"/cp "${initramfs}"/' bin/bundle

* Add necessary kernel modules. Bundle script gets modules to include in image from "src/etc/modules" . For Fusion MPT devices (i.e. lsiLogic scsi controller) support add "mptbase" and "mptscsih" modules:

echo -e "mptbase\nmptscsih" >> src/etc/modules

*  build disk images using special script bin/bundle

sudo ./bin/bundle -v output/$ARCH/rootfs.tar download/linux-image-3.2.0-41-virtual_3.2.0-41.66_i386.deb output/$ARCH/images
Resulting images located in output/i386/images . You could use bootable qcow2 image "output/i386/images/disk.img" or ami (blank.img), ari (initramfs), aki (kernel). OpenStack supports now only flat vmdk images for vmware and we need to convert qcow2 to raw:

qemu-img convert -O raw output/i386/images/disk.img output/i386/images/disk-raw.img

How to add image to glance:
glance add name="cirros-vmware" disk_format=raw container_format=bare is_public=true vmware_adaptertype="lsiLogic" vmware_disktype="preallocated" vmware_ostype="otherGuest" < disk-raw.img
 

понедельник, 3 июня 2013 г.

How to upload files thru rdp from linux

If you want to copy files from Linux to remote Windows machine you could do it thru RDP (rdesktop utility).

rdesktop -g 90% -r disk:mydir=/home/user/mydir 10.0.0.2

It will open graphical RDP session and you could see your shared folder from "My Computer" page.