Visualizzazione post con etichetta Linux. Mostra tutti i post
Visualizzazione post con etichetta Linux. Mostra tutti i post

1 agosto 2025

La Fonera: tramonto di un'idea



Vi sblocco un ricordo: La Fonera.

Un router/access point basato su software libero progettato per la condivisione della propria connessione ad internet in tempi in cui l'accesso al Web non era a portata di tutti com'è oggi.

La mia, aggiornata con l'ultima OpenWrt disponibile a Natale, mi ha abbandonato oggi: non si accende più nemmeno con un altro alimentatore.

Mi ha servito per quasi quindici anni, prima come router ed access point, poi 'solo' come access point secondario.

Qui un link ad una recensione dell'epoca, tanto per darvi un'idea di quanto fosse avanzata la fonera ai tempi e delle libertà che abbiamo perso nei dispositivi moderni, tutti APP-centrici e ben poco personalizzabili.

La parola Fonera per me è ricordo dei linux day e di una Idea .

L'Idea che si è accartocciata quasi del tutto sotto l'occupazione dei social, l'invasione delle fake news e, in parallelo, la crisi delle democrazie con l'appoggio esterno di troppi compagni a dittatori & affini.

Con Linux ci lavoro, in casa lo usiamo tutti, prole major inclusa, parenti e affini idem.

Ma, lo ammetto, più per comodità ed economia che per l'idea di libertà, trasparenza e coesione sociale che avevo anni fa.

Un client linux dura più di 10 anni senza decadimento di prestazioni.

Io appartengo a quella generazione in grado di assemblarsi un computer ed installare un sistema operativo lì dove né quella precedente né quelle successive sono in grado di farlo.

Non so se le mie figlie vorranno imparare quest'arte dell'indipendenza e della socialità tecnologica.

Ma poco importa: il futuro è sempre diverso dai calcoli dell'umanità.

Beh, io da anni mi aspetto questo presente.

E la morte della mia Fonera è solo un altro simbolo della fine di ogni illusione.

Ma non di ogni Idea.




17 marzo 2025

Resurrezione: come far tornare (quasi) nuovo un Macbook Pro 2011 con linux




