Installation/Live Images/USB-Stick for OFW11/Creation Guide
WARNING: These instructions are currently being written and under testing!
Contents
[hide]- 1 Creating the development machine
- 1.1 Installation details
- 1.2 Preparations before copying to final image
- 1.3 Cheat sheet for copying installation to USB-Stick
- 1.3.1 Copying OpenFOAM 3.0.x et al
- 1.3.2 Copying foam-extend 4.0 et al
- 1.3.3 Packing the sandbox to a compressed image
- 1.3.4 Copying the compressed images to the USB-stick
- 1.3.5 Making sure the compressed images are properly used
- 1.3.6 Copying the folders that were not compressed
- 1.3.7 Making the compressed filesystems mounted at start
- 1.3.8 Update the aliases file
- 1.3.9 Create symbolic links for easier navigation
- 1.3.10 Next steps - go back to transferring from-to the USB-stick
- 2 Creating the USB-Stick
- 3 Upgrading an existing USB-stick
1 Creating the development machine
1.1 Installation details
Rough outline of the installation steps, although specifies details are provided at each subsection:
- Install Lubuntu 15.10 x86_64 in a virtual machine.
- Install necessary packages inside virtual machine.
- Install Anaconda bundle of Python 2.7.
- Install OpenFOAM 3.0.x, as instructed here: Installation/Linux/OpenFOAM-3.0.x/Ubuntu#Ubuntu_15.10
- Install foam-extend 4.0, based on the instructions from here: Installation/Linux/foam-extend-3.2/Ubuntu#Ubuntu_15.10
- Install swak4Foam, PyFoam and cfMesh for OpenFOAM 3.0.x and in foam-extend 4.0 (although cfMesh is already integrated into it).
1.1.1 Install Lubuntu 15.10 x86_64 in a virtual machine
TODO
1.1.2 Packages that need to be installed in the development VM
TODO
Part of the software stack:
sudo apt-get install squashfs-tools
All of the packages for OpenFOAM and foam-extend (see next sections), along with the requested software that is listed in section First boot up of the new USB-Stick.
1.1.3 Install Anaconda 4.0.0 with Python 2.7
At the request of one of the instructors for OFW11, we need to install the Anaconda Python 2.7 software bundle. To do so, the following commands were used:
- We'll install it on OpenFOAM's folder, to make it easier to spot it in the crowd of software that is going to be installed:
mkdir ~/OpenFOAM cd OpenFOAM
- Download the Anaconda installer:
wget http://repo.continuum.io/archive/Anaconda2-4.0.0-Linux-x86_64.sh
- To install it, run:
bash Anaconda2-4.0.0-Linux-x86_64.sh -p $PWD/anaconda2
- It will show you the license and ask you to agree to this license.
- And it will ask you if it should prepend the installation path into PATH within .bashrc, to which you can reply no.
- As a note for the OpenFOAM and foam-extend installations, here is the command that will have to be used for loading the respective environment:
export PATH=/home/lubuntu/OpenFOAM/anaconda2/bin:$PATH
- Since we need to install a few more packages, run the previous command line and then run the following commands:
easy_install ipdb easy_install rst2pdf conda install seaborn conda install vtk=5.10.1
- Then we should clean up the downloaded files:
conda clean --tarballs
1.1.4 Install Salome 7.7.1
At the time of this writing, the version was 7.7.1 and the steps for installing it were as follows:
- Download the Universal Binaries package from their download page: Salome Downloads page
- Place the downloaded package inside the folder ~/OpenFOAM and then run in the command line:
cd ~/OpenFOAM chmod +x Salome-V7_7_1-LGPL-x86_64.run ./Salome-V7_7_1-LGPL-x86_64.run -t $PWD/salome
- It will then ask you for the language, to which you can simply press the Enter key.
- Once it's finished installing, we're done for now. We will use an alias for running the following command:
/home/lubuntu/OpenFOAM/salome/appli_V7_7_1/salome
1.1.5 Dakota 6.3
We will take the short-cut and install the binary package, instead of building it from source code. Installation steps:
- Download Dakota 6.3 from here: Dakota Downloads page
- Unpack it within the folder ~/OpenFOAM, e.g.:
cd ~/OpenFOAM tar -xf /Downloads/dakota-6.3-public-Linux.x86_64.tar.gz
- Rename the unpacked folder to dakota:
mv dakota-6.3.0.Linux.x86_64 dakota
- The environment script code to be used within OpenFOAM and foam-extend is as follows:
DAKOTA_INSTALL=$HOME/OpenFOAM/dakota export PATH=$PATH:$DAKOTA_INSTALL/bin:$DAKOTA_INSTALL/test export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$DAKOTA_INSTALL/lib:$DAKOTA_INSTALL/bin
1.1.6 Install HELYX-OS 2.4.0
At the time of this writing, a beta version of 2.4.0 was provided for the USB stick, nonetheless, we'll keep the instructions somewhat general here. Installation steps:
- Download HELYX-OS from the official download page: HELYX-OS project page
- We'll use a circumvention mechanism for the installation, by unpacking directly:
cd ~/OpenFOAM mkdir HELYX-OS PACKAGE=~/Downloads/20160531-Engys-HELYX-OS-2.4.0-linux-x86_64-FULL.bin ARCHIVE=`awk '/^__ARCHIVE_BELOW__/ {print NR + 1; exit 0; }' $PACKAGE` tail -n+$ARCHIVE $PACKAGE | tar -xzv -C HELYX-OS ./20160531-Engys-HELYX-OS-2.4.0-linux-x86_64-GUI.tar.bz2 > /dev/null unset PACKAGE ARCHIVE cd HELYX-OS tar -xf 20160531-Engys-HELYX-OS-2.4.0-linux-x86_64-GUI.tar.bz2 --transform='s_Engys/HELYX-OS__' rm 20160531-Engys-HELYX-OS-2.4.0-linux-x86_64-GUI.tar.bz2
- Launch HELYX-OS, because we need to configure it accordingly to use OpenFOAM 3.0.x:
v2.4.0/HELYX-OS.sh
- It will complain that the "Core" is not installed. Therefore, close that dialogue box and click on the X on the upper right corner of start window. Then click on the menu Edit --> Preferences and configure as follows:
- For the Core Folder, choose this path:
/home/lubuntu/OpenFOAM/OpenFOAM-3.0.x
- For the ParaView Executable, choose this path:
/home/lubuntu/OpenFOAM/ThirdParty-3.0.x/platforms/linux64Gcc/ParaView-4.4.0/bin/paraview
Then you can press the OK button and close HELYX-OS.
- For the Core Folder, choose this path:
- If all goes well, keep in mind to:
- Create an alias:
alias helyxos="$HOME/OpenFOAM/HELYX-OS/v2.4.0/HELYX-OS.sh"
- Copy the file ~/.HELYX-OS/application.properties to the USB-stick.
- Create an alias:
1.1.7 Install OpenFOAM 3.0.x
For the most part, follow the installation instructions given at Installation/Linux/OpenFOAM-3.0.x/Ubuntu, namely in section Ubuntu 14.04.
The changes needed are as follows:
- In step #2 on those other instructions, do not install the following packages:
bison qt4-dev-tools libqt4-dev libqtwebkit-dev python python-dev
because we will be using the Anaconda Python 2.7 bundle, provided by Continuum Analytics, at the request of one of the instructors, which already provides most of these packages (Bison will have to be custom built). At the time of this writing, version Anaconda 4.0.0 was used.
- In step #6 on those other instructions, instead of running:
source $HOME/OpenFOAM/OpenFOAM-3.0.x/etc/bashrc FOAMY_HEX_MESH=yes
run:
echo export FOAMY_HEX_MESH=yes >> OpenFOAM-3.0.x/etc/prefs.sh source $HOME/OpenFOAM/OpenFOAM-3.0.x/etc/bashrc
- Next we need to do a bit of manual file editing, where we need to edit the file OpenFOAM-3.0.x/etc/bashrc and find this line:
_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config/gperftools.sh`
Then add below it the lines needed for Python and PyFoam, namely to make it look like this:
_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config/gperftools.sh` _foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config/Python.sh` _foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config/PyFoam.sh` _foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config/Dakota.sh`
- Then we need to create the aforementioned files, by running the following commands (keep in mind the OpenFOAM environment needs to already be active):
foam echo 'export ANACONDA_PATH=$HOME/OpenFOAM/anaconda2' > etc/config/Python.sh echo 'export PATH=$ANACONDA_PATH/bin:$PATH' >> etc/config/Python.sh echo 'export PYTHONHOME=$ANACONDA_PATH' >> etc/config/Python.sh echo 'export PYTHONPATH=$ANACONDA_PATH/lib/python2.7/site-packages' >> etc/config/Python.sh echo 'export PYFOAM_DIR=$HOME/OpenFOAM/PyFoam' > etc/config/PyFoam.sh echo 'export PYTHONPATH=$PYTHONPATH:$PYFOAM_DIR/lib/python2.7/site-packages/' >> etc/config/PyFoam.sh echo 'export PATH=$PATH:$PYFOAM_DIR/bin' >> etc/config/PyFoam.sh echo 'DAKOTA_INSTALL=$HOME/OpenFOAM/dakota' > etc/config/Dakota.sh echo 'export PATH=$PATH:$DAKOTA_INSTALL/bin:$DAKOTA_INSTALL/test' >> etc/config/Dakota.sh echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$DAKOTA_INSTALL/lib:$DAKOTA_INSTALL/bin' >> etc/config/Dakota.sh echo 'unset DAKOTA_INSTALL' >> etc/config/Dakota.sh
- Keep a mental note that you do not need to run this command:
export QT_SELECT=qt4
because we will be using Anaconda's Qt 4.8.7 build.
- In sub-step #9.2 on those other instructions, we build ParaView with the following commands (we need to make a couple of fixes):
foam3rdParty sed -i -e 's=/usr/include=$ANACONDA_PATH/include=' etc/tools/ParaView4Functions sed -i -e 's=PYTHON_INCLUDE_PATH=PYTHON_INCLUDE_DIR=' etc/tools/ParaView4Functions ./makeParaView4 -python -mpi -python-lib $ANACONDA_PATH/lib/libpython2.7.so.1.0 -qmake $ANACONDA_PATH/bin/qmake > log.makePV 2>&1
1.1.7.1 Install additional contributions for OpenFOAM 3.0.x
1.1.7.1.1 Installing swak4Foam into OpenFOAM 3.0.x
These steps are a rough outline, given that the provided package was still a release candidate. Steps:
- Unpack the provided package swak4Foam-0.4rc.tgz into the folder ~/OpenFOAM/contribs, unpack and rename it accordingly:
cd ~/OpenFOAM/contribs/ tar -xzf swak4Foam-0.4rc.tgz mv swak4Foam-0.4rc swak4Foam
- Now we go into the source code folder and use the same hack as used in foam-extend's AllMake.stage5 for installing on the site folder:
cd swak4Foam find Utilities Libraries -name files | xargs -n 1 sed -i.old "s/FOAM_USER/FOAM_SITE/g" find Utilities Libraries -name options | xargs -n 1 sed -i.old "s/FOAM_USER/FOAM_SITE/g"
- Now we need to configure the settings needed for using Python:
echo 'export SWAK_PYTHON_INCLUDE="-I$PYTHONHOME/include/python2.7"' > swakConfiguration echo 'export SWAK_PYTHON_LINK="-L$PYTHONHOME/lib -lpython2.7"' >> swakConfiguration echo 'export SWAK_COMPILE_GRAMMAR_OPTION="-O1"' >> swakConfiguration
- We need to build Bison:
./maintainanceScripts/compileRequirements.sh
- Now we can build it:
./Allwmake > log.make 2>&1
If you want to built in parallel, run first:
export WM_NCOMPPROCS=4
- Clean up when completed, because we need to rebuild it for foam-extend 4.0:
./Allwclean
1.1.7.1.2 Installing PyFoam into OpenFOAM 3.0.x
At this point, the environment is already defined with the PYFOAM_DIR variable, which will make our life a bit easier. These steps are a rough outline, given that the provided package was still a release candidate. Steps:
- Unpack the provided package pyFoam-0.6.6.rc.tgz into the folder ~/OpenFOAM/contribs, unpack and rename it accordingly:
cd ~/OpenFOAM/contribs/ tar -xzf pyFoam-0.6.6.rc.tgz mv pyFoam-0.6.6.rc/PyFoam PyFoam rmdir pyFoam-0.6.6.rc
- If you've already installed a previous version of PyFoam:
[ -e "$PYFOAM_DIR" ] && rm -rf $PYFOAM_DIR
- Now we can install it:
mkdir -p $PYFOAM_DIR/lib/python2.7/site-packages/ python setup.py install --prefix=$PYFOAM_DIR
1.1.7.1.3 Installing cfMesh into OpenFOAM 3.0.x
Steps, using the source code from the online git repository:
- Go to the work folder and clone the repository:
cd ~/OpenFOAM/contribs/ git clone git://git.code.sf.net/p/cfmesh/code cfMesh
- Now we go into the source code folder and use the same hack as used in foam-extend's AllMake.stage5 for installing cfMesh on the site folder:
cd cfMesh find meshLibrary executables utilities -name files | xargs -n 1 sed -i.old "s/FOAM_USER/FOAM_SITE/g" find meshLibrary executables utilities -name options | xargs -n 1 sed -i.old "s/FOAM_USER/FOAM_SITE/g"
- Now we can build it:
./Allwmake > log.make 2>&1
If you want to built in parallel, run first:
export WM_NCOMPPROCS=4
1.1.8 Install foam-extend 4.0
For the most part, follow the installation instructions given at Installation/Linux/foam-extend-3.2/Ubuntu, namely in section Ubuntu 15.10.
The changes needed are as follows:
- Do not install the following packages:
qt4-dev-tools libqt4-dev python python-dev
because we will be using the Anaconda Python 2.7 bundle, provided by Continuum Analytics, at the request of one of the instructors, which already provides most of these packages (Bison will have to be custom built). At the time of this writing, version Anaconda 4.0.0 was used.
- Use the following commands to clone the repository:
cd ~ mkdir foam cd foam git clone git://git.code.sf.net/p/foam-extend/foam-extend-3.2 -b nextRelease foam-extend-4.0
- Next we need to do a bit of manual file editing, where we need to edit the file foam-extend-4.0/etc/bashrc and find this line:
# _foamSource $WM_PROJECT_DIR/etc/apps/ensight/bashrc
Then add below it the lines needed for Python and PyFoam, namely to make it look like this:
# _foamSource $WM_PROJECT_DIR/etc/apps/ensight/bashrc _foamSource $WM_PROJECT_DIR/etc/Python.sh _foamSource $WM_PROJECT_DIR/etc/PyFoam.sh _foamSource $WM_PROJECT_DIR/etc/Dakota.sh
- Then we need to create the aforementioned files, by running the following commands (keep in mind the foam-extend environment needs to already be active):
foam echo 'export ANACONDA_PATH=$HOME/OpenFOAM/anaconda2' > etc/Python.sh echo 'export PATH=$ANACONDA_PATH/bin:$PATH' >> etc/Python.sh echo 'export PYTHONHOME=$ANACONDA_PATH' >> etc/Python.sh echo 'export PYTHONPATH=$ANACONDA_PATH/lib/python2.7/site-packages' >> etc/Python.sh echo 'export CMAKE_INCLUDE_PATH=$ANACONDA_PATH/include' >> etc/Python.sh echo 'export CMAKE_LIBRARY_PATH=$ANACONDA_PATH/lib' >> etc/Python.sh echo 'export QT_BIN_DIR=$ANACONDA_PATH/bin/' >> etc/Python.sh echo 'export PYFOAM_DIR=$HOME/OpenFOAM/PyFoam' > etc/PyFoam.sh echo 'export PYTHONPATH=$PYTHONPATH:$PYFOAM_DIR/lib/python2.7/site-packages/' >> etc/PyFoam.sh echo 'export PATH=$PATH:$PYFOAM_DIR/bin' >> etc/PyFoam.sh echo 'DAKOTA_INSTALL=$HOME/OpenFOAM/dakota' > etc/Dakota.sh echo 'export PATH=$PATH:$DAKOTA_INSTALL/bin:$DAKOTA_INSTALL/test' >> etc/Dakota.sh echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$DAKOTA_INSTALL/lib:$DAKOTA_INSTALL/bin' >> etc/Dakota.sh echo 'unset DAKOTA_INSTALL' >> etc/Dakota.sh
- Need to disable the defaults for using custom CMake and Open-MPI:
sed -i -e 's=\(export WM_THIRD_PARTY_USE_CMAKE_322\)=#\1=' etc/bashrc sed -i -e 's=\(export WM_THIRD_PARTY_USE_OPENMPI_165\)=#\1=' etc/bashrc
- The following has to the prefs.sh file (you should already be inside the folder foam-extend-4.0 for this):
echo 'export WM_THIRD_PARTY_USE_BISON_27=1' > etc/prefs.sh echo 'export PYFOAM_SYSTEM=1' >> etc/prefs.sh echo 'export CMAKE_SYSTEM=1' >> etc/prefs.sh echo 'export WM_MPLIB=SYSTEMOPENMPI' >> etc/prefs.sh source $HOME/foam/foam-extend-4.0/etc/bashrc
- Now, to build foam-extend 4.0, we will use the following commands:
# wmake is required for subsequent targets ( cd wmake/src && make ) # build ThirdParty sources ( cd $WM_THIRD_PARTY_DIR && ./AllMake.pre ) > log.ThirdParty 2>&1 # We make sure the ThirdParty packages environment variables are up-to-date # before compiling the rest of OpenFOAM . $WM_PROJECT_DIR/etc/bashrc # build OpenFOAM libraries and applications ./Allwmake > log.make 2>&1
1.1.8.1 Install additional contributions for foam-extend 4.0
cfMesh is already integrated into foam-extend and PyFoam is the same as the one in OpenFOAM 3.0.x.
1.1.8.1.1 Installing swak4Foam into foam-extend 4.0
These steps assume you've already followed the steps at Installing swak4Foam into OpenFOAM 3.0.x. Steps:
- Now we go into the source code folder:
cd ~/OpenFOAM/contribs/swak4Foam
- Now we can build it:
./Allwmake > log.make 2>&1
If you want to built in parallel, run first:
export WM_NCOMPPROCS=4
- Clean up when completed, because we might need to rebuild it for something else:
./Allwclean
1.1.8.1.2 Installing FSI toolkit into foam-extend 4.0
The instructions for FSI toolkit will be available at Extend-bazaar/Toolkits/Fluid-structure_interaction after the time of this writing. These steps are a rough outline, given that the provided package was still a release candidate. Steps:
- Unpack the provided package Fsi_40.tgz into the folder ~/foam/contribs, unpack and rename it accordingly:
mkdir -p ~/foam/contribs/ tar -xzf Fsi_40.tgz
- Now we go into the source code folder and use the same hack as used in foam-extend's AllMake.stage5 for installing on the site folder:
cd FluidSolidInteraction find src -name files | xargs -n 1 sed -i.old "s/FOAM_USER/FOAM_SITE/g" find src -name options | xargs -n 1 sed -i.old "s/FOAM_USER/FOAM_SITE/g" find src/{solvers,utilities} -name options | xargs -n 1 sed -i.old "s/\(\-lfluidSolidInteraction\)/-L\$(FOAM_SITE_LIBBIN) \1/" find src/fluidSolidInteraction -type f -name "*.C" | xargs -n 1 sed -i.old 's=lduSolverPerformance::debug=blockLduMatrix::debug='
- Now we can build it:
./Allwmake > log.make 2>&1
If you want to built in parallel, run first:
export WM_NCOMPPROCS=4
- Clean up when completed, because we might need to rebuild it in a later update (and for saving some disk space):
./Allwclean
1.2 Preparations before copying to final image
This is a cheat sheet on the commands needed for cleaning up each installation before copying to the USB-Stick:
1.2.1 Clean up OpenFOAM 3.0.x et al
of30x foam3rdParty rm -r build rm log.* rm *.log
1.2.2 Clean up foam-extend 4.0 et al
fe40 foam rm log.*
1.2.3 Set-up the correct user IDs for 3rd party folders
This is for saving up space and time when packaging Anaconda, Salome and others:
cd ~/OpenFOAM sudo chown -R 999:999 salome sudo chown -R 999:999 anaconda2 sudo chown -R 999:999 dakota sudo chown -R 999:999 HELYX-OS sudo chown -R 999:999 PyFoam
1.3 Cheat sheet for copying installation to USB-Stick
Notes:
- This is meant to be used mid-way of the instructions from sub-section Transferring the local installation to the persistent partition file in the drive.
First of all, create our sandbox folder:
mkdir ~/sandbox
And if this isn't the first time copying, run:
sudo chown -R $USER:$USER ~/sandbox
1.3.1 Copying OpenFOAM 3.0.x et al
In a new terminal, run:
of30x cd ~/OpenFOAM TARGET=~/sandbox/OpenFOAM mkdir $TARGET/ rsync -a site/ $TARGET/site/ rsync -a OpenFOAM-3.0.x/ $TARGET/OpenFOAM-3.0.x/ rsync -a ThirdParty-3.0.x/ $TARGET/ThirdParty-3.0.x/ cd $TARGET/OpenFOAM-3.0.x/ rm -r platforms/linux64GccDPInt32OptSYSTEMOPENMPI/ rm -r platforms/linux64GccDPInt32Opt/{src,applications} cd $TARGET/ThirdParty-3.0.x/ rm -r CGAL-4.7/ ParaView-4.4.0/ scotch_6.0.3/ rm -r download
1.3.2 Copying foam-extend 4.0 et al
In a new terminal, run:
fe40 cd ~/foam TARGET=~/sandbox/foam mkdir $TARGET/ rsync -a site/ $TARGET/site/ rsync -a foam-extend-4.0/ $TARGET/foam-extend-4.0/ cd $TARGET/foam-extend-4.0/ find applications/{solvers,utilities} src -name "$WM_OPTIONS" | xargs rm -r rm -r ThirdParty/rpmBuild/{BUILD*,TGZS,RPMS,rpmDB}/* ThirdParty/rpmBuild/SOURCES/*.tar.gz find applications src -name "*.dep" | xargs rm rm log.*
1.3.3 Packing the sandbox to a compressed image
Given that the final installation well over 3 GiB, therefore we need to save up space by relying on squashfs to get the whole thing trimmed down to something more manageable (for more details, see this page).
But first, we must change the ownership of the contents:
sudo chown -R 999:999 ~/sandbox/OpenFOAM/OpenFOAM-3.0.x sudo chown -R 999:999 ~/sandbox/OpenFOAM/ThirdParty-3.0.x sudo chown -R 999:999 ~/sandbox/OpenFOAM/site sudo chown -R 999:999 ~/sandbox/foam/foam-extend-4.0 sudo chown -R 999:999 ~/sandbox/foam/site
To do so, run:
sudo mksquashfs ~/sandbox/OpenFOAM/OpenFOAM-3.0.x ~/sandbox/OpenFOAM-3.0.x.sqfs sudo mksquashfs ~/sandbox/OpenFOAM/ThirdParty-3.0.x ~/sandbox/ThirdParty-3.0.x.sqfs sudo mksquashfs ~/sandbox/OpenFOAM/site ~/sandbox/OpenFOAM-site-3.0.x.sqfs sudo mksquashfs ~/OpenFOAM/anaconda2 ~/sandbox/anaconda2.sqfs sudo mksquashfs ~/OpenFOAM/salome ~/sandbox/salome.sqfs sudo mksquashfs ~/OpenFOAM/dakota ~/sandbox/dakota.sqfs sudo mksquashfs ~/OpenFOAM/HELYX-OS ~/sandbox/HELYX-OS.sqfs sudo mksquashfs ~/OpenFOAM/PyFoam ~/sandbox/PyFoam.sqfs sudo mksquashfs ~/sandbox/foam/foam-extend-4.0 ~/sandbox/foam-extend-4.0.sqfs sudo mksquashfs ~/sandbox/foam/site ~/sandbox/foam-extend-site-4.0.sqfs
- Note: If this isn't the first time you are running these commands, then run before the commands above:
sudo rm ~/sandbox/*.sqfs
Check the final size of the files, just in case:
ls -l -h ~/sandbox/*.sqfs
1.3.4 Copying the compressed images to the USB-stick
It's simply this:
rsync -a -v --progress ~/sandbox/*.sqfs /media/$USER/OFW11/
1.3.5 Making sure the compressed images are properly used
In a new terminal, run:
cd /mnt/casper/upper/home/lubuntu/
Create the place-holder folders and symbolic links which will link into the original folders:
mkdir -p OpenFOAM/OpenFOAM-3.0.x mkdir -p OpenFOAM/ThirdParty-3.0.x mkdir -p OpenFOAM/site mkdir -p OpenFOAM/anaconda2 mkdir -p OpenFOAM/salome mkdir -p OpenFOAM/dakota mkdir -p OpenFOAM/HELYX-OS mkdir -p OpenFOAM/PyFoam mkdir -p foam/foam-extend-4.0 mkdir -p foam/site
1.3.6 Copying the folders that were not compressed
Simply run:
rsync -a ~/.HELYX-OS/ /mnt/casper/upper/home/lubuntu/.HELYX-OS/
1.3.7 Making the compressed filesystems mounted at start
Edit the rc.local file:
sudo nano /mnt/casper/upper/etc/rc.local
Place the following inside the file:
#!/bin/sh -e # # rc.local # # This script is executed at the end of each multiuser runlevel. # Make sure that the script will "exit 0" on success or any other # value on error. # # In order to enable or disable this script just change the execution # bits. # # By default this script does nothing. mount /cdrom/OpenFOAM-3.0.x.sqfs /home/lubuntu/OpenFOAM/OpenFOAM-3.0.x -t squashfs -o loop,ro mount /cdrom/ThirdParty-3.0.x.sqfs /home/lubuntu/OpenFOAM/ThirdParty-3.0.x -t squashfs -o loop,ro mount /cdrom/OpenFOAM-site-3.0.x.sqfs /home/lubuntu/OpenFOAM/site -t squashfs -o loop,ro mount /cdrom/anaconda2.sqfs /home/lubuntu/OpenFOAM/anaconda2 -t squashfs -o loop,ro mount /cdrom/salome.sqfs /home/lubuntu/OpenFOAM/salome -t squashfs -o loop,ro mount /cdrom/dakota.sqfs /home/lubuntu/OpenFOAM/dakota -t squashfs -o loop,ro mount /cdrom/HELYX-OS.sqfs /home/lubuntu/OpenFOAM/HELYX-OS -t squashfs -o loop,ro mount /cdrom/PyFoam.sqfs /home/lubuntu/OpenFOAM/PyFoam -t squashfs -o loop,ro mount /cdrom/foam-extend-4.0.sqfs /home/lubuntu/foam/foam-extend-4.0 -t squashfs -o loop,ro mount /cdrom/foam-extend-site-4.0.sqfs /home/lubuntu/foam/site -t squashfs -o loop,ro exit 0
Save and close, by using the key combination Ctrl+X and then hit the Y key separately.
Finally, make the script executable:
sudo chmod +x /mnt/casper/upper/etc/rc.local
1.3.8 Update the aliases file
Edit the .bash_aliases on the persistent mounted folder:
nano /mnt/casper/upper/home/lubuntu/.bash_aliases
And place the following code inside it:
alias of30x='source $HOME/OpenFOAM/OpenFOAM-3.0.x/etc/bashrc ; export PS1="(OF:\$WM_PROJECT_VERSION) $PS1"' alias fe40='source $HOME/foam/foam-extend-4.0/etc/bashrc ; export PS1="(FE:\$WM_PROJECT_VERSION) $PS1"' alias salome='/home/lubuntu/OpenFOAM/salome/appli_V7_7_1/salome' alias helyxos='$HOME/OpenFOAM/HELYX-OS/v2.4.0/HELYX-OS.sh' echo echo "Whenever you start a new terminal, you can activate a specific environment, by running only one of the following commands:" echo " For OpenFOAM 3.0.x, run: of30x" echo " For foam-extend 4.0, run: fe40" echo
Save and close, by using the key combination Ctrl+X and then hit the Y key separately.
Create a few symbolic links for easier navigation:
ln -s /cdrom/Training /mnt/casper/upper/home/lubuntu/Training ln -s /cdrom/Training /mnt/casper/upper/home/lubuntu/Desktop/Training ln -s /cdrom /mnt/casper/upper/home/lubuntu/USB-stick-root
1.3.10 Next steps - go back to transferring from-to the USB-stick
Now you can continue where you left off at section Transferring the local installation to the persistent partition file in the drive.
2 Creating the USB-Stick
Please keep in mind the description given here: Reminders
2.1 Commands for formatting USB-Stick drive
These steps are dedicated for creating a stick drive with a partition size that should fit all 8GB USB drives, including those that lie about their total size, such as those that really only have around 7,750,000,000 bytes. The following instructions aim for a primary partition of 7,654,604,800 bytes.
Steps:
- Switch to root or keep in mind to do the command with sudo.
- First of all, unmount the partition that it probably auto-mounted:
umount /dev/sdX1
- For creating the partition:
fdisk /dev/sdX d #delete o #create DOC partition table c #toggle DOS compatibility #should show: # DOS Compatibility flag is set (DEPRECATED!) n #new partition p #new partition 1 #partition 1 62 #first sector +7300M #end sector, as size in MB t #change type c #change to W95 FAT32 (LBA) a #make it bootable p #prints current table on screen make a note of the shown values, because you're going to need the End sector number w #write partition table
- Note
- Make sure you have the units in sectors:
u # use as many times as possible until it shows #Changing display/entry units to sectors
- Optional - Full clean up of partition:
dd if=/dev/zero of=/dev/sdX1 bs=512
- In another terminal (also as root), tun:
while killall -USR1 dd; do sleep 30; done
- Then look at the previous terminal window and every 30 seconds it should update on the current write status. Given how this command works, if you have more than one dd running, it will update for all running dd applications.
- It will probably end with the message:
dd: error writing '/dev/sdX1': No space left on device
because we didn't define the total number of bytes/blocks to write.
- Once completed, make sure it's fully written by running:
sync
wait until it returns control back to you.
- In another terminal (also as root), tun:
- Once complete, then for formatting the partition properly:
mkfs -t vfat -n OFW11 /dev/sdX1
2.2 Creating the live USB
Tested with Lubuntu 15.10 x86_64.
Need to have usb-creator-gtk installed and we will be using Lubuntu 64-bit as the basis for our stick drives. In addition, it's advisable to do these steps from a working installation of the desired Lubuntu version, even if it's within a virtual machine.
- Warning
- There is a critical bug in syslinux that is provided in Ubuntu 15.10, as reported here. The work around is to run the following commands:
cd wget http://launchpadlibrarian.net/200593067/syslinux_6.03+dfsg-5ubuntu1_amd64.deb wget http://launchpadlibrarian.net/200593072/syslinux-common_6.03+dfsg-5ubuntu1_all.deb sudo dpkg -i syslinux-common_6.03+dfsg-5ubuntu1_all.deb syslinux_6.03+dfsg-5ubuntu1_amd64.deb
- The Deb packages came from here and here.
- The following hack is optional, but advisable, if you don't want to have to do the last fix on the steps below every time you need to do another live USB:
sudo sed -i -e 's=\(if len(target_mounts) > 0:\)=if False: #\1=' /usr/share/usb-creator/usb-creator-helper
As this will disable the auto-mount-and-get-damaged-syslinux-from-casper.
Steps:
- As root (or with sudo), run:
usb-creator-gtk
- Select the ISO for the Lubuntu Live CD/DVD.
- Select the stick drive you want as the target for the Live USB.
- Note: Do not use the erase function, otherwise you will loose the correct booting mechanism that was created with fdisk and mkfs.
- Select the largest possible "Stored in reserved extra space", at least taking into account how much will be left over for the read-anywhere files, such as presentations and VM installers.
- For example:
- 690 MiB for the cloned Live CD
- 1.0 GiB for the read-anywhere data.
- 7.1 GiB - 1.0 GiB - 690 MiB = 5.42 GiB = 5556.4 MiB... which is larger than 4GiB, the file size limit for FAT32 partitions.
Finally, click on the "Make Startup Disk" button and wait a while for it to run...
When it's finally completed, we need to do some additional fixing:
- For example:
- Unmount the stick:
umount /dev/sdX1
- If you didn't do the hack for /usr/share/usb-creator/usb-creator-helper, then you'll need to redeploy the syslinux and MBR:
sudo syslinux -f /dev/sdX1 sudo dd if=/usr/lib/syslinux/mbr/mbr.bin of=/dev/sdX bs=446 count=1 conv=sync sudo sync
- Now interactively mount the USB-stick again and then you can finally unmount+eject interactively.
2.2.1 First boot up of the new USB-Stick
After booting up the USB-Stick in a real machine or virtual machine, install the necessary packages, with the following commands:
sudo apt-get update sudo apt-get install virtualbox-guest-utils virtualbox-guest-dkms
which will install the necessary guest additions for Virtualbox to be usable in case the USB-stick doesn't boot directly in the real machine.
Then continue to install the necessary packages for OpenFOAM 3.0.x and foam-extend 4.0:
sudo apt-get install git-core gitk build-essential cmake flex zlib1g-dev gnuplot gnuplot-x11 \ libreadline-dev libncurses-dev libxt-dev libopenmpi-dev openmpi-bin libboost-system-dev libboost-thread-dev libgmp-dev \ libmpfr-dev binutils-dev libiberty-dev rpm mercurial graphviz
As well as the requested software and necessary dependencies for them:
sudo apt-get install kompare emacs24 imagemagick openscad libmotif4 liblapack3
Now proceed with cleaning up the downloaded Deb files:
sudo apt-get clean sudo apt-get autoclean
Then change the desktop image, by right clicking on the desktop and choosing Desktop Preferences. Make sure you download the image from the Workshop website and place it in the folder /home/lubuntu/Images.
For adding a link to the LX terminal (as shown in the image to the right):
- Right click on the tool-bar at bottom and choose Add / Remove Panel Items.
- Click on the first occurrence of Application Launch Bar.
- Click on the button Preferences.
- In the new window Application Launch Bar, in the Installed Applications, browse into System Tools and pick LXTerminal.
- Click on the + Add button.
- Finally, click on the Close buttons for each one of the opened windows.
Similarly to the previous steps, we need to add the Keyboard Layout Handler to the main panel:
- Right click on the tool-bar at bottom and choose Add / Remove Panel Items.
- Click on the button + Add.
- In the new window, look for and select Keyboard Layout Handler and click on the + Add button.
- On the previous window, click on the Keyboard Layout Handler at the bottom of the list.
- Click on the Up button twice, so that it is placed above of the Digital Clock.
- Finally, click on the Close button.
You can also add the LXTerminal icon to the desktop environment, by right clicking in the System Tools -> LXTerminal icon at the LXDE main menu (start menu).
Finally, we need to add the standard lubuntu user to the group for virtual box share folders, to ensure that shared folders can work:
sudo usermod -aG vboxsf lubuntu
2.2.2 Transferring the local installation to the persistent partition file in the drive
Steps:
- Mount the stick with the interactive mount that Lubuntu has got from the file manager.
- Copy the image file to the home folder. This file will contain the persistent installation on the USB-stick, which is why it's best to first copy to your system, so that's quicker in storing several thousands of files inside it:
rsync -a -v --progress /media/$USER/OFW11/casper-rw ~/sandbox/casper-rw
- As root (or with sudo), run:
mkdir /mnt/casper mount -t auto ~/sandbox/casper-rw /mnt/casper/ -o loop
- The persistent home folder will now be located at /mnt/casper/upper/home/lubuntu/:
cd /mnt/casper/upper/home/lubuntu/
If it doesn't exist, then create it and change ownership:
mkdir -p /mnt/casper/upper/home/lubuntu/ chown -R $USER:$USER /mnt/casper/upper/home/lubuntu/
- Copy the files you have on the sandbox folder into the designated folder, as explained in section Cheat sheet for copying installation to USB-Stick.
- When you're done copying files to the image, make sure the persistent home folder has the correct owner permissions:
chown -R 999:999 /mnt/casper/upper/home/lubuntu/
- Then unmount it:
umount /mnt/casper
- Then copy the casper-rw file back to the USB-stick:
rm /media/$USER/OFW11/casper-rw rsync -a -v --progress ~/sandbox/casper-rw /media/$USER/OFW11/
- Finally, unmount the stick:
umount /dev/sdX1
2.2.3 Creating the bootable ISO for the virtual machine
References:
- Install the package genisoimage in your Lubuntu development system:
sudo apt-get install genisoimage
- Mount the USB-stick.
- Create a folder where you will place all files that will go into the ISO file. For example:
mkdir ISOroot
- Copy the folders syslinux and install from the USB-stick, into the folder ISOroot, so that you get this folder structure:
ISOroot |-- install |-- syslinux
- Copy the boot files into the folder syslinux, for example:
cp /media/$USER/OFW11/casper/{vmlinuz.efi,initrd.lz} ISOroot/syslinux/
- Edit the file ISOroot/syslinux/txt.cfg and change it to this:
default live label live menu label ^Try Lubuntu without installing kernel /syslinux/vmlinuz.efi append noprompt cdrom-detect/try-usb=true persistent file=/cdrom/preseed/lubuntu.seed boot=casper initrd=/syslinux/initrd.lz quiet splash --- label live-install menu label ^Install Lubuntu kernel /syslinux/vmlinuz.efi append noprompt cdrom-detect/try-usb=true persistent file=/cdrom/preseed/lubuntu.seed boot=casper only-ubiquity initrd=/syslinux/initrd.lz quiet splash --- label check menu label ^Check disc for defects kernel /syslinux/vmlinuz.efi append noprompt boot=casper integrity-check initrd=/syslinux/initrd.lz quiet splash --- label memtest menu label Test ^memory kernel /install/mt86plus label hd menu label ^Boot from first hard disk localboot 0x80
Essentially you will be changing the paths that state /casper/ to /syslinux/.
- Create the ISO file by running the following command from the parent folder where ISOroot is located:
mkisofs -o VMbootUSB.iso -b syslinux/isolinux.bin -c syslinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table ISOroot
- The final image file VMbootUSB.iso is what we will need to boot the USB-stick inside the virtual machine.
2.2.4 Creating the virtual machine in Virtualbox
Keep in mind that these steps are only needed for creating the virtual machine to be placed inside the USB-stick. Nonetheless, it might be useful in case the exported OVA file is incompatible.
References:
Side notes:
- On Ubuntu, had to install the necessary packages for getting the USB2/3 drivers for Virtualbox on the host side (the real machine):
sudo apt-get install virtualbox-ext-pack
And then run the following command for adding my user to the group vboxusers:
sudo usermod -aG vboxusers $USER
Then I had to log out and then log back in, otherwise it's not possible to use a real USB drive in a virtual machine within Virtualbox.
Steps:
- Simply create a new Virtual Machine in Virtualbox, meant for a Ubuntu 64-bit machine and without any disks, because we will boot straight from the USB drive.
- After the virtual machine is created, edit its settings and:
- increase the RAM to at least 2048MB;
- change from 1 to 2 virtual cores;
- choose for the optical drive to use the VMbootUSB.iso;
- probably best to turn off audio capabilities;
- in the USB section, choose USB 3.0 or 2.0 controller, depending on what kind of USB-stick you're using;
- still in the USB section, click on the button that adds a new USB device and choose your USB-stick.
- Boot up the VM and test it.
- If it works fine, do a standard shutdown within the virtual machine.
- Then use on the main menu for the Virtualbox the item File -> Export Appliance... to export the virtual machine to a settings file to be placed inside the USB-stick, preferably with the file name OFW11USBVM.ova.
- Best to place both the OFW11USBVM.ova and VMbootUSB.iso files inside the folder VM in the real USB-stick partition (i.e. not inside the booted up Live Lubuntu).
2.2.5 Adding auxiliary third-party software
The objective is to make the USB-stick as self-sufficient as possible, at least on Windows and Mac OS X, given that it seems redundant to install OpenFOAM inside a virtual machine within a Linux Distribution, given that OpenFOAM and foam-extend can be built without any problems on most Linux Distributions.
- First create the folder ThirdParty in main real partition of the USB-disk.
- Place the following files inside the new folder:
- VirtualBox installer for Windows (downloadable from here).
- VirtualBox installer for Mac OS X (downloadable from here).
- Browse and save the VitualBox User Guide: VirtualBox.com -> Documentation -> PDF version - Make sure to save the PDF file as VirtualBox-UserManual.pdf.
- Create the sub-folder VirtualBoxExtensionPack and add the following files:
- The VirtualBox Oracle VM VirtualBox Extension Pack file, which has the file extension .vbox-extpack.
- Browse and save the PUEL license page: VirtualBox Personal Use and Evaluation License (PUEL)
- Browse and save the FAQ about licensing: Licensing: Frequently Asked Questions
2.3 Cloning the original stick to a new image
Steps:
- Make sure you don't have the stick mounted! Example to umount:
umount /dev/sdX1
- As root (or with sudo), run:
dd if=/dev/sdX of=OFW11-2016_v5.img bs=512 count=14950463
- The value "14950463" is the End sector count 14950462 plus 1.
- 14950463 sector * 512 B/sector = 7654636544 B = 7654636544 ~= 7300 MiB
In the meantime, while it's copying:
- In another terminal (also as root), run:
while killall -USR1 dd; do sleep 30; done
- Then look at the previous terminal window and every 30 seconds it should update on the current write status. Given how this command works, if you have more than one dd running, it will update for all running dd applications.
- When it's done cloning, make sure the file system is synced:
sync
wait until it returns control back to you.
- Now you can mount the stick again, if you want. Or simply eject it.
3 Upgrading an existing USB-stick
Thanks to how the disk set-up is organized, we can easily do relative updates to the USB stick contents by updating only the packages we need, without the need to recreating the whole disk. The following two sections address the creation and deployment of an update.
3.1 Creating an upgrade iteration package
One example is the iteration done after image v4 was already deployed into the USB sticks and we had additional updates to the USB stick. The changes made were in the Training folder and the squash image files for foam-extend 4.0. The steps taken:
- We have 3 folders:
- USB-stick-structure_v4 - which has the folders ThirdParty and Training from the v4 image.
- USB-stick-structure_v5 - which has the folders ThirdParty and Training meant for the v5 image.
- upgrade_USB_v4_to_v5 - has the new squash files foam-extend-4.0.sqfs and foam-extend-site-4.0.sqfs for the v5 image and it will have the updated training material as well.
- To get a the updated training files into the difference file, we used the following command, executed at the base folder where all 3 sub-folders are present:
rsync -crv --progress USB-stick-structure_v5/ --compare-dest=$PWD/USB-stick-structure_v4/ upgrade_USB_v4_to_v5/
- To remove the empty folders that were created with the previous command:
find upgrade_USB_v4_to_v5/ -type d -empty -delete
- Finally, create a nice package that can be sent to the team handling the deployments to the USB sticks:
7z a upgrade_USB_v4_to_v5.zip upgrade_USB_v4_to_v5
3.2 Deploying an upgrade iteration package
On the deployment side, the steps should be fairly simple:
- Download the upgrade package file upgrade_USB_v4_to_v5.zip, from the link provided at the Download page, section Upgrade package v4 to v5.
- Place it in a convenient location, such as the Desktop folder or Download folder.
- Unzip it, either interactively or by using the following command line:
unzip upgrade_USB_v4_to_v5.zip
- Go into the unpacked folder:
cd upgrade_USB_v4_to_v5
- Now, for each stick, we can either use drag and drop or we can use a few commands to copy the files to each USB stick, namely:
- The next step will use rsync, which will make intermediate copies, for which the USB-stick will unlikely have enough space. Therefore, we must first delete the squash files that will be updated, e.g.:
rm /media/$USER/OFW11/{foam-extend-4.0.sqfs,foam-extend-site-4.0.sqfs}
- Next, we can copy the files:
rsync -av --progress ./ /media/$USER/OFW11/
- Finally, let's use sync to ensure that the USB-stick is fully updated:
sudo sync
- Now you can safely eject the USB-stick (interactively, no command available for this one).
- The next step will use rsync, which will make intermediate copies, for which the USB-stick will unlikely have enough space. Therefore, we must first delete the squash files that will be updated, e.g.:
3.3 Deploying within the virtual machine
This is meant to be done within the virtual machine appliance, not exactly meant to be done with the virtualization of the physical USB-stick, but it can also be done like that. The idea is that the package has to either be brought in via SSH or downloaded directly from within the virtual machine, because the likelihood of this working with drag and drop is very small.
Steps:
- Download the upgrade package file upgrade_USB_v4_to_v5.zip, from the link provided at the Download page, section Upgrade package v4 to v5.
- Place it in a convenient location, such as the Desktop folder or Download folder.
- Unzip it, either interactively or by using the following command line:
unzip upgrade_USB_v4_to_v5.zip
- Go into the unpacked folder:
cd upgrade_USB_v4_to_v5
- Next we need to unmount the two squash images:
sudo umount /home/lubuntu/foam/foam-extend-4.0 ; sudo umount /home/lubuntu/foam/site
- The next step will use rsync, which will make intermediate copies, for which the USB-stick will unlikely have enough space. Therefore, we must first delete the squash files that will be updated:
sudo rm /cdrom/{foam-extend-4.0.sqfs,foam-extend-site-4.0.sqfs}
- Next, we can copy the files:
sudo rsync -av --progress ./ /cdrom/
- Now we can mount again the two squash images:
- The main image:
sudo mount /cdrom/foam-extend-4.0.sqfs /home/lubuntu/foam/foam-extend-4.0 -t squashfs -o loop,ro
- The site image:
sudo mount /cdrom/foam-extend-site-4.0.sqfs /home/lubuntu/foam/site -t squashfs -o loop,ro
- The main image: