mercoledì 17 agosto 2016

Approccio a MariaDB su CentOS

Seguono alcuni appunti a riguardo dell'installazione e dell'utilizzo di MariaDB su CentOS 7.

Gli appunti sono basati sulla documentazione che si trova all'indirizzo https://mariadb.com/kb/en.

Installazione

# yum install mariadb-server

Avvio

[root@mariadbhost ~]# systemctl start mariadb
[root@mariadbhost ~]# systemctl|awk 'NR==1||/mariadb/'
UNIT             LOAD   ACTIVE SUB       DESCRIPTION
mariadb.service  loaded active running   MariaDB database server
[root@mariadbhost ~]# 

Spegnimento

[root@mariadbhost ~]# systemctl stop mariadb
[root@mariadbhost ~]# systemctl|awk 'NR==1||/mariadb/'
UNIT             LOAD   ACTIVE SUB       DESCRIPTION
[root@mariadbhost ~]# ps -efa | grep mariadb
root      2936  2425  0 11:26 pts/0    00:00:00 grep --color=auto mariadb
[root@mariadbhost ~]# 

Avvio automatico

[root@mariadbhost ~]# systemctl enable mariadb
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
[root@mariadbhost ~]# reboot
...
[root@mariadbhost ~]# systemctl|awk 'NR==1||/mariadb/'
UNIT             LOAD   ACTIVE SUB       DESCRIPTION
mariadb.service  loaded active running   MariaDB database server
[root@mariadbhost ~]# 

File di configurazione e di log predefiniti

[root@mariadbhost ~]# cat /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd

[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid

#
# include all files from the config directory
#
!includedir /etc/my.cnf.d

[root@mariadbhost ~]# find /etc/my.cnf.d/
/etc/my.cnf.d/
/etc/my.cnf.d/mysql-clients.cnf
/etc/my.cnf.d/client.cnf
/etc/my.cnf.d/server.cnf
[root@mariadbhost ~]# ls -l /etc/my.cnf.d/
total 12
-rw-r--r--. 1 root root 295 Jun 16 21:08 client.cnf
-rw-r--r--. 1 root root 232 Jun 16 21:08 mysql-clients.cnf
-rw-r--r--. 1 root root 744 Jun 16 21:08 server.cnf
[root@mariadbhost ~]# cat /etc/my.cnf.d/mysql-clients.cnf
#
# These groups are read by MariaDB command-line tools
# Use it for options that affect only one utility
#

[mysql]

[mysql_upgrade]

[mysqladmin]

[mysqlbinlog]

[mysqlcheck]

[mysqldump]

[mysqlimport]

[mysqlshow]

[mysqlslap]

[root@mariadbhost ~]# cat /etc/my.cnf.d/client.cnf
#
# These two groups are read by the client library
# Use it for options that affect all clients, but not the server
#


[client]

# This group is not read by mysql client library,
# If you use the same .cnf file for MySQL and MariaDB,
# use it for MariaDB-only client options
[client-mariadb]

[root@mariadbhost ~]# cat /etc/my.cnf.d/server.cnf
#
# These groups are read by MariaDB server.
# Use it for options that only the server (but not clients) should see
#
# See the examples of server my.cnf files in /usr/share/mysql/
#

# this is read by the standalone daemon and embedded servers
[server]

# this is only for the mysqld standalone daemon
[mysqld]

# this is only for embedded server
[embedded]

# This group is only read by MariaDB-5.5 servers.
# If you use the same .cnf file for MariaDB of different versions,
# use this group for options that older servers don't understand
[mysqld-5.5]

# These two groups are only read by MariaDB servers, not by MySQL.
# If you use the same .cnf file for MySQL and MariaDB,
# you can put MariaDB-only options here
[mariadb]

[mariadb-5.5]

[root@mariadbhost ~]# cat /var/run/mariadb/mariadb.pid
2770
[root@mariadbhost ~]# ps -efa | grep -w 2770
mysql     2770  2613  0 11:03 ?        00:00:00 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mariadb/mariadb.log --pid-file=/var/run/mariadb/mariadb.pid --socket=/var/lib/mysql/mysql.sock
root      2861  2425  0 11:11 pts/0    00:00:00 grep --color=auto -w 2770
[root@mariadbhost ~]# cat /var/log/mariadb/mariadb.log
160817 11:03:03 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
160817 11:03:03 [Note] /usr/libexec/mysqld (mysqld 5.5.50-MariaDB) starting as process 2770 ...
160817 11:03:03 InnoDB: The InnoDB memory heap is disabled
160817 11:03:03 InnoDB: Mutexes and rw_locks use GCC atomic builtins
160817 11:03:03 InnoDB: Compressed tables use zlib 1.2.7
160817 11:03:03 InnoDB: Using Linux native AIO
160817 11:03:03 InnoDB: Initializing buffer pool, size = 128.0M
160817 11:03:03 InnoDB: Completed initialization of buffer pool
InnoDB: The first specified data file ./ibdata1 did not exist:
InnoDB: a new database to be created!
160817 11:03:03  InnoDB: Setting file ./ibdata1 size to 10 MB
InnoDB: Database physically writes the file full: wait...
160817 11:03:04  InnoDB: Log file ./ib_logfile0 did not exist: new to be created
InnoDB: Setting log file ./ib_logfile0 size to 5 MB
InnoDB: Database physically writes the file full: wait...
160817 11:03:04  InnoDB: Log file ./ib_logfile1 did not exist: new to be created
InnoDB: Setting log file ./ib_logfile1 size to 5 MB
InnoDB: Database physically writes the file full: wait...
InnoDB: Doublewrite buffer not found: creating new
InnoDB: Doublewrite buffer created
InnoDB: 127 rollback segment(s) active.
InnoDB: Creating foreign key constraint system tables
InnoDB: Foreign key constraint system tables created
160817 11:03:04  InnoDB: Waiting for the background threads to start
160817 11:03:05 Percona XtraDB (http://www.percona.com) 5.5.49-MariaDB-37.9 started; log sequence number 0
160817 11:03:05 [Note] Plugin 'FEEDBACK' is disabled.
160817 11:03:05 [Note] Server socket created on IP: '0.0.0.0'.
160817 11:03:05 [Note] Event Scheduler: Loaded 0 events
160817 11:03:05 [Note] /usr/libexec/mysqld: ready for connections.
Version: '5.5.50-MariaDB'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  MariaDB Server
[root@mariadbhost ~]# 

Amministrazione

[root@mariadbhost ~]# mysqladmin  status
Uptime: 797  Threads: 1  Questions: 4  Slow queries: 0  Opens: 0  Flush tables: 2  Open tables: 26  Queries per second avg: 0.005
[root@mariadbhost ~]# mysqladmin  processlist
+----+------+-----------+----+---------+------+-------+------------------+----------+
| Id | User | Host      | db | Command | Time | State | Info             | Progress |
+----+------+-----------+----+---------+------+-------+------------------+----------+
| 5  | root | localhost |    | Query   | 0    |       | show processlist | 0.000    |
+----+------+-----------+----+---------+------+-------+------------------+----------+
[root@mariadbhost ~]# mysqladmin ver
mysqladmin  Ver 9.0 Distrib 5.5.50-MariaDB, for Linux on x86_64
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Server version  5.5.50-MariaDB
Protocol version 10
Connection  Localhost via UNIX socket
UNIX socket  /var/lib/mysql/mysql.sock
Uptime:   16 min 47 sec

Threads: 1  Questions: 33  Slow queries: 0  Opens: 0  Flush tables: 2  Open tables: 26  Queries per second avg: 0.032
[root@mariadbhost ~]# mysqladmin variables|grep datadir
| datadir                                           | /var/lib/mysql/                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
[root@mariadbhost ~]# mysqladmin 
mysqladmin  Ver 9.0 Distrib 5.5.50-MariaDB, for Linux on x86_64
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Administration program for the mysqld daemon.
Usage: mysqladmin [OPTIONS] command command....

Default options are read from the following files in the given order:
/etc/mysql/my.cnf /etc/my.cnf ~/.my.cnf 
The following groups are read: mysqladmin client client-server client-mariadb
The following options may be given as the first argument:
--print-defaults        Print the program argument list and exit.
--no-defaults           Don't read default options from any option file.
--defaults-file=#       Only read default options from the given file #.
--defaults-extra-file=# Read this file after the global files are read.

  -c, --count=#       Number of iterations to make. This works with -i
                      (--sleep) only.
  --debug-check       Check memory and open file usage at exit.
  --debug-info        Print some debug info at exit.
  -f, --force         Don't ask for confirmation on drop database; with
                      multiple commands, continue even if an error occurs.
  -C, --compress      Use compression in server/client protocol.
  --character-sets-dir=name 
                      Directory for character set files.
  --default-character-set=name 
                      Set the default character set.
  -?, --help          Display this help and exit.
  -h, --host=name     Connect to host.
  -b, --no-beep       Turn off beep on error.
  -p, --password[=name] 
                      Password to use when connecting to server. If password is
                      not given it's asked from the tty.
  -P, --port=#        Port number to use for connection or 0 for default to, in
                      order of preference, my.cnf, $MYSQL_TCP_PORT,
                      /etc/services, built-in default (3306).
  --protocol=name     The protocol to use for connection (tcp, socket, pipe,
                      memory).
  -r, --relative      Show difference between current and previous values when
                      used with -i. Currently only works with extended-status.
  -s, --silent        Silently exit if one can't connect to server.
  -S, --socket=name   The socket file to use for connection.
  -i, --sleep=#       Execute commands repeatedly with a sleep between.
  --ssl               Enable SSL for connection (automatically enabled with
                      other flags).
  --ssl-ca=name       CA file in PEM format (check OpenSSL docs, implies
                      --ssl).
  --ssl-capath=name   CA directory (check OpenSSL docs, implies --ssl).
  --ssl-cert=name     X509 cert in PEM format (implies --ssl).
  --ssl-cipher=name   SSL cipher to use (implies --ssl).
  --ssl-key=name      X509 key in PEM format (implies --ssl).
  --ssl-verify-server-cert 
                      Verify server's "Common Name" in its cert against
                      hostname used when connecting. This option is disabled by
                      default.
  -u, --user=name     User for login if not current user.
  -v, --verbose       Write more information.
  -V, --version       Output version information and exit.
  -E, --vertical      Print output vertically. Is similar to --relative, but
                      prints output vertically.
  -w, --wait[=#]      Wait and retry if connection is down.
  --connect-timeout=# 
  --shutdown-timeout=# 
  --plugin-dir=name   Directory for client-side plugins.
  --default-auth=name Default authentication client-side plugin to use.

Variables (--variable-name=value)
and boolean options {FALSE|TRUE}  Value (after reading options)
--------------------------------- ----------------------------------------
count                             0
debug-check                       FALSE
debug-info                        FALSE
force                             FALSE
compress                          FALSE
character-sets-dir                (No default value)
default-character-set             auto
host                              (No default value)
no-beep                           FALSE
port                              0
relative                          FALSE
socket                            (No default value)
sleep                             0
ssl                               FALSE
ssl-ca                            (No default value)
ssl-capath                        (No default value)
ssl-cert                          (No default value)
ssl-cipher                        (No default value)
ssl-key                           (No default value)
ssl-verify-server-cert            FALSE
user                              (No default value)
verbose                           FALSE
vertical                          FALSE
connect-timeout                   43200
shutdown-timeout                  3600
plugin-dir                        (No default value)
default-auth                      (No default value)

Where command is a one or more of: (Commands may be shortened)
  create databasename   Create a new database
  debug     Instruct server to write debug information to log
  drop databasename   Delete a database and all its tables
  extended-status         Gives an extended status message from the server
  flush-all-statistics    Flush all statistics tables
  flush-all-status        Flush status and statistics
  flush-client-statistics Flush client statistics
  flush-hosts             Flush all cached hosts
  flush-index-statistics  Flush index statistics
  flush-logs              Flush all logs
  flush-privileges        Reload grant tables (same as reload)
  flush-slow-log          Flush slow query log
  flush-status    Clear status variables
  flush-table-statistics  Clear table statistics
  flush-tables            Flush all tables
  flush-threads           Flush the thread cache
  flush-user-statistics   Flush user statistics
  kill id,id,... Kill mysql threads
  password [new-password] Change old password to new-password in current format
  old-password [new-password] Change old password to new-password in old format
  ping   Check if mysqld is alive
  processlist  Show list of active threads in server
  reload  Reload grant tables
  refresh  Flush all tables and close and open logfiles
  shutdown  Take server down
  status  Gives a short status message from the server
  start-slave  Start slave
  stop-slave  Stop slave
  variables             Prints variables available
  version  Get version info from server
[root@mariadbhost ~]# 

Creare un utente

[root@mariadbhost ~]# mysql -u root
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 5.5.50-MariaDB MariaDB Server

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> CREATE USER 'testuser'@'localhost' IDENTIFIED BY 'test123test!';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> SELECT User,Host FROM mysql.user;
+----------+-------------------------+
| User     | Host                    |
+----------+-------------------------+
| root     | 127.0.0.1               |
| root     | ::1                     |
|          | localhost               |
| root     | localhost               |
| testuser | localhost               |
|          | mariadbhost.localdomain |
| root     | mariadbhost.localdomain |
+----------+-------------------------+
7 rows in set (0.00 sec)

MariaDB [(none)]> 

Collegarsi

[root@mariadbhost ~]# mysql -u testuser -p -h localhost test
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 5.5.50-MariaDB MariaDB Server

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [test]> 

Creare un database

MariaDB [test]> CREATE DATABASE IF NOT EXISTS test;
Query OK, 1 row affected, 1 warning (0.00 sec)

MariaDB [test]> SHOW WARNINGS;
+-------+------+-----------------------------------------------+
| Level | Code | Message                                       |
+-------+------+-----------------------------------------------+
| Note  | 1007 | Can't create database 'test'; database exists |
+-------+------+-----------------------------------------------+
1 row in set (0.00 sec)

MariaDB [test]> USE test;
Database changed
MariaDB [test]>

Creare tabelle

MariaDB [test]> CREATE TABLE IF NOT EXISTS books (BookID INT NOT NULL PRIMARY KEY AUTO_INCREMENT, Title VARCHAR(100) NOT NULL, SeriesID INT, AuthorID INT); 
Query OK, 0 rows affected (0.04 sec)

MariaDB [test]> CREATE TABLE IF NOT EXISTS series (id INT NOT NULL PRIMARY KEY AUTO_INCREMENT);
Query OK, 0 rows affected (0.05 sec)

Aggiungere record a una tabella

MariaDB [test]> INSERT INTO books (Title,SeriesID,AuthorID) VALUES ('testbook1',1,1), ('testbook2',1,1), ('testbook3',1,1), ('testbook4',2,2), ('testbook5',2,2), ('testbook6',2,2), ('testbook7',0,1);
Query OK, 7 rows affected (0.02 sec)
Records: 7  Duplicates: 0  Warnings: 0

MariaDB [test]> 

Mostrare delle tabelle

MariaDB [test]> show tables;
+----------------+
| Tables_in_test |
+----------------+
| books          |
| series         |
+----------------+
2 rows in set (0.00 sec)

MariaDB [test]> describe books;
+----------+--------------+------+-----+---------+----------------+
| Field    | Type         | Null | Key | Default | Extra          |
+----------+--------------+------+-----+---------+----------------+
| BookID   | int(11)      | NO   | PRI | NULL    | auto_increment |
| Title    | varchar(100) | NO   |     | NULL    |                |
| SeriesID | int(11)      | YES  |     | NULL    |                |
| AuthorID | int(11)      | YES  |     | NULL    |                |
+----------+--------------+------+-----+---------+----------------+
4 rows in set (0.00 sec)

MariaDB [test]> select * from books;
+--------+-----------+----------+----------+
| BookID | Title     | SeriesID | AuthorID |
+--------+-----------+----------+----------+
|      1 | testbook1 |        1 |        1 |
|      2 | testbook2 |        1 |        1 |
|      3 | testbook3 |        1 |        1 |
|      4 | testbook4 |        2 |        2 |
|      5 | testbook5 |        2 |        2 |
|      6 | testbook6 |        2 |        2 |
|      7 | testbook7 |        0 |        1 |
+--------+-----------+----------+----------+
7 rows in set (0.00 sec)

MariaDB [test]> 

Modificare dei record

MariaDB [test]> update books set Title = 'lastbook' where BookID = 7;
Query OK, 1 row affected (0.02 sec)
Rows matched: 1  Changed: 1  Warnings: 0

MariaDB [test]> select * from books;
+--------+-----------+----------+----------+
| BookID | Title     | SeriesID | AuthorID |
+--------+-----------+----------+----------+
|      1 | testbook1 |        1 |        1 |
|      2 | testbook2 |        1 |        1 |
|      3 | testbook3 |        1 |        1 |
|      4 | testbook4 |        2 |        2 |
|      5 | testbook5 |        2 |        2 |
|      6 | testbook6 |        2 |        2 |
|      7 | lastbook  |        0 |        1 |
+--------+-----------+----------+----------+
7 rows in set (0.00 sec)

MariaDB [test]> 

sabato 9 gennaio 2016

Come eseguire il backup di uno smartphone Android su un PC Linux

Questi sono gli appunti che ho preso eseguendo il backup di uno smartphone Samsung S4 GT-I9515 con installato Android 5.0.1, su un sistema Fedora Linux 23 Workstation Edition.

Installare gli ADB tools

Sul sistema Linux, installare gli ADB tools (Android Debug Bridge):

root@localhost ~]# dnf install android-tools
...
Complete!
[root@localhost ~]# 

Abilitare la modalità sviluppatore sullo smartphone

Collegare lo smartphone al sistema Linux.

È necessario abilitare la modalità sviluppatore sullo smartphone. Per farlo bisogna andare in "Impostazioni" => "Altro" => "Info sul dispositivo" => quindi toccare su "Versione build" finché non si riceve conferma dell'avvenuta abilitazione della modalità sviluppatore.

Apparirà il nuovo menu "Impostazioni" => "Altro" => "Opzioni sviluppatore". Quindi in quel menu bisogna selezionare la casella "Debug USB".

Lo smartphone chiederà se ci si vuole collegare al PC, bisogna rispondere positivamente.

Fare il backup

Sul sistema Linux si può eseguire il comando "adb" senza parametri per vedere la lista delle opzioni disponibili:

[root@localhost ~]# adb
Android Debug Bridge version 1.0.32

...
 -s           - directs command to the device or emulator with the given
                                 serial number or qualifier. Overrides ANDROID_SERIAL
                                 environment variable.
...
 devices [-l]                  - list all connected devices
                                 ('-l' will also list device qualifiers)
...
device commands:
...
  adb backup [-f ] [-apk|-noapk] [-obb|-noobb] [-shared|-noshared] [-all] [-system|-nosystem] []
                               - write an archive of the device's data to .
                                 If no -f option is supplied then the data is written
                                 to "backup.ab" in the current directory.
                                 (-apk|-noapk enable/disable backup of the .apks themselves
                                    in the archive; the default is noapk.)
                                 (-obb|-noobb enable/disable backup of any installed apk expansion
                                    (aka .obb) files associated with each application; the default
                                    is noobb.)
                                 (-shared|-noshared enable/disable backup of the device's
                                    shared storage / SD card contents; the default is noshared.)
                                 (-all means to back up all installed applications)
                                 (-system|-nosystem toggles whether -all automatically includes
                                    system applications; the default is to include system apps)
                                 ( is the list of applications to be backed up.  If
                                    the -all or -shared flags are passed, then the package
                                    list is optional.  Applications explicitly given on the
                                    command line will be included even if -nosystem would
                                    ordinarily cause them to be omitted.)

  adb restore            - restore device contents from the  backup archive

  adb help                     - show this help message
  adb version                  - show version num
...
[root@localhost ~]# 

Verificare che lo smartphone venga riconosciuto:

[root@localhost ~]# adb devices -l
List of devices attached 
xxxxxxxx               device usb:3-1.6 product:zzzzzzzz model:GT_I9515 device:yyyyyy

[root@localhost ~]# 

Quindi eseguire il backup:

[root@localhost phone]# adb backup -apk -all -s xxxxxxxx -f NOMEFILEOUTPUTDIPROPRIASCELTA
Now unlock your device and confirm the backup operation.

Bisogna quindi sbloccare lo smartphone, esso chiederà se si vuole fare il backup, ed eventualmente chiederà la passowrd per la cifratura. Bisogna rispondere e poi il backup avrà inizio.

venerdì 31 luglio 2015

Fedora: installare codec video non-free

Per installare codec video non-free (che non vengono distribuiti direttamente da Fedora):

  • Aggiungere il repository RPM Fusion al proprio sistema: http://rpmfusion.org
  • installare i codec: dnf install gstreamer-plugins-bad gstreamer-plugins-bad-free-extras gstreamer-plugins-ugly gstreamer-ffmpeg libmatroska xvidcore xine-lib-extras-freeworld libdvdread libdvdnav gstreamer-plugins-good lsdvd libdvbpsi ffmpeg ffmpeg-libs gstreamer-ffmpeg

martedì 26 agosto 2014

FreeBSD: configurazione servizio Subversion - esempio di base

INSTALLAZIONE

root@fbsd1:~ # pkg install subversion
Updating repository catalogue
FreeBSD repository is up-to-date
All repositories are up-to-date
The following 7 packages will be affected (of 0 checked):

New packages to be INSTALLED:
        subversion: 1.8.10
        serf: 1.3.7
        apr: 1.5.1.1.5.3_3
        expat: 2.1.0_1
        sqlite3: 3.8.5_1
        gdbm: 1.11_2
        db48: 4.8.30.0_2

The process will require 32 MB more space
5 MB to be downloaded

Proceed with this action [y/N]: y
Fetching subversion-1.8.10.txz: 100% of 2 MB
Fetching serf-1.3.7.txz: 100% of 76 KB
Fetching apr-1.5.1.1.5.3_3.txz: 100% of 393 KB
Fetching expat-2.1.0_1.txz: 100% of 99 KB
Fetching sqlite3-3.8.5_1.txz: 100% of 654 KB
Fetching gdbm-1.11_2.txz: 100% of 143 KB
Fetching db48-4.8.30.0_2.txz: 100% of 915 KB
Checking integrity... done (0 conflicting)
[1/7] Installing expat-2.1.0_1: 100%
[2/7] Installing gdbm-1.11_2: 100%
[3/7] Installing db48-4.8.30.0_2: 100%
[4/7] Installing apr-1.5.1.1.5.3_3: 100%
[5/7] Installing serf-1.3.7: 100%
[6/7] Installing sqlite3-3.8.5_1: 100%
[7/7] Installing subversion-1.8.10: 100%
root@fbsd1:~ #

CREAZIONE DEL REPOSITORY

root@fbsd1:/m1pool/m1fs # svnadmin create /m1pool/m1fs/repos
root@fbsd1:/m1pool/m1fs #

root@fbsd1:/m1pool/m1fs # grep svn /etc/services
svn             3690/tcp   #Subversion
svn             3690/udp   #Subversion
root@fbsd1:/m1pool/m1fs #

root@fbsd1:/m1pool/m1fs # cd repos
root@fbsd1:/m1pool/m1fs/repos # find .
.
./hooks
./hooks/pre-commit.tmpl
./hooks/pre-revprop-change.tmpl
./hooks/post-lock.tmpl
./hooks/start-commit.tmpl
./hooks/post-unlock.tmpl
./hooks/pre-lock.tmpl
./hooks/pre-unlock.tmpl
./hooks/post-revprop-change.tmpl
./hooks/post-commit.tmpl
./format
./README.txt
./locks
./locks/db-logs.lock
./locks/db.lock
./conf
./conf/hooks-env.tmpl
./conf/svnserve.conf
./conf/authz
./conf/passwd
./db
./db/txn-current
./db/txn-protorevs
./db/write-lock
./db/transactions
./db/uuid
./db/format
./db/txn-current-lock
./db/revs
./db/revs/0
./db/revs/0/0
./db/fsfs.conf
./db/min-unpacked-rev
./db/revprops
./db/revprops/0
./db/revprops/0/0
./db/fs-type
./db/current
root@fbsd1:/m1pool/m1fs/repos #

CONFIGURAZIONE BASE

root@fbsd1:/m1pool/m1fs/repos/conf # mv svnserve.conf svnserve.conf~; cp svnserve.conf~ svnserve.conf
root@fbsd1:/m1pool/m1fs/repos/conf # vi svnserve.conf
root@fbsd1:/m1pool/m1fs/repos/conf # diff svnserve.conf~ svnserve.conf
19,20c19,20
< # anon-access = read
< # auth-access = write
---
> anon-access = none
> auth-access = write
27c27
< # password-db = passwd
---
> password-db = passwd
42c42
< # groups-db = groups
---
> groups-db = groups
47c47
< # realm = My First Repository
---
> realm = Marco Repository
54c54
< # force-username-case = none
---
> force-username-case = none
61c61
< # hooks-env = hooks-env
---
> hooks-env = hooks-env
root@fbsd1:/m1pool/m1fs/repos/conf # ed passwd
309
a
marco = MIAPASSWORD
.
w
326
q
root@fbsd1:/m1pool/m1fs/repos/conf # ed /etc/rc.conf
251
a
svnserve_enable="YES"
svnserve_data="/m1pool/m1fs/repos"
svnserve_flags="-d --listen-port=3690 --listen-host 192.168.0.11"
.
w
374
q
root@fbsd1:/m1pool/m1fs/repos/conf # pw groupadd -n svn -g 90
root@fbsd1:/m1pool/m1fs/repos/conf # pw useradd -n svn -u 90 -g svn -d /nonexistent -s /nonexistent
root@fbsd1:/m1pool/m1fs/repos/conf # chown -R svn:svn /m1pool/m1fs/repos
root@fbsd1:/m1pool/m1fs/repos/conf # service svnserve start
Starting svnserve.
root@fbsd1:/m1pool/m1fs/repos/conf # service svnserve status
svnserve is running as pid 3714.
root@fbsd1:/m1pool/m1fs/repos/conf #

IMPORT DEI DATI

root@fbsd1:/m1pool/m1fs/repos/conf # cd ~marco
root@fbsd1:~marco # svn import src file:///m1pool/m1fs/repos/marco/src -m "import iniziale"
...
Committed revision 1.
root@fbsd1:~marco #


[marco@othersystem ~]$ svn import src/ svn://192.168.0.11/othersys/src -m "initial import"
Authentication realm:  Marco Repository
Password for 'marco': 
Adding         ...

Committed revision 5.
[marco@othersystem ~]$ 

$ svn co svn://192.168.0.11/othersys
Authentication realm:  Marco Repository
Password for 'marco': ********

A    othersys/src
...

Checked out revision 5.
$

RIFERIMENTI

giovedì 14 agosto 2014

FreeBSD: gpg 2.x termina con errore perché non è stato installato pinentry

PROBLEMA

$ gpg ciphered.tar.gpg
gpg: 3DES encrypted data
gpg-agent[1264]: can't connect to the PIN entry module: IPC connect call failed
gpg-agent[1264]: command get_passphrase failed: No pinentry
gpg: problem with the agent: No pinentry
gpg: encrypted with 1 passphrase
gpg: decryption failed: No secret key
$

SOLUZIONE

root@fbsd1:/home/marco # pkg install pinentry
Updating repository catalogue
FreeBSD repository is up-to-date
All repositories are up-to-date
The following 85 packages will be affected (of 0 checked):

New packages to be INSTALLED:
        pinentry: 0.8.3_1
[...]
        xprop: 1.2.2

The process will require 669 MB more space
128 MB to be downloaded

Proceed with this action [y/N]: n
root@fbsd1:/home/marco # pkg
pkg: not enough arguments
Usage: pkg [-v] [-d] [-l] [-N] [-j |-c ] [-C ] [-R ] [-o var=value]  []


For more information on available commands and options see 'pkg help'.
root@fbsd1:/home/marco # pkg help
Usage: pkg [-v] [-d] [-l] [-N] [-j |-c ] [-C ] [-R ] [-o var=value]  []
[...]

Commands supported:
[...]
        search         Performs a search of package repository catalogues
[...]
root@fbsd1:/home/marco # pkg search pinentry
pinentry-0.8.3_1
pinentry-curses-0.8.3
pinentry-gtk-0.8.3
pinentry-gtk2-0.8.3
pinentry-qt4-0.8.3
root@fbsd1:/home/marco # pkg install pinentry-curses
Updating repository catalogue
FreeBSD repository is up-to-date
All repositories are up-to-date
The following 1 packages will be affected (of 0 checked):

New packages to be INSTALLED:
        pinentry-curses: 0.8.3

The process will require 78 KB more space
30 KB to be downloaded

Proceed with this action [y/N]: y
Fetching pinentry-curses-0.8.3.txz: 100% of 30 KB
Checking integrity... done (0 conflicting)
[1/1] Installing pinentry-curses-0.8.3: 100%
root@fbsd1:/home/marco #

$ gpg ciphered.tar.gpg
gpg: 3DES encrypted data

  lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk
  x Enter passphrase                                    x
  x                                                     x
  x                                                     x
  x Passphrase **************************************__ x
  x                                                     x
  x       [OK]                             [Cancel]     x
  mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj

gpg: encrypted with 1 passphrase
gpg: WARNING: message was not integrity protected
$ ls
ciphered.tar            ciphered.tar.gpg        prova
$

mercoledì 13 agosto 2014

File server SMB (SAMBA) su filesystem ZFS gestito da FreeBSD su macchina virtuale HyperV

Oggetto dell'articolo

Questo articolo mostra la configurazione di un file server con queste caratteristiche:

  • servizio: SMB,
  • filesystem: ZFS,
  • sistema operativo: FreeBSD 10.0-RELEASE,
  • hardware: virtualizzato Hyper-V (Windows 8 Pro).

Scopo

Lo scopo è quello di archiviare i dati più importanti su un filesystem che prevenga il più possibile la corruzione dei dati, ovvero quanto trattato in questo articolo: arstechnica.com/information-technology/2014/01/bitrot-and-atomic-cows-inside-next-gen-filesystems.

Si tratta di un'istrallazione casalinga. Per me tutta questa infrastruttura serve solo ed esclusivamente per tutelarmi dalla possibilità di corruzione del dato, che verrà quindi replicato più volte e verificato con checksum dal filesystem zfs, ma sullo stesso disco fisico, invece per tutelarmi dall'eventuale rottura del disco fisico farò manualmente ogni tanto una copia di backup del disco virtuale dei dati su dei dischi fisici esterni.

Creazione della macchina virtuale

Ho creato dalla console di gestione di Hyper-V una macchina virtuale con:

  • RAM: 1GB,
  • rete: collegamento a un commutatore virtuale,
  • disco rigido virtuale: a espansione dinamica di 32GB,
  • opzioni di gestione: "Avvia sempre automaticamente questa macchina virtuale".

Installazione e configurazione del sistema operativo

Ho installato FreeBSD sulla macchina virtuale.

Ho creato un utente diverso da root e l'ho aggiunto nel gruppo wheel, in modo poi da poterlo usare per collegarmi alla macchina in SSH e quindi poterla gestire diventando root con il comando su.

Ho modificato la configurazione della scheda di rete come da coreboarder.com/blog/?p=15.

After installing FreeBSD on a Hyper-V machine I had no network connection.
The solution is to modify rc.conf that DHCP will always work on boot
Edit /etc/rc.conf:
Comment the following with a “#”:
ifconfig_YOURNICID
Add the following:
ifconfig_YOURNICID=”SYNCDHCP media 100baseTX mediaopt full-duplex”
Save
Done

Ho riavviato il sistema operativo e una volta risalita la macchina mi ci sono collegato e ho testato la connettività di rete.

Quindi, prendendo spunto da 20.2.1.3. Loader Tunables - The Z File System (ZFS) - FreeBSD Handbook, prendendo però in cosiderazione questo warning:

ZFS WARNING: Recommended minimum kmem_size is 512MB; expect unstable behavior.
Consider tuning vm.kmem_size and vm.kmem_size_max in /boot/loader.conf.

Ho impostato queste configurazioni:

root@fbsd1:~ # ed  /boot/loader.conf
a
vm.kmem_size="512M"
vm.kmem_size_max="512M"
vfs.zfs.arc_max="40M"
vfs.zfs.vdev.cache.size="5M"
.
w
q
root@fbsd1:~ #

Quindi ho spento il sistema dalla shell del sistema operativo con il comando poweroff.

Aggiunta disco virtuale per ospitare i dati

Dalla console di gestione di Hyper-V ho aggiunto un disco rigido virtuale, che servirà per ospitare il filesystem ZFS e quindi i dati. L'ho aggiunto sul controller IDE 1, ho scelto di crearlo come VHDX ad espansione dinamica, di 300 GB.

Quindi ho riacceso la macchina virtuale e ho dato il comando "dmesg" per capire il nome del dispositivo aggiunto (il disco rigido virtuale):

dmesg
...
da1 at blkvsc1 bus 0 scbus2 target 1 lun 0
da1:  Fixed Direct Access SCSI-4 device
da1: 300.000MB/s transfers
da1: Command Queueing enabled
da1: 307200MB (629145600 512 byte sectors: 255H 63S/T 39162C)
...

Preparazione dell'area per i dati

Ho creato il pool e il filesystem ZFS, sempre prendendo spunto da 20.2.2.1. Single Disk Pool - The Z File System (ZFS) - FreeBSD Handbook.

root@fbsd1:~ # cd /
root@fbsd1:/ # zpool create m1pool /dev/da1
root@fbsd1:/ # zfs create m1pool/m1fs
root@fbsd1:/ # zfs set copies=3 m1pool/m1fs
root@fbsd1:/ # df -g
Filesystem  1G-blocks Used Avail Capacity  Mounted on
/dev/da0p2         36    2    31     7%    /
devfs               0    0     0   100%    /dev
m1pool            293    0   293     0%    /m1pool
m1pool/m1fs       293    0   293     0%    /m1pool/m1fs
root@fbsd1:/ #

D'ora in avanti per verificare i dati manualmente potrò fare:

root@fbsd1:/ # zpool status m1pool
  pool: m1pool
 state: ONLINE
  scan: none requested
config:

        NAME        STATE     READ WRITE CKSUM
        m1pool      ONLINE       0     0     0
          da1       ONLINE       0     0     0

errors: No known data errors
root@fbsd1:/ # zpool scrub m1pool
root@fbsd1:/ # echo $?
0
root@fbsd1:/ #

Ho creato l'utente da utilizzare con il servizio SMB posizionando la sua home directory nel filesystem ZFS.

root@fbsd1:/m1pool/m1fs # adduser -d /m1pool/m1fs -s nologin -u 1000 -w random
Username: m1user
Full name: Marco SMB Access
Uid [1000]:
Login group [m1user]:
Login group is m1user. Invite m1user into other groups? []:
Login class [default]:
Shell (sh csh tcsh nologin) [nologin]:
Home directory [/m1pool/m1fs/m1user]:
Home directory permissions (Leave empty for default):
Use password-based authentication? [yes]:
Use an empty password? (yes/no) [no]:
Use a random password? (yes/no) [yes]:
Lock out the account after creation? [no]:
Username   : m1user
Password   : 
Full Name  : Marco SMB Access
Uid        : 1000
Class      :
Groups     : m1user
Home       : /m1pool/m1fs/m1user
Home Mode  :
Shell      : /usr/sbin/nologin
Locked     : no
OK? (yes/no): yes
adduser: INFO: Successfully added (m1user) to the user database.
adduser: INFO: Password for (m1user) is: RANDOMPASSWORDISHERE
Add another user? (yes/no): no
Goodbye!
root@fbsd1:/m1pool/m1fs #

Configurazione del servizio SMB (SAMBA)

Prendendo spunto da 28.10. File and Print Services for Microsoft® Windows® Clients (Samba) - FreeBSD Handbook

root@fbsd1:/ # pkg
The package management tool is not yet installed on your system.
Do you want to fetch and install it now? [y/N]: y
Bootstrapping pkg from pkg+http://pkg.FreeBSD.org/freebsd:10:x86:64/latest, please wait...
Verifying signature with trusted certificate pkg.freebsd.org.2013102301... done
Installing pkg-1.3.6: 100%
Message for pkg-1.3.6:
 If you are upgrading from the old package format, first run:

  # pkg2ng
pkg: not enough arguments
Usage: pkg [-v] [-d] [-l] [-N] [-j |-c ] [-C ] [-R ] [-o var=value]  []


For more information on available commands and options see 'pkg help'.
root@fbsd1:/ # pkg install net/samba36
Updating repository catalogue
Fetching meta.txz: 100% of 940 B
Fetching digests.txz: 100% of 2 MB
Fetching packagesite.txz: 100% of 5 MB

Adding new entries: 100%
Incremental update completed, 23314 packages processed:
0 packages updated, 0 removed and 23314 added.
Updating database digests format: 100%
The following 13 packages will be affected (of 0 checked):

New packages to be INSTALLED:
        samba36: 3.6.24_2
        libsunacl: 1.0
        cups-client: 1.7.3_2
        openldap-client: 2.4.39_1
        tevent: 0.9.21
        python27: 2.7.8_2
        gettext: 0.18.3.1_1
        indexinfo: 0.2
        python2: 2_3
        talloc: 2.1.0
        tdb: 1.2.13,1
        pkgconf: 0.9.6_1
        popt: 1.16

The process will require 194 MB more space
34 MB to be downloaded

Proceed with this action [y/N]: y
Fetching samba36-3.6.24_2.txz: 100% of 21 MB
Fetching libsunacl-1.0.txz: 100% of 8 KB
Fetching cups-client-1.7.3_2.txz: 100% of 760 KB
Fetching openldap-client-2.4.39_1.txz: 100% of 995 KB
Fetching tevent-0.9.21.txz: 100% of 43 KB
Fetching python27-2.7.8_2.txz: 100% of 8 MB
Fetching gettext-0.18.3.1_1.txz: 100% of 2 MB
Fetching indexinfo-0.2.txz: 100% of 6 KB
Fetching python2-2_3.txz: 100% of 2 KB
Fetching talloc-2.1.0.txz: 100% of 48 KB
Fetching tdb-1.2.13,1.txz: 100% of 77 KB
Fetching pkgconf-0.9.6_1.txz: 100% of 23 KB
Fetching popt-1.16.txz: 100% of 62 KB
Checking integrity... done (0 conflicting)
[1/13] Installing indexinfo-0.2: 100%
[2/13] Installing gettext-0.18.3.1_1: 100%
[3/13] Installing python27-2.7.8_2: 100%
[4/13] Installing python2-2_3: 100%
[5/13] Installing talloc-2.1.0: 100%
[6/13] Installing pkgconf-0.9.6_1: 100%
[7/13] Installing libsunacl-1.0: 100%
===> Creating users and/or groups.
Creating group 'cups' with gid '193'.
Creating user 'cups' with uid '193'.
[8/13] Installing cups-client-1.7.3_2: 100%
[9/13] Installing openldap-client-2.4.39_1: 100%
[10/13] Installing tevent-0.9.21: 100%
[11/13] Installing tdb-1.2.13,1: 100%
[12/13] Installing popt-1.16: 100%
[13/13] Installing samba36-3.6.24_2: 100%
root@fbsd1:/ # cp /usr/local/share/examples/samba36/smb.conf.default /usr/local/etc/smb.conf
root@fbsd1:/ # vi /usr/local/etc/smb.conf
(esempio delle modifiche effettuate)
root@fbsd1:/m1pool/m1fs # diff /usr/local/share/examples/samba36/smb.conf.default /usr/local/etc/smb.conf
26c26
<    workgroup = MYGROUP
---
>    workgroup = WORKGROUP
41c41
< ;   hosts allow = 192.168.1. 192.168.2. 127.
---
>    hosts allow = 192.168.0.4 192.168.0.11  127.
45c45
<    load printers = yes
---
>    load printers = no
root@fbsd1:/m1pool/m1fs # echo 'samba_enable="YES"' >> /etc/rc.conf
root@fbsd1:/m1pool/m1fs # service samba start
Removing stale Samba tdb files:  done
Starting nmbd.
Starting smbd.
root@fbsd1:/m1pool/m1fs # smbpasswd -a m1user
New SMB password:
Retype new SMB password:
Added user m1user.
root@fbsd1:/m1pool/m1fs #

venerdì 20 dicembre 2013

CentOS: gestione dei volumi logici

PREPARATIVI

  • Ho spento la macchina virtuale.
  • Ho creato quattro hard disk virtuali di 10GB ciascuno.
  • Ho collegato un controller SCSI virtuale alla macchina virtuale.
  • Ho acceso la macchina virtuale.

ALL'AVVIO

Ora compaiono questi messaggi all'avvio (dmesg):
...
hv_vmbus: registering driver hv_storvsc
scsi2 : storvsc_host_t
scsi 2:0:0:0: Direct-Access     Msft     Virtual Disk     1.0  PQ: 0 ANSI: 4
scsi3 : storvsc_host_t
scsi 3:0:0:0: Direct-Access     Msft     Virtual Disk     1.0  PQ: 0 ANSI: 4
scsi 3:0:0:2: Direct-Access     Msft     Virtual Disk     1.0  PQ: 0 ANSI: 4
scsi 3:0:0:1: Direct-Access     Msft     Virtual Disk     1.0  PQ: 0 ANSI: 4
scsi 3:0:0:3: Direct-Access     Msft     Virtual Disk     1.0  PQ: 0 ANSI: 4
sd 2:0:0:0: [sda] 266338304 512-byte logical blocks: (136 GB/127 GiB)
sd 2:0:0:0: [sda] Write Protect is off
sd 2:0:0:0: [sda] Mode Sense: 0f 00 00 00
sd 3:0:0:0: [sdb] 20971520 512-byte logical blocks: (10.7 GB/10.0 GiB)
sd 3:0:0:2: [sdc] 20971520 512-byte logical blocks: (10.7 GB/10.0 GiB)
sd 3:0:0:0: [sdb] Write Protect is off
sd 3:0:0:0: [sdb] Mode Sense: 0f 00 00 00
sd 3:0:0:2: [sdc] Write Protect is off
sd 3:0:0:2: [sdc] Mode Sense: 0f 00 00 00
sd 2:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
sd 3:0:0:0: [sdb] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
sd 3:0:0:2: [sdc] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
 sda:
 sdb: sda1 sda2
 sdc:
sd 3:0:0:1: [sdd] 20971520 512-byte logical blocks: (10.7 GB/10.0 GiB)
sd 3:0:0:1: [sdd] Write Protect is off
sd 3:0:0:1: [sdd] Mode Sense: 0f 00 00 00
sd 2:0:0:0: [sda] Attached SCSI disk
sd 3:0:0:1: [sdd] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
sd 3:0:0:3: [sde] 20971520 512-byte logical blocks: (10.7 GB/10.0 GiB)
sd 3:0:0:3: [sde] Write Protect is off
sd 3:0:0:3: [sde] Mode Sense: 0f 00 00 00
sd 3:0:0:3: [sde] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
 sdd:
 sde: unknown partition table
sd 3:0:0:0: [sdb] Attached SCSI disk
 unknown partition table
sd 3:0:0:2: [sdc] Attached SCSI disk
 unknown partition table
 unknown partition table
sd 3:0:0:1: [sdd] Attached SCSI disk
sd 3:0:0:3: [sde] Attached SCSI disk
...
sd 2:0:0:0: Attached scsi generic sg0 type 0
sd 3:0:0:0: Attached scsi generic sg1 type 0
sd 3:0:0:2: Attached scsi generic sg2 type 0
sd 3:0:0:1: Attached scsi generic sg3 type 0
sd 3:0:0:3: Attached scsi generic sg4 type 0
...
So, my new volumes are: sdb sdc sdd sde.

CREAZIONE DEI VOLUMI FISICI

[root@centoshost ~]# ls /dev/sd*
/dev/sda  /dev/sda1  /dev/sda2  /dev/sdb  /dev/sdc  /dev/sdd  /dev/sde
[root@centoshost ~]# pvcreate /dev/sdb
  Physical volume "/dev/sdb" successfully created
[root@centoshost ~]# pvcreate /dev/sdc
  Physical volume "/dev/sdc" successfully created
[root@centoshost ~]# pvcreate /dev/sdd
  Physical volume "/dev/sdd" successfully created
[root@centoshost ~]# pvcreate /dev/sde
  Physical volume "/dev/sde" successfully created
[root@centoshost ~]#

CREAZIONE DEL GRUPPO DI VOLUMI

[root@centoshost ~]# vgcreate mytestvg /dev/sdb  /dev/sdc  /dev/sdd  /dev/sde
  Volume group "mytestvg" successfully created
[root@centoshost ~]# vgdisplay -v mytestvg
    Using volume group(s) on command line
    Finding volume group "mytestvg"
  --- Volume group ---
  VG Name               mytestvg
  System ID
  Format                lvm2
  Metadata Areas        4
  Metadata Sequence No  1
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                0
  Open LV               0
  Max PV                0
  Cur PV                4
  Act PV                4
  VG Size               39.98 GiB
  PE Size               4.00 MiB
  Total PE              10236
  Alloc PE / Size       0 / 0
  Free  PE / Size       10236 / 39.98 GiB
  VG UUID               VuOgyc-w2NO-wZ7j-dDnn-Hy77-OOgN-rLjXOt

  --- Physical volumes ---
  PV Name               /dev/sdb
  PV UUID               cwLnS8-bDiV-OoXC-p6Mt-QxqT-WDLr-JjgjNZ
  PV Status             allocatable
  Total PE / Free PE    2559 / 2559

  PV Name               /dev/sdc
  PV UUID               ChG7YS-Lpfu-606z-E5Vq-hrux-qxxx-HYEupJ
  PV Status             allocatable
  Total PE / Free PE    2559 / 2559

  PV Name               /dev/sdd
  PV UUID               KL8MMX-L6tl-hdIm-PLko-11Nh-xpPg-MwIqBT
  PV Status             allocatable
  Total PE / Free PE    2559 / 2559

  PV Name               /dev/sde
  PV UUID               MoLGEY-7J3e-YIdI-GPP1-50n2-F57e-ofu6Hu
  PV Status             allocatable
  Total PE / Free PE    2559 / 2559

[root@centoshost ~]#

CREAZIONE DEL VOLUME LOGICO

[root@centoshost ~]# lvcreate -l 2559 -n mytestlv1 mytestvg
  Logical volume "mytestlv1" created
[root@centoshost ~]#

[root@centoshost ~]# vgdisplay -v mytestvg
    Using volume group(s) on command line
    Finding volume group "mytestvg"
  --- Volume group ---
  VG Name               mytestvg
  System ID
  Format                lvm2
  Metadata Areas        4
  Metadata Sequence No  2
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               0
  Max PV                0
  Cur PV                4
  Act PV                4
  VG Size               39.98 GiB
  PE Size               4.00 MiB
  Total PE              10236
  Alloc PE / Size       2559 / 10.00 GiB
  Free  PE / Size       7677 / 29.99 GiB
  VG UUID               VuOgyc-w2NO-wZ7j-dDnn-Hy77-OOgN-rLjXOt

  --- Logical volume ---
  LV Path                /dev/mytestvg/mytestlv1
  LV Name                mytestlv1
  VG Name                mytestvg
  LV UUID                v5Btut-Kxod-g9Zm-KqtK-9HRr-pddL-7ziFOM
  LV Write Access        read/write
  LV Creation host, time centoshost, 2013-07-06 16:14:58 +0200
  LV Status              available
  # open                 0
  LV Size                10.00 GiB
  Current LE             2559
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:3

  --- Physical volumes ---
  PV Name               /dev/sdb
  PV UUID               cwLnS8-bDiV-OoXC-p6Mt-QxqT-WDLr-JjgjNZ
  PV Status             allocatable
  Total PE / Free PE    2559 / 0

  PV Name               /dev/sdc
  PV UUID               ChG7YS-Lpfu-606z-E5Vq-hrux-qxxx-HYEupJ
  PV Status             allocatable
  Total PE / Free PE    2559 / 2559

  PV Name               /dev/sdd
  PV UUID               KL8MMX-L6tl-hdIm-PLko-11Nh-xpPg-MwIqBT
  PV Status             allocatable
  Total PE / Free PE    2559 / 2559

  PV Name               /dev/sde
  PV UUID               MoLGEY-7J3e-YIdI-GPP1-50n2-F57e-ofu6Hu
  PV Status             allocatable
  Total PE / Free PE    2559 / 2559

[root@centoshost ~]# lvdisplay /dev/mytestvg/mytestlv1
  --- Logical volume ---
  LV Path                /dev/mytestvg/mytestlv1
  LV Name                mytestlv1
  VG Name                mytestvg
  LV UUID                v5Btut-Kxod-g9Zm-KqtK-9HRr-pddL-7ziFOM
  LV Write Access        read/write
  LV Creation host, time centoshost, 2013-07-06 16:14:58 +0200
  LV Status              available
  # open                 0
  LV Size                10.00 GiB
  Current LE             2559
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:3

[root@centoshost ~]#

CREAZIONE DEL FILESYSTEM SUL VOLUME LOGICO

[root@centoshost ~]# mke2fs /dev/mytestvg/mytestlv1
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
655360 inodes, 2620416 blocks
131020 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2684354560
80 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

Writing inode tables: done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 32 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
[root@centoshost ~]# tune2fs -l /dev/mytestvg/mytestlv1
tune2fs 1.41.12 (17-May-2010)
Filesystem volume name:   <none>
Last mounted on:          <not available>
Filesystem UUID:          ab9beb1c-2ded-4ae1-a083-c2f482ed074f
Filesystem magic number:  0xEF53
Filesystem revision #:    1 (dynamic)
Filesystem features:      ext_attr resize_inode dir_index filetype sparse_super large_file
Filesystem flags:         signed_directory_hash
Default mount options:    (none)
Filesystem state:         clean
Errors behavior:          Continue
Filesystem OS type:       Linux
Inode count:              655360
Block count:              2620416
Reserved block count:     131020
Free blocks:              2573521
Free inodes:              655349
First block:              0
Block size:               4096
Fragment size:            4096
Reserved GDT blocks:      639
Blocks per group:         32768
Fragments per group:      32768
Inodes per group:         8192
Inode blocks per group:   512
Filesystem created:       Sat Jul  6 16:19:40 2013
Last mount time:          n/a
Last write time:          Sat Jul  6 16:19:40 2013
Mount count:              0
Maximum mount count:      32
Last checked:             Sat Jul  6 16:19:40 2013
Check interval:           15552000 (6 months)
Next check after:         Thu Jan  2 15:19:40 2014
Reserved blocks uid:      0 (user root)
Reserved blocks gid:      0 (group root)
First inode:              11
Inode size:               256
Required extra isize:     28
Desired extra isize:      28
Default directory hash:   half_md4
Directory Hash Seed:      7a3b64a5-abf6-4070-93ba-7ed4775e1dc5
[root@centoshost ~]# mount /dev/mytestvg/mytestlv1 /mnt/
[root@centoshost ~]# mount | grep test
/dev/mapper/mytestvg-mytestlv1 on /mnt type ext2 (rw)
[root@centoshost ~]# ls /mnt
lost+found
[root@centoshost ~]# df -m /mnt
Filesystem           1M-blocks      Used Available Use% Mounted on
/dev/mapper/mytestvg-mytestlv1
                         10076        23      9542   1% /mnt
[root@centoshost ~]#

CREAZIONE DI CONTENUTO DI TEST

[root@centoshost ~]# cd /mnt
[root@centoshost mnt]# for x in $(seq 0 9); do dd if=/dev/zero of=zero${x}.bin  bs=1024 count=10240; done
10240+0 records in
10240+0 records out
10485760 bytes (10 MB) copied, 0.0253373 s, 414 MB/s
10240+0 records in
10240+0 records out
10485760 bytes (10 MB) copied, 0.026879 s, 390 MB/s
10240+0 records in
10240+0 records out
10485760 bytes (10 MB) copied, 0.0264344 s, 397 MB/s
10240+0 records in
10240+0 records out
10485760 bytes (10 MB) copied, 0.025419 s, 413 MB/s
10240+0 records in
10240+0 records out
10485760 bytes (10 MB) copied, 0.0263466 s, 398 MB/s
10240+0 records in
10240+0 records out
10485760 bytes (10 MB) copied, 0.0195509 s, 536 MB/s
10240+0 records in
10240+0 records out
10485760 bytes (10 MB) copied, 0.0192691 s, 544 MB/s
10240+0 records in
10240+0 records out
10485760 bytes (10 MB) copied, 0.0110749 s, 947 MB/s
10240+0 records in
10240+0 records out
10485760 bytes (10 MB) copied, 0.0104302 s, 1.0 GB/s
10240+0 records in
10240+0 records out
10485760 bytes (10 MB) copied, 0.0116289 s, 902 MB/s
[root@centoshost mnt]# ls -l
total 112876
drwx------. 2 root root    16384 Jul  6 16:19 lost+found
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero0.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero1.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero2.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero3.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero4.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero5.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero6.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero7.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero8.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero9.bin
[root@centoshost mnt]# df -m .
Filesystem           1M-blocks      Used Available Use% Mounted on
/dev/mapper/mytestvg-mytestlv1
                         10076       123      9441   2% /mnt
[root@centoshost mnt]#

RIDUZIONE DI UN GRUPPO DI VOLUMI - RIMUOVENDO VOLUMI FISICI DALLO STESSO:

[root@centoshost mnt]# pvscan
  PV /dev/sdb    VG mytestvg        lvm2 [10.00 GiB / 0    free]
  PV /dev/sdc    VG mytestvg        lvm2 [10.00 GiB / 10.00 GiB free]
  PV /dev/sdd    VG mytestvg        lvm2 [10.00 GiB / 10.00 GiB free]
  PV /dev/sde    VG mytestvg        lvm2 [10.00 GiB / 10.00 GiB free]
  PV /dev/sda2   VG vg_centoshost   lvm2 [126.51 GiB / 0    free]
  Total: 5 [166.49 GiB] / in use: 5 [166.49 GiB] / in no VG: 0 [0   ]
[root@centoshost mnt]# vgreduce mytestvg /dev/sde
  Removed "/dev/sde" from volume group "mytestvg"
[root@centoshost mnt]# vgreduce mytestvg /dev/sdd /dev/sdc
  Removed "/dev/sdd" from volume group "mytestvg"
  Removed "/dev/sdc" from volume group "mytestvg"
[root@centoshost mnt]# pvscan
  PV /dev/sdb    VG mytestvg        lvm2 [10.00 GiB / 0    free]
  PV /dev/sda2   VG vg_centoshost   lvm2 [126.51 GiB / 0    free]
  PV /dev/sdc                       lvm2 [10.00 GiB]
  PV /dev/sdd                       lvm2 [10.00 GiB]
  PV /dev/sde                       lvm2 [10.00 GiB]
  Total: 5 [166.50 GiB] / in use: 2 [136.50 GiB] / in no VG: 3 [30.00 GiB]
[root@centoshost mnt]#

ESTENSIONE DI UN VOLUME GROUP - AGGIUNGENDO VOLUMI FISIC AD ESSO

[root@centoshost mnt]# vgextend mytestvg /dev/sdc
  Volume group "mytestvg" successfully extended
[root@centoshost mnt]#

ESTENSIONE DI UN VOLUME LOGICO

[root@centoshost mnt]# lvextend -l +2559 /dev/mytestvg/mytestlv1
  Extending logical volume mytestlv1 to 19.99 GiB
  Logical volume mytestlv1 successfully resized
[root@centoshost mnt]# lvdisplay -v /dev/mytestvg/mytestlv1
    Using logical volume(s) on command line
  --- Logical volume ---
  LV Path                /dev/mytestvg/mytestlv1
  LV Name                mytestlv1
  VG Name                mytestvg
  LV UUID                v5Btut-Kxod-g9Zm-KqtK-9HRr-pddL-7ziFOM
  LV Write Access        read/write
  LV Creation host, time centoshost, 2013-07-06 16:14:58 +0200
  LV Status              available
  # open                 1
  LV Size                19.99 GiB
  Current LE             5118
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:3

[root@centoshost mnt]# pvscan
  PV /dev/sdb    VG mytestvg        lvm2 [10.00 GiB / 0    free]
  PV /dev/sdc    VG mytestvg        lvm2 [10.00 GiB / 0    free]
  PV /dev/sda2   VG vg_centoshost   lvm2 [126.51 GiB / 0    free]
  PV /dev/sdd                       lvm2 [10.00 GiB]
  PV /dev/sde                       lvm2 [10.00 GiB]
  Total: 5 [166.50 GiB] / in use: 3 [146.50 GiB] / in no VG: 2 [20.00 GiB]
[root@centoshost mnt]# vgdisplay -v mytestvg
    Using volume group(s) on command line
    Finding volume group "mytestvg"
  --- Volume group ---
  VG Name               mytestvg
  System ID
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  13
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               19.99 GiB
  PE Size               4.00 MiB
  Total PE              5118
  Alloc PE / Size       5118 / 19.99 GiB
  Free  PE / Size       0 / 0
  VG UUID               VuOgyc-w2NO-wZ7j-dDnn-Hy77-OOgN-rLjXOt

  --- Logical volume ---
  LV Path                /dev/mytestvg/mytestlv1
  LV Name                mytestlv1
  VG Name                mytestvg
  LV UUID                v5Btut-Kxod-g9Zm-KqtK-9HRr-pddL-7ziFOM
  LV Write Access        read/write
  LV Creation host, time centoshost, 2013-07-06 16:14:58 +0200
  LV Status              available
  # open                 1
  LV Size                19.99 GiB
  Current LE             5118
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:3

  --- Physical volumes ---
  PV Name               /dev/sdb
  PV UUID               cwLnS8-bDiV-OoXC-p6Mt-QxqT-WDLr-JjgjNZ
  PV Status             allocatable
  Total PE / Free PE    2559 / 0

  PV Name               /dev/sdc
  PV UUID               ChG7YS-Lpfu-606z-E5Vq-hrux-qxxx-HYEupJ
  PV Status             allocatable
  Total PE / Free PE    2559 / 0

[root@centoshost mnt]#

ESTENSIONE DI UN FILESYSTEM

[root@centoshost mnt]# resize2fs /dev/mytestvg/mytestlv1 $((4*5118))M # extent size * number of extents
resize2fs 1.41.12 (17-May-2010)
resize2fs: New size smaller than minimum (26802)

[root@centoshost mnt]# resize2fs /dev/mytestvg/mytestlv1 $((4*5118))M
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mytestvg/mytestlv1 is mounted on /mnt; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 2
resize2fs: Kernel does not support online resizing
[root@centoshost mnt]# cd
[root@centoshost ~]# umount /mnt/
[root@centoshost ~]# resize2fs /dev/mytestvg/mytestlv1 $((4*5118))M
resize2fs 1.41.12 (17-May-2010)
Please run 'e2fsck -f /dev/mytestvg/mytestlv1' first.

[root@centoshost ~]# e2fsck -f /dev/mytestvg/mytestlv1
e2fsck 1.41.12 (17-May-2010)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/mytestvg/mytestlv1: 21/655360 files (4.8% non-contiguous), 72536/2620416 blocks
[root@centoshost ~]# resize2fs /dev/mytestvg/mytestlv1 $((4*5118))M
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/mytestvg/mytestlv1 to 5240832 (4k) blocks.
The filesystem on /dev/mytestvg/mytestlv1 is now 5240832 blocks long.

[root@centoshost ~]# mount /dev/mytestvg/mytestlv1 /mnt
[root@centoshost ~]# df -m /mnt
Filesystem           1M-blocks      Used Available Use% Mounted on
/dev/mapper/mytestvg-mytestlv1
                         20151       128     19000   1% /mnt
[root@centoshost ~]# ls -l /mnt
total 102616
drwx------. 2 root root    16384 Jul  6 16:19 lost+found
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero0.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero1.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero2.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero3.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero4.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero5.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero6.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero7.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero8.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero9.bin
[root@centoshost ~]#

PERICOLOSO!!! - RIDUZIONE DI UN FILESYSTEM E DEL VOLUME LOGICO IN CUI È CONTENUTO

[root@centoshost ~]# umount /mnt
[root@centoshost ~]# resize2fs /dev/mytestvg/mytestlv1 $((4*2559))M
resize2fs 1.41.12 (17-May-2010)
Please run 'e2fsck -f /dev/mytestvg/mytestlv1' first.
[root@centoshost ~]# e2fsck -f /dev/mytestvg/mytestlv1
e2fsck 1.41.12 (17-May-2010)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/mytestvg/mytestlv1: 21/1310720 files (4.8% non-contiguous), 114938/5240832 blocks
[root@centoshost ~]# resize2fs /dev/mytestvg/mytestlv1 $((4*2559))M
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/mytestvg/mytestlv1 to 2620416 (4k) blocks.
The filesystem on /dev/mytestvg/mytestlv1 is now 2620416 blocks long.
[root@centoshost ~]# lvreduce -l -2559 /dev/mytestvg/mytestlv1
  WARNING: Reducing active logical volume to 10.00 GiB
  THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce mytestlv1? [y/n]: y
  Reducing logical volume mytestlv1 to 10.00 GiB
  Logical volume mytestlv1 successfully resized
[root@centoshost ~]# pvscan
  PV /dev/sdb    VG mytestvg        lvm2 [10.00 GiB / 0    free]
  PV /dev/sdc    VG mytestvg        lvm2 [10.00 GiB / 10.00 GiB free]
  PV /dev/sda2   VG vg_centoshost   lvm2 [126.51 GiB / 0    free]
  PV /dev/sdd                       lvm2 [10.00 GiB]
  PV /dev/sde                       lvm2 [10.00 GiB]
  Total: 5 [166.50 GiB] / in use: 3 [146.50 GiB] / in no VG: 2 [20.00 GiB]
[root@centoshost ~]# mount /dev/mytestvg/mytestlv1 /mnt
[root@centoshost ~]# df -m /mnt
Filesystem           1M-blocks      Used Available Use% Mounted on
/dev/mapper/mytestvg-mytestlv1
                         10076       123      9441   2% /mnt
[root@centoshost ~]# ls -l /mnt
total 102616
drwx------. 2 root root    16384 Jul  6 16:19 lost+found
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero0.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero1.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero2.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero3.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero4.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero5.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero6.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero7.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero8.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero9.bin
[root@centoshost ~]# (cd /mnt; for x in $(seq 9); do cmp --verbose  zero0.bin zero${x}.bin && echo "lucky... $x == 0"; done)
lucky... 1 == 0
lucky... 2 == 0
lucky... 3 == 0
lucky... 4 == 0
lucky... 5 == 0
lucky... 6 == 0
lucky... 7 == 0
lucky... 8 == 0
lucky... 9 == 0
[root@centoshost ~]#

CONVERSIONE DI UN VOLUME LOGICO - AGGIUNTA DI UN MIRROR

[root@centoshost ~]# vgdisplay mytestvg -v
    Using volume group(s) on command line
    Finding volume group "mytestvg"
  --- Volume group ---
  VG Name               mytestvg
  System ID
  Format                lvm2
  Metadata Areas        4
  Metadata Sequence No  32
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                4
  Act PV                4
  VG Size               39.98 GiB
  PE Size               4.00 MiB
  Total PE              10236
  Alloc PE / Size       2559 / 10.00 GiB
  Free  PE / Size       7677 / 29.99 GiB
  VG UUID               VuOgyc-w2NO-wZ7j-dDnn-Hy77-OOgN-rLjXOt

  --- Logical volume ---
  LV Path                /dev/mytestvg/mytestlv1
  LV Name                mytestlv1
  VG Name                mytestvg
  LV UUID                v5Btut-Kxod-g9Zm-KqtK-9HRr-pddL-7ziFOM
  LV Write Access        read/write
  LV Creation host, time centoshost, 2013-07-06 16:14:58 +0200
  LV Status              available
  # open                 1
  LV Size                10.00 GiB
  Current LE             2559
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:3

  --- Physical volumes ---
  PV Name               /dev/sdb
  PV UUID               cwLnS8-bDiV-OoXC-p6Mt-QxqT-WDLr-JjgjNZ
  PV Status             allocatable
  Total PE / Free PE    2559 / 0

  PV Name               /dev/sdc
  PV UUID               ChG7YS-Lpfu-606z-E5Vq-hrux-qxxx-HYEupJ
  PV Status             allocatable
  Total PE / Free PE    2559 / 2559

  PV Name               /dev/sdd
  PV UUID               KL8MMX-L6tl-hdIm-PLko-11Nh-xpPg-MwIqBT
  PV Status             allocatable
  Total PE / Free PE    2559 / 2559

  PV Name               /dev/sde
  PV UUID               MoLGEY-7J3e-YIdI-GPP1-50n2-F57e-ofu6Hu
  PV Status             allocatable
  Total PE / Free PE    2559 / 2559

[root@centoshost ~]# lvconvert -m1 /dev/mytestvg/mytestlv1
  mytestvg/mytestlv1: Converted: 0.0%
...
  mytestvg/mytestlv1: Converted: 100.0%
[root@centoshost ~]# vgdisplay mytestvg -v
    Using volume group(s) on command line
    Finding volume group "mytestvg"
  --- Volume group ---
  VG Name               mytestvg
  System ID
  Format                lvm2
  Metadata Areas        4
  Metadata Sequence No  34
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                4
  Act PV                4
  VG Size               39.98 GiB
  PE Size               4.00 MiB
  Total PE              10236
  Alloc PE / Size       5119 / 20.00 GiB
  Free  PE / Size       5117 / 19.99 GiB
  VG UUID               VuOgyc-w2NO-wZ7j-dDnn-Hy77-OOgN-rLjXOt

  --- Logical volume ---
  LV Path                /dev/mytestvg/mytestlv1
  LV Name                mytestlv1
  VG Name                mytestvg
  LV UUID                v5Btut-Kxod-g9Zm-KqtK-9HRr-pddL-7ziFOM
  LV Write Access        read/write
  LV Creation host, time centoshost, 2013-07-06 16:14:58 +0200
  LV Status              available
  # open                 1
  LV Size                10.00 GiB
  Current LE             2559
  Mirrored volumes       2
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:3

  --- Physical volumes ---
  PV Name               /dev/sdb
  PV UUID               cwLnS8-bDiV-OoXC-p6Mt-QxqT-WDLr-JjgjNZ
  PV Status             allocatable
  Total PE / Free PE    2559 / 0

  PV Name               /dev/sdc
  PV UUID               ChG7YS-Lpfu-606z-E5Vq-hrux-qxxx-HYEupJ
  PV Status             allocatable
  Total PE / Free PE    2559 / 0

  PV Name               /dev/sdd
  PV UUID               KL8MMX-L6tl-hdIm-PLko-11Nh-xpPg-MwIqBT
  PV Status             allocatable
  Total PE / Free PE    2559 / 2559

  PV Name               /dev/sde
  PV UUID               MoLGEY-7J3e-YIdI-GPP1-50n2-F57e-ofu6Hu
  PV Status             allocatable
  Total PE / Free PE    2559 / 2558

[root@centoshost ~]# pvscan
  PV /dev/sdb    VG mytestvg        lvm2 [10.00 GiB / 0    free]
  PV /dev/sdc    VG mytestvg        lvm2 [10.00 GiB / 0    free]
  PV /dev/sdd    VG mytestvg        lvm2 [10.00 GiB / 10.00 GiB free]
  PV /dev/sde    VG mytestvg        lvm2 [10.00 GiB / 9.99 GiB free]
  PV /dev/sda2   VG vg_centoshost   lvm2 [126.51 GiB / 0    free]
  Total: 5 [166.49 GiB] / in use: 5 [166.49 GiB] / in no VG: 0 [0   ]
[root@centoshost ~]# df -m
Filesystem           1M-blocks      Used Available Use% Mounted on
...
/dev/mapper/mytestvg-mytestlv1
                         10076       123      9441   2% /mnt
[root@centoshost ~]# 

FARE UN BACKUP SNAPSHOT DI UN VOLUME LOGICO

[root@centoshost ~]# lvcreate -l 2559 -s /dev/mapper/mytestvg-mytestlv1 -n mytestlv1-snap /dev/sdd
  WARNING: Snapshots of mirrors can deadlock under rare device failures.
  WARNING: Consider using the raid1 mirror type to avoid this.
  WARNING: See global/mirror_segtype_default in lvm.conf.
  Logical volume "mytestlv1-snap" created
[root@centoshost ~]# lvscan
  ACTIVE   Original '/dev/mytestvg/mytestlv1' [10.00 GiB] inherit
  ACTIVE   Snapshot '/dev/mytestvg/mytestlv1-snap' [10.00 GiB] inherit
  ACTIVE            '/dev/vg_centoshost/lv_root' [50.00 GiB] inherit
  ACTIVE            '/dev/vg_centoshost/lv_home' [72.60 GiB] inherit
  ACTIVE            '/dev/vg_centoshost/lv_swap' [3.91 GiB] inherit
[root@centoshost ~]# mkdir /mnt2
[root@centoshost ~]# mount /dev/mytestvg/mytestlv1-snap /mnt2
[root@centoshost ~]# ls -l /mnt2
total 102616
drwx------. 2 root root    16384 Jul  6 16:19 lost+found
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero0.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero1.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero2.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero3.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero4.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero5.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero6.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero7.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero8.bin
-rw-r--r--. 1 root root 10485760 Jul  6 16:48 zero9.bin
[root@centoshost ~]#
Then you may eventually backup the files to tape using you preferred software (tar for example) and remove the snapshot.
[root@centoshost ~]# pvscan
  PV /dev/sdb    VG mytestvg        lvm2 [10.00 GiB / 0    free]
  PV /dev/sdc    VG mytestvg        lvm2 [10.00 GiB / 0    free]
  PV /dev/sdd    VG mytestvg        lvm2 [10.00 GiB / 0    free]
  PV /dev/sde    VG mytestvg        lvm2 [10.00 GiB / 9.99 GiB free]
  PV /dev/sda2   VG vg_centoshost   lvm2 [126.51 GiB / 0    free]
  Total: 5 [166.49 GiB] / in use: 5 [166.49 GiB] / in no VG: 0 [0   ]
[root@centoshost ~]# umount /mnt2
[root@centoshost ~]# lvremove /dev/mytestvg/mytestlv1-snap
Do you really want to remove active logical volume mytestlv1-snap? [y/n]: y
  Logical volume "mytestlv1-snap" successfully removed
[root@centoshost ~]# pvscan
  PV /dev/sdb    VG mytestvg        lvm2 [10.00 GiB / 0    free]
  PV /dev/sdc    VG mytestvg        lvm2 [10.00 GiB / 0    free]
  PV /dev/sdd    VG mytestvg        lvm2 [10.00 GiB / 10.00 GiB free]
  PV /dev/sde    VG mytestvg        lvm2 [10.00 GiB / 9.99 GiB free]
  PV /dev/sda2   VG vg_centoshost   lvm2 [126.51 GiB / 0    free]
  Total: 5 [166.49 GiB] / in use: 5 [166.49 GiB] / in no VG: 0 [0   ]
[root@centoshost ~]#

COMANDI, MANUALI E ALTRI FILE AFFINI

[root@centoshost ~]# rpm -qd lvm2
/usr/share/doc/lvm2-2.02.98/COPYING
/usr/share/doc/lvm2-2.02.98/COPYING.LIB
/usr/share/doc/lvm2-2.02.98/INSTALL
/usr/share/doc/lvm2-2.02.98/README
/usr/share/doc/lvm2-2.02.98/VERSION
/usr/share/doc/lvm2-2.02.98/WHATS_NEW
/usr/share/man/man5/lvm.conf.5.gz
/usr/share/man/man8/blkdeactivate.8.gz
/usr/share/man/man8/fsadm.8.gz
/usr/share/man/man8/lvchange.8.gz
/usr/share/man/man8/lvconvert.8.gz
/usr/share/man/man8/lvcreate.8.gz
/usr/share/man/man8/lvdisplay.8.gz
/usr/share/man/man8/lvextend.8.gz
/usr/share/man/man8/lvm.8.gz
/usr/share/man/man8/lvmchange.8.gz
/usr/share/man/man8/lvmconf.8.gz
/usr/share/man/man8/lvmdiskscan.8.gz
/usr/share/man/man8/lvmdump.8.gz
/usr/share/man/man8/lvmetad.8.gz
/usr/share/man/man8/lvmsadc.8.gz
/usr/share/man/man8/lvmsar.8.gz
/usr/share/man/man8/lvreduce.8.gz
/usr/share/man/man8/lvremove.8.gz
/usr/share/man/man8/lvrename.8.gz
/usr/share/man/man8/lvresize.8.gz
/usr/share/man/man8/lvs.8.gz
/usr/share/man/man8/lvscan.8.gz
/usr/share/man/man8/pvchange.8.gz
/usr/share/man/man8/pvck.8.gz
/usr/share/man/man8/pvcreate.8.gz
/usr/share/man/man8/pvdisplay.8.gz
/usr/share/man/man8/pvmove.8.gz
/usr/share/man/man8/pvremove.8.gz
/usr/share/man/man8/pvresize.8.gz
/usr/share/man/man8/pvs.8.gz
/usr/share/man/man8/pvscan.8.gz
/usr/share/man/man8/vgcfgbackup.8.gz
/usr/share/man/man8/vgcfgrestore.8.gz
/usr/share/man/man8/vgchange.8.gz
/usr/share/man/man8/vgck.8.gz
/usr/share/man/man8/vgconvert.8.gz
/usr/share/man/man8/vgcreate.8.gz
/usr/share/man/man8/vgdisplay.8.gz
/usr/share/man/man8/vgexport.8.gz
/usr/share/man/man8/vgextend.8.gz
/usr/share/man/man8/vgimport.8.gz
/usr/share/man/man8/vgimportclone.8.gz
/usr/share/man/man8/vgmerge.8.gz
/usr/share/man/man8/vgmknodes.8.gz
/usr/share/man/man8/vgreduce.8.gz
/usr/share/man/man8/vgremove.8.gz
/usr/share/man/man8/vgrename.8.gz
/usr/share/man/man8/vgs.8.gz
/usr/share/man/man8/vgscan.8.gz
/usr/share/man/man8/vgsplit.8.gz