Mi hanno regalato un vecchio MacBook Pro 13"  (Early 2011 13" - MC724LL/A - MacBookPro8,1 - A1278 - 2419*) del 2011 (grazie Cogna'!).

Tastiera guasta.

Beh, si può usare una tastiera esterna eh, ma capisco che si perda la mobilità.

Dopo aver restituito al legittimo proprietario l'SSD ho valutato il da farsi.

Una Cpu Intel Core i7 2620M è ancora un motore ruggente.

Usando vecchi moduli di RAM dal mio magazzino ho pure scoperto che la mainboard supporta 16 GB di RAM.

Beh, una macchina così è un peccato buttarla via e mi sono deciso a intraprendere la complicata via della sostituzione della tastiera.

Così, armato di ricambio e guida di fixit, ho intrapreso la lunga e ansiogena via della riparazione.

E' stata dura.

38 step all'andata, 38 al ritorno.















Ho sudato sette camicie temendo di aver anche guastato irreparabilmente la macchina.

Ma ce l'ho fatta.

Visto che c'ero, poi, ho sostituito il lettore dvd con un secondo disco ssd.

La parte facile, anzi, facilissima, è stata quella del sistema operativo.

L'ultimo macOS supportato dal notebook è 10.13 High Sierra che è in EOL da tempo.

Ho installato LMDE6 che  ha riportato a nuova vita la macchina.

Nessun problema di drivers, fluidità e reattività.

Con Firefox, Libreoffice Writer e Calc aperti è indistinguibile dal mio pc

E ora?

Francamente, per quanto potente, il mac è troppo pesante e ha troppa poca autonomia per essere adoperato come portatile quando vado in giro.
Per quello ho un Dell Latitude 7280 che è molto più leggero e con una autonomia considerevole.

Per adesso lo userò come sistema di test per varie distro linux che voglio provare.

Poi, penso proprio che affiderò la macchina alla Prole: stanno già usando un vecchissimo Macbook con CPU Intel Core 2 T8100 e con 4gb di RAM e sempre LMDE6 come Sistema Operativo: funziona bene anche questo ma non è proprio un fulmine.

Sarà un bell'upgrade e magari potrò installare qualche suite educativa più moderna che il povero processore T8100 fa fatica a supportare.

Morale della favola? 

Una macchina del 2011 con un sistema operativo aggiornato a Marzo 2025.

Praticamente come nuova.

E che ci vuole? Basta usare linux.




Meditate, gente: quando Micro$oft terminerà il supporto a Windows 10 per il vostro computer (magari con CPU i7 e 32GB di RAM), non rottamatelo: installateci linux, sbatteteci la testa, chiedete aiuto.

E liberatevi una volta per tutte dalla sottomissione ai sistemi operativi proprietari.

12 gennaio 2024

Pivpn su sistemi debian/ubuntu based non supportati - PiVPN for unsupported Debian/ubuntu derivatives



 PiVPN è un ottimo sistema per realizzare velocemente un server vpn domestico.

E a che serve?

Beh, fondamentalmente a collegarsi da remoto al pc di casa vostra.

Realizzare una vpn è una faccenda relativamente complessa e richiede un minimo di competenza anche usando PiVpn che è un software in grado di automatizzare il 95% delle attività di installazione e configurazione.

Ma quel 5% residuo (procurarsi un DNS dinamico, aprire le porte del router, definire un IP statico per il server ecc.) va fatto a mano. Il wizard di PiVpn è ben fatto ma non fa miracoli.

Tuttavia tra 100 e 5 c'è una bella differenza e un gran risparmio di tempo e fatica.

Personalmente, infatti, ho configurato più volte server VPN partendo da zero ed è un compito, ormai, più noioso che impegnativo e preferisco usare PiVpn e risparmiarmi la noia.

Ma c'è un problema:

PiVPN si installa solo e soltanto su 

Raspbian and Raspberry PI OS bastai su Debian Stretch, Buster e Bullseye. Su Ubuntu Server, DietPi e

Alpine Linux.

E le derivate di Debian/Ubuntu?

Beh, la documentazione dice che potrebbe funzionare ma loro non danno supporto in merito.

Di fatto, l'installer di PiVPN si rifiuta di proseguire se non rileva i sistemi operativi supportati ufficialmente.

E allora come si fa?

Ecco qua il trucchetto:

Per esempio, da Linux Mint è necessario modificare (momentaneamente) il file /etc/os-release come segue: dopo il setup si può rimettere tutto come stava prima. Su Mint 21.1 e LMDE6 poi PiVPN si installa e funziona perfettamente:


#NAME="Linux Mint"

#VERSION="21.2 (Victoria)"

#ID=linuxmint

#ID_LIKE="ubuntu debian"

#PRETTY_NAME="Linux Mint 21.2"

#VERSION_ID="21.2"

NAME="Ubuntu"

VERSION="22.04 (Jammy)"

ID=ubuntu

ID_LIKE="ubuntu debian"

PRETTY_NAME="Ubuntu 22.04"

VERSION_ID="22.04"

HOME_URL="https://www.linuxmint.com/"

SUPPORT_URL="https://forums.linuxmint.com/"

BUG_REPORT_URL="http://linuxmint-troubleshooting-guide.readthedocs.io/en/latest/"

PRIVACY_POLICY_URL="https://www.linuxmint.com/"

VERSION_CODENAME=victoria

UBUNTU_CODENAME=jammy


oppure, per LMDE


#PRETTY_NAME="LMDE 6 (faye)"

#NAME="LMDE"

#VERSION_ID="6"

#VERSION="6 (faye)"

#VERSION_CODENAME=faye

#ID=linuxmint

#HOME_URL="https://www.linuxmint.com/"

#SUPPORT_URL="https://forums.linuxmint.com/"

#BUG_REPORT_URL="http://linuxmint-troubleshooting-guide.readthedocs.io/en/latest/"

#PRIVACY_POLICY_URL="https://www.linuxmint.com/"

#ID_LIKE=debian

NAME="Debian"

VERSION="12"

DEBIAN_CODENAME=bookworm

ID=debian


Dopodiché, basta lanciare curl -L https://install.pivpn.io | bash da un terminale root e seguire il wizard. Ed il gioco è fatto: in pochi minuti avrete il vostro server vpn.


In Google Translator's English:


PiVPN is an excellent way to quickly create a home VPN server.

And what's the point?

Well, basically to connect remotely to your home PC.

Creating a VPN is a relatively complex matter and requires a minimum of expertise even using PiVpn which is software capable of automating 95% of installation and configuration activities.

But that remaining 5% (procuring a dynamic DNS, opening the router ports, defining a static IP for the server, etc.) must be done by hand. The PiVpn wizard is well done but doesn't work miracles.

However, between 100 and 5 there is a big difference and a great saving of time and effort.

Personally, in fact, I have configured VPN servers several times starting from scratch and it is now a task that is more boring than challenging and I prefer to use PiVpn and save myself the boredom.

But there's a problem:

PiVPN installs only and only on Raspbian and Raspberry PI OS based on Debian Stretch, Buster and Bullseye. On Ubuntu Server, DietPi and Alpine Linux.

What about Debian/Ubuntu derivatives?

Well, the documentation says it might work but they don't support it.

In fact, the PiVPN installer refuses to continue if it does not detect officially supported operating systems.

So how do you do it?

Here's the trick:

For example, from Linux Mint it is necessary to (temporarily) modify the /etc/os-release file as follows: after setup you can put everything back as it was before. On Mint 21.1 and LMDE6 then PiVPN installs and works perfectly:

#NAME="Linux Mint"

#VERSION="21.2 (Victoria)"

#ID=linuxmint

#ID_LIKE="ubuntu debian"

#PRETTY_NAME="Linux Mint 21.2"

#VERSION_ID="21.2"

NAME="Ubuntu"

VERSION="22.04 (Jammy)"

ID=ubuntu

ID_LIKE="ubuntu debian"

PRETTY_NAME="Ubuntu 22.04"

VERSION_ID="22.04"

HOME_URL="https://www.linuxmint.com/"

SUPPORT_URL="https://forums.linuxmint.com/"

BUG_REPORT_URL="http://linuxmint-troubleshooting-guide.readthedocs.io/en/latest/"

PRIVACY_POLICY_URL="https://www.linuxmint.com/"

VERSION_CODENAME=victoria

UBUNTU_CODENAME=jammy


and, for LMDE


#PRETTY_NAME="LMDE 6 (faye)"

#NAME="LMDE"

#VERSION_ID="6"

#VERSION="6 (faye)"

#VERSION_CODENAME=faye

#ID=linuxmint

#HOME_URL="https://www.linuxmint.com/"

#SUPPORT_URL="https://forums.linuxmint.com/"

#BUG_REPORT_URL="http://linuxmint-troubleshooting-guide.readthedocs.io/en/latest/"

#PRIVACY_POLICY_URL="https://www.linuxmint.com/"

#ID_LIKE=debian

NAME="Debian"

VERSION="12"

DEBIAN_CODENAME=bookworm

ID=debian


After that, just run curl -L https://install.pivpn.io | bash from a root terminal and follow the wizard. And that's it: in a few minutes you will have your VPN server.

6 marzo 2019

Come resettare PulseAudio (e risolvere il problema di Sound Delay) in Linux Mint 19.1/Ubuntu 18.04 - How to reset Pulseaudio (and solve a sound delay problem) in Linux Mint 19.1/Ubuntu 18.04

Qualche tempo fa mi è successo un curioso incidente: stavo vedendo un film. Ho interrotto la riproduzione e dopo una mezz'ora ho avviato un altro film. L'audio era ritardato di circa 1 secondo. Ho riavviato il PC (non avevo voglia di fare debug) ma al reboot il problema si è ripresentato con tutti i player (vlc, MPV,) e anche su amazon video e netflix.
Dopo una lunga ricerca su google ho trovato un primo indizio sul wiki di Arch Linux.
A quanto pare "il problema potrebbe essere causato da una dimensione non corretta dei buffer"

Quindi, nel file:

/etc/pulse/daemon.conf

Ho impostato:

default-fragments = 4
default-fragment-size-msec = 2

Dopodichè ho riavviato il computer ma il problema è rimasto.
Ovviamente non è necessario riavviare il computer su linux per riavviare un pezzo del sistema. Per riavviare pulseaudio, da terminale come utente normale si procede così:

pulseaudio -k

che termina il processo pulseaudio. Entro pochi secondi systemd lo farà ripartire automaticamente. 
Ho continuato la ricerca e ho scoperto che pulseaudio ha dei files di configurazione locali 'per utente' posizionati nella cartella

/home/nomeutente/.config/pulse

cosa che mi è parsa subito ovvia quando ho notato che il riavvio del server audio va fatto come utente normale e non come root.

Quindi, dopo aver 'aggiustato' i parametri del buffer questi files di configurazione vanno cancellati prima di  riavviare il server audio.

mv ~/.config/pulse ~/.config/pulse.old
pulseaudio -k

questa procedura ha risolto il mio problema.
Ovviamente, quando siete sicuri che è tutto ok, i vecchi files di configurazione possono essere traquillamente cancellati:

rm -rf ~/.config/pulse.old

Tutto risolto?
No. Il vero problema è: "che cosa è successo al mio sistema per 'rompere' la configurazione?"
Purtroppo, non sono riuscito a individuarne la causa e questo, su sistema linux, è uno smacco serio.


********************************************************************************************************


A curious incident happened to me some time ago: I was watching a movie. I stopped playing and after half an hour I started another movie. The audio was delayed by about 1 second. I restarted the PC (I did not want to debug) but after the reboot the problem has recurred with all the players (vlc, MPV,) and also on amazon video and netflix.

After a long search on google I found a first clue on the wiki of Arch Linux.

Apparently "the problem could be caused by an incorrect buffer size"
So, in the file:

/etc/pulse/daemon.conf

I set:

default-fragments = 4
default-fragment-size-msec = 2

Then I restarted the computer but the problem remained.
Obviously it is not necessary to restart the computer on linux to restart a piece of the system. To restart pulseaudio, from the terminal as a normal user:

pulseaudio -k

which ends the pulseaudio process. Within a few seconds, systemd will restart it automatically.

I continued the search and found that pulseaudio has local configuration files 'per user' located in the folder
/home/nomeutente/.config/pulse

which seemed obvious to me when I noticed that the audio server should be restarted as a normal user and not as root.
Therefore, after having adjusted the buffer parameters, these configuration files must be deleted before restarting the audio server.

mv ~/.config/pulse ~/.config/pulse.old
pulseaudio -k

this procedure solved my problem.

Of course, when you're sure it's ok, the old configuration files can be quietly deleted:

rm -rf ~/.config/pulse.old

All solved?

No. The real problem is: "What happened to my system to 'break' the configuration?"

Unfortunately, I could not identify the cause and this, on linux system, is a serious failure.




20 febbraio 2019

Video in 4k su linux? Facile con MPV! - 4K Video on Linux? Easy with MPV!

Mi sono ritrovato nella necessità di visualizzare, sulla mia Linux box, film con risoluzione 2160p  - 3840×2160 pixel, ossia Ultra HD, (4K per gli amici al bar).
Nonostante una CPU Intel Core i7-7700T, una scheda grafica NVidia GT 1030 e un SSD come supporto il mio film 4K non ne voleva sapere di scorrere fluido su VLC.
In altri tempi avrei dedicato un po' di energia al debug del problema, oggi mi trovo nella necessità di usare il mio tempo libero per ... il tempo libero e non per indagare sul perchè non sta funzionando quello che voglio usare per impiegare il (poco) tempo libero.
Una breve ricerca mi  ha portato a scoprire un player multimediale leggero e funzionale ai miei scopi: MPV.
Il progetto è piuttosto giovane ed il software non ha nemmeno un'interfaccia grafica completa, ma funziona a meraviglia sulla mia configurazione hardware permettendomi di visualizzare video 2160p senza nessun problema di prestazioni.
E' multipiattaforma come VLC e ho testato su Mint 19.1 la versione 2:0.29.1+git3~zzbionic.
Seguendo queste semplici istruzioni è possibile usare la GUI di SMPlayer con MPV nel caso siano necessarie funzionalità aggiuntive.
MPV non è presente nei repo ufficiali e va installato da suoi PPA (qui uno dei tre):

sudo add-apt-repository ppa:mc3man/mpv-tests
sudo apt-get update
sudo apt-get install mpv


la barra del menu, scarna ma con il necessario per riprodurre video, scegliere lingue e sottotitoli


I found myself in the need to view, on my linux box, films with a resolution of 2160p - 3840 × 2160 pixels, or Ultra HD, (4K for friends at the bar).
Despite an Intel Core i7-7700T CPU, an NVidia GT 1030 graphics card and an SSD as support my 4K movie did not want to run smoothly on VLC.
In other times I would have devoted some energy to the debugging of the problem, today I find myself in the need to use my free time for ... free time and not to investigate why it is not working what I want to use for my (little) free time.
A brief research led me to discover a light and functional multimedia player for my purposes: MPV.
The project is quite young and the software does not even have a complete GUI, but it works wonders on my hardware configuration allowing me to view 2160p video without any performance problems.
It is multiplatform like VLC and I have tested on Mint 19.1 the version 2: 0.29.1 + git3 ~ zzbionic.
By following these simple instructions you can use the SMPlayer GUI with MPV in case additional features are required.

MPV is not present in the official repo and must be installed by its PPA (here one of the three):

sudo add-apt-repository ppa:mc3man/mpv-tests
sudo apt-get update
sudo apt-get install mpv

4 novembre 2015

How to build a cheap NAS for rsync backup with Raspberry Pi

(In my poor English at bottom)

"Il backup è Vita, il Backup è cosa buona e giusta"

Esistono molti sistemi di backup, dal semplice copia incolla su una penna usb alle soluzioni cloud di big data.
In ambiente domestico  si stanno diffondendo i NAS per poter salvaguardare la propria vita digitale fatta, ormai, di centinaia di GB di foto, film, ebook, files musicali e documenti.
Stiamo parlando di una spesa minima di 150 € per il NAS a cui aggiungere la spesa degli Hard Disk, un NAS a disco singolo da 1 TB può venire a costare ben più di € 200.

Ma volete mettere il piacere di far da sé?
Ora, a chi è dedicata questa guida?
Non solo agli utenti di GNU/Linux BSD eccetera.
E' dedicata anche agli utenti di windows che vogliano cimentarsi un po' con linux e che, tuttavia, non abbiano nessuna intenzione di abbandonare Windows sul loro PC:
questo NAS funzionerà anche per voi!

Quali competenze vi servono?


Competenze? 

Beh, saper instaurare una connessione ssh non guasta, saper usare un editor di testo tipo vim, nemmeno.
Se vi installate una classica ubuntu in Virtualbox potreste rapidamente acquisire le necessarie competenze.
Se partissimo da zero in tutti gli ambiti, questa guida sarebbe più lunga per i prerequisiti che per l'argmento principale, quindi, pur non dando per scontato nulla, linkerò delle guide utili ai vari segmenti del nostro lavoretto.

Cosa vi occorre:

Un Raspberry Pi funzionante (ma la guida è valida per qualunque computer con su linux, che so, un vecchio netbook che tenete spento da anni) ed un supporto esterno per il backup, tipicamente un Hard Disk esterno USB, ma, se, ad esempio, avete da salvare solo una ventina di GB di dati, potreste usare una microsd da 32 GB per il Raspberry più che sufficiente anche per il backup.

Il vantaggio di questa soluzione è nella sua completa automazione, economicità (il Raspberry vi costerà attorno ai 50 €, schedina micro SD per il suo sistema operativo inclusa) e nello stimolo didattico per chi si approccia all'universo linux di apprendere e migliorarsi.

Cos'è il Raspberry Pi? Ve lo andate a leggere qui.
Cos'è Linux? Idem, qui.

Per prima cosa: il sistema operativo originale del Raspberry non va bene.
E' troppo pesante ed è difficile ripulirlo dei servizi inutili, tanto vale usare direttamente una versione basica di Debian che potrete scaricare qui (e dove trovate le istruzioni per l'installazione)

