📜 ⬆️ ⬇️

Transferring Gentoo to LVM2 partition

Good day% username%!

In connection with their professional activities, we have to configure our clients' servers. Not all of them want or have the opportunity to purchase a Windows server. These organizations as a server OS, we put the Calculate Directory Server based on Gentoo . And, as a person who likes to sleep soundly, I would like the system to stand on a mirrored raid (RAID 1). Unfortunately, out of the box Calculate Directory Server does not support this feature. I also could not find a single more or less intelligible description of how to do this. So I had to spend a couple of evenings searching for a solution.


So, as a software reid, I took LVM2. On its merits on Habré already written, I will not repeat. As I said, there is no support for LVM volumes in the calculator, although the software itself is present. So, it remains a small matter - rebuild the kernel with Device Mapper support:
')
For these purposes, use the genkernel script:

# genkernel --menuconfig --lvm2 all


Other interesting parameters look here and in mana. After running the script, a menu will appear in which we will need to include the following items:

Device Drivers --->
Multi-device support (RAID and LVM) --->
[*] Multiple devices driver support (RAID and LVM)
< > RAID support
<*> Device mapper support


At the end of the kernel build and 3 cups of coffee, the new kernel and initramfs appear in the / boot folder themselves. Next, edit /boot/grub/grub.conf, where we replace the following values:

kernel /boot/vmlinuz --> /boot/ kernel-x86_64-2.6.31-gentoo-r6
initrd /boot/initrd --> initrd /boot/initramfs-x86_64-2.6.31-gentoo-r6


After that, we reboot with a new kernel and raise mirror reyd. To begin, let us indicate which sections will be used in Reid:

# pvcreate /dev/sda3 /dev/sda4 /dev/sdb


In this case, I added 3 sections, because on one of them will be located the log used to synchronize mirrors, but more on that below. In the meantime, add these disks to the VGMirror virtual group:

# vgcreate VGMirror /dev/sda3 /dev/sda4 /dev/sdb


And now you can create a 20GB mirror:

# lvcreate -L 20G -m 1 -n MirrorVolume VGMirror


So you became the lucky owner of level 1 Reid, located at / dev / VGMirror / MirrorVolume :) You could also create a mirror two-disk reyd using the --corelog parameter, but at each reboot you would be able to fully resync disks, which is not according to Feng Shui
Now we can proceed to transfer the system to a new section. First, let's create a file system on it:

# mkfs.ext4 /dev/VGMirror/MirrorVolume

And we will mount where it is not a pity;)

# mount /dev/VGMirror/MirrorVolume /mnt/calculate


And, as a matter of fact, we transfer everything from the root to the new section, except the daddy / proc:

# cd / ;cp $(ls /|sed 's\proc\\') /mnt/calculate -axv


In the meantime, this whole trash heap is copied, crawl into / boot / grub / grub.conf (which is still on / dev / sda2) and add a directive to the dolvm kernel parameters to automatically detect and activate LVM volumes and change the root parameter:

root=/dev/sda2 --> root=/dev/mapper/VGMirror-MirrorVolume


That's all, now you can reboot and pray :)

PS After a successful launch of the system, you can demolish the original, and / boot to transfer to your small and smart partition under ext2. But it is better to restrict yourself to the transfer of / boot, and leave root on / dev / sda2 for such a wonderful thing that is present in Calculate Linux, like updating the system.

PSS Everything, now you can kick, but not much, please, after all, my first article is not only on Habré, but in general :)

Sources:
LVM Configuration
Tale of Linux and LVM (Logical Volume Manager)
LVM HOWTO
man

Source: https://habr.com/ru/post/78487/


All Articles