Tiny Core Linux

Tiny Core Extensions => TCE Q&A Forum => Topic started by: SeventhSin on July 02, 2019, 02:03:07 PM

Title: open-vm-tools: error on shares mapping
Post by: SeventhSin on July 02, 2019, 02:03:07 PM
Hello all,

Currently testing with TinyCorePure64 in a VM deployed in VMwareWorkstation, but the same behavior has been observed on x86. I have enabled "Shared Folders" in the VM's configuration and created a test share, named vm-share. During boot (pre-X), the following message shows-up briefly:

Code: [Select]
fusermount: option allow_other only allowed if 'user_allow_other' is set in /etc/fuse.conf
Post-X, a new folder pops-up: /mnt/hgfs-vm-shared/. However it is empty, since nothing gets mounted.

Code: [Select]
tc@box:/$ tree /mnt/hgfs-vm-shared/
/mnt/hgfs-vm-shared/

0 directories, 0 files

Running vmhgfs-fuse manually leads to the desired behavior:

Code: [Select]
tc@box:/$ mkdir -p /mnt/hgfs/ && vmhgfs-fuse /mnt/hgfs
tc@box:/$ tree /mnt/hgfs
/mnt/hgfs
`-- vm-shared
    `-- New\ folder

2 directories, 0 files

Of course there is no /etc/fuse.conf.
Title: Re: open-vm-tools: error on shares mapping
Post by: andyj on July 02, 2019, 04:10:02 PM
/etc/fuse.conf is created when the vmtoolsd service is started. Add this to /opt/bootsync.sh or /opt/bootlocal.sh:

Code: [Select]
/usr/local/etc/init.d/open-vm-tools start
Title: Re: open-vm-tools: error on shares mapping
Post by: SeventhSin on July 03, 2019, 03:52:56 AM
/etc/fuse.conf is created when the vmtoolsd service is started. Add this to /opt/bootsync.sh or /opt/bootlocal.sh:

Code: [Select]
/usr/local/etc/init.d/open-vm-tools start

That solved it, thank you andyj !

Just a quick question: wouldn't it be more... "elegant" to have a root folder, say /mnt/hgfs and all the shared folders mounted under that instead of "polluting" (subjective choice of words) the /mnt with one entry per shared folder?

What do you guys think?
Title: Re: open-vm-tools: error on shares mapping
Post by: andyj on July 03, 2019, 04:49:36 AM
Shared folders are mounted in /etc/profile.d//etc/profile.d/open-vm-tools.sh when you log in. It would be a one-character change so it shouldn't be a big deal for the next version, whenever that is. Since I only have one shared folder it's not an issue for me. In theory they should be unmounted when you log out, but if ash supports a logout script I don't know what it is. Someone would have to look through the source and see. As always, suggestions and patches to open-vm-tools are welcome.
Title: Re: open-vm-tools: error on shares mapping
Post by: SeventhSin on July 03, 2019, 06:21:52 AM
@andyj

I also noticed that the Services option in the ControlPanel app doesn't show open-vm-tools service as started although there is a
Code: [Select]
/usr/local/etc/init.d/open-vm-tools start entry in /opt/bootlocal.sh.
Title: Re: open-vm-tools: error on shares mapping
Post by: Rich on July 03, 2019, 06:44:13 AM
Hi SeventhSin
Try entering  services  at the command line and see if any errors are printed out.
Title: Re: open-vm-tools: error on shares mapping
Post by: SeventhSin on July 03, 2019, 06:52:40 AM
Hi SeventhSin
Try entering  services  at the command line and see if any errors are printed out.

Hi Rich.

Code: [Select]
tc@tc-pure-10:~$ services
Found total 6 services.

Then the app's GUI gets displayed.
Title: Re: open-vm-tools: error on shares mapping
Post by: SeventhSin on July 03, 2019, 07:23:08 AM
I also noticed a difference between TinyCore and TinyCorePure64: on TinyCore, there is one extra service showing up as started in services: fuse (this one does not appear on TinyCorePure64).

open-vm-tools not being listed as started holds true for TinyCore as well.
Title: Re: open-vm-tools: error on shares mapping
Post by: Rich on July 03, 2019, 10:52:02 AM
Hi SeventhSin
Post the output of these commands:
Code: [Select]
which ps
cat /usr/local/etc/init.d/open-vm-tools
Title: Re: open-vm-tools: error on shares mapping
Post by: andyj on July 03, 2019, 11:57:25 AM
I see this:

(https://www.asjohnson.com/open-vm-service.png)

Have you added open-vm-tools to onboot.lst? Maybe you need to reboot?
Title: Re: open-vm-tools: error on shares mapping
Post by: SeventhSin on July 03, 2019, 12:16:35 PM
Hi SeventhSin
Post the output of these commands:
Code: [Select]
which ps
cat /usr/local/etc/init.d/open-vm-tools

Here you go, Rich.

TinyCorePure64 10.1:

Code: [Select]
tc@tc-pure-10-1:~$ which ps
/usr/local/bin/ps


Code: [Select]
#!/bin/sh
# Start, stop, and restart vmtoolsd

grep -q user_allow_other /etc/fuse.conf || echo "user_allow_other" >>/etc/fuse.c                                                                                                                                                             onf

case "$1" in
start)

