Arch linux lvm install

Install Arch Linux on LVM

You should create your LVM Volumes between the partitioning and formatting steps of the installation procedure. Instead of directly formatting a partition to be your root file system, the file system will be created inside a logical volume (LV).

  • Install the required packages. (refer to LVM#Installation)
  • Create partition(s) where your physical volumes (PVs) will reside.
  • Create your PVs. If you have one disk it is best to just create one PV in one large partition. If you have multiple disks you can create partitions on each of them and create a PV on each partition.
  • Create your volume group (VG) and add all PVs to it.
  • Create logical volumes (LVs) inside that VG.
  • Continue with Installation guide#Format the partitions.
  • When you reach the “Create initial ramdisk environment” step in the Installation guide, add the lvm2 hook to /etc/mkinitcpio.conf (see below for details).

Warning: /boot cannot reside in LVM when using a boot loader which does not support LVM; you must create a separate /boot partition and format it directly. While this partition is already necessary for UEFI/GPT it is an additional partition for both BIOS/MBR and BIOS/GPT. Create the partition /boot for BIOS systems irrespective of the partition table and create a Linux filesystem on it (partition type 8300 in gdisk). Mount the created partition to /boot . Only GRUB is known to support LVM. Nevertheless, it requires this separate boot partition.

Installation

You will follow along with the installation guide until you come to Installation guide#Partition the disks. At this point you will diverge and doing all your partitioning with LVM in mind.

Create partitions

First, partition your disks as required before configuring LVM.

  • If you use GUID Partition Table, set the partition type GUID to E6D6D379-F507-44C2-A23C-238F2A3DF928 (partition type Linux LVM in fdisk and 8e00 in gdisk).
  • If you use Master Boot Record partition table, set the partition type ID to 8e (partition type Linux LVM in fdisk).

Create physical volumes

To list all your devices capable of being used as a physical volume:

Warning: Make sure you target the correct device, or below commands will result in data loss!

Create a physical volume on them:

This command creates a header on each device so it can be used for LVM. As defined in LVM#LVM building blocks, DEVICE can be any block device, e.g. a disk /dev/sda , a partition /dev/sda2 or a loop back device. For example:

You can track created physical volumes with:

You can also get summary information on physical volumes with:

Tip: If you run into trouble with a pre-existing disk signature, you can delete it using wipefs.

Create and extend your volume group

First you need to create a volume group on any one of the physical volumes:

# vgcreate volume_group physical_volume 
# vgcreate VolGroup00 /dev/sda2

See lvm(8) for a list of valid characters for volume group names.

Читайте также:  Сколько весит установленный линукс

Extending the volume group is just as easy:

# vgextend volume_group physical_volume 

For example, to add both sdb1 and sdc to your volume group:

# vgextend VolGroup00 /dev/sdb1 # vgextend VolGroup00 /dev/sdc

You can track how your volume group grows with:

This is also what you would do if you wanted to add a disk to a RAID or mirror group with failed disks.

Note: You can create more than one volume group if you need to, but then you will not have all your storage presented as a single disk.

Combined creation of physical volumes and volume groups

LVM allows you to combine the creation of a volume group and the physical volumes in one easy step. For example, to create the group VolGroup00 with the three devices mentioned above, you can run:

# vgcreate VolGroup00 /dev/sda2 /dev/sdb1 /dev/sdc

This command will first set up the three partitions as physical volumes (if necessary) and then create the volume group with the three volumes. The command will warn you if it detects an existing filesystem on any devices.

Create logical volumes

  • If you wish to use snapshots, logical volume caching, thin provisioned logical volumes or RAID see LVM#Logical volumes.
  • If a logical volume will be formatted with ext4, leave at least 256 MiB free space in the volume group to allow using e2scrub(8) . After creating the last volume with -l 100%FREE , this can be accomplished by reducing its size with lvreduce -L -256M volume_group/logical_volume .

Now we need to create logical volumes on this volume group. You create a logical volume with the next command by specifying the new volume’s name and size, and the volume group it will reside on:

# lvcreate -L size volume_group -n logical_volume 
# lvcreate -L 10G VolGroup00 -n lvolhome

This will create a logical volume that you can access later with /dev/VolGroup00/lvolhome . Just like volume groups, you can use any name you want for your logical volume when creating it besides a few exceptions listed in lvm(8) § VALID_NAMES .

You can also specify one or more physical volumes to restrict where LVM allocates the data. For example, you may wish to create a logical volume for the root filesystem on your small SSD, and your home volume on a slower mechanical drive. Simply add the physical volume devices to the command line, for example:

# lvcreate -L 10G VolGroup00 -n lvolhome /dev/sdc1

To use all the free space left in a volume group, use the next command:

# lvcreate -l 100%FREE volume_group -n logical_volume 

You can track created logical volumes with:

Note: You may need to load the device-mapper kernel module ( modprobe dm_mod ) for the above commands to succeed.

Tip: You can start out with relatively small logical volumes and expand them later if needed. For simplicity, leave some free space in the volume group so there is room for expansion.

Format and mount logical volumes

Your logical volumes should now be located in /dev/YourVolumeGroupName/ . If you cannot find them, use the next commands to bring up the module for creating device nodes and to make volume groups available:

# modprobe dm_mod # vgscan # vgchange -ay

Now you can format your logical volumes and mount them as normal partitions (see mount a file system for additional details):

# mkfs.fstype /dev/volume_group/logical_volume # mount /dev/volume_group/logical_volume /mountpoint 
# mkfs.ext4 /dev/VolGroup00/lvolhome # mount /dev/VolGroup00/lvolhome /home

Warning: When choosing mountpoints, just select your newly created logical volumes (use: /dev/Volgroup00/lvolhome ). Do not select the actual partitions on which logical volumes were created (do not use: /dev/sda2 ).

Читайте также:  Nslookup для linux аналог

Configure the system

Make sure the lvm2 package is installed.

  • lvm2 provides the lvm2 hook. If you are running mkinitcpio in an arch-chroot for a new installation, lvm2 must be installed inside the arch-chroot for mkinitcpio to find the lvm2 hook. If lvm2 only exists outside the arch-chroot, mkinitcpio will output Error: Hook ‘lvm2’ cannot be found .
  • If your root filesystem is on LVM RAID see #Configure mkinitcpio for RAID.

Adding mkinitcpio hooks

In case your root filesystem is on LVM, you will need to enable the appropriate mkinitcpio hooks, otherwise your system might not boot. Enable:

  • udev and lvm2 for the default busybox-based initramfs
  • systemd and lvm2 for systemd-based initramfs

udev is there by default. Edit the file and insert lvm2 between block and filesystems like so:

HOOKS=(base udev . block lvm2 filesystems)

For systemd based initramfs:

HOOKS=(base systemd . block lvm2 filesystems)

Afterwards, you can continue in normal installation instructions with the create an initial ramdisk step.

Configure mkinitcpio for RAID

If your root filesystem is on LVM RAID additionally to the lvm2 hook, you need to add dm-raid and the appropriate RAID modules (e.g. raid0 , raid1 , raid10 and/or raid456 ) to the MODULES array in mkinitcpio.conf . Also dm_integrity module is needed if you created RAID with integrity checksums ( —raidintegrity option in lvcreate ).

For busybox based initramfs:

MODULES=(dm-raid dm_integrity raid0 raid1 raid10 raid456) HOOKS=(base udev . block lvm2 filesystems)

For systemd based initramfs:

MODULES=(dm-raid dm_integrity raid0 raid1 raid10 raid456) HOOKS=(base systemd . block lvm2 filesystems)

For systems using LVM thin volumes the location of systemd between udev and block causes the malfunction of the thin volume. just with the parameters (base udev autodetect modconf block lvm2 filesystems keyboard fsck) works: root FS inside a lvm logical volume, and other LVM’s (normal and thin) at other locations.

Kernel boot options

If the root file system resides in a logical volume, the root= kernel parameter must be pointed to the mapped device, e.g /dev/vg-name/lv-name .

Источник

How to Install Arch Linux with LVM (Logical Volume Manager)

Automated Video Animation Software

Have you ever wanted more storage without resetting a partition? I’ll show you how to install Arch Linux with LVM, the Logical Volume Manager.

arch linux with lvm

Intro

The Arch Linux distribution is the home of a tinkerer’s dream.

Back then, when I was a heavy computer user, I would enjoy tinkering with the system.

It amazed me what I can do with only the arch wiki and the command line at my disposal.

The latest Linux software is available is through the rolling release packages and the AUR with pacman .

The AUR is an Arch Linux user repository developed by the community where people share and support builds of software packages.

Accessing the AUR is as simple as using a similar packager manager that functions just like pacman :

yay has the same functionalities just like pacman , but much more when I would install AUR packages.

Moving onwards, I was scanning through the Arch Linux documentation when I was looking for the best way to update my new system.

Читайте также:  Как подключить usb в линуксе

Eventually, I came across information about disks.

Specifically, Linux file systems, and what each one is used for.

This lead to me experimenting with one package available on Linux called F2FS.

I believed that F2FS was the perfect choice for me since my laptop on Linux has an NVME SSD.

Having a specific Linux file system for my hard drive would improve the overall performance, not having to worry about optimizing it myself.

For how long did I use the Arch Linux installation when trying out new packages?

I ended up using one of the software packages called F2FS on Arch Linux for quite some time.

hard drive representing f2fs

In fact, I used it for approximately 3 months when I started to get used to Arch Linux.

I spent most of my time on Arch Linux seeing what this distro had to offer.

In Arch Linux, I discovered that setting up basic tweaks with battery life tools, desktop environment, video memory, and users took much longer as compared to an easier distro.

It felt like, with Arch Linux, I finally had a system that was optimized to the extreme (not exaggerating).

Reverting back to Ubuntu would end up being a lost cause.

But in reality, the EXT4 package was more than enough and I barely noticed any hardware improvements.

Since F2FS was really meant to be used on micro-sized hardware chips, I removed it and had to reinstall the base system from the repository again!

I’d figured, «Is there a way I can experiment with different internals without affecting my system»?

Yes, there was; Virtualization!

How was my experience when switching over to KVM and LVM?

I decided to try out a natively supported hypervisor which was KVM.

When I finished installing it, I had no clue how to use it.

Coming from a VirtualBox background, KVM did things differently.

Usually, the installation process of using a virtual machine for Arch users is pretty much a straightforward process.

I installed this and that without giving much thought.

With KVM, setting up basic settings such as the GUI was something I had to open Google for support.

Plus, even before that, I had trouble launching the program from a couple of commands I attempted to use.

Perhaps I missed a dependency I couldn’t find, but it really had to do with not enabling one of the Linux systemd services.

But nonetheless, I quickly adapted to it, and I noticed that there were fewer bottlenecks when doing intensive tasks, such as launching two Linux virtual labs simultaneously on the desktop environment.

After getting used to KVM, my search results recommended a wiki page talking about LVM.

The Arch Linux wiki is a great source to follow through and learn more.

In simple terms, LVM is a tool that lets you create virtual partitions, which means that if you have an urge to get rid of one that isn’t used anymore, LVM can remove it without leaving any side-effects.

Or, what if you need a certain partition to have more disk storage when the time comes? No worries, LVM can extend it on the fly!

What software did I use to create the video?

At the time of recording this video, my current setup was Fedora for my distribution of choice because installing Arch was too cumbersome for me to screen capture.

Plus, it was updated just as often as Arch Linux.

If you’re a complete Linux beginner to Arch Linux, I recommend that you download a configuration such as Vbox and Ubuntu.

Источник

Оцените статью
Adblock
detector