= How to set up syncpkgcd in kvm on Frugalware-1.1 First we install qemu from -current as -stable has 0.10.x and the setup just fails in it for some reason (it reports various IO errors). -current has 0.12.x, and that worked fine for me: ---- $ wget http://ftp.frugalware.org/pub/frugalware/frugalware-current/frugalware-i686/qemu-0.12.1-2-i686.fpm # pacman -U qemu-0.12.1-2-i686.fpm ---- You don't have have to rebuild the package, it will work out of the box on -stable as well. The nest step would be to boot a netinstall cd in qemu, but the netinstall cd has grub on it and the config loads a graphical menu called gfxboot, but gfxboot just freezes in kvm. You have two choices: disable kvm and just run the installer in qemu or boot the kernel/inird manually, so that you won't have to use grub at all. We will do the later. ---- $ wget http://ftp.frugalware.org/pub/frugalware/frugalware-stable/boot/vmlinuz-2.6.30-fw3-i686 $ wget http://ftp.frugalware.org/pub/frugalware/frugalware-stable/boot/initrd-i686.img.gz $ gunzip initrd-i686.img.gz ---- The last step is necessary because qemu expects an uncompressed initrd. Then we create two disk images, one for the system, and a bigger one for build data: ---- $ qemu-img create hda.img 10G $ qemu-img create hdb.img 40G ---- NOTE: This will _not_ allocate 10G and 40G of space right now, don't worry. See here for more info: http://administratosphere.wordpress.com/2008/05/23/sparse-files-what-why-and-how/ Now we boot the installer in kvm: ---- $ qemu -enable-kvm -vnc :1 -m 1024 -hda hda.img -kernel vmlinuz-2.6.30-fw3-i686 -initrd initrd-i686.im-append "initrd=initrd-i686.img.gz load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=53100 rw root=/dev/ram quiet" ---- The -kernel and -initrd switches let you boot init from the initrd and not from hda, which contains only zeroes, so such a boot would fail at the moment. About the other switches: -vnc lets you monitor the output of the virtual machine on a vnc display, see later. -m 1024 sets the memory size to 1G, finally -hda sets the first hard drive to hda.img. That should be enough for now, hdb.img will be used only when we configured syncpkgcd and the build chroots would require a lot of space. If you do it on a remote server, you can create an ssh tunnel to access vnc and run a viewer on localhost: $ ssh -L 5901:localhost:5901 Then you can view the console of the virtual machine on your local machine: $ krdc localhost:1 The setup part has nothing special, do a base-only install and give a meaningful hostname, like -kvm0 or similar. After the setup is complete and it would reboot, don't hit ENTER to reboot yet. Switch to tty2 (alt + right arrow worked for me via vnc) and `vi /mnt/target/boot/grub/menu.lst` (use mnt etc if '/' is fscked up by vnc): - remove useless vga= kernel parameter - delete the gfxboot line You already know why the removal of gfxboot is necessary. The vga= removal is not a must, but transferring a huge framebuffer over vnc is slower and we all hate lagging remote consoles. Now you can switch back to tty1 and hit ENTER. When it shows the BIOS, just hit Ctrl-C in the qemu cmdline, so that you can restart with different options. Start qemu with booting from hda: $ qemu -enable-kvm -vnc :1 -m 1024 -hda hda.img -hdb hdb.img -redir tcp:19023::22 The most important change is that now you no longer need the setup kernel/inird, but we also add hdb.img and we use -redir to redirect the host port 19023 to the guest port 22, which means you can ssh to the guest and stop using the ugly vnc interface. Of course you can replace 19023 with anything else, just choose an unused port. So we started qemu and we connect to it using vnc once again. You can just log in as root to set up ssh: # pacman -S openssh iptables vim sudo If we are at package installation, we install iptables, vim and sudo as well. Iptables, because we want to block anything incoming except ssh, vim because we need The Editor :), sudo because syncpkgcd uses sudo. Comment out the line which allows incoming ssh connections: # vi /etc/sysconfig/firewall Also edit Edit /etc/inittab to halt and not reboot for ctrl-alt-del (s/-r now/-h now/): # vi /etc/inittab That's necessary because later the host service will send ctrl-alt-del to the guest machine when it wants to shut it down and it'll wait for the shutdown, it it just reboots, it'll finally kill it after a timeout (300 secs by default), which is always bad. Reboot the guest machine ('reboot' as root), then you should be able to ssh to it if you put the followings to your `~/.ssh/config` on the host: Host -kvm0 NoHostAuthenticationForLocalhost yes HostName localhost Port 19023 This way a simple 'ssh -kvm0' should work. If it does, shut it down using halt as root. Now let's set alter the host machine's /etc/sysconfig/qemu-system to start/stop the virtual machine from init: machines=('qemu -enable-kvm -vnc :1 -m 1024 -hda /home/vmiklos/virt/hda.img -hdb /home/vmiklos/virt/hdb.img -redir tcp:19023::22') You already know what the switches mean, the only thing is that we use full path for hda/hdb as you can't be sure what will be the working directory when the init script is executed. Use # service qemu-system start and then try to re-ssh to the machine as a user. If that works, then use $ man syncpkgcd to read how to set up syncpkgcd inside kvm. NOTE: As you can see we did not configure hdb.img. So far the guest machine has a /dev/sdb device. Then it's up to you to determine what directories do you move to that bigger partition. So far here is what I used: I created a /data directory, added an fstab entry to mount /dev/sdb1 to /data, formatted /data as ext3, mounted it, then: - moved /var/cache/ccache to /data + symlinked it back - same for /var/cache/pacman-g2 - same for /var/chroot - same for /home/syncpkgd