documentation:lvm
Differences
This shows you the differences between two versions of the page.
| documentation:lvm [2020/02/01 12:35] – external edit 127.0.0.1 | documentation:lvm [2020/02/01 13:01] (current) – removed lucid | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== How to Setup Linux Volume Management for a Linux Install ====== | ||
| - | Guide assumes a fresh install will be performed, existing disk partitions will removed before LVM is created. This can be embedded into the Arch Install Guide, which does not exist yet. Encryption article needs to be written as well. | ||
| - | =====Installation with LVM===== | ||
| - | The following details an installation using LVM on Archlinux, though it can be adapted to create any LVM management scheme even for non-boot disks. | ||
| - | |||
| - | ==== Wiping ==== | ||
| - | Check if there is anything on the disk | ||
| - | < | ||
| - | |||
| - | Wipe | ||
| - | < | ||
| - | |||
| - | ==== Make Partitions ==== | ||
| - | < | ||
| - | Select MBR/ | ||
| - | Set size to 1G, this will be /boot | ||
| - | Make an Extended Partition, this will show as a 1K partition and will contain the LVM physical volume | ||
| - | Inside the extended partition, create a partition using all of the remaining space. | ||
| - | |||
| - | Example of the lsblk for after you are done: | ||
| - | < | ||
| - | ├─nvme0n1p1 259:2 0 | ||
| - | ├─nvme0n1p2 259:5 0 | ||
| - | └─nvme0n1p5 259:6 0 222.6G | ||
| - | |||
| - | ==== Make LVM ==== | ||
| - | Create the physical volume on the nested partition in the extended partition | ||
| - | < | ||
| - | |||
| - | The volume group will be created here and given a name, use the same partition as above. | ||
| - | < | ||
| - | |||
| - | Logical Volume creation starts here. The follow commands will setup a root and swap partition. Be sure to use the same volume group name as you created in the previous step. Sizes are specified as G=gigabyte, M=megabyte, and so on. | ||
| - | < | ||
| - | lvcreate -l 100%FREE < | ||
| - | |||
| - | Example: | ||
| - | < | ||
| - | ├─nvme0n1p1 | ||
| - | ├─nvme0n1p2 | ||
| - | └─nvme0n1p5 | ||
| - | ├─archvg-root 254:2 0 214.6G | ||
| - | └─archvg-swap 254:3 0 | ||
| - | |||
| - | ==== Formating ==== | ||
| - | < | ||
| - | mkswap / | ||
| - | swapon / | ||
| - | |||
| - | The lvm partitions are always refered to as ''/ | ||
| - | |||
| - | Example: | ||
| - | < | ||
| - | |||
| - | ==== Pacstrap and rest of install guide ==== | ||
| - | After you have your partitions you can continue installing Arch with the guide. You only need to take note to use the lvm names of the partitions and make sure to edit the '' | ||
| - | |||
| - | ==== Editing mkinitcpio ==== | ||
| - | Before installing the boot loader (grub), do the following so that the kernel can see the lvm structure. | ||
| - | Add systemd and sd-lvm2 to ''/ | ||
| - | |||
| - | < | ||
| - | |||
| - | Generate init using new hooks | ||
| - | < | ||
| - | |||
| - | =====Appending disk to LVM and extending the ext4 filesystem===== | ||
| - | |||
| - | There are numerous scenarios where one may want to resize your LVM root volume, such as after a migration to a larger boot disk. | ||
| - | |||
| - | ====Create partition of appended disk==== | ||
| - | |||
| - | First the space that is going to be appended needs to be partitioned. | ||
| - | I prefer to use '' | ||
| - | |||
| - | < | ||
| - | $ sudo cfdisk /dev/sdX | ||
| - | </ | ||
| - | |||
| - | Take note of the newly created '' | ||
| - | |||
| - | ====Create physical volume==== | ||
| - | |||
| - | Create a physical volume with '' | ||
| - | |||
| - | < | ||
| - | $ sudo pvcreate /dev/sdX | ||
| - | </ | ||
| - | |||
| - | ====Append the physical volume to the volume group==== | ||
| - | |||
| - | You can type '' | ||
| - | |||
| - | < | ||
| - | $ sudo vgextend < | ||
| - | </ | ||
| - | |||
| - | ====Extend logical volume==== | ||
| - | |||
| - | You can now extend the root logical volume with '' | ||
| - | |||
| - | < | ||
| - | $ sudo lvextend -l +100%FREE / | ||
| - | </ | ||
| - | |||
| - | You can type '' | ||
| - | |||
| - | ====Extend ext4 filesystem==== | ||
| - | |||
| - | You can check your filesystem size, before and after extending with '' | ||
| - | |||
| - | Extend filesystem with resize2fs without umount: | ||
| - | |||
| - | < | ||
| - | sudo resize2fs / | ||
| - | </ | ||
documentation/lvm.1580560512.txt.gz · Last modified: 2021/06/18 16:36 (external edit)