Installing Kali Linux as Guest OS in KVM Hypervisor

Hi, I have run the below command to install Kali Linux using linux-2020.4-installer-amd64.iso from https://www.kali.org/downloads/ #virt-install --name kalilinux --memory 4096 --vcpus=2 --location=/linuxkvmaddgbdisk/kali-linux-2020.4-installer-amd64.iso,kernel=install.amd/gtk/vmlinuz,initrd=install.amd/gtk/initrd.gz --network=bridge:br0 --os-type=linux --os-variant=debian9 --graphics=none --extra-args "console=ttyS0" -v --disk path=/linuxkvmaddgbdisk/kalilinux.img,size=50 I am not able to get the root login prompt when I run the below command to set IP and hostname for the guest OS. Am I missing any parameters from the above virt-install command to install Kali Linux as Guest OS in KVM Hypervisor? #virsh console kalilinux Connected to domain kalilinux Escape character is ^] Any help will be highly appreciated. I look forward to hearing from you. Thanks in Advance. Best Regards, Kaushal

On 12/1/20 5:28 PM, Kaushal Shriyan wrote:
Hi,
I have run the below command to install Kali Linux using linux-2020.4-installer-amd64.iso from https://www.kali.org/downloads/
#virt-install --name kalilinux --memory 4096 --vcpus=2 --location=/linuxkvmaddgbdisk/kali-linux-2020.4-installer-amd64.iso,kernel=install.amd/gtk/vmlinuz,initrd=install.amd/gtk/initrd.gz --network=bridge:br0 --os-type=linux --os-variant=debian9 --graphics=none --extra-args "console=ttyS0" -v --disk path=/linuxkvmaddgbdisk/kalilinux.img,size=50
I am not able to get the root login prompt when I run the below command to set IP and hostname for the guest OS. Am I missing any parameters from the above virt-install command to install Kali Linux as Guest OS in KVM Hypervisor?
Just a hunch, maybe --extra-args work only for installation and are not persistent? I guess installer doesn't persist kernel cmd line passed in installation phase (why would it anyway?). I guess you need to configure grub so that it appends the argument or configure /etc/initttab and uncomment line that enables getty for ttyS0 console. Michal

On Tue, Dec 01, 2020 at 06:15:55PM +0100, Michal Privoznik wrote:
On 12/1/20 5:28 PM, Kaushal Shriyan wrote:
Hi,
I have run the below command to install Kali Linux using linux-2020.4-installer-amd64.iso from https://www.kali.org/downloads/
#virt-install --name kalilinux --memory 4096 --vcpus=2 --location=/linuxkvmaddgbdisk/kali-linux-2020.4-installer-amd64.iso,kernel=install.amd/gtk/vmlinuz,initrd=install.amd/gtk/initrd.gz --network=bridge:br0 --os-type=linux --os-variant=debian9 --graphics=none --extra-args "console=ttyS0" -v --disk path=/linuxkvmaddgbdisk/kalilinux.img,size=50
I am not able to get the root login prompt when I run the below command to set IP and hostname for the guest OS. Am I missing any parameters from the above virt-install command to install Kali Linux as Guest OS in KVM Hypervisor?
Just a hunch, maybe --extra-args work only for installation and are not persistent? I guess installer doesn't persist kernel cmd line passed in
Exactly, --extra-args is just for convenience of not having to edit the kernel cmdline manually when the serial console/GUI window opens with grub. Erik

On Thu, Dec 3, 2020 at 8:54 PM Erik Skultety <eskultet@redhat.com> wrote:
On 12/1/20 5:28 PM, Kaushal Shriyan wrote:
Hi,
I have run the below command to install Kali Linux using linux-2020.4-installer-amd64.iso from https://www.kali.org/downloads/
#virt-install --name kalilinux --memory 4096 --vcpus=2
--location=/linuxkvmaddgbdisk/kali-linux-2020.4-installer-amd64.iso,kernel=install.amd/gtk/vmlinuz,initrd=install.amd/gtk/initrd.gz
--network=bridge:br0 --os-type=linux --os-variant=debian9 --graphics=none --extra-args "console=ttyS0" -v --disk path=/linuxkvmaddgbdisk/kalilinux.img,size=50
I am not able to get the root login prompt when I run the below command to set IP and hostname for the guest OS. Am I missing any parameters from
On Tue, Dec 01, 2020 at 06:15:55PM +0100, Michal Privoznik wrote: the
above virt-install command to install Kali Linux as Guest OS in KVM Hypervisor?
Just a hunch, maybe --extra-args work only for installation and are not persistent? I guess installer doesn't persist kernel cmd line passed in
Exactly, --extra-args is just for convenience of not having to edit the kernel cmdline manually when the serial console/GUI window opens with grub.
Erik
Hi Erik, Thanks for your reply. I am not sure if I completely understand it. Is there an issue in the below command? Do I need to remove --extra-args "console=ttyS0" in the below command to have ssh console access to the KVM Guest VM? Please suggest. #virt-install --name kalilinux --memory 4096 --vcpus=2 --location=/linuxkvmaddgbdisk/kali-linux-2020.4-installer-amd64.iso,kernel=install.amd/gtk/vmlinuz,initrd=install.amd/gtk/initrd.gz --network=bridge:br0 --os-type=linux --os-variant=debian9 --graphics=none --extra-args "console=ttyS0" -v --disk path=/linuxkvmaddgbdisk/kalilinux.img,size=50 I look forward to hearing from you. Thanks in Advance. Best Regards, Kaushal

On 12/4/20 6:26 PM, Kaushal Shriyan wrote:
On Thu, Dec 3, 2020 at 8:54 PM Erik Skultety <eskultet@redhat.com> wrote:
On 12/1/20 5:28 PM, Kaushal Shriyan wrote:
Hi,
I have run the below command to install Kali Linux using linux-2020.4-installer-amd64.iso from https://www.kali.org/downloads/
#virt-install --name kalilinux --memory 4096 --vcpus=2
--location=/linuxkvmaddgbdisk/kali-linux-2020.4-installer-amd64.iso,kernel=install.amd/gtk/vmlinuz,initrd=install.amd/gtk/initrd.gz
--network=bridge:br0 --os-type=linux --os-variant=debian9 --graphics=none --extra-args "console=ttyS0" -v --disk path=/linuxkvmaddgbdisk/kalilinux.img,size=50
I am not able to get the root login prompt when I run the below command to set IP and hostname for the guest OS. Am I missing any parameters from
On Tue, Dec 01, 2020 at 06:15:55PM +0100, Michal Privoznik wrote: the
above virt-install command to install Kali Linux as Guest OS in KVM Hypervisor?
Just a hunch, maybe --extra-args work only for installation and are not persistent? I guess installer doesn't persist kernel cmd line passed in
Exactly, --extra-args is just for convenience of not having to edit the kernel cmdline manually when the serial console/GUI window opens with grub.
Erik
Hi Erik,
Thanks for your reply. I am not sure if I completely understand it. Is there an issue in the below command? Do I need to remove --extra-args "console=ttyS0" in the below command to have ssh console access to the KVM Guest VM? Please suggest.
#virt-install --name kalilinux --memory 4096 --vcpus=2 --location=/linuxkvmaddgbdisk/kali-linux-2020.4-installer-amd64.iso,kernel=install.amd/gtk/vmlinuz,initrd=install.amd/gtk/initrd.gz --network=bridge:br0 --os-type=linux --os-variant=debian9 --graphics=none --extra-args "console=ttyS0" -v --disk path=/linuxkvmaddgbdisk/kalilinux.img,size=50
I look forward to hearing from you. Thanks in Advance.
For accessing your guest via SSH you do not need a serial console. SSH works over network, not serial consoles. And those --extra-args: just take virtualization out of the picture for a second. You bought yourself a new desktop and want to install a distro onto it. You plug an USB stick in and as the installer boots you change the kernel cmd line. Then you proceed with installing the distro. I don't think that the installer will copy those extra kernel args you added into the freshly installed grub, why would it? Therefore, when you want to have some extra args after the installation, you have to edit the guest. Since at this point you are not booting kernel directly, libvirt/qemu can't help you and you need to hand edit grub config in the guest. And in this specific case, there is an alternative approach - editing /etc/inittab so that the init enables serial console. Then again, you do NOT need serial console for SSH. But what may come handy is NSS module: https://libvirt.org/nss.html so that you can just: ssh user@guest Michal

