Saturday, December 31, 2016

How to create bootable PIXEL USB stick for Mac

The Debian+PIXEL is for x86 platforms. The PIXEL ISO, which is a 1.3GB download.


The latest RASPBERRY PI DESKTOP image is DEBIAN STRETCH (add nomodeset in enterprise.cfg) https://downloads.raspberrypi.org/rpd_x86/images/rpd_x86-2017-12-01/2017-11-16-rpd-x86-stretch.iso

Reference : Fixing booting of the x86 image on Macs

Instructions to create EFI bootable USB stick for Mac. (tested working on my old MacBook Air 11-inch, Late 2010, Intel Core 2 Duo)

shell script    Select all
And here are the instructions to create EFI bootable USB stick on Mac # Running on Mac # list disk volumes diskutil list # assume format USB stick (64G) on /dev/disk1 with 2 partitions 8g and remaining 55g respectively # if for 32G USB stick, the 2 partition sizes can be divided into 4g and remaining 27g respectively sudo diskutil partitionDisk /dev/disk1 MBRFormat FAT32 LINUX 8g FAT32 PERSISTENCE 0b # for older Mac OSX 10.6, the partition type is "MS-DOS FAT32" # sudo diskutil partitionDisk /dev/disk1 MBRFormat "MS-DOS FAT32" LINUX 8g "MS-DOS FAT32" PERSISTENCE 0b mkdir -p /Volumes/LINUX/efi/boot # Download Enterprise-0.4.0.tar.gz to ~/Download # from https://github.com/SevenBits/Enterprise/releases cd ~/Downloads curl -OL https://github.com/SevenBits/Enterprise/releases/download/v0.4.0/Enterprise-0.4.0.tar.gz tar xzvf Enterprise-0.4.0.tar.gz cp ~/Downloads/Enterprise-0.4.0/*.efi /Volumes/LINUX/efi/boot/ cp ~/Downloads/2016-12-13-pixel-x86-jessie.iso /Volumes/LINUX/efi/boot/boot.iso # create enterprise.cfg cat > /Volumes/LINUX/efi/boot/enterprise.cfg << EOF autoboot 0 entry Debian family Debian initrd /live/initrd1.img kernel /live/vmlinuz1 findiso=/efi/boot/boot.iso boot=live config live-config quiet splash EOF # umount disk sudo diskutil unmountDisk disk1 # Reboot Mac and press Option key on restart and select EFI Boot for boot menu # Running on Debian PIXEL sudo fdisk -l #assume /dev/sdb is the USB stick sudo fdisk /dev/sdb # (d) (2) to delete partition 2 # and then (n) (p) (2) to recreate primary partition 2 for Linux in fdisk # (w) to write to partition table and quit fdisk # Reboot to let partition table effective # Running on Debian PIXEL # unmount /dev/sdb2 sudo umount /dev/sdb2 # format and label /dev/sdb2 sudo mkfs.ext4 -L persistence /dev/sdb2 # rename /dev/sdb2 if manually # sudo e2label /dev/sdb2 "persistence" # create persistence.conf sudo mkdir -p /mnt/persistence sudo mount -t ext4 /dev/sdb2 /mnt/persistence echo / union | sudo tee /mnt/persistence/persistence.conf #unmount /dev/sdb2 sudo umount /dev/sdb2 # Reboot # Running on Mac # recreate enterprise.cfg with persistence cat > /Volumes/LINUX/efi/boot/enterprise.cfg << EOF autoboot 0 entry Debian family Debian initrd /live/initrd1.img kernel /live/vmlinuz1 findiso=/efi/boot/boot.iso boot=live config live-config quiet splash persistence EOF # Reboot and Running on Debian PIXEL to verify the persistence mounting df -h


