Changes

Jump to: navigation, search

LVM Install Guide

13,616 bytes added, 7 years ago
m
fix typo
== Introduction == {{fancywarningfancynote| This page tutorial will show you how to install Funtoo, including the rootfs, on logical volumes. This guide is meant to complement the regular [[Funtoo_Linux_Installation|Funtoo Installation Guide]]. It is recommended that you open it in another tab/window and follow along with it as we will only be documenting the steps that are different or in addition to the regular guide.}} LVM (Logical Volume Management) offers a much more flexible way of managing your storage devices. Not only does it allow you to resize your volumes  == Live CD == Please read the [[Funtoo Linux Installation#Live CD|Live CD]] section in the regular guide. The only thing you need in addition to the [[Requirements|requirements]] it mentions is the sys-fs/lvm2 package or equivalent. If you use [http://www.sysresccd.org/ System Rescue CD], it includes the lvm2 package. == Prepare the drives and partitions == {{fancynote|For this guide, we are assuming you are using MBR, that you have a /dev/sda1 (a boot drive) and /dev/sdb1 (a system drive), and that you are only using LVM with one drive, even though LVM supports adding multiple hard disks and partitions to a volume group. Please adapt these instructions to suit your needs.}} Preparing the hard disk for an LVM install isn't much different from a normal install except that we won't be creating a bunch of partitions as we are going to use logical volumes instead. Find the disk: <console># fdisk -l</console> Verify the disk: <console># fdisk -l /dev/sdb</console> Zap the disk: <console># sgdisk --zap-all /dev/sdb</console> Create the partition table: {{fancynote|If you are using MBR, review paritioning [[Funtoo_Linux_Installation#Partitioning_Using_fdisk_.28MBR.29|Partitioning Using fdisk]] and if you are using GPT, review [[Partitioning using gdisk]]. The basic idea is to create what ncessary and then allocate the rest for LVM.}} For MBR, this is the boot partition (if you want it on the system drive), every else goes to LVM like so: <console># fdisk /dev/sdb</console> <pre>Disk /dev/sdb: 596.2 GiB, 640135028736 bytes, 1250263728 sectorsUnits: sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisklabel type: dosDisk identifier: 0xaa6abfe1 Device Boot Start End Blocks Id System/dev/sdb1 2048 264191 131072 83 Linux/dev/sdb2 264192 1250263727 624999768 83 Linux</pre> For GPT, this is the BIOS boot partion and the boot partition (if you want them on the system drive), every else goes to LVM like so: <console># gdisk /dev/sdb</console> <pre>Disk /dev/sdb: 596.2 GiB, 640135028736 bytes, 1250263728 sectorsUnits: sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisklabel type: dosDisk identifier: 0x6ba8799c Device Boot Start End Blocks Id System/dev/sdb1 2048 6143 2048 ef EFI (FAT-12/16/32)/dev/sdb2 6144 268287 131072 83 Linux/dev/sdb3 268288 1250263727 624997720 83 Linux</pre> You'll notice in both cases that a swap partition wasn't created. This is becasue if one is desired, it can be done in LVM. Create the physical volume: {{fancynote|As a reminder, for this guide, we are assuming you are using MBR, that you have a /dev/sda1 (a boot drive) and /dev/sdb1 (a system drive), and that you are only using LVM with one drive. Change this to suit your purposes.}} Our first step is to create a physical volume which basically just tells the lvm where to write the data to. <console># pvcreate -f -f /dev/sdb1</console> <pre> Physical volume "/dev/sdb1" successfully created</pre> Display the physical volume: <console># pvdisplay</console> <pre> "/dev/sdb1" is a new physical volume of "596.17 GiB" --- NEW Physical volume --- PV Name /dev/sdb1 VG Name PV Size 596.17 GiB Allocatable NO PE Size 0 Total PE 0 Free PE 0 Allocated PE 0 PV UUID IDDrWr-t3PD-7t31-fRQ3-pay2-eMGy-1NgrD0</pre> Create the volume group: Now that we have a place to store our data we need to create a volume group for it. A volume group is simply a named group of at least one physical volume. This allows multiple physical volumes to be used to store data. In our simple example we only have one physical volume so we'll create a volume group and add our physical volume to it in one command. We are going to call our volume group "funtoo" but you can name it anything you want.  <console># vgcreate funtoo /dev/sdb1</console> <pre> Volume group "funtoo" successfully created</pre> Display the volume group: <console># vgdisplay</console> <pre> --- Volume group --- VG Name funtoo System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 1 VG Access read/write VG Status resizable MAX LV 0 Cur LV 0 Open LV 0 Max PV 0 Cur PV 1 Act PV 1 VG Size 596.17 GiB PE Size 4.00 MiB Total PE 152619 Alloc PE / Size 0 / 0 Free PE / Size 152619 / 596.17 GiB VG UUID jFubWA-SGaa-w3C7-Zrst-9Hqo-mWPZ-9JqYZ4</pre> Create the logical volumes: We now come to the heart of using LVM, logical volumes. Here we get to create logical volumes to store our data. Remember that the best part of LVM is the ability to resize volumes later on the fly so keep that in mind when deciding how big to make volumes. No need to allocate all your space right away. Also keep in mind when choosing a file system type that it must support resizing in order to take advantage of LVM's resizing features. For our simple example we are only going to create 4 logical volumes and use them for: (SWAP) /(ROOT), /home/my and /home/my/media. <console># lvcreate -L 32G -n SWAP funtoo</console> <pre> Logical volume "SWAP" created</pre> <console># lvcreate -L 64G -n ROOT funtoo</console> <pre> Logical volume "ROOT" created</pre> <console># lvcreate -L 128G -n home_my funtoo</console> <pre> Logical volume "home_my" created</pre> <console># lvcreate -L 256G -n home_my_media funtoo</console> <pre> Logical volume "home_my_media" created</pre> Display the logical volumes: <console># lvdisplay</console> <pre> --- Logical volume --- LV Path /dev/funtoo/SWAP LV Name SWAP VG Name funtoo LV UUID VkdEAk-Jshp-qcQ0-jU7m-m7f4-fyG6-1FZJlh LV Write Access read/write LV Creation host, time funtoo, 2014-07-24 04:39:19 -0400 LV Status available # open 0 LV Size 32.00 GiB Current LE 8192 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:1 --- Logical volume --- LV Path /dev/funtoo/ROOT LV Name ROOT VG Name funtoo LV UUID 2WE7dL-R5BN-dM78-eMx5-hwS8-SjWJ-mUjzL4 LV Write Access read/write LV Creation host, time funtoo, 2014-07-24 04:39:24 -0400 LV Status available # open 0 LV Size 64.00 GiB Current LE 16384 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:2 --- Logical volume --- LV Path /dev/funtoo/home_my LV Name home_my VG Name funtoo LV UUID OJnpYM-399Y-8pa3-iMTY-Nle3-IyK1-keDtng LV Write Access read/write LV Creation host, time funtoo, 2014-07-24 04:40:16 -0400 LV Status available # open 0 LV Size 128.00 GiB Current LE 32768 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:3 --- Logical volume --- LV Path /dev/funtoo/home_my_media LV Name home_my_media VG Name funtoo LV UUID tt7cin-igC4-VD85-fDKV-J692-fV3F-auJYcU LV Write Access read/write LV Creation host, time funtoo, 2014-07-24 04:40:30 -0400 LV Status available # open 0 LV Size 256.00 GiB Current LE 65536 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:4</pre> Activate swap: <console># mkswap /dev/mapper/funtoo-SWAP</console> <pre>Setting up swapspace version 1, size = 33554428 KiBno label, UUID=ccc83857-28da-4508-a393-84e974e0eeb1</pre> <console># swapon /dev/mapper/funtoo-SWAP</console> Create the filesystems: {{fancynote|Before proceeding you should read through the brief section [[Funtoo Linux Installation#Creating filesystems|Creating filesystems]] in the install guide and decide what type of filesystem you would like to use. Do not actually create any file systems though, we will cover that below.}} <console># mkfs.ext2 /dev/sda1</console> <pre>[...]</pre> <console># mkfs.ext4 /dev/mapper/funtoo-ROOT</console> <pre>mke2fs 1.42.10 (18-May-2014)Creating filesystem with 16777216 4k blocks and 4194304 inodesFilesystem UUID: 0ab8f9ab-e824-4d69-a9c4-201d4ccd99acSuperblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624, 11239424 Allocating group tables: done Writing inode tables: done Creating journal (32768 blocks): doneWriting superblocks and filesystem accounting information: done </pre> <console># mkfs.ext4 /dev/mapper/funtoo-home_my</console> <pre>mke2fs 1.42.10 (18-May-2014)Creating filesystem with 33554432 4k blocks and 8388608 inodesFilesystem UUID: 46e394c1-3635-4f13-ba51-10c537d2b5edSuperblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624, 11239424, 20480000, 23887872 Allocating group tables: done Writing inode tables: done Creating journal (32768 blocks): doneWriting superblocks and filesystem accounting information: done </pre> <console># mkfs.xfs /dev/mapper/funtoo-home_my_media</console> <pre>meta-data=/dev/mapper/funtoo-home_my_media isize=256 agcount=4, agsize=16777216 blks = sectsz=512 attr=2, projid32bit=0data = bsize=4096 blocks=67108864, imaxpct=25 = sunit=0 swidth=0 blksnaming =version 2 bsize=4096 ascii-ci=0log =internal log bsize=4096 blocks=32768, version=2 = sectsz=512 sunit=0 blks, lazy-count=1realtime =none extsz=4096 blocks=0, rtextents=0</pre> Label the filesystems: <console># e2label /dev/sda1 boot</console> == Prepare for chroot == Activiate the volumes: <console># vgscan# vgchange -a work in progress y</console> Mount the filesystems: <console># mkdir -p /mnt/funtoo# mount /dev/mapper/funtoo-ROOT /mnt/funtoo# mkdir -p /mnt/funtoo/boot# mount /dev/sda1 /mnt/funtoo/boot# mkdir -p /mnt/funtoo/home/my# mount /dev/mapper/funtoo-home_my /mnt/funtoo/home/my# mkdir -p /mnt/funtoo/home/my/media# mount /dev/mapper/funtoo-home_my_media /mnt/funtoo/home/my/media</console> == Resume from Funtoo Linux Installation == You may safely resume from [http://www.funtoo.org/Funtoo_Linux_Installation#Installing_the_Stage_3_tarball Installing the Stage 3 tarball] with few exceptions: === fstab === <pre># <filesystem> <mountpoint> <type> <opts> <dump> <pass>/dev/funtoo/SWAP none swap sw 0 0/dev/funtoo/ROOT / ext4 noatime 0 1LABEL=boot /boot ext2 noatime 0 0/dev/funtoo/home_my /home/my ext4 noatime 0 2/dev/funtoo/home_my_media /home/my/media xfs noatime 0 2</pre> === kernel === Enable kernel options:{{kernelop|title=|desc=General setup ---> [*] Initial RAM filesystem and RAM disk (initramfs/initrd) support}}{{kernelop|title=|desc=Device Drivers ---> Generic Driver Options ---> [*] Maintain a devtmpfs filesystem to mount at /dev}}{{kernelop|title=|desc=Device Drivers ---> [*] Multiple devices driver support ---> <*>Device Mapper Support}} Build initramfs (genkernel): {{fancynote|This builds only an initramfs with lvm support. It does not build the whole kernel so you still have to do that.}} <console># genkernel --lvm initramfs</console> === boot-update === <pre>boot { generate grub default "Funtoo Linux" timeout 3"Funtoo Linux" { kernel kernel-genkernel-x86_64-3.14.13 initrd initramfs-genkernel-x86_64-3.14.13 params += dolvm real_root=/dev/mapper/funtoo-ROOT rootfstype=ext4 resume=swap:/dev/mapper/funtoo-SWAP quiet}</pre>
=== software ===
== Introduction ==<console># emerge -va lvm2</console> This tutorial will show you how to install Funtoo, including For the rootfsmost part, on logical volumesLVM "just works" without any additional configuration. This guide is meant to complement the regular especially true for versions below 2.02.107. If you are using >=sys-fs/lvm2-2.02.107 with Funtoo, there are two features be desired that are turned off by default: The Metadata Daemon ([https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Logical_Volume_Manager_Administration/metadatadaemon.html lvmetad]) Thinly-Provisioned Logical Volumes ([Funtoo_Linux_Installation|Funtoo Installation Guide]https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Logical_Volume_Manager_Administration/thinprovisioned_volumes.html Thin Volumes]) Enabling either is simply a matter of enabling their USE flags. It  == Cleaning up == <console># exit# cd /# cat /proc/mounts | grep funtoo | awk '{print $2}' | grep "^$MOUNTPOINT" | sort -r | xargs umount# umount /mnt/funtoo# swapoff -v /dev/mapper/funtoo-SWAP# vgchange -a n# init 0</console> == Special notes == === Resizing === {{fancynote|Resizing is recommended to open it in another tab, window ectfilesystem specific.. and follow along with it as we will only Most can be grown but cannot be documenting the steps that are different or in addition to the regular guideshrunk.}} ==== Growing /home/my by 8G ==== <console># lvextend -L+8G /dev/mapper/funtoo-home_my</console> ===== ext2/ext3/ext4 ===== <console># resize2fs /mnt/funtoo/home/my</console> ===== xfs =====
=== Introduction to LVM ===<console>LVM (Logical Volume Management) offers a much more flexible way of managing your storage devices. Not only does it allow you to resize your volumes while the system is still up, it also frees you from having to decide exactly how many or how big volumes need to be at the time of installation. # xfs_growfs /mnt/funtoo/home/my</console>
For a detailed tour and introduction to LVM please consult the [[LVM Fun]] page.==== Shrinking /home/my by 8G ====
{{fancynote|You generally need to umount first.}}
== Live CD ==Please read the [[Funtoo Linux Installation#Live CD|Live CD]] section in the regular guide. The only thing you need in addition to the [[Requirements|requirements]] it mentions is the sys-fs= ext2/lvm2 package or equivalent. If you use [http:ext3//www.sysresccd.org/ System Rescue CD], it includes the lvm2 package.ext4 =====
== Prepare Hard Disk ==<console>Preparing the hard disk for an LVM install isn't much different from a normal install except that we won't be creating a bunch of partitions as we are going to use logical volumes instead. All we need is a # umount /boot partition, if your using gpt, you'll need the GRUB partition, and the rest of the space will just be one big partition which we'll create our logical volumes out of.mnt/funtoo/home/my# lvreduce -r -L -8G /dev/mapper/funtoo-home_my</console>
{{fancynote|We're using the previous mentioned setup to keep things simple in this guide. We are also assuming your only using one hard disk though LVM supports adding multiple hard disks and partitions to a volume group. Please adapt these instructions to suit your needs}}===== xfs =====
The regular install guide does a good job explaining MRB, GPT, and gdisk/fdisk so we won't XFS cannot be repeating that hereshrunk. Read through the [[Funtoo Linux Installation#Prepare Hard Disk|Prepare Hard Disk]] section and create the previous mentioned partitions. If your following our setup your partition table should look like the following when completed:
'''GPT partition table'''<console> TODO </console>== Beyond the basics ==
'''MRB partition table'''<console> TODO </console>The [[LVM Fun]] page may be of interest.
As well as these pages from Red Hat: [https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Logical_Volume_Manager_Administration/snapshot_command.html Creating Snapshot Volumes]
[https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Logical_Volume_Manager_Administration/thinly_provisioned_volume_creation.html Creating Thinly-Provionsed Logical Volumes]
[https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Logical_Volume_Manager_Administration/mirror_create.html Creating Mirrored Volumes]
[[Category:HOWTO]]
[[Category:Install]]
[[Category:Official Documentation]]
wiki-staff
93
edits

Navigation menu