LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Virtualization and Cloud (http://www.linuxquestions.org/questions/linux-virtualization-and-cloud-90/)
-   -   how do I create an initramfs for a Debian guest running in kvm (http://www.linuxquestions.org/questions/linux-virtualization-and-cloud-90/how-do-i-create-an-initramfs-for-a-debian-guest-running-in-kvm-4175413388/)

chekhov_neo 06-26-2012 02:28 AM

how do I create an initramfs for a Debian guest running in kvm
 
Hello there!

I am new to kvm, qemu and kernel hacking. I tried to set up a Debian guest running inside a kvm. I was able to install it and it booted up successfully. Now I have the latest kernel source from kernel.org. I compile it and try to load this kernel in the Debian box like this:

Code:

kvm -smp 2 -m 512 -kernel /home/arun/kernel/linux/arch/x86_64/boot/bzImage -append "root=/dev/sda1
However it results in a kernel panic with the following error:

Code:

VFS: Cannot open root device "sda1" or unknown-block(0,0): error -6
After some googling I understand that I have to give the initramfs via -initrd switch of kvm command. So I created the initramfs using the mkinitramfs tool. But qemu does not load it:

Code:

qemu: error reading initrd /home/arun/kernel/linux/arch/x86_64/boot/bzImage/initramfs
How to properly create the initramfs for the Debian host?

Thanks!

honeybadger 06-27-2012 05:52 AM

Me had a filed day with this. It is about the newer kernels changing the partition names so when it 'was' hdb1 in my case it turned into sda1. I think you are looking at a simillar issue.
Hope this helps.

chekhov_neo 06-28-2012 06:52 PM

hello honeybadger, thank you for responding. I tried with various combinations: /dev/sda, /dev/sda1, (hd0,msdos1).
None of them worked. :( The last one was the one present the grub configuration corresponding to the stock kernel.

honeybadger 06-29-2012 12:52 PM

Can you tell what the kernel version number was when it was orignally installed and what is the version number that you are installing now (latest eaning 3.4.x something).
If you are using debain 5 then this kernel could possibly be the newer ones and thus causing confusion of the device names.
Do you have a live cd/dvd that can help us here to understand what exactly is going on here.
How did you make the kernel? Was it 'make oldconfig' or did you manually configure the kernel?

chekhov_neo 07-02-2012 07:17 PM

Quote:

Originally Posted by honeybadger (Post 4715104)
Can you tell what the kernel version number was when it was orignally installed and what is the version number that you are installing now (latest eaning 3.4.x something).
If you are using debain 5 then this kernel could possibly be the newer ones and thus causing confusion of the device names.
Do you have a live cd/dvd that can help us here to understand what exactly is going on here.
How did you make the kernel? Was it 'make oldconfig' or did you manually configure the kernel?

The stock kernel version is 2.6.32 and I'm trying to install 3.4.4.
I installed the stock OS from a Debian 6 iso.
I used a custom minimal config that results in a small bzimage size.

I'm guessing the problem is in recognizing the root file system. I tried to use the initramfs of the host system. This time, I didn't face the error as before but the boot failed saying "could not load module /lib/mod/linux-3.4.4/module.dep". Then I copied the corresponding module files to /lib/mod/ from the host to the VM. It still gave the above error.

This is why I doubt that it is not recognizing the file system correctly.

honeybadger 07-03-2012 04:01 AM

All of what you did seems correct. But then a file system recognised by 2.4.x kernels and not by the 3.4.x kernel is something that would kill linus :). I belive that you should have two kernels (the old one would be vmlinx.old I believe for debian) try booting using that kernel. Just link it to vmlinuz.
When I installed slackware 13.0 by mbr was hdb and my root was hdb1. I installed the 2.4.47 (that was the last of the 2.4.x series) and I could not boot I had the same issues like you. You would also find that post on this forum :), When I booted up with a live (and newer) distro I found out that the boot sector was now sda and the root was at sda1. I made the changes to grub and well everything just worked fine.
Hope this helps.


All times are GMT -5. The time now is 09:09 PM.