Additional configurations or installation for PIXEL using Terminal
shell script    Select all
# username of this image is pi # password is raspberry #keyboard configuration #Preferences -> Mouse and Keyboard Settings -> Keyboard -> Keyboard Layout... sudo dpkg-reconfigure keyboard-configuration #reload the keymap (need reboot to be effective) sudo invoke-rc.d keyboard-setup start #reset timezone sudo dpkg-reconfigure tzdata #generate locale sudo dpkg-reconfigure locales sudo locale-gen en_US.UTF-8 # requires reboot sudo update-locale LC_ALL="en_US.UTF-8" #scan private hidden SSID network sudo iwlist wlan0 scanning essid "yourSSID" # then edit /etc/wpa_supplicant/wpa_supplicant.conf and add scan_ssid=1 in the network block for auto scan #reset wireless interface sudo ifdown wlan0 sudo ifup wlan0 # or sudo service network-manager restart # For Buster or above sudo vi /etc/network/interfaces.d/wlan0 wpa-scan-ssid 1 wpa-ssid "Your SSID network" wpa-key-mgmt WPA-PSK wpa-psk "password" # then reboot #reinstall sshd on the system sudo apt-get update sudo apt-get purge openssh-server sudo apt-get install -y openssh-server ssh # List available upgrade sudo apt-get update sudo apt-get -V -u --assume-no upgrade #two fingers tap on touch pad for Right Click synclient tapbutton2=3 #node.js x86 (32 bit) download cd $HOME wget --no-check-certificate https://nodejs.org/dist/v6.9.2/node-v6.9.2-linux-x86.tar.xz tar xJvf node-v6.9.2-linux-x86.tar.xz # put this in $HOME/.bashrc export PATH=$HOME/node-v6.9.2-linux-x86/bin:$PATH #google app engine for python download cd $HOME wget --no-check-certificate https://storage.googleapis.com/appengine-sdks/featured/google_appengine_1.9.49.zip unzip google_appengine_1.9.49.zip # put this in $HOME/.bashrc export PATH=$HOME/google_appengine:$PATH #Traditional Chinese input method, need reboot to be effective and control+space to activate #Choose Auto in Preferences -> Input Method sudo apt-get install -y scim-tables-zh im-config # install additional Chinese fonts sudo apt-get install -y ttf-wqy-microhei ttf-wqy-zenhei xfonts-wqy # install vlc sudo apt-get install -y vlc browser-plugin-vlc # restart control panel lxpanelctl restart #install spotify #add repo and certificate see instructions here https://www.spotify.com/download/linux/ sudo apt-get update sudo apt-get install -y spotify-client Here is Visual Studio Code (32 bits) for Debian https://go.microsoft.com/fwlink/?LinkID=760680








EFI bootable USB stick for Ubuntu 16.10 Exton x64 platforms (PC or Mac)

exton-os-64bit-mate-refracta-1840mb-161231.iso (which is Ubuntu 16.10 for x64 platforms) can be downloaded from here https://sourceforge.net/projects/exton-os/ and copy to /Volumes/LINUX/efi/boot/ as boot.iso

or alternatively use the exton-os-light-64bit-isohybrid-970mb-161021.iso image from https://sourceforge.net/projects/exton-os/files/

The setup for this image for persistence in Mac is similar to the Debian PIXEL above
except the enterprise.cfg content should be
shell script    Select all
cat > /Volumes/LINUX/efi/boot/enterprise.cfg << EOF autoboot 0 entry Ubuntu family Ubuntu initrd /live/initrd.img kernel /live/vmlinuz findiso=/efi/boot/boot.iso boot=live username=live config live-config splash persistence EOF


Additional configuration and installation for Ubuntu 16.10 Exton x64 using Terminal
shell script    Select all
# additional installation for swift 3.0 for Exton OS Ubuntu 16.10 # username of this Ubuntu image is root # password is root sudo apt-get update sudo apt-get install -y libicu-dev clang-3.6 git cd $HOME # To download swift 3 release for Ubuntu 16.04 instead as the one for ubuntu1610 has bugs wget --no-check-certificate https://swift.org/builds/swift-3.0.2-release/ubuntu1604/swift-3.0.2-RELEASE/swift-3.0.2-RELEASE-ubuntu16.04.tar.gz tar xzvf $HOME/swift-3.0.2-RELEASE-ubuntu16.04.tar.gz export PATH=$HOME/swift-3.0.2-RELEASE-ubuntu16.04/usr/bin:$PATH #wget --no-check-certificate https://swift.org/builds/development/ubuntu1610/swift-DEVELOPMENT-SNAPSHOT-2017-01-05-a/swift-DEVELOPMENT-SNAPSHOT-2017-01-05-a-ubuntu16.10.tar.gz #tar xzvf $HOME/swift-DEVELOPMENT-SNAPSHOT-2017-01-05-a-ubuntu16.10.tar.gz #export PATH=$HOME/swift-DEVELOPMENT-SNAPSHOT-2017-01-05-a-ubuntu16.10/usr/bin:$PATH sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-3.6 100 sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-3.6 100 swift --version #node.js x64 (64 bit) download cd $HOME wget --no-check-certificate https://nodejs.org/dist/v6.9.3/node-v6.9.3-linux-x64.tar.xz tar xJvf node-v6.9.3-linux-x64.tar.xz # put this in $HOME/.bashrc export PATH=$HOME/node-v6.9.3-linux-x64/bin:$PATH node --version npm --version #install spotify sudo apt-get update sudo apt-get install -y spotify-client #Traditional Chinese input method sudo apt-get install -y ibus-cangjie ibus restart #then choose input method in System -> Preferences -> Other # install R # see insturctions here https://cloud.r-project.org/bin/linux/ubuntu/README.html cd $HOME echo deb https://cran.cnr.berkeley.edu//bin/linux/ubuntu yakkety/ | sudo tee /etc/apt/sources.list.d/r.list sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB9 gpg --keyserver keyserver.ubuntu.com --recv-key E084DAB9 gpg -a --export E084DAB9 | sudo apt-key add - sudo apt-get update sudo apt-get install -y r-base # download R Studio from https://www.rstudio.com/products/rstudio/download/ and install sudo apt-get install -y libjpeg62 libgstreamer0.10-0 libgstreamer-plugins-base0.10-0 cd ~/Downloads wget --no-check-certificate https://download1.rstudio.org/rstudio-1.0.136-amd64.deb sudo dpkg -i rstudio-1.0.136-amd64.deb # install Quantlib 1.9.1 sudo apt-get update sudo apt-get install -y libboost1.60-all-dev cd $HOME wget https://ncu.dl.sourceforge.net/project/quantlib/QuantLib/1.9.1/QuantLib-1.9.1.tar.gz tar xzvf QuantLib-1.9.1.tar.gz cd QuantLib-1.9.1 ./autogen.sh ./configure --prefix=/usr make -j9 sudo make install # Install RQuantLib Package in R # install.packages("RQuantLib") # install Quantlib-Python cd $HOME wget https://jaist.dl.sourceforge.net/project/quantlib/QuantLib/1.9/other%20languages/QuantLib-SWIG-1.9.tar.gz tar xzvf QuantLib-SWIG-1.9.tar.gz cd QuantLib-SWIG-1.9 ./autogen.sh ./configure make -C Python sudo make -C Python install # upgrade pip sudo apt-get update sudo apt-get install -y python-pip pip install --upgrade pip sudo pip install numpy # install ipython sudo pip install ipython # install jupyter notebook sudo pip install jupyter # List available upgrade sudo apt-get update sudo apt list --upgradeable # test QuantLib and QuantLib-Python cd $HOME cat > $HOME/qlversion.cpp <<EOF #include <iostream> #include <ql/version.hpp> int main() { std::cout << "Current QL Version:" << QL_LIB_VERSION << std::endl; return 0; } EOF g++ qlversion.cpp -o qlversion ./qlversion cat > $HOME/swap.py <<EOF import numpy as np import QuantLib as ql # Set Evaluation Date today = ql.Date(31,3,2015) ql.Settings.instance().setEvaluationDate(today) # Setup the yield termstructure rate = ql.SimpleQuote(0.03) rate_handle = ql.QuoteHandle(rate) dc = ql.Actual365Fixed() disc_curve = ql.FlatForward(today, rate_handle, dc) disc_curve.enableExtrapolation() hyts = ql.YieldTermStructureHandle(disc_curve) discount = np.vectorize(hyts.discount) start = ql.TARGET().advance(today, ql.Period('2D')) end = ql.TARGET().advance(start, ql.Period('10Y')) nominal = 1e7 typ = ql.VanillaSwap.Payer fixRate = 0.03 fixedLegTenor = ql.Period('1y') fixedLegBDC = ql.ModifiedFollowing fixedLegDC = ql.Thirty360(ql.Thirty360.BondBasis) index = ql.Euribor6M(ql.YieldTermStructureHandle(disc_curve)) spread = 0.0 fixedSchedule = ql.Schedule(start, end, fixedLegTenor, index.fixingCalendar(), fixedLegBDC, fixedLegBDC, ql.DateGeneration.Backward, False) floatSchedule = ql.Schedule(start, end, index.tenor(), index.fixingCalendar(), index.businessDayConvention(), index.businessDayConvention(), ql.DateGeneration.Backward, False) swap = ql.VanillaSwap(typ, nominal, fixedSchedule, fixRate, fixedLegDC, floatSchedule, index, spread, index.dayCounter()) engine = ql.DiscountingSwapEngine(ql.YieldTermStructureHandle(disc_curve)) swap.setPricingEngine(engine) print(swap.NPV()) print(swap.fairRate()) EOF python swap.py sudo apt-get install -y git cd $HOME git clone git://github.com/mmport80/QuantLib-with-Python-Blog-Examples.git cd QuantLib-with-Python-Blog-Examples/ python blog_frn_example.py








If for Debian PIXEL-x86 and Ubuntu-16.10 Exton-x64 together in one USB stick with persistence
shell script    Select all
# Running on Mac # copy iso to USB stick rm -f /Volumes/LINUX/efi/boot/boot.iso cp ~/Downloads/2016-12-13-pixel-x86-jessie.iso /Volumes/LINUX/efi/boot/pixel.iso cp ~/Downloads/exton-os-64bit-mate-refracta-1840mb-161231.iso /Volumes/LINUX/efi/boot/exton.iso # set up enterprise.cfg in USB stick and assume persistence is already formatted as ext4 with persistence.conf cat > /Volumes/LINUX/efi/boot/enterprise.cfg << EOF entry Debian PIXEL family Debian iso pixel.iso initrd /live/initrd1.img kernel /live/vmlinuz1 findiso=/efi/boot/pixel.iso boot=live config live-config quiet splash persistence entry Debian STRETCH family Debian iso stretch.iso initrd /live/initrd1.img kernel /live/vmlinuz1 findiso=/efi/boot/stretch.iso boot=live config live-config quiet splash nomodeset persistence entry Ubuntu 16.10 Exton family Ubuntu iso exton.iso initrd /live/initrd.img kernel /live/vmlinuz findiso=/efi/boot/exton.iso boot=live username=live config live-config splash persistence EOF








Add the Original Ubuntu 16.04 from Ubuntu to the EFI bootable USB stick

For the Original ubuntu-16.04.1-desktop-amd64.iso image, add it by copying the downloaded iso image to the LINUX FAT32 partition and create the enterprise.cfg as below
shell script    Select all
# Running on Mac # copy iso to USB stick rm -f /Volumes/LINUX/efi/boot/boot.iso cp ~/Downloads/2016-12-13-pixel-x86-jessie.iso /Volumes/LINUX/efi/boot/pixel.iso cp ~/Downloads/exton-os-64bit-mate-refracta-1840mb-161231.iso /Volumes/LINUX/efi/boot/exton.iso cp ~/Downloads/ubuntu-16.04.1-desktop-amd64.iso /Volumes/LINUX/efi/boot/ubuntu.iso cat > /Volumes/LINUX/efi/boot/enterprise.cfg << EOF entry Debian PIXEL family Debian iso pixel.iso initrd /live/initrd1.img kernel /live/vmlinuz1 findiso=/efi/boot/pixel.iso boot=live config live-config quiet splash persistence entry Debian STRETCH family Debian iso stretch.iso initrd /live/initrd1.img kernel /live/vmlinuz1 findiso=/efi/boot/stretch.iso boot=live config live-config quiet splash nomodeset persistence entry Ubuntu 16.10 Exton family Ubuntu iso exton.iso initrd /live/initrd.img kernel /live/vmlinuz findiso=/efi/boot/exton.iso boot=live username=live config live-config splash persistence entry Ubuntu 16.04-1 family Ubuntu iso ubuntu.iso initrd /casper/initrd.lz kernel /casper/vmlinuz.efi findiso=/efi/boot/ubuntu.iso file=/cdrom/preseed/ubuntu.seed boot=casper persistent quiet splash --- EOF # Reboot and running in the new Ubuntu 16.04-1 # it requires a Linux partition named casper-rw in order to enable the persistent feature. # So we need to create a third partition in Linux and then format it. # Running on Ubuntu 16.04 # First remove the second partition and recreate second partition with smaller size and add a third partition to it sudo fdisk -l #assume /dev/sdb is the USB stick # umount the partition 2 in order to modify it sudo umount /dev/sdb2 # partition the USB stick sudo fdisk /dev/sdb # (d) (2) to delete partition 2 # and then (n) (p) (2) to recreate primary partition 2 for Linux in fdisk # choose size say 20G if for 64G USB stick # and then (n) (p) (3) to recreate primary partition 3 for Linux in fdisk # choose size say remaining sectors # (w) to write to partition table and quit fdisk # Reboot to let partition table effective # Running on Ubuntu 16.04-1 # format the second partition with label persistence and add persistence.conf sudo mkfs.ext4 -L persistence /dev/sdb2 sudo mkdir -p /media/ubuntu/persistence sudo mount /dev/sdb2 /media/ubuntu/persistence echo / union | sudo tee /media/ubuntu/persistence/persistence.conf # format the third partition with label casper-rw sudo mkfs.ext4 -L casper-rw /dev/sdb3 # Reboot to start other configuration and installation