On Mon, Dec 07, 2020 at 11:13:08AM +0100, Michal Privoznik wrote:
On 12/4/20 6:26 PM, Kaushal Shriyan wrote:
On Thu, Dec 3, 2020 at 8:54 PM Erik Skultety <eskultet@redhat.com> wrote:
On 12/1/20 5:28 PM, Kaushal Shriyan wrote:
Hi,
I have run the below command to install Kali Linux using linux-2020.4-installer-amd64.iso from https://www.kali.org/downloads/
#virt-install --name kalilinux --memory 4096 --vcpus=2
--location=/linuxkvmaddgbdisk/kali-linux-2020.4-installer-amd64.iso,kernel=install.amd/gtk/vmlinuz,initrd=install.amd/gtk/initrd.gz
--network=bridge:br0 --os-type=linux --os-variant=debian9 --graphics=none --extra-args "console=ttyS0" -v --disk path=/linuxkvmaddgbdisk/kalilinux.img,size=50
I am not able to get the root login prompt when I run the below command to set IP and hostname for the guest OS. Am I missing any parameters from
On Tue, Dec 01, 2020 at 06:15:55PM +0100, Michal Privoznik wrote: the
above virt-install command to install Kali Linux as Guest OS in KVM Hypervisor?
Just a hunch, maybe --extra-args work only for installation and are not persistent? I guess installer doesn't persist kernel cmd line passed in
Exactly, --extra-args is just for convenience of not having to edit the kernel cmdline manually when the serial console/GUI window opens with grub.
Erik
Hi Erik,
Thanks for your reply. I am not sure if I completely understand it. Is there an issue in the below command? Do I need to remove --extra-args "console=ttyS0" in the below command to have ssh console access to the KVM Guest VM? Please suggest.
#virt-install --name kalilinux --memory 4096 --vcpus=2 --location=/linuxkvmaddgbdisk/kali-linux-2020.4-installer-amd64.iso,kernel=install.amd/gtk/vmlinuz,initrd=install.amd/gtk/initrd.gz --network=bridge:br0 --os-type=linux --os-variant=debian9 --graphics=none --extra-args "console=ttyS0" -v --disk path=/linuxkvmaddgbdisk/kalilinux.img,size=50
I look forward to hearing from you. Thanks in Advance.
For accessing your guest via SSH you do not need a serial console. SSH works over network, not serial consoles.
And those --extra-args: just take virtualization out of the picture for a second. You bought yourself a new desktop and want to install a distro onto it. You plug an USB stick in and as the installer boots you change the kernel cmd line. Then you proceed with installing the distro. I don't think that the installer will copy those extra kernel args you added into the freshly installed grub, why would it?
Therefore, when you want to have some extra args after the installation, you have to edit the guest. Since at this point you are not booting kernel directly, libvirt/qemu can't help you and you need to hand edit grub config in the guest. And in this specific case, there is an alternative approach - editing /etc/inittab so that the init enables serial console.
Unless that specific Kali version is powered by systemd (which it most likely is) in which case you're going to see a note in /etc/inittab that it's deprecated and changes will be ignored. IMO the safest bet here is to edit the grub config as Michal suggested as the first option. Regards, Erik

On Tue, Dec 01, 2020 at 09:58:26PM +0530, Kaushal Shriyan wrote:
Hi,
I have run the below command to install Kali Linux using linux-2020.4-installer-amd64.iso from https://www.kali.org/downloads/
#virt-install --name kalilinux --memory 4096 --vcpus=2 --location=/linuxkvmaddgbdisk/kali-linux-2020.4-installer-amd64.iso,kernel=install.amd/gtk/vmlinuz,initrd=install.amd/gtk/initrd.gz --network=bridge:br0 --os-type=linux --os-variant=debian9 --graphics=none --extra-args "console=ttyS0" -v --disk path=/linuxkvmaddgbdisk/kalilinux.img,size=50
I am not able to get the root login prompt when I run the below command to set IP and hostname for the guest OS. Am I missing any parameters from the above virt-install command to install Kali Linux as Guest OS in KVM Hypervisor?
I'm not sure why you need to set the IP address. Are you running a network with static IPs, without DHCP? As I cannot see where br0 is connected I can't guess more than that. You can use Michal's approach if you use the default libvirt network, though.
#virsh console kalilinux Connected to domain kalilinux Escape character is ^]
You might be connected at this point. It's just that the guest sent the "login: " prompt before you connected. Try pressing enter at this point to see whether there's something listening on the serial console. If it's not, then I wonder where it would listen, given the --graphics=none. There are ways to modify the guest image. Easiest thing might be to use virt-customize. But I truly believe you have a working system and all you need to do is write the username and press enter. In the end it will look like this: I'm trying to reproduce the install right now with comparable command-line, but it's getting stuck on something unrelated. If I manage to get it to work I will let you know what I found.
Any help will be highly appreciated. I look forward to hearing from you. Thanks in Advance.
Best Regards,
Kaushal
participants (4)
-
Erik Skultety
-
Kaushal Shriyan
-
Martin Kletzander
-
Michal Privoznik