This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| linux:general:lvm [2018/12/20 17:42] – Discussion status changed lunetikk | linux:general:lvm [2020/11/16 17:39] (current) – lunetikk | ||
|---|---|---|---|
| Line 35: | Line 35: | ||
| < | < | ||
| pvcreate /dev/sdb1 | pvcreate /dev/sdb1 | ||
| - | vgcreate | + | vgcreate |
| - | lvcreate -l 100%FREE -n backup data | + | lvcreate -l 100%FREE -n backuplv datavg |
| - | mkfs.ext3 -Ldata /dev/data/backup | + | mkfs.ext3 -Lbackup |
| - | #mkfs.xfs -Ldata /dev/data/backup | + | #mkfs.xfs -Lbackup |
| vi /etc/fstab | vi /etc/fstab | ||
| - | / | + | / |
| + | </ | ||
| + | |||
| + | === Extend Physical Volume (PV) === | ||
| + | |||
| + | Get the "PV Name"/ Partition via | ||
| + | < | ||
| + | |||
| + | --- Physical volume --- | ||
| + | PV Name / | ||
| + | VG Name | ||
| + | PV Size < | ||
| + | ... | ||
| + | </ | ||
| + | |||
| + | (Resize VMDK to 1,3TB) Check if your disk resize has already been recognized via | ||
| + | < | ||
| + | |||
| + | major minor # | ||
| + | ... | ||
| + | | ||
| + | | ||
| + | ... | ||
| + | </ | ||
| + | |||
| + | sdc is not 1,3TB, so get the scsi target via | ||
| + | < | ||
| + | |||
| + | ... | ||
| + | [2: | ||
| + | dir: / | ||
| + | ... | ||
| + | </ | ||
| + | |||
| + | Then rescan the adapter | ||
| + | < | ||
| + | |||
| + | The OS now knows that the disk has 1,3TB | ||
| + | < | ||
| + | |||
| + | major minor # | ||
| + | ... | ||
| + | | ||
| + | | ||
| + | ... | ||
| + | </ | ||
| + | |||
| + | Resize the partition (see Create new Physical Volume (PV))\\ | ||
| + | The partitiontable might have an old state, to refresh it try the following commands | ||
| + | < | ||
| + | |||
| + | kpartx -a /dev/sdc | ||
| + | |||
| + | partx -a /dev/sdc | ||
| + | </ | ||
| + | Looking at / | ||
| + | |||
| + | If both sdc and sdc1 are up to date, resize the PV | ||
| + | < | ||
| + | |||
| + | Archiving volume group " | ||
| + | Resizing volume "/ | ||
| + | Resizing physical volume /dev/sdc1 from 153599 to 340786 extents. | ||
| + | Updating physical volume "/ | ||
| + | Creating volume group backup "/ | ||
| + | Physical volume "/ | ||
| + | 1 physical volume(s) resized or updated / 0 physical volume(s) not resized | ||
| + | </ | ||
| + | |||
| + | pvdisplay and vgdisplay are now resized | ||
| + | < | ||
| + | |||
| + | --- Physical volume --- | ||
| + | PV Name / | ||
| + | VG Name | ||
| + | PV Size < | ||
| + | |||
| + | |||
| + | vgdisplay | ||
| + | |||
| + | --- Volume group --- | ||
| + | VG Name | ||
| + | ... | ||
| + | VG Size < | ||
| </ | </ | ||
| === Extend Logical Volume (LV) === | === Extend Logical Volume (LV) === | ||
| - | Create a new partition for free space (example above)\\ | + | Extend the disk (PV/ |
| - | Then extend the LV | + | Then extend the LV (100% is the full VG, check the "Other commands" |
| < | < | ||
| - | pvcreate /dev/sdb1 | ||
| - | vgextend data /dev/sdb1 | ||
| lvextend -l +100%FREE / | lvextend -l +100%FREE / | ||
| + | #if ext3/4 use | ||
| resize2fs / | resize2fs / | ||
| + | #if xfs use | ||
| + | xfs_growfs / | ||
| </ | </ | ||
| Line 72: | Line 156: | ||
| | lvdisplay | | lvdisplay | ||
| | vgchange -ay < | | vgchange -ay < | ||
| + | | vgextend datavg / | ||
| | lvextend -L+5G / | | lvextend -L+5G / | ||
| + | | lvextend -L 10G / | ||
| + | | lvcreate -L20G -n backuplv datavg | ||
| + | | lvresize -r -L+5G / | ||
| === Useful links === | === Useful links === | ||
| Line 79: | Line 167: | ||
| [[https:// | [[https:// | ||
| + | ==== Troubleshooting ==== | ||
| + | |||
| + | === Cant mount a logical volume === | ||
| + | |||
| + | __**Description**__ | ||
| + | |||
| + | Mounting the device leads to the following error | ||
| + | |||
| + | < | ||
| + | mount: special device / | ||
| + | </ | ||
| + | |||
| + | Checking the LV via " | ||
| + | < | ||
| + | LV Status | ||
| + | </ | ||
| + | |||
| + | __**Reason**__ | ||
| + | |||
| + | Its deactivated. | ||
| + | |||
| + | Maybe you are missing the services in autostart? check / | ||
| + | < | ||
| + | chkconfig boot.lvm on | ||
| + | chkconfig boot.lvm_monitor on | ||
| + | </ | ||
| + | |||
| + | __**Fix**__ | ||
| + | |||
| + | Run the following command to activate it | ||
| + | < | ||
| + | |||
| + | and remount | ||
| + | |||
| + | < | ||
| \\ | \\ | ||
| + | |||
| + | === New added disk doesnt appear in / | ||
| + | |||
| + | __**Description**__ | ||
| + | |||
| + | After adding a new disk to your VM the disk doesnt appear in / | ||
| + | |||
| + | __**Reason**__ | ||
| + | |||
| + | The VM didnt rescan the scsi devices | ||
| + | |||
| + | __**Fix**__ | ||
| + | |||
| + | Run the following command rescan the scsi hosts for new devices | ||
| + | < | ||
| + | |||
| \\ | \\ | ||
| ~~DISCUSSION: | ~~DISCUSSION: | ||