My experiment last week with sshfs came to a grinding halt when I realized that while the share works, and can be automatically started, the permissions do not work and Hudson can't actually use the sshfs share; also, I couldn't get sshfs to compile for OpenSolaris, so it's really a non-starter.
Next up was mount_nfs
, but after fighting with that, /etc/nfs.conf
and /etc/exports
for a couple days off and on, I realized there's a much simpler solution using Virtual Box itself: vboxsf
. Note that it's sf (shared folder) not fs (file system).
Thanks to David Herron for the inspiration.
Here's how to set up a vboxfs share:
- Ignore the Virtual Box wiki which suggests that you can't just use a Shared Folder: you can.
- Guest: Launch your guest, then install the Virtual Box Guest Additions onto it.
- Host: Create a user and set its uid and gid to some value which can be created on the guest / slave. For example, on Mac OSX 10.5 Server, launch
System Preferences > System > Accounts
, and create a "hudsonbuild" user with User ID and Group ID set to 500.Note that uid 500 and gid 500 are the defaults for the first user on a Fedora system; on Ubuntu it's 1000; on other systems YMMV.
- Host: Create a folder in the root of your host called
/shared
. Put some files there. Give it full write permissions, and set its ownership to the user who'll be sharing the files:find /shared -type f -exec chmod 666 \; find /shared -type d -exec chmod 777 \; chown -R 500:500 /shared
- Host: Add a Shared Folder. NOTE: If your guest is running, shut it down or see the next item. From the Virtual Box GUI (on the host), select
Settings > Shared Folders > New (+)
. Add a shared folder called "shared" mapped to/shared
(or call it something else and map it to a different path on your host). - Guest: Alternatively, you can add a Shared Folder to a running guest from its
Devices
menu. Add a shared folder called "shared" mapped to/shared
. - Guest: As root, create a folder on the guest called /shared. Leave it empty, but make sure it's owned by your user.
- Guest: As root, add this to the guest's /etc/fstab:
shared /shared vboxsf auto,exec,rw,uid=500,gid=500 0 0
- Guest: As root, mount the share one of three ways:
# mount everything in /etc/fstab mount -a # mount using mount (and optional -o options) mount -t vboxfs -o auto,exec,rw,uid=500,gid=500 shared /shared # mount using mount.vboxsf (and optional -w and -o options) /sbin/mount.vboxsf -w -o rw,uid=500,gid=500 shared /shared
- Guest: If this mount doesn't start automatically when the VirtualBox guest is started, you can add one of the above commands to the script you use to start the Hudson slave, eg:
!/bin/bash # # Init file for Hudson server daemon # # chkconfig: 2345 65 15 # description: Hudson server # HOWTO: # 1. rename this file on target server (Hudson slave node) to /etc/init.d/hudson # 2. to enable this script to run on startup, as root type the following: # Fedora: # chkconfig --add hudson; chkconfig --list hudson # OpenSolaris: # for n in 0 1 6; do cd /etc/rc${n}.d; ln -s /etc/init.d/hudson K15hudson; done # for n in 2 3 4 5; do cd /etc/rc${n}.d; ln -s /etc/init.d/hudson S65hudson; done # svccfg add hudson; svcs | grep hudson RETVAL=0 #run Hudson as a slave node java -jar /opt/hudson/slave.jar -jnlpUrl \ http://vboxsvr:8080/computer/${slaveNodeName}/slave-agent.jnlp & /sbin/mount.vboxsf -w shared /shared & exit $RETVAL
0 comments:
Post a Comment