Difference between revisions of "Vnx-rootfsubuntu"
(→Installing additional software) |
|||
(33 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | {{Title|How to create a Ubuntu root | + | {{Title|How to create a KVM Ubuntu root filesystem for VNX}} |
== Basic installation == | == Basic installation == | ||
− | Follow this procedure to create a Ubuntu based root | + | Follow this procedure to create a KVM Ubuntu based root filesystem for VNX. The procedure has been tested with Ubuntu 9.10, 10.04, 10.10, 11.04, 12.04, 13.04, 13.10, 14.04, 14.10, 15.04, 15.10 and 16.04. |
<ul> | <ul> | ||
<li>Create the filesystem disk image:</li> | <li>Create the filesystem disk image:</li> | ||
− | qemu-img create -f qcow2 vnx_rootfs_kvm_ubuntu.qcow2 | + | qemu-img create -f qcow2 vnx_rootfs_kvm_ubuntu.qcow2 20G |
<li>Get Ubuntu installation CD. For example:</li> | <li>Get Ubuntu installation CD. For example:</li> | ||
− | wget ftp://ftp.rediris.es/mirror/ubuntu-releases/ | + | wget ftp://ftp.rediris.es/mirror/ubuntu-releases/16.04/ubuntu-16.04-server-i386.iso |
− | cp ubuntu- | + | cp ubuntu-16.04-server-i386.iso /almacen/iso |
Note: use 'server' or 'desktop' CD versions depending on the system you want to create. | Note: use 'server' or 'desktop' CD versions depending on the system you want to create. | ||
<li>Create the virtual machine with:</li> | <li>Create the virtual machine with:</li> | ||
− | vnx --create-rootfs vnx_rootfs_kvm_ubuntu.qcow2 --install-media /almacen/iso/ubuntu- | + | vnx --create-rootfs vnx_rootfs_kvm_ubuntu.qcow2 --install-media /almacen/iso/ubuntu-16.04-server-i386.iso --mem 512M |
+ | Note: add '''"--arch x86_64"''' option for 64 bits virtual machines | ||
<li>Follow Ubuntu installation menus to install a basic system with ssh server.</li> | <li>Follow Ubuntu installation menus to install a basic system with ssh server.</li> | ||
− | <li>Configure a serial console on ttyS0:</li> | + | <li>Configure a serial console on ttyS0 (skip this step for 15.04 or later releases):</li> |
cd /etc/init | cd /etc/init | ||
cp tty1.conf ttyS0.conf | cp tty1.conf ttyS0.conf | ||
Line 21: | Line 22: | ||
GRUB_CMDLINE_LINUX_DEFAULT="console=ttyS0" | GRUB_CMDLINE_LINUX_DEFAULT="console=ttyS0" | ||
GRUB_TIMEOUT=0 | GRUB_TIMEOUT=0 | ||
+ | GRUB_RECORDFAIL_TIMEOUT=1 | ||
+ | <!--li>Only for Ubuntu 15.10 or later releases (do not include it in 20.04, it conflicts with udev):</li> | ||
+ | GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0" | ||
+ | --> | ||
<li>Make grub process the previous changes:</li> | <li>Make grub process the previous changes:</li> | ||
update-grub | update-grub | ||
+ | <li>Add a timeout to systemd-networkd-wait-online service to avoid long waits at startup. Edit /lib/systemd/system/systemd-networkd-wait-online.service and change the following line:</li> | ||
+ | ExecStart=/lib/systemd/systemd-networkd-wait-online --timeout 20 | ||
<li>Finally, delete the net udev rules file and halt the system:</li> | <li>Finally, delete the net udev rules file and halt the system:</li> | ||
rm /etc/udev/rules.d/70-persistent-net.rules | rm /etc/udev/rules.d/70-persistent-net.rules | ||
Line 33: | Line 40: | ||
<li>Restart the system with the following command:</li> | <li>Restart the system with the following command:</li> | ||
vnx --modify-rootfs vnx_rootfs_kvm_ubuntu.qcow2 --update-aced --mem 512M | vnx --modify-rootfs vnx_rootfs_kvm_ubuntu.qcow2 --update-aced --mem 512M | ||
+ | Note: add '''"--arch x86_64"''' option for 64 bits virtual machines | ||
Note: ignore the errors "timeout waiting for response on VM socket". 768M are needed if you are installing a root filesystem with desktop interface | Note: ignore the errors "timeout waiting for response on VM socket". 768M are needed if you are installing a root filesystem with desktop interface | ||
<li>Access the system through the text console to easy the copy-paste of commands:</li> | <li>Access the system through the text console to easy the copy-paste of commands:</li> | ||
Line 42: | Line 50: | ||
apt-get dist-upgrade | apt-get dist-upgrade | ||
<li>Install XML::DOM perl package and ACPI daemon:</li> | <li>Install XML::DOM perl package and ACPI daemon:</li> | ||
− | apt-get install libxml- | + | apt-get install libxml-libxml-perl libnetaddr-ip-perl acpid |
+ | <li>For 17.10 or newer install ifupdown</li> | ||
+ | apt-get install ifupdown | ||
<!--li>Only for Ubuntu 10.04:</li> | <!--li>Only for Ubuntu 10.04:</li> | ||
<ul> | <ul> | ||
Line 57: | Line 67: | ||
mount /dev/sdb /mnt/ | mount /dev/sdb /mnt/ | ||
perl /mnt/vnxaced-lf/install_vnxaced | perl /mnt/vnxaced-lf/install_vnxaced | ||
+ | Change 'sdb' by 'vdb' in case virtio drivers are being used. | ||
<li>Edit /etc/network/interfaces file and comment all lines related to eth0, eth1, etc interfaces. Leave only the loopback (lo) interface.</li> | <li>Edit /etc/network/interfaces file and comment all lines related to eth0, eth1, etc interfaces. Leave only the loopback (lo) interface.</li> | ||
+ | <li>For Ubuntu 22.04, uninstall cloud-init:</li> | ||
+ | apt remove --purge cloud-init cloud-initramfs-copymods cloud-initramfs-dyn-netconf cloud-guest-utils netplan.io | ||
+ | <li>Reduce networkd-wait timeout. Edit the systemd-networkd-wait-online.service:</li> | ||
+ | sudo vim /etc/systemd/system/network-online.target.wants/systemd-networkd-wait-online.service | ||
+ | And in the [Service] block, add the following line: | ||
+ | TimeoutStartSec=5sec | ||
<li>Optional: install graphical user interface.</li> | <li>Optional: install graphical user interface.</li> | ||
<ul> | <ul> | ||
<li>Minimal:</li> | <li>Minimal:</li> | ||
+ | # recommended option | ||
+ | sudo apt-get install lubuntu-desktop | ||
+ | |||
+ | # old recipe not tested in later versions | ||
sudo apt-get install xorg gnome-core gksu gdm gnome-system-tools gnome-nettool firefox-gnome-support | sudo apt-get install xorg gnome-core gksu gdm gnome-system-tools gnome-nettool firefox-gnome-support | ||
<li>Complete:</li> | <li>Complete:</li> | ||
Line 76: | Line 97: | ||
<li>Apache server:</li> | <li>Apache server:</li> | ||
sudo apt-get install apache2 | sudo apt-get install apache2 | ||
− | update-rc.d -f apache2 remove | + | update-rc.d -f apache2 remove # to avoid automatic start in old versions |
− | <li>Other | + | systemctl disable apache2.service # to avoid automatic start in new versions |
+ | |||
+ | <li>Other tools</li> | ||
sudo apt-get install traceroute | sudo apt-get install traceroute | ||
+ | sudo apt-get install xterm # needed to have the 'resize' tool to resize consoles | ||
</ul> | </ul> | ||
<li>Create a file /etc/vnx_rootfs_version to store version number and informacion about modification:</li> | <li>Create a file /etc/vnx_rootfs_version to store version number and informacion about modification:</li> | ||
<pre> | <pre> | ||
− | VER=v0. | + | VER=v0.25 |
− | OS=Ubuntu | + | OS=Ubuntu 16.04 32 bits |
− | DESC= | + | DESC=Basic Ubuntu 16.04 root filesystem without GUI |
</pre> | </pre> | ||
− | <li>Stop the machine with | + | <li>Zero the image empty space to allow reducing the size of the image:</li> |
− | vnx_halt | + | dd if=/dev/zero of=/mytempfile |
+ | rm -f /mytempfile | ||
+ | |||
+ | <li>Stop the machine with vnx_halt:</li> | ||
+ | sudo vnx_halt | ||
+ | |||
+ | <li>Reduce the size of the image:</li> | ||
+ | mv vnx_rootfs_kvm_ubuntu.qcow2 vnx_rootfs_kvm_ubuntu.qcow2.bak | ||
+ | qemu-img convert -O qcow2 vnx_rootfs_kvm_ubuntu.qcow2.bak vnx_rootfs_kvm_ubuntu.qcow2 | ||
+ | |||
</ul> | </ul> | ||
Line 134: | Line 167: | ||
<ul> | <ul> | ||
+ | <li>Sometimes after restarting, the virtual machines stop at showing the grub menu and do not start until you manually choose one option. To avoid it, just follow the instructions here: http://www.linuxquestions.org/questions/linux-server-73/how-to-disable-grub-2-menu-even-after-server-crash-796562/. Beware that the changes you make to grub.cfg file are lost after executing "update-grub" command. | ||
+ | </li> | ||
<li>In Ubuntu 12.04 Desktop, graphical commands execution does not work. Command execution fails with "ERROR: no user logged on display :0.0" (see /var/log/vnxaced.log). If you just open a "terminal" window, commands work correctly (does not work if you open other applications; only when you start a terminal...).</li> | <li>In Ubuntu 12.04 Desktop, graphical commands execution does not work. Command execution fails with "ERROR: no user logged on display :0.0" (see /var/log/vnxaced.log). If you just open a "terminal" window, commands work correctly (does not work if you open other applications; only when you start a terminal...).</li> | ||
<li>Each time a cdrom is mounted (for example, whenever a command is executed on the virtual machine) the following error appears in the console:</li> | <li>Each time a cdrom is mounted (for example, whenever a command is executed on the virtual machine) the following error appears in the console:</li> |
Latest revision as of 02:41, 9 December 2023
How to create a KVM Ubuntu root filesystem for VNX
Contents
[hide]Basic installation
Follow this procedure to create a KVM Ubuntu based root filesystem for VNX. The procedure has been tested with Ubuntu 9.10, 10.04, 10.10, 11.04, 12.04, 13.04, 13.10, 14.04, 14.10, 15.04, 15.10 and 16.04.
- Create the filesystem disk image:
qemu-img create -f qcow2 vnx_rootfs_kvm_ubuntu.qcow2 20G
wget ftp://ftp.rediris.es/mirror/ubuntu-releases/16.04/ubuntu-16.04-server-i386.iso cp ubuntu-16.04-server-i386.iso /almacen/iso
Note: use 'server' or 'desktop' CD versions depending on the system you want to create.
vnx --create-rootfs vnx_rootfs_kvm_ubuntu.qcow2 --install-media /almacen/iso/ubuntu-16.04-server-i386.iso --mem 512M
Note: add "--arch x86_64" option for 64 bits virtual machines
cd /etc/init cp tty1.conf ttyS0.conf sed -i -e 's/tty1/ttyS0/' ttyS0.conf
GRUB_CMDLINE_LINUX_DEFAULT="console=ttyS0" GRUB_TIMEOUT=0 GRUB_RECORDFAIL_TIMEOUT=1
update-grub
ExecStart=/lib/systemd/systemd-networkd-wait-online --timeout 20
rm /etc/udev/rules.d/70-persistent-net.rules halt -p
Configuration
- Restart the system with the following command:
vnx --modify-rootfs vnx_rootfs_kvm_ubuntu.qcow2 --update-aced --mem 512M
Note: add "--arch x86_64" option for 64 bits virtual machines Note: ignore the errors "timeout waiting for response on VM socket". 768M are needed if you are installing a root filesystem with desktop interface
virsh console vnx_rootfs_kvm_ubuntu.qcow2
sudo su
apt-get update apt-get dist-upgrade
apt-get install libxml-libxml-perl libnetaddr-ip-perl acpid
apt-get install ifupdown
mount /dev/sdb /mnt/ perl /mnt/vnxaced-lf/install_vnxaced
Change 'sdb' by 'vdb' in case virtio drivers are being used.
apt remove --purge cloud-init cloud-initramfs-copymods cloud-initramfs-dyn-netconf cloud-guest-utils netplan.io
sudo vim /etc/systemd/system/network-online.target.wants/systemd-networkd-wait-online.service
And in the [Service] block, add the following line:
TimeoutStartSec=5sec
- Minimal:
# recommended option sudo apt-get install lubuntu-desktop # old recipe not tested in later versions sudo apt-get install xorg gnome-core gksu gdm gnome-system-tools gnome-nettool firefox-gnome-support
sudo apt-get install ubuntu-desktop
Note: to avoid nautilus being launched any time you remotely execute a command on the virtual machine using VNX (which interferes with the normal execution of commands), you should disable the start of programs when media insertion takes place. Go to "System settings->System->Details->Removable Media" and deselect the checkbox "Never prompt or start programs on media insertion".
- Apache server:
sudo apt-get install apache2 update-rc.d -f apache2 remove # to avoid automatic start in old versions systemctl disable apache2.service # to avoid automatic start in new versions
sudo apt-get install traceroute sudo apt-get install xterm # needed to have the 'resize' tool to resize consoles
VER=v0.25 OS=Ubuntu 16.04 32 bits DESC=Basic Ubuntu 16.04 root filesystem without GUI
dd if=/dev/zero of=/mytempfile rm -f /mytempfile
sudo vnx_halt
mv vnx_rootfs_kvm_ubuntu.qcow2 vnx_rootfs_kvm_ubuntu.qcow2.bak qemu-img convert -O qcow2 vnx_rootfs_kvm_ubuntu.qcow2.bak vnx_rootfs_kvm_ubuntu.qcow2
If everything went well, your root filesystem will be ready to be used with VNX. You can make a simple test using the simple_ubuntu.xml scenario distributed with VNX.
Installing additional software
To install additional software or to modify your root file system, you just have to:
- Start a virtual machine from it:
vnx --modify-rootfs vnx_rootfs_kvm_ubuntu.qcow2
dhclient eth0
Note: use "ip link show" to know which network interface to use.
vnx_halt
Examples
- dhcp server and relay:
- Install dhcp3 packages:
apt-get install dhcp3-server dhcp3-relay
update-rc.d -f isc-dhcp-server remove update-rc.d -f isc-dhcp-relay remove
Updating VNXACED
You can automatically update the VNXACE daemon with the following command:
vnx --modify-rootfs vnx_rootfs_kvm_ubuntu.qcow2 --update-aced -y
If VNXACE daemon is not updated automatically, you can do it manually by accessing the virtual machine console and type:
mount /dev/sdb /mnt/ perl /mnt/vnxaced-lf/install_vnxaced
Known problems
- Sometimes after restarting, the virtual machines stop at showing the grub menu and do not start until you manually choose one option. To avoid it, just follow the instructions here: http://www.linuxquestions.org/questions/linux-server-73/how-to-disable-grub-2-menu-even-after-server-crash-796562/. Beware that the changes you make to grub.cfg file are lost after executing "update-grub" command.
- In Ubuntu 12.04 Desktop, graphical commands execution does not work. Command execution fails with "ERROR: no user logged on display :0.0" (see /var/log/vnxaced.log). If you just open a "terminal" window, commands work correctly (does not work if you open other applications; only when you start a terminal...).
- Each time a cdrom is mounted (for example, whenever a command is executed on the virtual machine) the following error appears in the console:
Jul 27 22:33:31 vnx kernel: [ 4384.875886] ata1.01: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x6 Jul 27 22:33:31 vnx kernel: [ 4385.291374] ata1.01: BMDMA stat 0x5 Jul 27 22:33:31 vnx kernel: [ 4385.493411] sr 0:0:1:0: [sr0] CDB: Read(10): 28 00 00 00 00 18 00 00 01 00 Jul 27 22:33:31 vnx kernel: [ 4385.493460] ata1.01: cmd a0/01:00:00:00:08/00:00:00:00:00/b0 tag 0 dma 2048 in Jul 27 22:33:31 vnx kernel: [ 4385.493461] res 01/60:00:00:00:08/00:00:00:00:00/b0 Emask 0x3 (HSM violation) Jul 27 22:33:31 vnx kernel: [ 4386.263553] ata1.01: status: { ERR }
Despite of the error trace, the commands are executed correctly. This error does not appear on Ubuntu 9.10 filesystems.