Installing GENTOO 2008.0 on a QEMU DISK IMAGE (and KDE4).

  • Ersteller SueBradely12345
  • Erstellt am
S

SueBradely12345

GESPERRT
Installing GENTOO 2008.0 on a QEMU
DISK IMAGE (and KDE4).


http://linux.50webs.org/gentoo/qemu-gentoo.htm
http://linuxhelp.150m.com/gentoo/qemu-gentoo.htm

A couple of years ago, I wrote a script to automatically install Gentoo 2006.0 from the Gentoo LiveCD. Recently, I trimmed the script to install Gentoo 2008.0 on a Qemu (virtual) hard-disk. I used the KVM version of Qemu, but everything should be the same for non-KVM Qemu. This guide was written for those using an AMD64 system, but other systems should be similar. Most of the necessary changes are obvious.

Download the following:

qemu-gentoo-2008.sh.bz2
livecd-amd64-installer-2008.0-r1.iso (696M)
portage-20080721.tar.bz2 from distfiles.gentoo.org (31M)

Although, I recommend the 2008-07-21 version of portage, because it has been checked and is known to compile KDE 4.0.5, you may wish to use the latest portage version which can be found here:

portage-latest.tar.bz2 from distfiles.gentoo.org (31M)

Code:
mkdir /b

The directory /b will be seen by Qemu/KVM as the hard-disk /dev/hdb.

Code:
mv qemu-gentoo-2008.sh.bz2 portage-20080721.tar.bz2 /b 
bunzip2 qemu-gentoo-2008.sh.bz2 
chmod +x qemu-gentoo-2008.sh 
/sbin/modprobe kvm-amd 
qemu-img create -f raw gentoo.img 10G 
qemu-system-x86_64 -boot d -m 256 -soundhw es1370 -usbdevice tablet \ 
      gentoo.img -cdrom livecd-amd64-installer-2008.0-r1.iso -hdb fat:/b &

Although the Gentoo LiveCD recognizes the Qemu Cirrus Logic video card and sets the correct driver in the xorg.conf file, the X-server is unable to start the graphics environment (it turns out that the cirrus drivers have not been compiled). The screen flashes a few times and a window appears asking if you wish to see the X log. Say no, then OK and hit return a couple of times to get to the console. Once at the console, enter the command:

Code:
vi /etc/X11/xorg.conf

Search for the string cirrus and replace it with vesa.

Alternatively, you can also use the following commands to edit the xorg.conf file:

Code:
mv /etc/X11/xorg.conf /etc/X11/xorg.conf-old 
awk '{print gensub(/cirrus/,"vesa","g")}' /etc/X11/xorg.conf-old > /etc/X11/xorg.conf

After editing xorg.conf, start the window manager Xfce4 with:

Code:
startxfce4

Open a terminal window in Xfce4. Then mount the first (and only) partition of /dev/hdb and run the script:

Code:
mkdir /b 
mount /dev/hdb1 /b
(the script assumes /dev/hdb1 is mounted on /b)
Code:
/b/qemu-gentoo-2008.sh
(run the script)

The script will partition the virtual hard-disk /dev/hda and set up Gentoo 2008.0 on /dev/hda3. Of course, these days you no longer need a swap partition and you never needed a boot partition. However, to keep in step with Gentoo we will have both.

I would have usually formated /dev/hdb3 with the Reiser3 filesystem, however, this usually extremely reliable filesystem, has been deliberately sabotaged. This sabotage causes massive corruption of files after a short time. By comparison, I have used the Reiser3 filesystem for nearly ten years now and have never had any corruption, at all, on any of my many Reiser3 boxes.

When the script finishes, you should:

Code:
Shutdown the LiveCD.

Then boot up Gentoo 2008.0 from the hard-disk, with:

Code:
qemu-system-x86_64 -m 256 -soundhw es1370 -usb -usbdevice tablet gentoo.img &

At this point you have a functional Gentoo system which uses the Xfce4 desktop.

The sound does not work because (since at least 2005) Gentoo has refused to compile the LiveCD kernel with the ALSA OSS emulation option. This means that the sound does not work for a few (very popular) older cards. The symptom of this problem is that the device /dev/dsp does not get created. This old, well-known problem, is easily fixed by recompiling your kernel with the following options:

Code:
Device Drivers  --->
    Sound  --->
        Advanced Linux Sound Architecture  --->
            <M> Sequencer support
            <M> Sequencer dummy client
            <M> OSS Mixer API
            <M> OSS PCM (digital audio) API
                [ * ] OSS PCM (digital audio) API - Include plugin system
           [ * ] OSS Sequencer API
           [ * ] Support old ALSA API

A new kernel will also stop the system loading every pata and sata module it can find.

The script adds 8139too and snd_ens1370 to /etc/modules.autoload.d/kernel-2.6 which causes the correct ethernet and sound kernel modules to be loaded at boot. To connect to the internet using Qemu's default networking, you need to connect to Qemu's DHCP server, which you do with the command:

Code:
dhcpcd eth0

Adding the KDE desktop to your Gentoo system.