Sapete instaurare una connessione ssh dal vostro PC al Raspberry usando putty o, meglio, Mobaxterm?

Ecco qui la guida ufficiale di Raspberry.
Poi, il vostro hard disk esterno deve essere formattato con un file system più digeribile possibile per linux: NTFS di windows funzionerà lo stesso, ma le prestazioni del sistema ne sarebbero degradate, quindi formattate il vostro hard disk esterno direttamente in ext4, ci sono molti tool per fare questa operazione anche da un computer windows.
Andiamo con ordine: siete seduti di fronte al vostro PC con una connessione ssh al Raspberry funzionante.


ssh username@IPdelRaspberry


Quasi tutte le operazioni andranno eseguite come utente amministrativo root, quindi digitiamo:


su root



e inseriamo la password scelta in fase di installazione.




Per prima cosa occorre impostare il fuso orario e la tastiera, ecco i comandi:

dpkg-reconfigure tzdata

dpkg-reconfigure console-data
dpkg-reconfigure console-data
dpkg-reconfigure locales

E' sempre il caso di operare con software aggiornato:


apt-get update

apt-get upgrade

rispondendo Y alla richiesta del sistema di installare eventuali aggiornamenti

Poi è il momento di installare il software necessario ai nostri scopi;

 apt-get install screen vim rsync


