Thursday, September 15, 2022

Compiling the Linux Kernel 5.19.8 under Ubuntu 22.04

Compiling the Linux Kernel version 5.19.8 in Ubuntu 22.04

First we need to install the following:

sudo apt install git libncurses-dev gawk openssl libssl-dev dkms libudev-dev libpci-dev libiberty-dev autoconf llvm

sudo apt install libncurses5-dev libncursesw5-dev

sudo apt install pkg-config

sudo apt install bison

sudo apt install flex

sudo apt install libelf-dev

sudo apt install openssl

sudo apt-get install libssl-dev

sudo apt-get install liblz4-tool 

After downloading and decompressing the Kernel file, under a Terminal go to that directory and run the configuration script:

MyPC:~/Downloads/LinuxKernel/linux-5.19.8$ make menuconfig


We can check our hardware characteristics using the following commands:

lshw

lscpu

lsmod

lspci

lsusb

With that information we can set the configuration file properly.

The compilation process can be started with the command:

make -j 8

The number 8 means that 8 threads will be used for the compilation process. You can check with the command lscpu how many cores and threads your computer support. If you have 4 cores and every core can support 2 threads that makes a total of 8. Using all your threads will speed up the compilation process, in average using 8 threads the compilation would be over in about 30 minutes. If you use just one core or thread it would take over 2 hours to finish the compilation.

If you get the following error:

make[1]: *** No rule to make target 'debian/canonical-certs.pem', needed by 'certs/x509_certificate_list'.  Stop.

make[1]: *** Waiting for unfinished jobs....

make: *** [Makefile:1847: certs] Error 2

make: *** Waiting for unfinished jobs....

You can fix it editing your ".config" file and changing the line:

CONFIG_SYSTEM_TRUSTED_KEYS="debian/canonical-certs.pem"

to

CONFIG_SYSTEM_TRUSTED_KEYS=""

and run again the command for compilation.

Wednesday, March 09, 2022

Installing jGRASP in Linux

First download and unzip jGRASP for Linux (the bundled version).

Unzip it in a directory, in this case it was downloaded inside the directory "snap". Then create a link to it in /usr/bin/jgrasp as follows:

 sudo  ln  -s  /home/username/snap/jgrasp/bin/jgrasp  /usr/bin/jgrasp

You can call the program from command line or you can also create a desktop icon to call its execution.

Adding support for JavaFX:

First download the JavaFX and unzip it in a proper location, it could be also inside the "snap" directory. Then you need to go in jGRASP to "Settings ==> Compiler Settings ==> Workspace", a new window will be opened, and go to the "JavaFX" tab, there browse and input the JavaFX home path.


Note: the JavaFX has to be of the proper architecture, i.e. x64, or any other correctly corresponding to your machine, otherwise graphics won't work. 


After that, for testing purposes you can use the following code from Oracle.

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
 
public class HelloWorld extends Application {
    public static void main(String[] args) {
        launch(args);
    }
    
    @Override
    public void start(Stage primaryStage) {
        primaryStage.setTitle("Hello World!");
        Button btn = new Button();
        btn.setText("Say 'Hello World'");
        btn.setOnAction(new EventHandler<ActionEvent>() {
 
            @Override
            public void handle(ActionEvent event) {
                System.out.println("Hello World!");
            }
        });
        
        StackPane root = new StackPane();
        root.getChildren().add(btn);
        primaryStage.setScene(new Scene(root, 300, 250));
        primaryStage.show();
    }
}

The outcome will be the following:


Every time the button is clicked you will get the string:

Hello World!

That string is in the terminal in pure text mode.





---

Thursday, February 24, 2022

Converting A4 PDF to Letter Size

 One solution that usually works is to use pdfjam from the texlive distribution

pdfinfo input.pdf 

pdfjam --outfile output.pdf --paper letter input.pdf 

pdfinfo output.pdf 

We can also do the opposite, from Letter size to A4 size.



----///

Wednesday, January 26, 2022

SOFT & HARD LINKS

Soft links

Commonly referred to as symbolic links, soft links link together non-regular and regular files. They can also span multiple filesystems. By definition, a soft link is not a standard file, but a special file that points to an existing file. Format: 

ln -s (file path [original] you want to point to) (the soft path pointing to the original)

Example:

ln -s  /home/simon/snap/jgrasp/bin/jgrasp   /usr/bin/jgrasp

Hard links

The concept of a hard link is the most basic. Every file on the Linux filesystem starts with a single hard link. The link is between the filename and the actual data stored on the filesystem. Creating an additional hard link to a file means a few different things. The syntax is:

ln (original file path) (new file path)

Example:

ln  TestFile  /tmp/link2TestF

First, you create a new filename pointing to the exact same data as the old filename. This means that the two filenames, though different, point to identical data. When changes are made to one filename, the other reflects those changes. The permissions, link count, ownership, timestamps, and file content are the exact same. If the original file is deleted, the data still exists under the secondary hard link. The data is only removed from your drive when all links to the data have been removed. If you find two files with identical properties but are unsure if they are hard-linked, use the "ls -i" command to view the inode number. Files that are hard-linked together share the same inode number. Example:

ls  -li  TestFile  /tmp/link2TestF

Conclusion

  • A hard link always points a filename to data on a storage device.
  • A soft link always points a filename to another filename, which then points to information on a storage device.



Reference: RedHat.

---