# Interface check
NIF1=$(wc -l < /proc/net/dev)

# Load vmblock
vmblock_dev=/tmp/VMwareDnD
vmblockfusemntpt=/var/run/vmblock-fuse
[ -d $vmblock_dev ] || mkdir -m 1777 -p $vmblock_dev

if grep -q "$vmblockfusemntpt" /etc/mtab; then
        true
else
        mkdir -m 1777 -p $vmblockfusemntpt
        vmware-vmblock-fuse -o subtype=vmware-vmblock,default_permissions,allow_                                                                                                                                                             other $vmblockfusemntpt
fi

# Start vmtoolsd
if pidof vmtoolsd &>/dev/null; then
        echo vmtoolsd already running
else
        rm -f /var/run/vmtoolsd.pid
        /usr/local/bin/vmtoolsd --background=/var/run/vmtoolsd.pid
fi

# add the following to .xession after mouse initialization if .xsession doesn't                                                                                                                                                              run scripts in /usr/local/etc/X.d
# [ $(which vmware-checkvm) ] && # [ vmware-checkvm ] && # vmware-user

# Use ethtool to optimize vmxnet
        if which ethtool &> /dev/null; then
                for e in $(grep eth /proc/net/dev|cut -d: -f1); do
                        ethtool -K $e gso on &> /dev/null
                        ethtool -K $e tso on &> /dev/null
                done
        fi

# Start DHCP client for new interfaces
if ! grep -q nodhcp /proc/cmdline; then
        NIF2=$(wc -l < /proc/net/dev)
        if [ $NIF2 -gt $NIF1 ]; then
                  /etc/init.d/dhcp.sh
        fi
fi
;;
stop)
        if pidof vmtoolsd &>/dev/null; then
                killall vmtoolsd
                echo stopped vmtoolsd
                umount -l /mnt/hgfs
        else
                echo vmtoolsd is not running
        fi
;;
restart)
        $0 stop
        $0 start
;;
*)
        echo "Usage: $0 (start|stop|restart)"
        exit 1
;;
esac

TinyCore 10.1:

Code: [Select]
tc@tc-10:~$ which ps
/usr/local/bin/ps


Code: [Select]
#!/bin/sh
# Start, stop, and restart vmtoolsd

grep -q user_allow_other /etc/fuse.conf || echo "user_allow_other" >>/etc/fuse.conf

case "$1" in
start)

# Interface check
NIF1=$(wc -l < /proc/net/dev)

# Load vmblock
vmblock_dev=/tmp/VMwareDnD
vmblockfusemntpt=/var/run/vmblock-fuse
[ -d $vmblock_dev ] || mkdir -m 1777 -p $vmblock_dev

if grep -q "$vmblockfusemntpt" /etc/mtab; then
        true
else
        mkdir -m 1777 -p $vmblockfusemntpt
        vmware-vmblock-fuse -o subtype=vmware-vmblock,default_permissions,allow_other $vmblockfusemntpt
fi

# Start vmtoolsd
if pidof vmtoolsd &>/dev/null; then
        echo vmtoolsd already running
else
        rm -f /var/run/vmtoolsd.pid
        /usr/local/bin/vmtoolsd --background=/var/run/vmtoolsd.pid
fi

# add the following to .xession after mouse initialization if .xsession doesn't run scripts in /usr/local/etc/X.d
# [ $(which vmware-checkvm) ] && # [ vmware-checkvm ] && # vmware-user

# Use ethtool to optimize vmxnet
        if which ethtool &> /dev/null; then
                for e in $(grep eth /proc/net/dev|cut -d: -f1); do
                        ethtool -K $e gso on &> /dev/null
                        ethtool -K $e tso on &> /dev/null
                done
        fi

# Start DHCP client for new interfaces
if ! grep -q nodhcp /proc/cmdline; then
        NIF2=$(wc -l < /proc/net/dev)
        if [ $NIF2 -gt $NIF1 ]; then
                  /etc/init.d/dhcp.sh
        fi
fi
;;
stop)
        if pidof vmtoolsd &>/dev/null; then
                killall vmtoolsd
                echo stopped vmtoolsd
                umount -l /mnt/hgfs
        else
                echo vmtoolsd is not running
        fi
;;
restart)
        $0 stop
        $0 start
;;
*)
        echo "Usage: $0 (start|stop|restart)"
        exit 1
;;
esac
Title: Re: open-vm-tools: error on shares mapping
Post by: SeventhSin on July 03, 2019, 12:18:42 PM
I see this:

(https://www.asjohnson.com/open-vm-service.png)

Have you added open-vm-tools to onboot.lst? Maybe you need to reboot?

I have open-vm-tools-desktop.tcz in /mnt/sda1/tce/onboot.lst. Everything is backed-up, nice and juicy, no problem there.

I see that open-vm-tools misses the green check-box in your screenshot too. This is exactly how it shows in my Services app as well.

TinyCorePure64:

(https://i.imgur.com/uFMUpDt.png)

TinyCore:

(https://i.imgur.com/lNge9a6.png)
Title: Re: open-vm-tools: error on shares mapping
Post by: andyj on July 03, 2019, 12:29:33 PM
I patched /usr/local/etc/init.d/open-vm-tools so the light comes on, but clicking the button doesn't do anything. I'm not sure what that program is looking for.
Title: Re: open-vm-tools: error on shares mapping
Post by: SeventhSin on July 03, 2019, 12:44:26 PM
I patched /usr/local/etc/init.d/open-vm-tools so the light comes on, but clicking the button doesn't do anything. I'm not sure what that program is looking for.

I can confirm that clicking the service button doesn't do anything on any of the systems. Attempting to disable fuse on TinyCore 10.1 fails too, the green checkbox comes back after clicking it.
Title: Re: open-vm-tools: error on shares mapping
Post by: Rich on July 03, 2019, 12:51:11 PM
Hi andyj
The  services  program is looking for a non-zero value to be returned from  /usr/local/etc/init.d/PogramName status. The  tftp
program uses this:
Code: [Select]
status)
pidof udpsvd
;;
The NFS utilities use this:
Code: [Select]
status)
if ps | awk '{print $3}' | grep -e "/usr/local/sbin/rpc.statd" >/dev/null && ps | awk '{print $3}' | grep -e "/usr/local/sbin/rpc.statd" >/dev/null && ps | awk '{print $3}' | grep -e "\[nfsd\]" >/dev/null; then
echo "NFS-server is running."
exit 0
else
echo "NFS-server is not running."
exit 1
fi
;;
If you use the latter, include this at the top of the file:
Code: [Select]
alias ps='busybox ps'
Title: Re: open-vm-tools: error on shares mapping
Post by: andyj on July 03, 2019, 03:25:18 PM
The main problem I'm having is that vmtoolsd, the program that provides copy/paste/resolution resizing/usb redirection, is a daemon that runs as root, whereas the mounts for the shared folders are through fuse and run as the logged in user. I could assume the user is tc, but I could also be wrong. I'm not sure how to handle both in one click.
Title: Re: open-vm-tools: error on shares mapping
Post by: Rich on July 03, 2019, 05:26:59 PM
Hi andyj
... I could assume the user is tc, but I could also be wrong. ...

I don't know if this helps, but maybe you can adapt what  tftp  uses:
Code: [Select]
case "${1}" in
start)
if [ -z "$HOME" ]; then
                   [ "$USER" ] || USER="$(cat /etc/sysconfig/tcuser)" || USER="tc"
                   HOME=/home/"$USER"
                fi
/sbin/udpsvd -E 0 69 tftpd $HOME &
;;
Title: Re: open-vm-tools: error on shares mapping
Post by: andyj on July 04, 2019, 05:57:22 AM
We need to get back to what the open-vm-tools "service" does and does not do. The service daemon vmtoolsd communicates with the host for things like status, time sync and power off. This is the only program run as root. The rest of the programs are user space programs, run separately, and do not require the daemon to be running. The shared folders do not require any other programs to be running, and can be used in a text only environment which is why they are mounted in /etc/profile.d/open-vm-tools.sh. The remaining program is started from /usr/local/etc/X.d/open-vm-tools which provides desktop resizing and copy/paste. This program exits when X exits.

I'll make a few changes. One, /etc/fuse.conf is created when the service is started if it doesn't already exist. It isn't needed by the service, it is needed for shared folders, so I'll move this bit of code from /usr/local/etc/init.d/open-vm-tools to /usr/local/tce.installed/open-vm-tools so it gets created when the extension is loaded. Two, I'll add a "status" option to /usr/local/etc/init.d/open-vm-tools so the services dialog will function correctly. Three, I'll update /etc/profile.d/open-vm-tools.sh to mount each shared folder as a subdirectory in /mnt/hgfs. If anyone can tell me how to make a script that runs when $USER logs off then the shared folders can be unmounted at that time. For now this part remains to be done.
Title: Re: open-vm-tools: error on shares mapping
Post by: Rich on July 04, 2019, 07:24:31 AM
Hi andyj
... If anyone can tell me how to make a script that runs when $USER logs off then the shared folders can be unmounted at that time. ...
Maybe use  inotifywait  to monitor for a  close_write  event in either  /var/run/utmp  or  /var/log/wtmp. Then use either  who, last, or w
to see if the user is still logged in.
Title: Re: open-vm-tools: error on shares mapping
Post by: andyj on July 04, 2019, 09:55:03 AM
I modified /root/.profile to run the tc login through strace, but busybox isn't looking for anything on exit beyond .ash_history. So it's a kludge or nothing.
Title: Re: open-vm-tools: error on shares mapping
Post by: SeventhSin on July 05, 2019, 04:19:50 AM
...
Three, I'll update /etc/profile.d/open-vm-tools.sh to mount each shared folder as a subdirectory in /mnt/hgfs.

@andyj, thank you so much for taking this into consideration.