Che cosa abbiamo installato?



screen è un programma che consente di lanciare un comando e disconnettersi dal raspberry con la certezza del proseguimento del funzionamento del comando;

vim è un editor di testo (non molto intuitivo nel funzionamento ma da qualche parte si deve pur cominciare)
rsync è il programma di sincronizzazione che useremo per il backup.

il passo successivo consiste nel far riconoscere il disco usb al raspberry. Linux riconosce automaticamente i dischi, ma non effettua, automaticamente, il montaggio di tali dischi sul file -system nelle versioni server come quella installata sul Raspberry.

E' come se voi inseriste una penna usb in un pc windows che non la apre automaticamente.
Inoltre, sempre per fare un parallelo con windows, bisogna fare in modo che il disco montato finisca sempre nello stesso punto del file system, in altri termini che la lettera assegnata da Windows alla pennetta usb resti sempre la stessa anche dopo vari riavvi e ricollegamenti.
Iniziamo a fare sul serio: digitiamo

fdisk -l


E ci ritroviamo di fronte qualcosa del genere:



Disk /dev/mmcblk0: 7969 MB, 7969177600 bytes

4 heads, 16 sectors/track, 243200 cylinders, total 15564800 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00027aa3

        Device Boot      Start         End      Blocks   Id  System

/dev/mmcblk0p1            2048      104447       51200    b  W95 FAT32
/dev/mmcblk0p2          104448     1742847      819200   83  Linux
/dev/mmcblk0p3         1742848     1945599      101376   82  Linux swap / Solaris