First, you must uninstall the QT 4 libraries on the LiveCD with (you may ask why they are there):

Code:
emerge -C qt:4

If you used the script, then this has been done for you.

If you want KDE4 (version 4.0.5), then hide the package.mask file (only for KDE4) with:

Code:
mv /usr/portage/profiles/{package.mask,hide-package.mask}

If you want KDE3 (version 3.5.9), then do not hide the package.mask file.

Now you should check what happens in a dry run:

Code:
emerge -pv mesa 
emerge -pv kde-meta

KDE 3.5.9 is chosen automatically if you did not hide the package.mask file and KDE 4.0.5 is chosen if you did.

Then you should download all the source files with:

Code:
emerge -f mesa
emerge -f kde-meta

Now you should compile everything. This took somewhere between 12 & 16 hours on my box. I think that is good, considering that the compilation is being done in a virtual system. For KDE3 the following commands were necessary:

Code:
emerge mesa 
emerge flex 
emerge kde-meta

For whatever reason, kdepim-meta-3.5.9 and related packages did not compile. Everything else did. If you need kdepim 3.5.9, you should use a version of portage different from portage-20080721.tar.bz2.

For KDE4 these commands were necessary:

Code:
emerge mesa 
USE="mdnsresponder-compat" emerge avahi 
USE="-doc" emerge glib 
emerge kde-meta

Without the proper USE-variable KDE4's compositing is disabled at compile time. The stated reason is that the X-org development headers are missing. However, this is not true. You need USE="xcomposite" and even with this, compositing is not possible for older graphics cards, like the Cirrus Logic. The script qemu-gentoo-2008.sh now sets some USE-variables, like xcomposite, for you. You should check /etc/make.conf and see if you approve of the choices. Remember that the default USE-variables are listed in:

/usr/portage/profiles/targets/desktop/make.defaults

and your current configuration can be seen by typing:

Code:
emerge --info

Now you need to configure KDE.

This is done by changing a line in your /home/gentoo/.dmrc file.

For KDE4, change the line Session=xfce to Session=kde-4.

You should save the downloaded files so that you can trash your virtual Gentoo system without losing them.

First, shutdown Gentoo. Then mount the image gentoo.img with:

Code:
mount -o loop,offset=$((1124550*512)) gentoo.img /1

1124550 is the number of sectors to the start of the 3rd partition. It comes from:

Code:
fdisk -lu
Disk /dev/hda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders, total 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Disk identifier: 0x934947c5

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1   *          63      128519       64228+  83  Linux
/dev/hda2          128520     1124549      498015   82  Linux swap / Solaris
/dev/hda3         1124550    20964824     9920137+  83  Linux

Now you can copy files to and from the image. To save the downloaded files:

Code:
mkdir /gentoo 
cp -r /1/usr/portage/distfiles /gentoo

Don't forget to unmount your Gentoo disk image before booting Gentoo 2008.0.

Code:
umount /1

So, what did I think of KDE4. Well, the main selling feature of KDE4, compositing, is turned off for older graphics cards like the Cirrus Logic. The system complains that: Required X extensions (XComposite and XDamage) are not available. KDE4 has more polished graphics, but it is missing some of the little features that made KDE3 so useable. The start "menu" is awful and it would be hard to use KDE4, if one was forced to use this grotesque feature. Thankfully, SuSE 11.0 has the old menu as an option. Things like the taskbar icons cannot be moved and some configuration options are poorer. Hopefully, KDE4 will catch up with KDE3 soon. However, at this point, KDE4 is definitely a regression.

If I get time I will write an article on how to transfer your virtual Gentoo 2008 system to a system using your real hardware.

For further information I recommend the Gentoo installation manual.
 
For those who just want to see what the script does, here are the commands:

Für diejenigen, möchte nur sehen, was das Skript tut, hier sind die Befehle:

echo -e "n\np\n1\n\n8\nn\np\n2\n\n70\nn\np\n3\n\n\nt\n2\n82\na\n1\np\nw"|fdisk /dev/hda
(partitions the virtual harddisk)
mkfs.ext2 /dev/hda1 (formats the boot partition)
mkswap /dev/hda2 (sets up the swap area)
mkfs.ext3 /dev/hda3 (formats the Gentoo 2008 partition)
mkdir /1 (creates a mount point for the 3rd partition)
mount /dev/hda3 /1 (mounts the 3rd partition)
cd /mnt/livecd
tar -cpf - * | tar -C /1 -xpf - (copies the LiveCD)
rm -f /1/usr/portage/{eclass,profiles} (removes some links)
tar -xjpf /b/portage*.tar.* -C /1/usr/ (unpacks the copy of portage in /b)
rm -f /1/etc/gconf /1/var/db (removes more links)
mv /1/usr/livecd/gconf /1/etc (copies configuration files)
mv /1/usr/livecd/db /1/var (copies emerge database)
rm -fr /1/usr/livecd (some house-keeping)
rm -f /1/home/gentoo/Desktop/* (more house-keeping)
rm -f /1/etc/runlevels/default/{autoconfig,local} (important)
awk '{print gensub(/cirrus/,"vesa","g")}' /etc/X11/xorg.conf > /1/etc/X11/xorg.conf
(corrects the graphics configuration)
cp /etc/profile.csh /1/etc/profile.csh (copies eselect configuration)
cp /etc/ld.so.conf /1/etc/ld.so.conf (adds /usr/local/lib to ld.so.conf)
echo -e "ACCEPT_KEYWORDS=\"~amd64\"
GENTOO_MIRRORS=\"http://distfiles.gentoo.org\"
FETCHCOMMAND=\"/usr/bin/wget -t 2 -T 30 --passive-ftp \\\${URI} -P \\\${DISTDIR}\"
USE=\"arts xcomposite htmlhandbook mplayer ffmpeg flac a52 aac cdparanoia cdr dv dvd dvdr
dvdread gimp imagemagick gif ncurses gcj fortran zlib cups curl curlwrappers doc nls\"
VIDEO_CARDS=\"cirrus fbdev glint i810 mach64 mga neomagic nv r128 radeon s3virge savage
sis tdfx trident vesa vga via vmware voodoo\"
CAMERAS=\"adc65 agfa_cl20 aox barbie canon casio_qv clicksmart310 digigr8 digita dimagev
dimera3500 directory enigma13 fuji gsmart300 hp215 iclick jamcam jd11 kodak_dc120
kodak_dc210 kodak_dc240 kodak_dc3200 kodak_ez200 konica konica_qm150 largan lg_gsm
mars mustek panasonic_coolshot panasonic_dc1000 panasonic_dc1580 panasonic_l859
pccam300 pccam600 polaroid_pdc320 polaroid_pdc640 polaroid_pdc700 ptp2 ricoh ricoh_g3
samsung sierra sipix_blink sipix_blink2 sipix_web2 smal sonix sony_dscf1 sony_dscf55
soundvision spca50x sq905 stv0674 stv0680 sx330z template toshiba_pdrm11\"
" | tee -a /1/etc/make.conf (adds USE-variables, etc, to the make.conf file)
echo -e "#filesystem mount type options dump fsck-order
/dev/hda1 /boot ext2 defaults 1 2
/dev/hda2 swap swap defaults 0 0
/dev/hda3 / ext3 noatime 0 1
none /proc proc defaults 0 0
none /dev/shm tmpfs defaults 0 0
/dev/fd0 /a vfat user,noauto 0 0
/dev/cdrom /cd iso9660 user,noauto,ro,exec 0 0
" | tee /1/etc/fstab (creates a new fstab file)
chroot /1 /bin/bash << EOG (change-roots to the new system)
mount /dev/hda1 /boot (mounts the boot partition)
grub-install /dev/hda1 (installs the grub machinary)
/sbin/grub --batch << EOB (configures the grub machinary)
root (hd0,0)
setup (hd0)
quit
EOB
passwd << EOP (sets the root password as the single letter p)
p
p
EOP
umount /boot (unmounts the boot partition)
emerge -C qt:4 (emerge --unmerge qt:4)
exit (exits the change root environment)
EOG
mount /dev/hda1 /1/boot (mounts the boot partition)
cp -r /boot/* /1/boot/ (copies the boot machinary)
echo -e "default 0
timeout 5
title GENTOO 2008.0 kernel-genkernel-x86_64-2.6.24-gentoo-r7 /dev/hda3
kernel (hd0,0)/kernel-genkernel-x86_64-2.6.24-gentoo-r7 root=/dev/ram0 real_root=/dev/hda3 udev ro
initrd (hd0,0)/initramfs-genkernel-x86_64-2.6.24-gentoo-r7
" | tee -a /1/boot/grub/menu.lst (adds a boot entry to the menu.lst file)
echo -e "8139too\nsnd_ens1370" >> /1/etc/modules.autoload.d/kernel-2.6
(makes sure the ethernet & sound drivers are loaded at boot)
 
It may be a good way for gentoo noobs to get a running system. But there is no effect of learning how gentoo is working.

(war um ist der ganze threat in englisch? will da jemand sein englisch mal testen?)
 
very cool that he is interested in gentoo an these page.
.
.
.
EDIT (autom. Beitragszusammenführung) :
.

For me is this script an good possibility to make an komplit and autark auto install cd/dvd for an PC with out internet. You must only link the files on the cd.
 
Zuletzt bearbeitet:
But there is no effect of learning how gentoo is working.
Your argument is wrong.

Most people who try to get gentoo running, fail, give up and learn nothing.

Giving them a platform from which to learn about gentoo, eventually has them learning a lot more.


Ihr Argument ist falsch.

Die meisten Menschen versuchen, um gentoo laufen, scheitern, aufgeben und lernen nichts.

Durch die Bereitstellung einer Plattform, von denen zu lernen über Gentoo, schließlich hat Lernen sie eine Menge mehr.
 

Ähnliche Themen

Nginx als Reverse Proxy für Nextcloud und Emby

Zugriff Ubuntu 16.04. auf Freigabe 18.04. LTS nicht möglich

Email via script via Exchange Server (SASL)

Senior System & Network Admin in Berlin

X startet nichtmehr

Zurück
Oben