Installation/Live Images/USB-Stick for OFW11

From OpenFOAMWiki
< Installation‎ | Live Images
Revision as of 20:38, 17 January 2016 by Wyldckat (Talk | contribs)

WARNING: These instructions are currently being written and under testing!

1 Creating the development machine

In a nutshell:

  1. Install Lubuntu 15.10 in a virtual machine.
  2. Install OpenFOAM 3.0.x, as instructed here: Installation/Linux/OpenFOAM-3.0.x/Ubuntu#Ubuntu_15.10
  3. Install foam-extend 3.2.x, based on the instructions from here: Installation/Linux/foam-extend-3.2/Ubuntu#Ubuntu_15.10
  4. Install swak4Foam, PyFoam and cfMesh for OpenFOAM 3.0.x, since these are already in foam-extend 3.2.x.


2 Creating the USB-Stick

2.1 Reminders

  • sdX refers to the device itself for the USB drive.
  • sdX1 refers to the first partition.
  • You can find the actual device identification if you use the auto-mount feature that Linux Distributions provide to explore the drive's contents. Then run:
    mount

    and the last entry is likely the one related to the USB drive, assuming it's the latest one mounted in the system. For example, it may show this:

    /dev/sdf1 on /media/ofuser/F361-E869 type vfat (rw,nosuid,nodev,relatime,uid=1000,gid=1000,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,showexec,utf8,flush,errors=remount-ro,uhelper=udisks2)

    which means that:

    • /dev/sdf is the drive's device identification path;
    • /dev/sdf1 is the drive's first partition path.


2.2 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:

  1. Switch to root or keep in mind to do the command with sudo.
  2. First of all, unmount the partition that it probably auto-mounted:
    umount /dev/sdX1
  3. 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
  4. Optional - Full clean up of partition:
    dd if=/dev/zero of=/dev/sdX1 bs=512
    1. In another terminal (also as root), tun:
      while killall -USR1 dd; do sleep 30; done
    2. 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.
    3. 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.

    4. Once completed, make sure it's fully written by running:
      sync

      wait until it returns control back to you.

  5. Once complete, then for formatting the partition properly:
    mkfs -t vfat /dev/sdX1


2.3 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.

Steps:

  1. As root (or with sudo), run:
    usb-creator-gtk
  2. Select the ISO for the Lubuntu Live CD/DVD.
  3. 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.
  4. 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.
  5. Finally, click on the "Make Startup Disk" button and wait a while for it to run...


2.3.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 3.2.x:

sudo apt-get install git-core build-essential cmake flex bison zlib1g-dev qt4-dev-tools libqt4-dev libqtwebkit-dev gnuplot gnuplot-x11 \
libreadline-dev libncurses-dev libxt-dev libopenmpi-dev openmpi-bin libboost-system-dev libboost-thread-dev libgmp-dev \
libmpfr-dev python python-dev binutils-dev libiberty-dev rpm mercurial graphviz

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.


2.3.2 Transferring the local installation to the persistent partition file in the drive

Note: These instructions will mount and transfer the files directly to the persistent file in the USB drive, so you might want to not operate directly on this file.

  • If so, copy the file casper-rw to a local disk and roughly follow the steps accordingly with the new path for the file.

Steps:

  1. Mount the stick with the interactive mount that Lubuntu has got from the file manager.
  2. As root (or with sudo), run:
    mkdir /mnt/casper
    mount -t auto /media/$USER/*/casper-rw /mnt/casper/ -o loop
  3. 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 owership:

    mkdir -p /mnt/casper/upper/home/lubuntu/
    chown -R 999:999 /mnt/casper/upper/home/lubuntu/
  4. 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/
  5. Then unmount it:
    umount /mnt/casper
  6. Also unmount the stick:
    umount /dev/sdX1


2.4 Cloning the original stick to a new image

Steps:

  1. Make sure you don't have the stick mounted! Example to umount:
    umount /dev/sdX1
  2. As root (or with sudo), run:
    dd if=/dev/sdX of=OFW11-2016_v2.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
    1. In another terminal (also as root), tun:
    while killall -USR1 dd; do sleep 30; done
    1. 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.
  3. When it's done cloning, make sure the file system is synced:
    sync

    wait until it returns control back to you.

  4. Now you can mount the stick again, if you want. Or simply eject it.


2.5 Cloning the image to a new stick

It's almost the reverse of the previous steps:

  1. Make sure you don't have the stick mounted! Example to umount:
    umount /dev/sdX1
  2. As root (or with sudo), run:
    dd if=OFW11-2016_v2.img of=/dev/sdX bs=512
    1. In another terminal (also as root):
    ps -a
    1. In another terminal (also as root), tun:
    while killall -USR1 dd; do sleep 30; done
    1. 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.
  3. When it's done cloning, make sure the file system is synced:
    sync

    wait until it returns control back to you.

  4. Now you can mount the stick, if you want. Or simply eject it.