Disk /dev/sda: 1000.2 GB, 1000204886016 bytes

81 heads, 63 sectors/track, 382818 cylinders, total 1953525168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x5ba59dda
Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2048  1953525167   976761560   83  Linux


Niente paura. 

Il comando che abbiamo dato elenca i dischi del sistema, un po' alla volta si prende dimestichezza, per adesso basti saper che mmcblk0 è la scheda microSD del Raspberry mntre sda è l'hard disk USB.
Ecco, a noi interessa proprio la stringa /dev/sda1 che sta a significare che la nostra partizione ext4 sull'hard disk esterno si chiama, appunto, /dev/sda1.
Manca ancora un pezzo:

ls /dev/disk/by-uuid -alh


drwxr-xr-x 2 root root 160 gen  1  1970 .

drwxr-xr-x 6 root root 120 gen  1  1970 ..
lrwxrwxrwx 1 root root  15 gen  1  1970 0a0e4e5a-7652-402a-89ea-5e524f5f8a37 -> ../../mmcblk0p2
lrwxrwxrwx 1 root root  10 gen  1  1970 6ba8c7e8-5c61-4448-8b73-26175ca6adfe -> ../../sda1
lrwxrwxrwx 1 root root  15 gen  1  1970 972837af-21d7-41cf-9f1e-4a3bb27b87ae -> ../../mmcblk0p3
lrwxrwxrwx 1 root root  15 gen  1  1970 A51D-3FFB -> ../../mmcblk0p1



Vediamo di capirci qualcosa. Avete presente l'sda1 che vien fuori dall'ultimo comando?
E che vuol dire l'ultimo comando?
Chiediamo al sistema di elencare tutte le partizioni presenti elencandole per UUID, ossia quel codice alfanumerico che identifica univocamente le partizioni.
Nel nostro caso: 6ba8c7e8-5c61-4448-8b73-26175ca6adfe
E che ce ne facciamo?
Beh, lo usiamo per dire al sistema che sda1 è identificato da 6ba8c7e8-5c61-4448-8b73-26175ca6adfe sempre e per sempre, anche se stacchiamo l'hard disk o riavviamo il sistema.
Creiamo una cartella in cui il nostro bravo raspberry andrà a montare l'hard disk esterno:

cd /media/   Ci spostiamo nella cartella /media/
mkdir 1tb  creiamo la cartella 1tb
chown -R user:user 1tb/   diamo all'utente il possesso della cartella
chmod -R 755 1tb/  assegnamo i permessi di scrittura e lettura a questa cartella


Ora, un attimo di attenzione. 

1tb è una cartella vuota, di proprietà dell'utente pi in cui tutti possono leggere e solo pi può scrivere.
Tutto qua.


