domingo, 5 de marzo de 2023

Volume group exercise

 Exercise 25.1: Logical VolumesWe are going to create a logical volume using two 250 MB partitions. We are going to assume you have real partitionable diskspace available.

1.  Create two 250 MB partitions of type logical volume (8e).

2.  Convert the partitions to physical volumes.

3.  Create a volume group namedmyvgand add the two physical volumes to it. Use the default extent size.

4.  Allocate a 300 MB logical volume namedmylvmfrom volume groupmyvg.

5.  Format and mount the logical volumemylvmat/mylvm

6.  Uselvdisplayto view information about the logical volume.

7.  Grow the logical volume and corresponding filesystem to 350 MB

Solution 25.11. 

 

1.  Execute: $ sudo fdisk /dev/sdausing whatever hard disk is appropriate, and create the two partitions. While infdisk, typingtwill let you set the partition type to 8e.  While it doesn’t matter if you don’t set the type, it is a good idea to lessen confusion.  Usewto rewrite thepartition table and exit, and then$ sudo partprobe -s or reboot to make sure the new partitions take effect.

 
 
2.  Assuming the new partitions are/dev/sdaXand/dev/sdaY:

$ sudo pvcreate /dev/sdaX$ 
$ sudo pvcreate /dev/sdaY
$ sudo pvdisplay

3.

$ sudo vgcreate myvg /dev/sdaX /dev/sdaY
$ sudo vgdisplay



4.

$ sudo lvcreate -L 300M -n mylvm myvg$ sudo lvdisplay

5.

$ sudo mkfs.ext4 /dev/myvg/mylvm

$ sudo mkdir /mylvm$ 

$ sudo mount /dev/myvg/mylvm /mylvm


If you want the mount to be persistent, edit/etc/fstab to include the line:

in /etc/fstab  

/dev/myvg/mylvm /mylvm ext4 defaults 0 0 

6.
$ sudo lvdisplay


7.

$ df -h

$ sudo lvresize -r -L 350M /dev/myvg/mylvm

$ df -h

or  sudo lvresize -r -L +50M /dev/myvg/mylvm or with older methods you can do:

$ df -h

$ sudo lvextend -L 350M /dev/myvg/mylvm

$ sudo resize2fs /dev/myvg/mylvm

$ df -h 

https://trainingportal.linuxfoundation.org/learn/course/linux-system-administration-essentials-lfs207/logical-volume-management-lvm/lab-exercises?page=1

No hay comentarios:

Publicar un comentario