-
How to create a simple Telegram bot in python
The basic idea was to starting handling some python code and having fun, that lead me to create a Telegram bot with the ability to send simple text mesage into a group to bother my friends.
The documentation about python Telegram library to create a bot is available in the official site https://python-telegram-bot.org/, here you can find any information with a bunch of example.
To keep things simple in this stage I decided to avoid DB and others cool stuff, all the phrases that the bot will use are saved in text files and picked up randomly.
(more…) -
How to extend a LVM volume adding a new disk
In this how-to I’m going to explain the way to increase the disk space by adding a new hard disk and extending the LVM volume. After that more free disk space to the system is available.
System preparation
Firstly, after you connected the new disk, take a look to the the system with lsblk command.
What is lsblk?
From: https://www.man7.org/linux/man-pages/man8/lsblk.8.html
lsblk lists information about all available or the specified block devices. The lsblk command reads the sysfs filesystem and udev db to gather information. If the udev db is not available or lsblk is compiled without udev support, then it tries to read LABELs, UUIDs and filesystem types from the block device. In this case root permissions are necessary. The command prints all block devices (except RAM disks) in a tree-like format by default.
pippo@pluto:~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 465.8G 0 disk
├─sda1 8:1 0 512M 0 part /boot/efi
├─sda2 8:2 0 1G 0 part /boot
└─sda3 8:3 0 464.3G 0 part
└─ubuntu--vg-ubuntu--lv 253:0 0 464.3G 0 lvm /
sdb 8:16 0 238.5G 0 disk
├─sdb1 8:17 0 100M 0 part
├─sdb2 8:18 0 16M 0 part
├─sdb3 8:19 0 237.9G 0 part
└─sdb4 8:20 0 520M 0 part
pippo@pluto:~$In my case I have a disk with 4 partitions under the device “/dev/sdb” and we must delete the non necessary partitions with fdisk in order to create the new one to use.
What is fdisk?
From: From: https://www.man7.org/linux/man-pages/man8/fdisk.8.html
fdisk is a dialog-driven program for creation and manipulation of partition tables. It understands GPT, MBR, Sun, SGI and BSD partition tables.
pippo@pluto:~$ sudo fdisk /dev/sdb
Welcome to fdisk (util-linux 2.31.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.Command (m for help): d
Partition number (1-4, default 4):
Partition 4 has been deleted.
Command (m for help): d
Partition number (1-3, default 3):
Partition 3 has been deleted.
Command (m for help): d
Partition number (1,2, default 2):
Partition 2 has been deleted.
Command (m for help): d
Selected partition 1
Partition 1 has been deleted.Command (m for help): n
Partition number (1-128, default 1):
First sector (34-500118158, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-500118158, default 500118158):
Created a new partition 1 of type 'Linux filesystem' and of size 238.5 GiB.
Partition #1 contains a vfat signature.
Do you want to remove the signature? [Y]es/[N]o: y
The signature will be removed by a write command.
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.After the steps above we created the condition necessary to proceed with LVM volume extention part. Performing a new check with lsblk we can verify if the behaviour is as expected.
pippo@pluto:~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 465.8G 0 disk
├─sda1 8:1 0 512M 0 part /boot/efi
├─sda2 8:2 0 1G 0 part /boot
└─sda3 8:3 0 464.3G 0 part
└─ubuntu--vg-ubuntu--lv 253:0 0 464.3G 0 lvm /
sdb 8:16 0 238.5G 0 disk
└─sdb1 8:17 0 238.5G 0 part
pippo@pluto:~$LVM taks
Firstly create a physical volume with the pvcreate command and the new partition path /dev/sdb1.
pippo@pluto:~$ sudo pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created.
pippo@pluto:~$After that we need to retrieve the Volume Group Name (VG Name) with the vgdisplay command, in this case is “ubuntu-vg“.
pippo@pluto:~$ sudo vgdisplay
--- Volume group ---
VG Name ubuntu-vg
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 1
Max PV 0
Cur PV 1
Act PV 1
VG Size <464.26 GiB
PE Size 4.00 MiB
Total PE 118850
Alloc PE / Size 118850 / <464.26 GiB
Free PE / Size 0 / 0
VG UUID VpkffP-MEmJ-6CU6-eQfo-h0QW-af1K-3Xesz3Secondly we need to use the vgextend command to extend the volume group “ubuntu-vg” into “/dev/sdb1“.
pippo@pluto:~$ sudo vgextend ubuntu-vg /dev/sdb1
Volume group "ubuntu-vg" successfully extended
pippo@pluto:~$After that we can verify that the Free PE is equal to the size of the added disk with vgdisplay command, then find the Logical Volume Path (LV Path) with the lvdisplay command.
pippo@pluto:~$ sudo lvdisplay
--- Logical volume ---
LV Path /dev/ubuntu-vg/ubuntu-lv
LV Name ubuntu-lv
VG Name ubuntu-vg
LV UUID whhBcQ-XLri-IRxE-z23h-NUWG-HB2M-pxlvHo
LV Write Access read/write
LV Creation host, time ubuntu-server, 2021-09-18 12:33:24 +0000
LV Status available
# open 1
LV Size <464.26 GiB
Current LE 118850
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0Thirdly extend the volume with the lvextend command to the desired size.
pippo@pluto:~$ sudo lvextend -L+238G /dev/ubuntu-vg/ubuntu-lv
Size of logical volume ubuntu-vg/ubuntu-lv changed from <464.26 GiB (118850 extents) to <702.26 GiB (179778 extents).
Logical volume ubuntu-vg/ubuntu-lv successfully resized.
pippo@pluto:~$The last step, but not least, is to resize the filesystem via resize2fs command.
pippo@pluto:~$ sudo resize2fs /dev/ubuntu-vg/ubuntu-lv
resize2fs 1.44.1 (24-Mar-2018)
Filesystem at /dev/ubuntu-vg/ubuntu-lv is mounted on /; on-line resizing required
old_desc_blocks = 59, new_desc_blocks = 88
The filesystem on /dev/ubuntu-vg/ubuntu-lv is now 184092672 (4k) blocks long.
pippo@pluto:~$Conclusion
In conclusion those are the steps necessary how to extend a LVM volume adding a new disk, I made this tutorial on Ubuntu 18.04 LTS but it is valid for all the distros. Moreover, if you have free space on the disk, you can start from LVM task paragraph.
-
Another World (Out of This World) Shadow Box
L’idea è nata casualmente girovagando su Etsy, successivamente ho scoperto la pagina Instagram di @briefcade_shadowboxes che mi ha motivato a finalizzare e concretizzare quella che era una semplice idea.
Se siete interessati ad uno Shadow Box su un “vostro titolo del cuore” senza sbattimenti e con la certezza di avere un risultato di alto livello, vi consiglio di fare un giro nella pagina linkata sopra.
L’idea iniziale era quella di creare uno Shadow box di Super Mario Bros. ma poco dopo ho deciso di optare per Another World (Out of This World), altro titolo che mi ha dato tanto in ambito videoludico.
E che Another World (Out of This World) Shadow Box sia!
Another World (Out of This World) è un videogioco di fantascienza, genere Action-Adventure Platform, capace di catturare il giocatore sin dal primo fotogramma.
Il gioco inizia con l’arrivo del giovane fisico, a bordo della sua Ferrari 288 GTO, nel suo laboratorio.
Durante l’esecuzione di un esperimento con un acceleratore di particelle, nel tentativo di scoprire cosa è successo alla nascita del nostro universo, il laboratorio viene colpito da un fulmine che crea una fusione delle particelle con una successiva esplosione causa dell’apertura di un buco nello spazio tempo che teleporta il protagonista in un mondo alieno.La scena dell’arrivo al laboratorio è quella che ho scelto per realizzare il mio piccolo tributo a questo titolo, nonostante forse sia la meno adatta allo scopo.
Dopo aver generato le differenti immagini necessarie ed averle stampate su carta con grammatura elevata, ho tagliato ed assemblato il tutto.
Di seguito alcune foto di quanto fatto per ottenere il mio Another World Shadow Box.
Ho preferito il risultato con il frame bianco all’interno nonostante questo copra parte del lavoro.
Il risultato è sicuramente migliorabile ma come prima volta sono veramente soddisfatto.
-
Game Boy Advance con schermo LCD IPS
Ho acquistato un Game Boy Advance usato perfettamente funzionante ma in condizioni estetiche veramente pessime.
Da subito ho iniziato a cercare cosa poter fare per riportarlo ad un nuovo splendore, scoprendo un intero mondo di mod ed appassionati che lo trasformano in un oggetto attuale.
I kit plug & play disponibili per questa console portatile sono:
- Display LCD IPS
- Batteria al litio con modulo di ricarica USB Type-C
- Amplificatore audio e speaker
Dato lo scarso budget e la voglia di metterci le mani il prima possibile mi sono messo alla ricerca del kit per la sostituzione del display e per una nuova shell.
Dopo un giro sui vari siti “specializzati” come RetroSix ed affini ho deciso di provare a cercare una via più economica… e l’ho trovata!
Ho acquistato un kit omnicomprensivo su AliExpress per installare su Game Boy Advance un LCD IPS per la modica cifra di 38€ spedizione inclusa.
IPS V2 Kit <– Link AliExpress
Il kit può essere montato in due modi:
- Luminosità fissa, la via più semplice dove è richiesta solo un poco di manualità e precisione
- Luminosità regolabile a 10 livelli, dove è richiesta anche la capacità di effettuare saldature a stagno su circuiti con una certa precisione
Avendo perso il mio saldatore a stagno in questa prima fase ho optato per la via numero 1.
Personalmente prima di effettuare il montaggio del pannello LCD sulla shell, che risulta essere pre-tagliata per far alloggiare correttamente lo schermo, ho preferito effettuare alcuni test di funzionamento.
Successivamente ho incollato la guarnizione biadesiva sulla parte frontale, poi ho rimosso la pellicola dal pannello e l’ho incollato facendo attenzione nel mantenere la messa in squadro e l’allineamento.
Bisogna tenere in considerazione che la parte frontale dell’LCD risulta essere asimmetrica.
Dopo aver montato la lente frontale ho applicato la pellicola isolante sul retro del pannello e sono andato avanti con il ri-assemblare la console all’interno della nuova shell verde.
Il risultato è fantastico ma considero questo lo step 1, infatti prevedo di collegare la regolazione della luminosità e successivamente installare il kit con batteria al litio.
Ecco come risulta essere il Game Boy Advance con LCD IPS.
-
Keytool SSL certificate request
How To create Keytool SSL certificate request? We can divide the request in three steps:
- The creation of the certificate’s Private Key
- The generation of the CSR (This is the information that you must submit to your SSL provider for the creation of the certificate)
- The import of the certificate in your keystore via keytool
Below the commands for the described steps:
- Keytool -genkey -alias AliasName -keyalg RSA -keysize 2048 -keystore “PathKeystore”
- keytool -certreq -alias AliasName -keyalg RSA -file FileName.csr -keystore “PathKeystore” -ext SAN=dns:DNSName.it,Hostname,…
- keytool -import -alias AliasName -keystore “PathKeystore” -file FileName.cer
For more information check the Keytool Oracle Documentation
-
Lanciare il test del display su un portatile Dell Latitude E5450
Delle volte capita di avere dei pixel malfunzionanti sul display LCD o che l’illuminazione non sia omogenea.
Per lanciare il test sul Latitude E5450 è necessario spegnerlo ed accenderlo mantenendo premuto il tasto D, da rilasciare appena il portatile si è acceso.
Fatto ciò viene lanciato il test che visualizza sullo schermo 2 cicli di colori: bianco, nero, rosso, verde, blu.
Se ci sono pixel malfunzionanti o una luminosità non omogenea se ne avrà immediatamente l’evidenza con questo test.
-
Come configurare il DHCP su un router Cisco
Per configurare il DHCP (Dynamic Host Configuration Protocol) su un router Cisco è necessario essere in possesso di alcune informazioni basilari quali:
- rete dove attivare il servizio
- indirizzo del/dei DNS server
- gateway della rete
- nome del dominio
- durata del lease
- eventuali indirizzi o range di indirizzi da escludere dal DHCP
-
Sostituire Unity con Mate-Desktop su Ubuntu 14 LTS
Recentemente ho avuto la necessità di installare Ubuntu Desktop 14 LTS su un netbook ed il desktop environment Unity si è dimostrato troppo pesante e goffo su una macchina dalle risorse esigue, oltre alle mie ingerenze personali nei suoi confronti.
Per prima cosa ho installato il necessario di Mate-Desktop aprendo un terminale e digitando i seguenti comandi:
$ sudo su
$ apt-add-repository ppa:ubuntu-mate-dev/ppa
$ apt-add-repository ppa:ubuntu-mate-dev/trusty-mate
$ apt-get update && apt-get upgrade
$ apt-get install --no-install-recommends ubuntu-mate-core ubuntu-mate-desktop
Terminata l’installazione ho riavviato il PC e mi sono loggato con Mate verificando il corretto funzionamento del tutto. (more…)
-
Creare una pendrive avviabile (bootabile) per installare Linux su un netbook
Dopo alcune verifiche è emerso che il netbook che mi hanno chiesto di riparare ha l’hard disk danneggiato.
Non essendo in possesso della versione di Windows 7 Starter preinstallato ho deciso di installare Ubuntu con Mate-Desktop sul nuovo disco.
Per creare la chiavetta avviabile ho scaricato ed utilizzato il programma Universal USB Installer scaricabile gratuitamente dal sito ufficiale.
Oltre a questo programma stand-alone ho scaricato l’ISO 32bit di Ubuntu Desktop ed ho recuperato una pendrive vuota. (more…)
-
Come ridimensionare foto in blocco (batch) con XnView su Windows
Al fine di ottimizzare lo spazio disco utilizzato ho deciso di ridimensionare le foto diminuendone qualità e risoluzione.
Per fare ciò ho utilizzato XnView, che ho trovato molto più pratico ed intuitivo di IrfanView.
Il software è scaricabile direttamente dal sito internet.
In alternativa si può scaricare ed utilizzare XnConverter, software della stessa casa orientato alla conversione pura di immagini.
Una volta installato il software è sufficiente aprirlo e lanciare il tool di conversione dal menu Strumenti –> Conversione…
(more…)