E il nostro sda1 con tutto quel po' po' di codice lungo appresso? 

vim /etc/fstab

#                            
proc            /proc           proc            defaults                0       0
/dev/mmcblk0p1  /boot           vfat            defaults                0       0
/dev/mmcblk0p3  none            swap            sw                      0       0
UUID=6ba8c7e8-5c61-4448-8b73-26175ca6adfe       /media/1tb      ext4    defaults        0       2

Ecco qua dove andiamo ad inserire il nostro codice che abbiamo ricavato dal comando ls /dev/disk/by-uuid -alh, nella riga in grassetto.
Ora, usare vim non è semplicissimo, si può adoperare al suo posto nano, un altro editor un po' meno ostico, ma alla fine della fiera si deve aggiungere al normale file fstab quella riga.
Ovviamente il codice sarà diverso per ogni partizione (altrimenti che identificativo unico sarebbe?) e bisogna vedere come avete chiamato la cartella in cui andare a montare il disco esterno.
Una volta salvato potete uscire e 'montare' la nuova partizione nel sistema con il comando

mount -a

potete verificar il successo dell'operazione entrando nella cartella /media/1tb e verificando lo spazio disponibile nel sistema con il comando

df -h

File system     Dim. Usati Dispon. Uso% Montato su
rootfs          772M  533M    223M  71% /
/dev/root       772M  533M    223M  71% /
devtmpfs        215M     0    215M   0% /dev
tmpfs            44M  224K     44M   1% /run
tmpfs           5,0M     0    5,0M   0% /run/lock
tmpfs           108M     0    108M   0% /run/shm
/dev/mmcblk0p1   50M   19M     31M  38% /boot
/dev/sdb1       917G  270G    602G  31% /media/1tb

In questo caso il disco da 1tb è occupato per il 31%.
Riavviate fiduciosi il raspberry, il disco sarà di nuovo lì, montato e scrivibile.
E ora?
Ora dobbiamo finalmente impostare il nostro sistema di backup a partire dal PC di cui vogliamo fare il backup.
In questa guida, al momento, prepareremo il backup di un computer che usa linux, poi aggiungerò anche una sezione per un client windows.
Spostiamoci, quindi, sul computer di cui si deve fare il backup.
Imposteremo un sistema che, automaticamente, alle 20 di sera, sincronizzerà il contenuto di una propria cartella con il disco da 1tb collegato al raspberry.
Coraggio, il peggio è alle spalle.
Accendiamo il nostro PC linux di cui, ad esempio, desideriamo fare il backup della nostra home.
Apriamo una finestra di terminale e digitiamo:


ssh-keygen -t rsa -C "Raspberry"

non inserire alcuna password quando ci verrà richiesto ma premiamo semplicemente invio.
Cosa abbiamo fatto? Abbiamo generato una coppia di chiavi, per i dettagli suggerisco la lettura di questa guida.

Copiamo la chiave pubblica sul raspberry con il comando

ssh-copy-id -i ~/.ssh/id_rsa.pub username@IPdelRaspberry

e proviamo a connetterci al raspberry senza inserire la password

ssh username@IPdelRaspberry

se non ci viene richiesta la password siamo a posto.

Nella nostra home possiamo preparare lo script di backup:

creiamo il file backup.sh, lo rendiamo eseguibile (esercizio ;) ) e dentro ci incolliamo:

#!/bin/bash

rsync --exclude=".cache" -avrzh --delete --progress --log-file=/home/username/raspberrypi.log /home/username/ -e "ssh" username@IPdelRaspberry:/media/1tb/



rsync è il programma di backup, il parametro  --exclude="lost+found" esclude la cartella .cache dal backup (si possono aggiungere tutte le esclusioni necessarie), --delete cancella i files dalla cartella di backup non più presenti nella cartella sorgente, -- progress visualizza il progresso dell'operazione, poi abbiamo la generazione del log (sempre utile) e la cartella di origine.

Per ultimo,  -e "ssh" username@IPdelRaspberry:/media/1tb/ vuol dire che rsync si collega usando il protocollo ssh col nome utente indicato al raspberry nella cartella /media/1tb/

E come facciamo a farlo lanciare automaticamente ogni sera alle 20?

Editiamo come root il  file /etc/crontab aggiungendo la riga in grassetto allo script:


# /etc/crontab: system-wide crontab

# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.

SHELL=/bin/sh

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# m h dom mon dow user  command

17 *    * * *   root    cd / && run-parts --report /etc/cron.hourly
25 6    * * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6    * * 7   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6    1 * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
00 20 * * * username /home/username/backup.sh >/dev/null 2>&1

E questo è tutto.

Ogni sera alle 20, se entrambe le macchine sono accese, il PC automaticamente sincronizzerà la home con il raspberry.

Non aspettatevi grandi prestazioni nel trasferimento dei files, ecco perchè l'ideale è usare questo sistema per il backup notturno magari del classico muletto, un PC a basso consumo che faccia da file server domestico.

PRO:

  • economicità nei componenti e nei consumi;
  • estremamente didattico per imparare ad usare linux;
  • completamente automatico

CONTRO:



  • Se ci si deve ricorare di accendere il PC prima delle 20 non è davvero un backup automatico (ma ne parleremo nella prossima puntata)
  • prestazioni insufficienti
  • recupero files di backup dal disco usb non immediato nè rapido


