Thursday, November 10, 2011

multiboot -fedora 16, archlinux and vista


this guide will show how i do multiboot, with fedora 16, archlinux and vista, while keeping the linux system partitions (/, /home, /var and /tmp) on lvm2 over encrypted partitions (the guide might not be useful if you want to use encrypted partitions over lvm2).

since my previous article about multiboot, multiboot, here i come, fedora 16 was released and i've managed to ruin my fedora 15 grub config. even though i could fix grub, i've decided to take it almost from scratch (i've kept only the vista partition untouched) and document as much as possible.


the current configuration i have is this:
  • /dev/sda1: fedora 16 boot (150MB, ext2, primary)
  • /dev/sda2: windows vista (70GB, ntfs, primary)
  • /dev/sda4: extended (remaining, up to 1T)
    • /dev/sda5: encrypted (150GB, luks, logical)
      • /dev/mapper/vg_007 (lvm2)
        • /dev/vg_007/lv_swap (2GB, swap)
        • /dev/vg_007/lv_f16_root (25GB, ext4)
        • /dev/vg_007/lv_f16_home (5GB, ext4)
        • /dev/vg_007/lv_f16_tmp (2GB, ext4)
        • /dev/vg_007/lv_f16_var (4GB, ext4)
        • /dev/vg_007/lv_arch_root (25GB, ext4)
        • /dev/vg_007/lv_arch_home (5GB, ext4)
        • /dev/vg_007/lv_arch_tmp (2GB, ext4)
        • /dev/vg_007/lv_arch_var (16GB, ext4)
    • (582GB, free)
    • /dev/sda6: arch boot (100MB, ext2, logical)
    • /dev/sda7: encrypted (160GB, luks, logical)
      •  /dev/mapper/007-ST-DATA-LNX (ext4)
    • /dev/sda8: vista data (40GN, vfat, logical)
i've chosen some small home partitions as i keep most of my data on 007-ST-DATA-LNX and i intend to keep only minimum (like configs) in the /home directories, with big data symlinked from 007-ST-DATA-LNX.

based on other articles i've read on arch configuration, i've also decided to start with a big lv_arch_var.

the 007 is not related in any way with the mi6, but with the hard-disk being my seventh one and also a seagate (thus 007 and ST).


note: this was left untouched since my original installation of fedora 15.

in order to avoid any complications, its always good to install your m$ os as soon as possible, as they can be picky about existing partitions and will always overwrite the mbr.

but even before vista, i wanted to make sure that i have some space reserved for a boot partition.

  • boot from a linux live cd
  • create /dev/sda1 at the beginning of the disk
  • reboot
and continue with vista installation:
  • boot from vista cd
  • install vista

now we could waste the next 8-16 hours to update vista or we could continue with installing your linux distros. i advise the later, as it would allow us at some point to make a backup of a clean vista with ntfsclone.

fedora 16

note: this guide should be usable more or less with any other distro

continuing from the previous step, boot now from the fedora 16 cd into the live system.

no previous encrypted and lvm2 configuration

in case you are using a clean disk, you'll have to add the logical volumes that will keep the encrypted partitions, encrypt them, create a volume group and then add the logical volumes to it.

open a terminal and:
  • gain root:
    $ su -
  • create the logical partition /dev/sda5 (use cfdisk or fdisk)
  • encrypt /dev/sda5 and unlock it:
    # cryptsetup -v -c aes-xts-plain -y -s 512 luksFormat /dev/sda5
    # cryptsetup luksOpen /dev/sda5 007-ROOT
  • create the vg_007 volume group:
    # vgcreate vg_007 /dev/mapper/007-ROOT
  • create the logical volumes (you could create the arch volumes at this point, too, but you can do it also when you'll install arch):
    # lvcreate -v -n lv_swap -L 2G vg_007
    # lvcreate -v -n lv_f16_root -L 25G vg_007
    # lvcreate -v -n lv_f16_home -L 5G vg_007
    # lvcreate -v -n lv_f16_tmp -L 2G vg_007
    # lvcreate -v -n lv_f16_var -L 4G vg_007
  • in order for the installer to go smoothly, it is best to deactivate now the lvm2 and lock the encrypted partition (the installer will ask you later for the password):
    # vgchange -a n
    # cryptsetup luksClose 007-ROOT

using existing encrypted and lvm2 configuration

you don't have to do anything in this case. if you want to unlock and inspect the lvm2 partitions, don't forget to deactivate and lock them before installing the os.

common steps

now that we have the disk partitioned for fedora, simply launch the installer. at some point, the installer will ask Which type of installation would you like? and you should select Create Custom Layout.

the installer will ask for the password used to decrypt /dev/sda5 and will present all existing partitions, including the lvm2 ones.

use this mapping:

partitionmount pointformatfile-system

later on, when asked where to install grub, accept the default /dev/sda.

except the initial part when you manually configure the encrypted and lvm2 partitions, there's nothing very different compared with a regular installation.


installing arch is not that complicated either. just insert the arch cd and boot from it. the boot process should leave you at a root prompt.

now, all you have to do is to:
  • unlock /dev/sda5:
    # cryptsetup luksOpen /dev/sda5 007-ROOT
  • activate the lvm2:
    # vgchange -a y
  • if you haven't created the lvm partitions for arch when you created those for fedora, you'll have to create them now:
    # lvcreate -v -n lv_arch_root -L 25G vg_007
    # lvcreate -v -n lv_arch_home -L 5G vg_007
    # lvcreate -v -n lv_arch_tmp -L 2G vg_007
    # lvcreate -v -n lv_arch_var -L 16G vg_007
  • start the install process:
    # /arch/setup
  • when you get to 4. Prepare hard drives:
    • select 3. Manually Configure block devices, filesystems and mountpoints
    • select dev directly by /dev/*
    • use the mapping in the table bellow
    • select Done when finished
  • when you get to 7. Configure System
    • modify /etc/rc.conf to contain:
    • modify /etc/mkinitcpio.conf to contain (keep the order!):
      HOOKS=...keymap encrypt lvm2 filesystems...
  • skip 8. Install Bootloader as we will use the grub from fedora and we don't want to mess with its config
  • exit the installer and reboot the machine (you will boot to fedora).

arch partition mapping:

partitionmount pointformatfile-system

grub tweaking

ok. we are almost done and all we have now to do is make grub2 boot correctly arch.

by default, fedora's grub2 will try to autodetect windows and arch. while windows autodetection works, the one for arch is not, probably because we are using encryption and lvm.

the solution is simple tough:
  • modify /etc/default/grub to save selected os (nice to have) and to disable the os prober (having that would only clutter the menu):
  • identify the uuid of the windows partition:
    # blkid /dev/sda2
    /dev/sda2: UUID="EC8074DA8074ACA8" TYPE="ntfs"
  • create /etc/grub.d/50_WindowsVista for the vista installation (and make it executable):
    exec tail -n +3 $0

    # partition numbering is like in /dev
    # /dev/sda1 -> (hd0,1)
    # /dev/sda2 -> (hd0,2)
    menuentry "Windows Vista Home Premium" {
            insmod part_msdos
            insmod ntfs
            set root='(hd0,msdos2)'
            search --no-floppy --fs-uuid --set=root EC8074DA8074ACA8
            chainloader +1
  • identify the uuid of the arch boot partition:
    # blkid /dev/sda6
    /dev/sda6: LABEL="ARCH_BOOT" UUID="ee393ce1-bff0-4373-ab79-adab37a506cc" TYPE="ext2"
  • create /etc/grub.d/51_ArchLinux for the vista installation (and make it executable):
    exec tail -n +3 $0

    # partition numbering is like in /dev
    # /dev/sda1 -> (hd0,1)
    # /dev/sda2 -> (hd0,2)
    menuentry "ArchLinux" {
            set gfxpayload=keep
            insmod part_msdos
            insmod ext2
            set root='(hd0,msdos6)'
            search --no-floppy --fs-uuid --set=root ee393ce1-bff0-4373-ab79-adab37a506cc
            linux   /vmlinuz-linux root=/dev/mapper/vg_007-lv_arch_root cryptdevice=/dev/sda5:vg_007 ro vga=773
            initrd  /initramfs-linux.img
  • rebuild the /boot/grub2/grub2.cfg:
    # grub2-mkconfig -o /boot/grub2/grub.cfg
  • install the changes:
    # grub2-install /dev/sda
that's it. now we should have a system that can boot fedora 16, arch linux and vista.

other distros could be added to the mix, though maintaining the grub menu might not be as easy as with arch.

if anybody finds this useful or knows a better way, please let me know.

i would also love to know how i can chainload a second grub2 from the main one, as all the info i've found so far was only how to chainload from grub to grub2, but not from grub2 to grub2.

Tuesday, November 08, 2011

certifications on odesk

while looking for contracts, i've came across the oDesk. in their own words:

oDesk is the marketplace for online workteams, with the best business model for both employers and contractors.

one nice feature of oDesk is that you can take a couple of test to asses your knowledge and expertise in various areas. and you can do that for free!

tests have a 40 minutes limit and can be repeated after 30 days, if you haven't made it perfect from the first and think you can do better a second (or third, forth, etc...) time.

once finished, the test will also show you what are your weak areas, so that you can concentrate on improving those in particular.

according to the oDesk, i'm in the top 20 programmers that have taken the python and c++ test from oDesk. it's not bad, but it could be much better :-)

so, while i'm not sure if i will get even one contract via oDesk, at least i know what i should improve and where i've started to get rusty.

oDesk Certified C++ Programmer oDesk Certified Python 2.x Developer

Saturday, November 05, 2011

multiboot, here i come

these past days i've been doing some late autumn cleaning through my pc and laptop and finally settled to use my pc as the main box.
this also gave me an opportunity to do some clean installs and reorganize my disks.

for a long time i've wanted to try other distros. doing that in a virtual machine is kind of ok (with the added benefit that you always have something that works and a web browser at hand to look on the net for answers), but you never get 100% of what the machine can give. it's also the problem that, if you discover that you like more the distro from your VM, than you have to reinstall it again on the hard-drive to use it directly.

after a lot of thinking i've decided to try multibooting.

this is nice, as i always have something that work just a reboot away, but, at least the solution i came with, not without its share of problems. overall, i find it quite acceptable.

for me, these were the main challenges of multiboot:
  • maintain the list of boot-able OS's up-do-date
  • make sure that when installing a new os i don't destroy the booting capability of the existing ones (or i have at least some way to recover that booting capability later)
  • maintain the content of /boot for each linux distro

at the present i have these OS's installed:
in a couple of days fedora 16 is going to be released and i'll put it along the other distros, while keeping fedora 15 for a couple of weeks until fedora 16 stabilizes - no new release is without its share of small problems and i'm sure this will be case, too. having already a multiboot system in place should make this much simpler.

i might also try, at some point, sabayon 7 or ubuntu 11.10.

the hardware for my main box is:
there is no dedicated video card, as the Intel 3000HD from the i5 worked quite ok until now. this allowed me to reduce power consumption, heat and noise to a minimum, and this is always a good thing in my book ;-)

the only driver problem so far was with the network driver from fedora 15 (and archlinux core CD): the driver was a bit finicky and the connection dropped a lot. the best solution was to download the driver sources from realtek support page, compile the driver and install it
bellow is a diagrams with my current partitions. i use one unencrypted lvm2 for linux boot partitions and one encrypted lvm2 for the rest of the linux partions.

in the next couple of days i'll try to post more info on how i've configured the system.

let me know if this is useful to you.