Additional configuration and installation for Ubuntu 16.04-1 using Terminal
shell script    Select all
# additional installation for swift 3.0.2 for Ubuntu 16.04 # username of this Ubuntu image is ubuntu # password is ubuntu # Additional installation needs to add these lines in /etc/apt/sources.list echo "deb http://archive.ubuntu.com/ubuntu/ xenial universe" | sudo tee --append /etc/apt/sources.list echo "deb http://archive.ubuntu.com/ubuntu/ xenial-updates universe" | sudo tee --append /etc/apt/sources.list echo "deb http://security.ubuntu.com/ubuntu/ xenial-security universe" | sudo tee --append /etc/apt/sources.list # To install swift 3.0.2 release for Ubuntu 16.04-1 is sudo apt-get update # for AppStream cache update failed error sudo chmod 777 /var/cache/app-info/xapian/default -R sudo apt-get update sudo apt-get install -y libicu-dev clang-3.6 git cd $HOME wget --no-check-certificate https://swift.org/builds/swift-3.0.2-release/ubuntu1604/swift-3.0.2-RELEASE/swift-3.0.2-RELEASE-ubuntu16.04.tar.gz tar xzvf $HOME/swift-3.0.2-RELEASE-ubuntu16.04.tar.gz export PATH=$HOME/swift-3.0.2-RELEASE-ubuntu16.04/usr/bin:$PATH sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-3.6 100 sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-3.6 100 swift --version #node.js x64 (64 bit) download cd $HOME wget --no-check-certificate https://nodejs.org/dist/v6.9.3/node-v6.9.3-linux-x64.tar.xz tar xJvf node-v6.9.3-linux-x64.tar.xz # put this in $HOME/.bashrc export PATH=$HOME/node-v6.9.3-linux-x64/bin:$PATH node --version npm --version #install spotify sudo apt-get update sudo apt-get install -y spotify-client #Traditional Chinese input method sudo apt-get install -y ibus-cangjie ibus restart # install R # see insturctions here https://cloud.r-project.org/bin/linux/ubuntu/README.html cd $HOME echo deb https://cran.cnr.berkeley.edu//bin/linux/ubuntu xenial/ | sudo tee /etc/apt/sources.list.d/r.list sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB9 gpg --keyserver keyserver.ubuntu.com --recv-key E084DAB9 gpg -a --export E084DAB9 | sudo apt-key add - sudo apt-get update sudo apt-get install -y r-base # download R Studio from https://www.rstudio.com/products/rstudio/download/ and install sudo apt-get install -y libjpeg62 libgstreamer0.10-0 libgstreamer-plugins-base0.10-0 cd ~/Downloads wget --no-check-certificate https://download1.rstudio.org/rstudio-1.0.136-amd64.deb sudo dpkg -i rstudio-1.0.136-amd64.deb # install Quantlib 1.9.1 sudo apt-get update sudo apt-get install -y libboost1.58-all-dev cd $HOME wget https://ncu.dl.sourceforge.net/project/quantlib/QuantLib/1.9.1/QuantLib-1.9.1.tar.gz tar xzvf QuantLib-1.9.1.tar.gz cd QuantLib-1.9.1 ./autogen.sh ./configure --prefix=/usr make -j9 # uninstall old library # cd ~/Downloads/QuantLib-1.9 # sudo make uninstall sudo make install # Install RQuantLib Package in R # install.packages("RQuantLib") # install Quantlib-Python cd $HOME wget http://jaist.dl.sourceforge.net/project/quantlib/QuantLib/1.9/other%20languages/QuantLib-SWIG-1.9.tar.gz tar xzvf QuantLib-SWIG-1.9.tar.gz cd QuantLib-SWIG-1.9 ./autogen.sh ./configure # if there is "out of memory" error use this below to configure # ./configure CXXFLAGS="--param ggc-min-expand=1 --param ggc-min-heapsize=32768" make -C Python # uninstall old QuantLib-Python package # sudo -H pip uninstall QuantLib-Python sudo make -C Python install # upgrade pip and install numpy sudo apt-get update sudo apt-get install -y python-pip sudo -H pip install --upgrade pip sudo -H pip install numpy # test QuantLib and QuantLib-Python cd $HOME cat > $HOME/qlversion.cpp <<EOF #include <iostream> #include <ql/version.hpp> int main() { std::cout << "Current QL Version:" << QL_LIB_VERSION << std::endl; return 0; } EOF g++ qlversion.cpp -o qlversion ./qlversion sudo apt-get install -y git cd $HOME git clone git://github.com/mmport80/QuantLib-with-Python-Blog-Examples.git cd QuantLib-with-Python-Blog-Examples/ python blog_frn_example.py # List available upgrade sudo apt-get update sudo apt list --upgradeable


install Emscripten SDK for WebAssembly
shell script    Select all
# need Debian Stretch 32 bits image or Ubuntu 64 bits # need cmake for building in Debian Stretch(32 bits) sudo apt-get update sudo apt-get install cmake libxml2-dev ocaml python-yaml # Get the emsdk repo git clone https://github.com/juj/emsdk.git # Enter that directory cd emsdk # Fetch the latest registry of available tools. ./emsdk update # Download and install the latest SDK tools. Need rebuilding libraries in Debian Stretch 32 bits ./emsdk install latest # Make the "latest" SDK "active" for the current user. (writes ~/.emscripten file) ./emsdk activate latest # Activate PATH and other environment variables in the current terminal source ./emsdk_env.sh # Test mkdir $HOME/hello cd $HOME/hello cat > $HOME/hello/hello_world.c <<EOF #include <stdio.h> int main() { printf("hello, world!\n"); return 0; } EOF # compile and test emcc hello_world.c node a.out.js emcc hello_world.c -s WASM=0 -o hello.html # start webserver and test http://localhost:8080/hello.html emrun --no_browser --port 8080 .