Sono stato un po' prolisso, sicuramente imperfetto, migliorerò la guida nel tempo e aggiungerò qualcosina anche per windows quanto prima.

Buon backup a tutti







"The Backup is life, the backup is a good and right thing"
There are a lot of backup systems: from a simple  copy and past on an usb pendrive to big data cloud.
In the home environment are spreading the NAS in order to safeguard their digital life made, now, of hundreds of GB of photos, movies, ebooks, music files and documents.
We are talking about a minimum cost of 150 € for the NAS to wich add the cost of the hard drive, a single disc 1 TB NAS can cost well over € 200.
But you want to put the pleasure of doing it yourself?
Now, who to bring this guide?
Not only users of GNU / Linux BSD etc.
It 'also dedicated to Windows users who want to try a little with linux and that, however, they have no intention of giving up Windows on their  PC:
this NAS will work for you too (in the next part of this guide)!
What skills do you need?
Skills? Well, you should know how to establish an ssh connection and how to use a text editor like vim.
If you installed a classic ubuntu in virtualbox you could rapidly acquire the necessary skills.
Starting from scratch in all areas of this guide would be longer for the prerequisites thanb for the beef, therefore, while not assuming anything, I'll link someuseful guides to the various segments of our job.

What you need:


running Raspberry Pi (but the guide applies to any computer running on Linux, say, an old netbook that you hold off for years) and external media for backup, typically a USB external hard drive, but if, for example, you have to save only about twenty GB of data, you could use a microSD 32GB for Raspberry more than enough even for the backup.


The advantage of this solution is in its full automation, cost (the Raspberry will cost around 50 €, Micro SD Card to its operating system included) and stimulating educational for those approaches universe linux to learn and improve.


What is the Raspberry Pi? You'll go read here.

What is Linux? Go here.

First: the original operating system of Raspberry's not good.

It is too heavy and full of unnecessary services (including a graphical desktop), you might use directly a basic version of Debian that you can download here (where you can find also instructions for installation)


You know how to establish an ssh connection from your PC to the Raspberry using putty or, better, MobaXterm?

Here is the official documentation of Raspberry.
Then, your external hard drive must be formatted with a file system can be more digestible for linux: NTFS windows work, yes, but system performance will be degraded, then format your external hard drive directly in ext4, there are many tools to help with that too from a windows computer.

Now you're sitting in front of your PC with a ssh functioning connection to the Raspberry.


ssh username@IPdelRaspberry


Almost all operations will be run as an administrative user root, then type:


su root


and enter the password chosen during installation.


First, you must set the time zone and keyboard, here are the commands:


dpkg-reconfigure tzdata

dpkg-reconfigure console-data
dpkg-reconfigure console-data
dpkg-reconfigure locales

It's bettere work  with updated software:


apt-get update
apt-get upgrade

Then it's time to install the necessary software for our purposes


 apt-get install screen vim rsync


What we have installed?

Screen is a program that allows you to run a command and disconnect from raspberry with the certainty of the continuing operation of the command;
Vim is a text editor (not very intuitive in operation but somewhere it has to start)

rsync is the synchronization program that we will use for backup.

The next step is to recognize the USB disk to raspberry. Linux disks automatically recognizes, but does not, automatically, the installation of such records on file -system versions server as the one installed on Raspberry.
And 'as if you inseriste a USB stick into a Windows PC that does not open automatically.
Moreover, to make a parallel with windows, we must make sure that the disk mounted to end at the same point of the file system, in other words that the letter assigned by Windows to the USB key always remains the same even after several reboots and reconnections.

We begin to get serious: we type


fdisk -l


And we are faced with something like this:



Disk /dev/mmcblk0: 7969 MB, 7969177600 bytes
4 heads, 16 sectors/track, 243200 cylinders, total 15564800 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00027aa3


       Device Boot      Start         End      Blocks   Id  System
/dev/mmcblk0p1            2048      104447       51200    b  W95 FAT32
/dev/mmcblk0p2          104448     1742847      819200   83  Linux
/dev/mmcblk0p3         1742848     1945599      101376   82  Linux swap / Solaris


Disk /dev/sda: 1000.2 GB, 1000204886016 bytes
81 heads, 63 sectors/track, 382818 cylinders, total 1953525168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x5ba59dda
Device Boot      Start         End      Blocks   Id  System


/dev/sda1            2048  1953525167   976761560   83  Linux

No fear. The command we have given lists disks in the system, a bit 'at a time you get comfortable, for now suffice it to know that mmcblk0 is the microSD card Raspberry mntre sda is the USB hard drive. Here, we are interested in just the string / dev / sda1 which means that our ext4 partition external hard drive is called, precisely, / dev / sda1. Still missing a piece:



ls /dev/disk/by-uuid -alh

drwxr-xr-x 2 root root 160 gen  1  1970 .

drwxr-xr-x 6 root root 120 gen  1  1970 ..

lrwxrwxrwx 1 root root  15 gen  1  1970 0a0e4e5a-7652-402a-89ea-5e524f5f8a37 -> ../../mmcblk0p2

lrwxrwxrwx 1 root root  10 gen  1  1970 6ba8c7e8-5c61-4448-8b73-26175ca6adfe -> ../../sda1

