Como montar uma partição LVM no Linux?
Autor: Gabriel P. Silva | Publicado: 2016-11-11T13:52:00-02:00



Como montar uma partição LVM ?
O LVM é um ferramenta de gerenciamento de volumes lógicos que permite o gerenciamento do espaço em disco usando a noção de volumes lógicos e grupos de volumes. O maior benefício do uso do LVM ao invés de partições convencionais é a flexibilidade na alocação de armazenamento para os usuários e aplicações sem as limitações dadas pelo tamanho dos discos individualmente.

No LVM, o armazenamento físico, no qual os volumes lógicos são cirados, é uma partição tradicional (p.ex., /dev/sda2, /dev/sdb1). Essas partições devem ser iniciadas como "volumes físicos" e rotulados como tal (p.ex. "Linux LVM") para que possam ser usados pelo LVM. Uma vez que as partições sejam rotuladas como volumes LVM, elas não podem mais serem montadas diretamente com o comando "mount".

Se você tentar montar uma partição LVM (p.ex., /dev/sb2), irá receber a seguinte mensagem de erro.
$ mount /dev/sdb2 /mnt
mount: unknown filesystem type 'LVM2_member'

Se você montar uma partição LVM adequadamente, você deve montar os "volumes lógicos" criados dentro dessa partição. Veja como : 

Primeiro, examine uma lista de grupos de volumes disponíveis
Isso pode ser feito executando:

$ sudo pvs  PV&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;         VG&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Fmt&nbsp;  Attr PSize&nbsp;&nbsp; PFree/dev/sda2&nbsp; fedora_gabriel lvm2 a--&nbsp; 465,27g&nbsp;&nbsp;&nbsp; 0 

Os nomes dos volumes disponíveis e dos grupos de volumes sob as colunas PV e VG, respectivamente. Neste exemplo há apenas um grupo de volume com o nome "fedora_gabriel" criado em /dev/sda2.

Depois, vamos verificar quais volumes lógicos existem dentro de um grupo de volume, com o seguinte comando:

$ sudo lvdisplay &lt;volume-group-name&gt;
O comando lvdisplay mostra informações sobre os volumes lógicos disponíveis (i.e., nome do dispositivo, nome do volume, tamanho do volume, etc.) como mostrado a seguir.

$ sudo lvdisplay fedora_gabriel&nbsp;--- Logical volume ---&nbsp; LV Path&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /dev/fedora_gabriel/swap&nbsp; LV Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; swap&nbsp; VG Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fedora_gabriel&nbsp; LV UUID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ovFJhd-Ac7n-o8HK-UAIu-WUaC-hKQv-VBfbcl&nbsp; LV Write Access&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; read/write&nbsp; LV Creation host, time localhost, 2013-06-20 16:26:59 -0300&nbsp; LV Status&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; available&nbsp; # open&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2&nbsp; LV Size&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 7,80 GiB&nbsp; Current LE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1996&nbsp; Segments&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1&nbsp; Allocation&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; inherit&nbsp; Read ahead sectors&nbsp;&nbsp;&nbsp;&nbsp; auto&nbsp; - currently set to&nbsp;&nbsp;&nbsp;&nbsp; 256&nbsp; Block device&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 253:1&nbsp;&nbsp; &nbsp; --- Logical volume ---&nbsp; LV Path&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /dev/fedora_gabriel/home&nbsp; LV Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; home&nbsp; VG Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fedora_gabriel&nbsp; LV UUID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0wBtar-j9l1-ZVCP-P7Ik-EDXn-dJsI-13msIy&nbsp; LV Write Access&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; read/write&nbsp; LV Creation host, time localhost, 2013-06-20 16:26:59 -0300&nbsp; LV Status&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; available&nbsp; # open&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1&nbsp; LV Size&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 407,47 GiB&nbsp; Current LE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 104313&nbsp; Segments&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1&nbsp; Allocation&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; inherit&nbsp; Read ahead sectors&nbsp;&nbsp;&nbsp;&nbsp; auto&nbsp; - currently set to&nbsp;&nbsp;&nbsp;&nbsp; 256&nbsp; Block device&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 253:2&nbsp;&nbsp; &nbsp; --- Logical volume ---&nbsp; LV Path&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /dev/fedora_gabriel/root&nbsp; LV Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; root&nbsp; VG Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fedora_gabriel&nbsp; LV UUID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; F6R9ZL-r6Ai-i1Sp-8eaB-L4ws-dmoX-EMSXcT&nbsp; LV Write Access&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; read/write&nbsp; LV Creation host, time localhost, 2013-06-20 16:27:06 -0300&nbsp; LV Status&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; available&nbsp; # open&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1&nbsp; LV Size&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 50,00 GiB&nbsp; Current LE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 12800&nbsp; Segments&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1&nbsp; Allocation&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; inherit&nbsp; Read ahead sectors&nbsp;&nbsp;&nbsp;&nbsp; auto&nbsp; - currently set to&nbsp;&nbsp;&nbsp;&nbsp; 256&nbsp; Block device&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 253:0 

Montando um volume lógico
Se você quisier montar um volume lógico em particular, use o nome mostrado em "LV Path" (i.e., /dev/fedora_gabriel/home) como a seguir.

$ sudo mount /dev/fedora_gabriel/home /mnt

Você pode verificar se a montagem ocorreu adequadamente executando o comando "mount" sem argumentos, que mostrará uma lista de todos os sistemas montados:

$ mount

Se você quiser montar o volume lógico automaticamente durante o "boot", adicione a seguinte linha ao arquivo /etc/fstab. Você deve especificar o tipo de sistema de arquivos do volume (p.ex. ext4), que pode ser obtido a partir do comando mount acima. 

/dev/fedora/home /mnt ext4 defaults 0 0

Espero que tenha ajudado. Deixe seu comentário. Abs.