HowTo: vmware-tools in ZeroShell

Home Page Forums Network Management ZeroShell HowTo: vmware-tools in ZeroShell

This topic contains 15 replies, has 0 voices, and was last updated by  xmas79 6 years, 6 months ago.

Viewing 15 posts - 1 through 15 (of 17 total)
  • Author
    Posts
  • #42345

    xmas79
    Member

    Brief history: I was disappointed I couldn’t properly shutdown my ZeroShell VM during (occasional) main server maintenance. So I decided to dig into this adventure… Successfully! Maybe it’s not the cleanest way to do it, but it simply works…

    Works on: VMware Server 2.0.0, ZeroShell-1.0.beta12-VMWARE.zip, others not tried.
    Tools required: a brain.
    Time required: about 15min. (if you know what you’re doing).
    Hope: there’s nothing wrong here.

    ZeroShell for VMware essentially is a Live distro. It keeps Databases and configurations into a persistent device, but the system itself is set up on a ReadOnly filesystem. Unfortunately, vmware-tools installation needs to create some symbolic link and to copy files into this ReadOnly file system. That means we need to transform it in a ReadWrite one (and persistent! I remember you / is in RAM!). Let’s see what we can do…

    Step 1: ReadWrite filesystem setup and vmware-tools installation files copy:
    1. Shutdown your VM and install a supplementary CD device mounting vmware-tools disk image. The file is called “linux.iso” and can be found in the VMware installation directory.
    2. Start ZeroShell and gain root access in the console (not SSH because vmware-tools installation will reset your network device)
    3. Type “loadkeys it” to load Italian keyboard (if you’re Italian of course), because we need to type a lot!
    4. Mount the secondary cd with the vmware-tools on a temporary directory


    a. mkdir /mnt/hdd
    b. mount -t auto /dev/hdd /mnt/hdd

    5. Copy tar.gz installation file to the /Database directory and uncompress it

    cp /mnt/hdd/VMxxxxxx.tar.gz /Database
    cd /Database
    tar -xvzf VMxxxxxx.tar.gz

    The second CD/DVD has done all his job. We can safely delete this hardware on next reboot.
    Now you should have a directory called “vmware-tools-distrib” which contains installation files. What we need now is a ReadWrite copy of the /sbin and /usr:

    cd /Database
    mkdir rootfs
    cd rootfs
    mkdir sbin && mkdir usr
    cp -a /sbin/* /Database/rootfs/sbin
    cp -a /usr/* /Database/rootfs/usr

    We also need a copy of the current modules directory that is inside /lib:

    mkdir modules
    cp -a /lib/modules/* /Database/rootfs/modules

    Now we are ready to switch to a RW filesystem:

    mount -o remount,rw /
    unlink /sbin && ln -s /Database/rootfs/sbin /sbin
    unlink /lib/modules && ln -s /Database/rootfs/modules /lib/modules
    unlink /usr && /cdrom/usr/bin/ln -s /Database/rootfs/usr /usr

    Now RW filesystem is ready.

    Step 2: Prepararing for vmware-tools installation:

    mkdir /Database/vmware-tools
    cd /Database/vmware-tools
    mkdir etc
    cd etc
    mkdir init.d
    mkdir rc.d
    cd rc.d
    mkdir rc0.d
    mkdir rc1.d
    ...
    mkdir rc6.d

    Step 3: vmware-tools installation:

    cd /Database/vmware-tools-distrib
    ./vmware-install.pl

    At this point, vmware installation should ask where we want to install and which folder contains rc0.d, rc1.d etc. folders. Of course you will answer:

    /Database/vmware-tools/TheFolderItAsksFor/

    So if it asks you “/usr/bin” you’ll answer “/Database/vmware-tools/usr/bin/” and so on… (note the trailing / at the end of the path). It will complaint about non-existing folders. Just accept to create them. Everything that goes to /Database/vmware-tools/xxx is OK.

    The installation will terminate properly. Now you only need to “configure” vmware tools:

    cd /Database/vmware-tools/usr/bin
    ./vmware-config-tools.pl

    It should complaint that some modules have not been properly configured for your system and asks you to compile. Just tell “NO” to all questions and… Voilà! “vmware-guestd” process should be now running and perfectly working.

    Step 4: Post installation.
    Vmware-tools sadly creates a “vmware-tools” folder inside /etc… Which is in in RAM!!!! That means if we do not backup this folder, on the next reboot we’ll lose our configuration.

    cd /Database/vmware-tools
    mkdir startup
    mkdir startup/etc
    mkdir startup/etc/vmware-tools
    cp -a /etc/vmware-tools/* /Database/vmware-tools/startup/etc/vmware-tools

    Now we only need to restore that folder (and links to vmware files) on every startup. Save the following script “run.sh” in “/Database/vmware-tools/startup”:

    #!/bin/bash
    mount -o remount,rw /

    unlink /usr && /cdrom/usr/bin/ln -s /Database/rootfs/usr /usr
    unlink /sbin && ln -s /Database/rootfs/sbin /sbin

    cp -a /Database/vmware-tools/scripts/etc/* /etc

    /Database/vmware-tools/etc/init.d/vmware-tools start

    Now WebLogin into ZeroShell. Go to the panel “Startup/Cron”, select “post boot”, enable status, and add the following line:
    /Database/vmware-tools/startup/run.sh
    Save and reboot and enjoy your vmware-tools!

    Credits go to Fulvio for this excellent product!
    Natale Galioto.

    Disclaimer: This information is provided “as is”. The author of this information disclaim any loss or liability, either directly or indirectly as a consequence of applying the information presented herein, or in regard to the use and application of said information. No guarantee is given, either expressed or implied, in regard to the merchantability, accuracy, or acceptability of the information.

    #50091

    divide
    Member

    Thanks for the great guide! VMware-tools integration is very important element for zeroshell.

    Your guide definetly gives a step closer to fully vmware supported appliance. VMware-tools utilisation scripts are of course important elements, but I think that also the vmxnet module for network is the key element when using zeroshell in vmware virtualization. Making this work, may need to compile the driver in config procedure. So I am wondering is this also possible?

    #50092

    xmas79
    Member

    Sorry for late response… I think it should be possible… In the download page there are links to all what we need to make gcc working properly for this purpose. We only need to configure the environment correctly… But the only thing we really don’t have is… time… Sorry.

    Best regards,
    Natale.

    #50093

    imported_fulvio
    Participant

    Thanks for this How-To. I have just linked it in the documentation page.

    Regards
    Fulvio

    #50094

    marcb
    Member

    Xmas thanks for this its a very comprehensive guide and even an idiot like me should be able to follow it! 😀

    #50095

    ptaylor
    Member

    In my case, I’m using VMWare Workstation 7 and it’s version of VMware tools.. It’s not quite working…

    First, inside the script that kicks of vmware-tools, that’s in rc.d on mine, not init.d.

    Next, after a reboot, it isn’t running. When I manually execute run.sh, I get this:

    cp: cannot stat ‘/Database/vmware-tools/scripts/etc/*’: No such file or directory
    Warning: Unable to find VMware Tools’s main database /etc/vmware-tools/locations

    #50096

    ptaylor
    Member

    Ahh – Looks like a typo in the original instructions – there is no scripts directory..

    Instead of the copy statement:
    cp -a /Database/vmware-tools/scripts/etc/* /etc

    It should be:
    cp -a /Database/vmware-tools/startup/etc/* /etc

    Mine is working now, though I did have to change the line that starts vmware tools from:
    /Database/vmware-tools/etc/init.d/vmware-tools start

    To:
    /Database/vmware-tools/etc/rc.d/vmware-tools start

    #50097

    jbo5112
    Member

    Thank you very much for this help. Adding the vmware modules isn’t very difficult if you know how to compile a kernel (you don’t even have to configure it). You’ll just have to find a full Linux distribution with a compatible GCC. I’m running 1.0.beta13, which uses GCC 4.3.2 and kernel 2.6.25.20. It requires another i386 (32-bit x86) linux distribution with GCC 4.3.x. The last number indicates a bug fix and is almost always binary compatible. Once you have a distribution with a compatible GCC, you compile/install the same kernel that zeroshell uses, reboot, install vmware-tools, and copy the modules to zeroshell. I apologize if this guide is a little incoherent, it’s getting quite late.

    Creating Build Environment
    I created a virtual machine with a minimal Ubuntu 9.04 server with the packages GCC and make installed and as many virtual CPU’s as I have real CPU cores. Next I downloaded the specific zeroshell kernel source from kernel.org (2.6.25.20) to the folder /usr/src on the Ubuntu server, by finding the specific, local url with a web browser then using that as an argument to ‘wget’ (e.g. “wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.25.20.tar.bz2“).

    Compiling the Kernel
    (note: should be replaced with the kernel version used e.g.: 2.6.25.20)
    Unpack this by running the command “tar jxf linux-.tar.bz2 && ln -sf linux- linux”, and then run “cd linux” to change to the new folder. We now need the kernel configuration from zeroshell. Copy the file /proc/config.gz on the zeroshell machine to the newly created folder on your module build machine using whatever method you want. I copied it to and from network storage on a 3rd machine using sftp.

    On the module build machine (in the /usr/src/linux folder, which now contains config.gz), run “gunzip config.gz && mv config .config && make -j4 bzImage && cp arch/i386/boot/bzImage /boot/vmlinuz- && make -j4 modules && make -j4 modules_install”. This will take several minutes on a fast machine, and the ‘4’ in -j4 should be the number of CPU’s in your build machine.

    Set up boot entry
    Now you need to create a new initram image, which I was able to do with “update-initram -c -k “. Finally, unless you’re running grub2, you’ll need to edit “/boot/grub/menu.lst”. It needs an entry for your new kernel. The easiest way is to duplicate the first entry (which begins with the keyword “title”) and edit your new first entry. The vmlinuz and initrd file names need to be updated to reflect the names of your newly created files, which are both in the /boot directory. If you don’t know an editor, you can probably use mcedit, nano, pico, or joe. Here is my entry:

    title           Ubuntu 9.04, kernel 2.6.25.20
    uuid 77b2642d-59df-47dd-86c8-62590146519d
    kernel /boot/vmlinuz-2.6.25.20 root=UUID=77b2642d-59df-47dd-86c8-62590146519d ro quiet splash
    initrd /boot/initrd.img-2.6.25.20
    quiet

    Build vmware modules
    Once you save the file and quit the editor, you’re ready to reboot (the command is “reboot”) and install the vmware-tools package. The new entry is probably now your default, but you may need to select it from the boot list. Install the vmware-tools normally. The new kernel modules will be located in /lib/modules//misc and need to be copied to your modules folder on zeroshell (/Database/rootfs/modules). Run the command “cd /lib/modules/ && tar jcf misc.tar.bz2 misc”. This will generate a file misc.tar.bz2, which needs to be copied to the same kernel module folder on zeroshell (/Database/rootfs/modules//) and extracted (“tar jxf misc.tar.bz2”).

    Installing vmware-tools also modified some of the files in /lib/modules/2.6.25.20, which I didn’t copy over to zeroshell. However, I’m not sure if it’s safe to copy them over to zeroshell. I didn’t check to see if the files on Ubuntu matched what is on Zeroshell before I installed vmware-tools, and I’m too tired to do this again. Without these changes, the modules aren’t properly installed, but they’re still perfectly usable. If the forum lets me edit this, I’ll check into copying the other files over and update this.

    The modules will need to be loaded as part of the boot script. Here’s my updated script to actually load the modules:

    !/bin/bash
    mount -o remount,rw /

    unlink /usr && /cdrom/usr/bin/ln -s /Database/rootfs/usr /usr
    unlink /sbin && ln -s /Database/rootfs/sbin /sbin
    unlink /lib/modules && ln -s /Database/rootfs/modules /lib/modules

    cp -a /Database/vmware-tools/scripts/etc/* /etc

    for f in /lib/modules/2.6*/misc/*.o; do
    insmod "$f"
    done

    /Database/vmware-tools/etc/init.d/vmware-tools start
    /etc/init.d/netconfig restart

    Are there any plans to merge this into the vmware download, so it’s all pre-installed? At some point, I can clean up the installation and submit a tar of the necessary files to go on the virtual disk (assuming that is legal and there is somewhere to submit them). It would help if I understood the zeroshell boot process better. I don’t know that I’ll be available for much maintenance, but I try to do things well enough that no one gets that job.

    Is there any reason that you put the vmware-tools in a separate folder from everything in rootfs?

    #50098

    jbo5112
    Member

    I checked the files /lib/modules/2.6.25.20/modules.* aren’t the same between zeroshell and the linux system where I installed that kernel with the same configuration. What’s worse is that when vmware tools is installed, it scrambles the order of the lines in some of the files. If you want the modules properly installed, you’ll have to compare sorted versions of the files from before and after vmware tools is installed. If someone is interested, I can provide details of what changes I made for zeroshell 1.0.beta13 and the vmware tools in ESXi 4.1. All the modules install without these changes, but I’ve only tried running a vmxnet3 NIC with the changes in place.

    I previously left something out for for my vmxnet3 under ESXi. The boot script needs to run “/etc/init.d/netconfig restart” to initialize the device, and I’ve updated the script in my previous post.

    #50099

    Sam13
    Member

    Thanks for the great guide! VMware-tools integration is very important element for zeroshell.
    Your guide definetly gives a step closer to fully vmware supported appliance. VMware-tools utilisation scripts are of course important elements, but I think that also the vmxnet module for network is the key element when using zeroshell in vmware virtualization. Making this work, may need to compile the driver in config procedure. So I am wondering is this also possible..
    Regards…

    #50100

    jbo5112
    Member

    The modules cannot be compiled on zeroshell. They can be compiled on another system and copied onto the zeroshell system. On the current release of zeroshell, this requires a system with GCC 4.3.X and kernel 2.6.25.20 configured and installed. The configuration is store in /proc/config.gz on zeroshell and it needs to be gunzipped and placed in /usr/src/linux/.config on the machine with GCC.

    I think vmware-tools might be specific to the version of VMware that you’re running. With the proper version of the kernel installed, including sources, and a back up copy of /lib/modules/2.6.25.20/modules.* (.bin files not required) you can now install vmware-tools on the machine with GCC to build the kernel modules. The modules will end up in “/lib/modules/2.6.25.20/misc/”. To find the updates to the backed up files, you’ll have to compare sorted versions of the files, so you can add the new entries to the same files on zeroshell. When I installed the same kernel on Ubuntu 9.04 server, my files in /lib/modules/2.6.25.20/modules.* weren’t the same as the files on zeroshell. It might have helped if I had downloaded the kernel from zeroshell instead of a kernel.org mirror. However, the command insmod appeared to work without changing the modules.* files on zeroshell, but I did not check to see if the modules actually worked.

    I’m currently running Zeroshell on ESXi with a working vmxnet3 NIC. I don’t know how to check if anything else works, except all the modules load and vmmemctl and vmtoolsd show up in my process list. I did run into a problem with vmware creating .old.? files for me that BROKE THEIR PROGRAMS. Delete these if you ever find them. My vmware init doesn’t appear to load the modules automatically, but I have all the additional entries in my modules.* files for your modding pleasure.

    file: modules.alias

    alias pci:v00001022d00002000sv*sd*bc*sc*i* vmxnet
    alias pci:v000015ADd00000720sv*sd*bc*sc*i* vmxnet
    alias pci:v000015ADd00000740sv*sd*bc*sc*i* vmci
    alias pci:v000015ADd000007B0sv*sd*bc*sc*i* vmxnet3
    alias pci:v000015ADd000007C0sv*sd*bc*sc*i* pvscsi

    file: modules.dep

    /lib/modules/2.6.25.20/misc/pvscsi.ko:
    /lib/modules/2.6.25.20/misc/vmblock.ko:
    /lib/modules/2.6.25.20/misc/vmci.ko:
    /lib/modules/2.6.25.20/misc/vmhgfs.ko:
    /lib/modules/2.6.25.20/misc/vmmemctl.ko:
    /lib/modules/2.6.25.20/misc/vmxnet.ko:
    /lib/modules/2.6.25.20/misc/vmxnet3.ko:
    /lib/modules/2.6.25.20/misc/vsock.ko: /lib/modules/2.6.25.20/misc/vmci.ko

    file: modules.pcimap

    pvscsi               0x000015ad 0x000007c0 0xffffffff 0xffffffff 0x00000000 0x00000000 0x0
    vmci 0x000015ad 0x00000740 0xffffffff 0xffffffff 0x00000000 0x00000000 0x0
    vmxnet 0x00001022 0x00002000 0xffffffff 0xffffffff 0x00000000 0x00000000 0x0
    vmxnet 0x000015ad 0x00000720 0xffffffff 0xffffffff 0x00000000 0x00000000 0x0
    vmxnet3 0x000015ad 0x000007b0 0xffffffff 0xffffffff 0x00000000 0x00000000 0x0

    file: modules.symbols

    alias symbol:VMCIContext_GetPrivFlags vmci
    alias symbol:VMCIDatagram_CreateHnd vmci
    alias symbol:VMCIDatagram_CreateHndPriv vmci
    alias symbol:VMCIDatagram_DestroyHnd vmci
    alias symbol:VMCIDatagram_Send vmci
    alias symbol:VMCIDs_Lookup vmci
    alias symbol:VMCIEvent_Subscribe vmci
    alias symbol:VMCIEvent_Unsubscribe vmci
    alias symbol:VMCIMemcpyFromQueue vmci
    alias symbol:VMCIMemcpyFromQueueV vmci
    alias symbol:VMCIMemcpyToQueue vmci
    alias symbol:VMCIMemcpyToQueueV vmci
    alias symbol:VMCIQueuePair_Alloc vmci
    alias symbol:VMCIQueuePair_AllocPriv vmci
    alias symbol:VMCIQueuePair_Detach vmci
    alias symbol:VMCISock_GetAFValue vsock
    alias symbol:VMCISock_GetLocalCID vsock
    alias symbol:VMCISock_KernelDeregister vsock
    alias symbol:VMCISock_KernelRegister vsock
    alias symbol:VMCI_DeviceGet vmci
    alias symbol:VMCI_DeviceRelease vmci
    alias symbol:VMCI_GetContextID vmci
    alias symbol:VMCI_Version vmci

    I also moved my installation to of everything for vmware-tools /DB instead of /Database so it is installed on zeroshell instead of just the current Database. However, the boot script needs to be modified for each database. Also my vmware tools install creates the file /etc/udev/rules.d/99-vmware-scsi-udev.rules and the symbolic a link /etc/pam.d/vmtoolsd, which I backed up and have my script restore.

    #50101

    Jiellen29
    Member

    Thanks for the help,i really appreciate it…
    God bless!!

    #50102

    pazzer
    Member

    Hi Xmas/all

    Thank you for this fantastic documentation of how it’s done!

    For any of those out there who may benefit, I thought I’d comment on my experience on installing VMtools into ZS;

    – My ZS(s) runs off VMware VMDK disks on ESX 4.1

    – Initial ZS install was just extracting the USB/SATA img to a 2Gb disk with DD (this was the quickest / cleanest method I came across for a VM)

    – I’ve partitioned the spare 1Gb (left over from the imaging process) and formatted as ext3

    – During the process documented above, I found that upon installing modules into the target directory (/Database) that the script would halt with a ‘no space remaining warning’ – I cleaned up the filesystem as best I could, still no joy. The image on disk occupies close to 700/800Mb I think. Anyway, moving on…

    – I mounted the spare 1Gb partition and used that to copy/build upon

    – The ‘run.sh’ script mentioned needed to be placed elsewhere, so I chose the /Database dir, gave it some ‘chmod +x’

    – Added the mkdir and mount commands for the 1gb partition to run.sh, so that the partition with the vmtools on was accessible, before the daemon is started

    Success!
    I’ll come back for this one, and get the vmxnet3 nailed. Not sure that I need to memory-balloon my ZS router/NAT/VPN/DNS though!!
    Thanks for the info Xmas, and thank you ZS!

    #50103

    Anonymous
    Member

    DELETED

    #50104

    gordonf
    Member

    After following xmas79’s instructions to the letter, I had to apply the fixes ptaylor described. I also had to grant Execute access to the run.sh script (chmod 722 /Database/vmware-tools/startup/run.sh) before the script would launch on startup.

    I got release 1.0 beta 16 running on VM hardware version 8, on ESXi 5.0 with Intel E1000 virtual NICs. I also had to use VMware Converter to convert the VM download to something that would work on ESXi; the “Sparse” disk format isn’t supported there.

    It’s my hope I can replace my physical router (Snapgear SG300) and wireless AP (some Netgear box) with this virtual machine and some USB wireless adapter.

Viewing 15 posts - 1 through 15 (of 17 total)

You must be logged in to reply to this topic.