lrwxrwxrwx 1 root root  15 gen  1  1970 972837af-21d7-41cf-9f1e-4a3bb27b87ae -> ../../mmcblk0p3

lrwxrwxrwx 1 root root  15 gen  1  1970 A51D-3FFB -> ../../mmcblk0p1

And let's figure it out. 

You remember the sda1 that comes out from the last command?
And that means the last command?
We ask the system to list all partitions by listing by UUID, ie the alphanumeric code that uniquely identifies partitions.
In our case: 6ba8c7e8-5c61-4448-8b73-26175ca6adfe
And what do we do?
Well, we use it to tell the system that sda1 is identified by 6ba8c7e8-5c61-4448-8b73-26175ca6adfe always and forever, even if we detach the hard disk or reboot the system.

We create a folder in which our raspberry will mount the external hard drive:



cd /media/  we are moving in the /media/ directory
mkdir 1tb we create the directory 1tb
chown -R pi:pi 1tb/ give to the user the possession of the directory 1tb


chmod -R 755 1tb/  → let's assign the permissions to the directory

Now, a moment's attention. 1tb is an empty folder, that you own more when everyone can read and write can only pi. That's all. And our sda1 with all the little 'bit' of long code below?

vim /etc/fstab

#                              
proc            /proc           proc            defaults                0       0
/dev/mmcblk0p1  /boot           vfat            defaults                0       0
/dev/mmcblk0p3  none            swap            sw                      0       0
UUID=6ba8c7e8-5c61-4448-8b73-26175ca6adfe       /media/1tb      ext4    defaults        0       2


Here's where we're going to put our code that we have obtained from the command ls / dev / disk / by-uuid -alh, in bold line. Now, using vim is not easy, you can use nano in place, another editor a bit less difficult, but at the end of the fair is to be added to fstab that line. Obviously, the code will be different for each partition. Once saved, you can go out and 'mount' the new partition in the system with the command



mount -a



you can verify the success of entering into the / media / 1TB and verifying the space available in the system with the command





df -h


File system     Dim. Usati Dispon. Uso% Montato su

rootfs          772M  533M    223M  71% /

/dev/root       772M  533M    223M  71% /

devtmpfs        215M     0    215M   0% /dev

tmpfs            44M  224K     44M   1% /run

tmpfs           5,0M     0    5,0M   0% /run/lock

tmpfs           108M     0    108M   0% /run/shm

/dev/mmcblk0p1   50M   19M     31M  38% /boot

/dev/sdb1       917G  270G    602G  31% /media/1tb


In this case the 1tb disc is busy for the 31%. Restart confident the raspberry, the disc will be back there, still mounted and writable. And now? Now we finally set up our backup system from the PC we want to backup. In this guide, at the time, we will prepare to back up a computer running Linux, then add a section to a windows client. Let's move, then, on your computer that you should back up. We will set up a system that automatically at 20 pm, will synchronize the contents of your folder with 1TB disk connected to the raspberry. Courage, the worst is behind us. We turn on our PC linux which, for example, want to back up our home. Open a terminal window and type:

ssh-keygen -t rsa -C "Raspberry"

not enter a password when we will be asked (twice). What have we done? We have generated a key pair, for details suggest the reading of this guide. We copy the public key on the raspberry with the simple command

ssh-copy-id -i ~/.ssh/id_rsa.pub username@IPdelRaspberry

and we try to connect to the raspberry without password

ssh username@IPdelRaspberry

if no password is asked we're ok. In our home directory we can prepare the backup script backup.sh
Edit it with vim, nano or a text editor, then make ite executable (how? A little exercise)

#!/bin/bash
rsync --exclude=".cache" -avrzh --delete --progress --log-file=/home/username/raspberrypi.log /home/username/ -e "ssh" username@IPdelRaspberry:/media/1tb/

Here's our backup script: rsync is the backup program, the parameter --exclude = "lost + found" folder .cache exclude from backup (you can add all the exclusions necessary), --delete delete files from the backup folder is no longer in the folder source - progress shows the progress of the operation, then we have the generation of log (always useful) and the source folder. Finally, -e "ssh" username @ IPdelRaspberry: / media / 1TB / means that rsync is connected using the ssh protocol with the user name indicated in raspberry in the / media / 1TB / And how do we do that launch automatically every night at 20? Edit it as root / etc / crontab and add the line in bold script:


# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# m h dom mon dow user  command
17 *    * * *   root    cd / && run-parts --report /etc/cron.hourly
25 6    * * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6    * * 7   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6    1 * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
00 20 * * * username /home/username/backup.sh >/dev/null 2>&1

And that's it.

Every night, at 20, if both machines are on, the PC automatically synchronize the home with the raspberry.
Do not expect great performance in the transfer of the files, which is why it is best to use this system for the nightly backup maybe using a classic forklift, a low-power PC to serve as a home file server

PRO:

cheap price for components and consumption
extremely educational to learn to use linux

AGAINST:

recover files from the backup disk usb not immediate nor fast
If you must remember to turning on your PC before 20 is not an automatic backup
poor performance 
I was a bit 'confused, certainly imperfect, will improve the guide over time and add something for windows as soon as possible. Good backup at all