miércoles, 20 de enero de 2021

Ubuntu 20.04 Focal - Final makeups


Here's a small list of personal tweaks applied after an upgrade from 18.04 Bionic to 20.04 Focal:

apt install kde-plasma-desktop

apt install plasma-nm

# Migrate networkd to NetworkManager in 5 steps

nano /etc/netplan/01-netcfg.yaml

netplan generate

netplan apply

systemctl daemon-reload

systemctl restart netplanXXX

# Disable/hide default virtual keyboard of vanilla SDDM

echo 'InputMethod=' >> /etc/sddm.conf

# reboot

# Disable/stop baloo_file

printf '\n[Basic Settings]\nIndexing-Enabled=false\n' >> .config/baloofilerc

# SDDM Theme : Sugar Candy :: Some minor tweaks

nano /usr/share/sddm/themes/sugar-candy/theme.conf.user

Hope you like it!

lunes, 28 de diciembre de 2020

Minimal Ubuntu 18.04 on Aspire One Cloudbook


Here's a cookbook of tips to setup a Aspire One Cloudbook 14 with a minimal (but usable for your parents) Ubuntu.

  1. Setup the BIOS
    1. Press F2 when the Acer logo appears, and then change the EFI system to legacy.
    2. Reboot and then press F12 when the logo appears (to choose the installing media).
  2. Installation. I have selected a Lubuntu 18.04 installation but it's not a critical choice. More on this onwards.
    1. When prompted, specify the following options for the partitions: discard (as the Cloudbook 14 has a eMMC drive) and noatime.
    2. When prompted, install nothing but "OpenSSH Server" (as it won't be a standard desktop)
  3. After-install setup
    1. Update the dependencies with apt update && apt upgrade.
    2. In other linux machine, download and compile a recent kernel (currently 5.10.3):
      1. make clean menuconfig; make -j $(nproc);
      2. make bindeb-pkg # as we're going to scp the generated kernel to the aspire1
        In the parent directory there'll be a "linux-image-5.10.3*.deb" file
    3. In the Cloudbook, scp the remote .deb file into local (i.e. scp john@remotelinux:/tmp/linux-image-5.10.3*.deb .)
    4. Install it with sudo apt install ./linux-image-5.10.3*.deb and reboot.
    5. Now you're running with the latest trouble-free kernel.
    6. Additional installations:
      1. apt install python x11-utils x11-apps xinit xterm xinput xserver-xorg-input-synaptics openbox firefox pm-utils
      2. (optional) apt install lxterminal.
    7. Try the X system with the command xinit. Everything should be fine here: an xterm window is ready and the trackpad clicks perfectly.
      If you exit the terminal window you'll be back to the console.
    8. Prepare the graphical system to launch automatically the browser with (remember it's targeted to your parents) echo 'openbox & firefox' > $HOME/.xinitrc

Hope you like it!

sábado, 23 de mayo de 2020

Working like WSL2 (without having it)


Here is an approach to work with a non-WSL Linux guest (with VirtualBox or VmWare) and launching native Windows commands (f.e. MS Office Excel)


Hi all,

Some people have WSL2. Some people not, like me, and we are in the middle-of-nowhere with WSL1, as we are not able to do real stuff with Docker, Kubernetes, and so on, because WSL1 lacks the needed capabilities that a real Linux kernel has, so the only solution (see rants section below) is to stick with VirtualBox (or VmWare if you prefer) and work isolated from Windows apps.

But here's a way to overcome such limitations.

The idea is to run a small agent in the Windows side (the host) that will be capable of running whatever command you send from the Linux side (the guest).

In order to do that, you'll need:
  • Windows:
    • Java 11 (https://adoptopenjdk.net/?variant=openjdk11&jvmVariant=hotspot)
    • Groovy (https://dl.bintray.com/groovy/maven/apache-groovy-binary-3.0.4.zip)
  • Linux:
    • Netcat

Once you have them installed, you'll have to do:

1. Create the agent in Groovy

Create a file (f.e. c:\GroovySocketServer1070.groovy) with the following content:

new groovy.ui.GroovySocketServer (new GroovyShell(), // false"println line.execute().text", // true1070);

That's all: A poor-man's telnet server written in three lines of Groovy, that will execute whatever command it receives at port 1070!
There's a caveat: If there's an error it will be lost, as STDERR is not captured.

You can run the agent  with a command like (the paths must reflect the exact locations of the Java and Groovy installations) this:

C:\>PATH=C:\p\groovy-3.0.4\bin;C:\p\jdk-11\bin;%PATH% C:\>groovy C:\GroovySocketServer1070.groovy

2. Launch the commands from Linux

From the Linux guest you can launch any Windows program like this:

$ echo "C:\\Windows\\System32\\cmd.exe /C dir" | nc -N 1070 $ echo "C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\EXCEL.EXE" | nc -N realhost 1070 &

Bonus point: The GroovySocketServer allows multiple concurrent executions (so you don't have to wait for the termination of other commands)!

Sweet and easy: You can execute any host program from the guest.

Hope you like it!


domingo, 20 de mayo de 2018

EXT4 virtual disk optimization (2nd edition)


Following the previous post, if you want to create a brand-new ext4 filesystem with most of the performance settings activated, you can do it this way:

# mkfs
mkfs.ext4 -T news -m 1 -I 128 -v -O "^has_journal,^dir_index,^dir_nlink,^huge_file,^metadata_csum,^quota" /dev/sda1
# tune2fs
tune2fs -o "journal_data_writeback,^user_xattr,^acl,nobarrier,discard" /dev/sda1
And then, in the /etc/fstab file you can use the following mount-point parameters:
# /etc/fstab

No implicit nor explicit warranty of any kind is stated here. These commands and/or settings may cause data loss. Use them wisely at your own risk!

lunes, 31 de julio de 2017

EXT4 virtual disk optimization

Hi all,

These are my tweaks in order to squeeze the performance of a EXT4 virtual disk (in example /dev/sdb1).

No implicit nor explicit warranty of any kind is stated here. These commands and/or settings may cause data loss. Use them wisely at your own risk!

tune2fs -o journal_data_writeback /dev/sdb1
tune2fs -O ^has_journal /dev/sdb1
sudo e2fsck -f /dev/sdb1
tune2fs -o ^user_xattr /dev/sdb1
tune2fs -o ^acl /dev/sdb1
tune2fs -o nobarrier /dev/sdb1
tune2fs -o discard /dev/sdb1
tune2fs -O ^dir_index /dev/sdb1
tune2fs -O ^dir_nlink /dev/sdb1
tune2fs -O ^huge_file /dev/sdb1
tune2fs -O ^metadata_csum /dev/sdb1
tune2fs -O ^quota /dev/sdb1
tune2fs -r 0 /dev/sdb1

dumpe2fs /dev/sdb1 | less

References and Kudos:

  1. https://developer.ridgerun.com/wiki/index.php/High_performance_SD_card_tuning_using_the_EXT4_file_system

sábado, 1 de abril de 2017

JSF 2.1 within embedded Tomcat 8 (2017)

This post relates about configuring the following aspects to get a working JSF 2.1 application:
  • Maven 3
  • JSF 2.1.7
  • Embedded Tomcat 8


<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
 <name>spa-jsf-generator Maven Webapp</name>




  <!-- JSF -->

  <!-- Java standards -->

  <!-- Tomcat -->

  <!-- Testing -->


<?xml version = "1.0" encoding = "UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
 id="WebApp_ID" version="2.5">




  <servlet-name>Faces Servlet</servlet-name>

  <servlet-name>Faces Servlet</servlet-name>



package eu.altotek.spa_jsf_generator;

import java.io.File;

import org.apache.catalina.WebResourceRoot;
import org.apache.catalina.core.StandardContext;
import org.apache.catalina.startup.Tomcat;
import org.apache.catalina.webresources.DirResourceSet;
import org.apache.catalina.webresources.StandardRoot;

public class Main {

 public static void main(final String[] args) throws Exception {

  final String webappPath = new File("src/main/webapp").getAbsolutePath();
  final Tomcat tomcat = new Tomcat();

  final StandardContext ctx = (StandardContext) tomcat.addWebapp("/", webappPath);

  // Declare an alternative location for your "WEB-INF/classes" dir
  // Servlet 3.0 annotation will work
  final String targetClassesPath = new File("target/classes").getAbsolutePath();
  final WebResourceRoot resources = new StandardRoot(ctx);
  resources.addPreResources(new DirResourceSet(//
    resources, "/WEB-INF/classes", //
    targetClassesPath, "/"));



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

<html xmlns="http://www.w3.org/1999/xhtml">
<title>JSF Tutorial!</title>



package eu.altotek.spa_jsf_generator.jsf;

import javax.faces.bean.ManagedBean;

public class HelloWorld {

 public HelloWorld() {
  System.out.println(this + "started!");

 public String getMessage() {
  return "Hello " + this;

References & kudos

  • https://www.mkyong.com/jsf2/jsf-2-0-hello-world-example/
  • http://musingsofaprogrammingaddict.blogspot.com.es/2009/12/running-jsf-2-on-embedded-jetty.html
  • https://www.mkyong.com/jsf2/jsf-2-0-tomcat-it-appears-the-jsp-version-of-the-container-is-older-than-2-1/
  • https://www.tutorialspoint.com/jsf/jsf_first_application.htm
  • http://alexgorbatchev.com/SyntaxHighlighter/

viernes, 15 de enero de 2016

Instalación paso a paso de Linux Mint 17 via PXE/Netboot


Después de un breve descanso, he querido instalar un linux en un portátil un poco antiguo, y la distrubución escogida ha sido Linux Mint 17.3 (Rosa).

Aquí están las instrucciones para hacer una instalación desde red (mediante PXE+dnsmasq+TFTP+NFS) :

NOTA: Hay que cambiar la IP por la tuya!!

sudo bash
apt-get install dnsmasq nfs-kernel-server nfs-common syslinux

# archivos
mkdir -p /srv/tftp/pxelinux.cfg
ln -s /cdrom /tmp/cdrom

# dhcp/tftp
cat <<EOF > /srv/tftp/pxelinux.cfg/default
DEFAULT /cdrom/casper/vmlinuz
KERNEL cdrom/casper/vmlinuz
APPEND ip=dhcp netboot=nfs boot=casper root=/dev/nfs nfsroot= initrd=/cdrom/casper/initrd.lz splash --

cat <<EOF >> /etc/dnsmasq.conf

service dnsmasq restart

# nfs
cat <<EOF >> /etc/exports

/tmp/cdrom       *(ro,sync,fsid=0,no_subtree_check)
service nfs-kernel-server restart ; exportfs -a

A disfrutar!