Loading...
 

Slax USB GNU Linux


Slax GNU/Linux Live USB drive prepared for the R course taught at the OMD-AjBCN

1.1. Setup

1.1.1. Slax base iso

Slax 9.x: https://slax.org
(64 bits)

1.1.2. USB setup

  • Get a 16Gb USB3 disk
    • "SanDisk Ultra Flair USB 3.0 Flash drive" seems to be the fastest comapred to most usb 3.x usb disk brands, acording to IMI techs (Andreu T.).
  • Make two partitions
    leave 4Mb of NO free space at the beggining of usb disk (if you leave some empty space, windows doesn't search for the ntfs or fat32 partition, regardless of being the first or the second in sort order at the disk).
    1. ~7.5Gb ntfs (labelled as 7gbntfs, in our case; adapt to your preferences)
    2. ~8.5Gb ext4 (labelled as 8gbext4, in our case; adapt to your preferences)
  • uncompress slax.iso in your linux disk (with isomaster for instance)
  • create (with sudo) a folder slax in the new usb ext4 partition
  • copy your slax folder to your usb ext4 partition
  • run as root the file in your usb ext4 partition: sudo bash ./slax/boot/bootinst.sh to make your usb bootable
  • shutdown your computer, and boot it again this time from your usb stick. Slax should boot
  • make your desired changes following guidelines on slax.org website (see more details below, also)
  • change keyboard by hand tweaking a file in the persistent changes folder
    • Edit this file /root/.fluxbox/startup and add there near the top a line such as
      setxkbmap es
  • reboot slax to check that your changes were kept as desired. Power off the machine.
  • test the usb disk in a computer booting MS Windows or Mac OSX, to double check that the disk is recognized by default and you can read and write to this partition from that OS.
  • clone your usbdisk (with partitions and all) with dd.
    • find your usb-disk device name ( /dev/sdc in this example). You can find out with command sudo lsblk or sudo fdisk -l
    • make image with dd. Example:
      sudo dd if=/dev/sdc of=/media/xavi/mollero_ext4/usbdisk/backup_slaxomdr_yymmdd.img bs=4M status=progress
    • clone back over another usb with dd again (or theoretically with a dd GUI, but gdiskdump fails for me on Kubuntu 16.04)
      To restore the image to another USB drive just invert the process. Just make sure that the new USB drive ( /dev/sdd in this example) is as big or bigger than the original one
      sudo dd if=/media/xavi/mollero_ext4/usbdisk/backup_slaxomdr_yymmdd.img of=/dev/sdd bs=4M status=progress


1.1.3. Customizations

1.1.3.1. Quick list

  1. Keyboard
  2. Add parcellite to systray (ideally run by default when booting in).
  3. Add kupfer to systray (ideally run by default when booting in). But fails to say when you clonse the konsole that is shown up when running it.
  4. Background
  5. Clock
  6. Installed programs
    1. firefox-esr
    2. R RStudio et al. (see bash script below)
    3. gnumeric (spreadshseet)
    4. abiword (text-processing program)
    5. clamTk (antiviryus for windows os and partitions)
    6. testdisk (in case of need)
    7. git-cola (git GUI)
  7. Associate through file manager "Pcmanfm":
    • pdf with firefox web browser
    • Rmd & R with RStudio
    • xls & xlsx with gnumeric spreadsheet program
    • csv, README.md & LICENSE to leafpad (plain text editor)

1.1.3.2. My Custom Directory

You can place new files in the usb disk so that they show up in the default "home" folder of the default root user once the usb is booted. Example:

  • Custom directory (e.g. my_custom_dir) with files under the Documents folder of the default root user.
    • You need to place the folder "my_custom_dir" at (adapt path to your case):
      /media/xavi/8gbext4/slax/changes/home/guest/Documents/my_custom_dir/
  • Alternatively, you can place those files under the ntfs partiton ( 7gbntfs ), so that they are viewable from the slax system And from another computer with MS Windows (or Mac OSX) operating systems and operate with those files normally as with any other usbdisk.

1.1.3.3. Mount usb ntfs sister partition by default

To allow the user to mount both partitions when booted with slax linux, you can run a shell command to mount the ntfs partition at run time (it doesn't mount automatically at boot time for some unknown reason).
You can make a shell script with this command in a terminal window:

nano /root/munta_usb.sh


and add these contents inside:

File contents
mount -a
pcmanfm /media/sdb1 &


And save the file to disk.
Then, change its perms so that it can be executable, with this command:

chmod +x /root/munta_usb.sh


Later on, users will have to open the file manager, and click on the "munta_usb.sh" file in the default folder shown, and choose "Execute" (the button at the left of the pop-up window).

1.1.3.4. Fix RStudio 1.2.x launcher

RStudio 1.2.x in Slax 9.8+ doesn't seem to run by default, for unknown reasons, while it did run with no problems in Slax 9.2 and using Rstudio 1.1.x. The solution/workaround involves calling rstudio with --no-sandbox argument. To make this change work for the menu entry in Slax, you need to edit the file holding the information of the menu entry in slax. Slax uses xlunch program to manage runnig programs from a nice and small UI (https://xlunch.org). Config file for rstudio is stored at:
/usr/share/applications/rstudio.desktop. That file needs to get the call to rstudio tweaked to add that --no-sandbox parameter. Final version should be like:

Updated contents of /usr/share/applications/rstudio.desktop
[Desktop Entry]
Exec=/usr/lib/rstudio/bin/rstudio --no-sandbox %F
Icon=rstudio
Type=Application
Terminal=false
Name=RStudio
Categories=Development;IDE;
MimeType=text/x-r-source;text/x-r;text/x-R;text/x-r-doc;text/x-r-sweave;text/x-r-markdown;text/x-r-html;text/x-r-presentation;application/x-r-data;application/x-r-project;text/x-r-history;text/x-r-profile;text/x-tex;text/x-markdown;text/html;text/css;text/javascript;text/x-chdr;text/x-csrc;text/x-c++hdr;text/x-c++src;


In addition, and just in case this file is not added to the changes folder in slax usb, I also copied that rstudio.desktop file to another folder, the folder where xlunch.org documentation says that a user can override the values from the systemwide configuration: /root/.local/share/applications/

Get these certs from the samba share at Ajuntament de Barcelona (See http://omd-gid.imi.bcn/Kubuntu#Certificat_del_navegador ) and import them to firefox browser certificate authorities:

  • Certificat IMI arrel (IMICARaiz.crt)
  • IMI Entitat certificadora (IMICAEmisora1V01.crt)
  • FWIMICA.crt

1.1.3.6. https cert for gitlab.ajuntament.bcn through git

Trust the certificate from gitlab.ajuntament.bcn also through git command calls.

Command in a terminal window
openssl s_client -showcerts -servername gitlab.ajuntament.bcn -connect gitlab.ajuntament.bcn:443 </dev/null 2>/dev/null | sed -n -e '/BEGIN\ CERTIFICATE/,/END\ CERTIFICATE/ p'  > ~/gitlab-ajuntament-bcn.pem
cat ~/gitlab-ajuntament-bcn.pem | tee -a /etc/ssl/certs/ca-certificates.crt

1.1.3.7. Pending

Pending to test/implement

  • set parcellite to boot by default by means of tweaking whatever system file is needed?
  • test synaptic instead of kupfer?
  • add some terminal window program that allows copy & paste (default one doesn't). Terminator didn't work (didn't install properly for some reason, in some tests I did in the early stages of customizing the usbdisk). geany did the trick (with the embedded terminal). And Rstudio terminal panel.

1.1.4. Troubleshooting

1.1.4.1. Your customized slax usbdisk can't enter the graphical mode

Setting up the slax-usb stick in one computer, might set the temp path under the "changes" directory as a symbolic link to a temp folder in a hard disk (e.g. +/dev/sda5/tmp/+- ) of the physical computer where you are testing or tweaking the usb disk in. The first time I saw this, the temp folder was set to reuse an ext4 partition on the host computer where the usbdisk was plugged in.

However, when you place your customized usbdisk into another computer, that tmp folder might no exist in that other computer, and therefore, your customized slax wouldn't be able to boot into the graphical mode, due to being unable to create temp files or folders for the Xorg graphic display, or others.

Therefore, if the customized slax usbdisk is not able to boot into the graphical mode but only in text mode, you can log in that text screen with the usual credentials (user root, password: toor, as indicated in that login screen itself), and attempt to start the graphical mode by hand by means of running the command startx. See the error message that will be displayed in the screen. If it says anything related to being not able to create a file or folder under tmp, then you need to double check that the folder where the symbolic links points to does exist.

One quick workaround to solve this problem is to remove the tmp symbolic link and create a real tmp folder in the usbdisk instead. It might make things slower, but at least it will work.

1.1.5. Custom modules (.sb)

Following the guidelines on how to make custom slax modules:
https://www.slax.org/customize.php

  • Background image: /modules/slax_wallpaper_ajbcn.sb
  • Firefox: 06-firefox.sb

1.1.6. Install extra system programs

apt install dirmngr apt-transport-https ca-certificates software-properties-common gnupg2
apt install -y default-jre default-jdk
echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" | tee /etc/apt/sources.list.d/webupd8team-java.list
echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" | tee -a /etc/apt/sources.list.d/webupd8team-java.list
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys C2518248EEA14886
apt update
apt install oracle-java8-installer # falla per que repo ppa:webupd8team/java sembla no estar mantingut ja?
apt install -y squashfs-tools syslinux-utils libnss-winbind winbind cifs-utils nfs-common git git-cola mc htop parcellite kupfer p7zip-full printer-driver-cups-pdf meld sendemail gigolo g++
apt-key adv --keyserver hkp://keys.gnupg.net:80 --recv-key 'E19F5F87128899B192B1A2C2AD5F960A256A04AF'
add-apt-repository 'deb https://cloud.r-project.org/bin/linux/debian stretch-cran35/'
#apt install -y  r-recommended  r-cran-xml libgraphviz-dev libcairo2-dev r-cran-cairodevice freeglut3 freeglut3-dev r-cran-rglpk r-cran-rgl r-cran-misc3d libx11-dev libxt-dev libcurl4-gnutls-dev libxml2-dev r-cran-xml libgraphviz-dev libcairo2-dev bwidget tk-table libv8-dev r-cran-rjava libmpfr-dev libc6 libssl-dev texlive-latex-extra texlive-lang-spanish libx11-dev libxml2-dev libxt-dev r-cran-misc3d subversion git texmaker tk-dev unaccent xvfb libgdal-dev libproj-dev libmagick++-dev r-cran-rcolorbrewer r-cran-doparallel libssh2-1-dev libudunits2-dev libgdal-dev libgeos-dev libproj-dev libjq-dev libprotobuf-dev protobuf-compiler libssl-dev libcairo2-dev libapparmor-dev # per a r 3.3
apt install -y  r-recommended  libgraphviz-dev libcairo2-dev freeglut3 freeglut3-dev libx11-dev libxt-dev libcurl4-gnutls-dev libxml2-dev libgraphviz-dev libcairo2-dev bwidget tk-table libv8-dev libmpfr-dev libc6 libssl-dev texlive-latex-extra texlive-lang-spanish libx11-dev libxml2-dev libxt-dev subversion git texmaker tk-dev unaccent xvfb libgdal-dev libproj-dev libmagick++-dev r-cran-rcolorbrewer libssh2-1-dev libudunits2-dev libgdal-dev libgeos-dev libproj-dev libjq-dev libprotobuf-dev protobuf-compiler libssl-dev libcairo2-dev libapparmor-dev # per a r 3.6
R CMD javareconf
apt install gnumeric abiword clamtk testdisk # extra programs for word precessing and spreadsheet programs, antivirus and other useful goodies smbclient samba gadmin-samba

1.1.7. Install R packages

if (!require("devtools")) install.packages("devtools"); require("devtools")

  install.pacman <- function(){
  # Check Availability of package manager "PacMan" (and install it, if missing)
  # if you have R < 3.5
  if (version$major==3 && version$minor < 5) {
    if (!require("pacman")) {
      # Instal.la devtools si et cal
      if (!require("devtools")) install.packages("devtools"); require("devtools")
      cat("R Version: ", paste0(version$major,".",version$minor), ". ")
      cat("Tens una versió de R anterior a 3.5, per tant, instal.lem la versió corresponent de PacMan (0.4.1)\n")
      # Instal.la la darrera versió de pacman (0.4.1) que anava abans de la que va només amb R 3.5+ (pacman v0.5)
      install_version("pacman", version = "0.4.1"); require("pacman")      
    }
  } else {
    # if you have R 3.5 or higher
    if (!require("pacman")) install.packages("pacman"); require("pacman")
  }
}
install.pacman()

# Carrega (i instal.la i si cal abans) els paquets que s'empren a les sessions del curs
p_load(addinslist, aplpack, autocogs, bitops, brew, cartogram, cartography, caTools, checkpoint, 
       collapsibleTree, colorspace, condformat, cowplot, CRANsearcher, crosstalk, cshapes, 
       d3heatmap, data.table, devtools, dichromat, doMC, doParallel, dplyr, DT, editData, esquisse, 
       eurostat, ff, flextable, foreign, formattable, fs, future.apply, gapminder, 
       geofacet, geogrid, geofacet, GGally, gganimate, ggforce, ggiraph, ggiraphExtra, ggmap,
       gitlabr, googleVis, Hmisc, htmltools, htmlwidgets, huxtable, janitor, kableExtra, knitr, 
       leaflet, leaflet.extras,  leaflet.minicharts, logging, magick, mapdeck, mapmisc, maps, mapview, marmap,
       mclust, Nozzle.R1, oce, OceanView, officer, openxlsx, pacman, parallel, pivottabler, plotly, 
       plotrix, plyr, png, purrr, purrrlyr, RColorBrewer, RCurl, raster, readr, readxl, relimp, reshape2, 
       rhandsontable, rio, rJava, rjson, rmapshaper, rmarkdown, rnaturalearth, rnaturalearthdata,
       RODBC, rosm, rpivotTable, rsvg, R.utils, rworldmap, scales, sem, sf, sp, SnowballC, stringr, 
       svglite, svgPanZoom, tictoc, tidyverse, tm, tmap, treemap, trelliscopejs, vembedr, 
       VennDiagram, webshot, widgetframe, wordcloud, wordcloud2, XML, xml2, xtable)

if (version$major==3 && version$minor >= 4) { # requereixen R 3.4+
  p_load(ggsn)
}

if (version$major==3 && version$minor >= 5) { # requereixen R 3.5+
p_load(GADMTools)
  }

if (!require("rnaturalearthhires")) install.packages("rnaturalearthhires",
                 repos = "http://packages.ropensci.org",
                 type = "source")

# Llista de mínims
p_load("devtools", "plotly", "stringr", "xml2", "data.table", "xtable", "plyr", "dplyr", "reshape2", "rjson", "d3heatmap", "htmlwidgets", "googleVis", "knitr", "rmarkdown",  "addinslist", "tidyverse", "magick", "webshot", "officer", "flextable", "huxtable", "RODBC", "leaflet", "gitlabr", "colorspace", "mapdeck", "rsvg", "png", "cartography", "rJava", "sf", "tmap", "rio", "caTools", "bitops", "kableExtra", "RCurl", "XML")


Addins (not in CRAN but elsewhere):

  • mapedit.addin

1.2. Screenshots

Slax Ajbcn CursR 00 Escriptori

Slax Ajbcn CursR 00 Menu Progs
.

.
Slax Sjbcn CursR 01 RStudio Exemple

.
Slaxusb Connexio Wifi Ajbcn

1.3. Pending

  • nothing, afaik


Alias names for this page:
Slax | SlaxUSB

Image Seed: noun \ˈsēd\ : the beginning of something which continues to develop or grow

Knowledge seeds

Switch Language