Difference between pages "Rootfs over encrypted lvm over raid-1 on GPT" and "RHEL5 Kernel HOWTO"

From Funtoo
(Difference between pages)
Jump to: navigation, search
 
m
 
Line 1: Line 1:
This howto describes how to setup LVM and rootfs with cryptoLUKS-encrypted raid-1 over drive with GPT
+
== Introduction ==
= Rootfs over encrypted lvm over raid-1 on GPT =
+
  
To start read [[Rootfs_over_encrypted_lvm|Rootfs over encrypted lvm]]
+
This HOWTO will show you how to get a RHEL5-based OpenVZ kernel running on a Funtoo Linux system. 
  
How to prepare the hard disk for GPT read [[Funtoo_Linux_Installation#GPT_Partitions|Funtoo Linux Installation on GPT_Partitions]].
+
== Step 1: Downgrade {{Package|sys-fs/udev}}, {{Package|sys-fs/lvm2}} ==
For example, installing a new system on <code>/dev/sdb</code>
+
  
 +
Downgrade udev to a version compatible with kernels previous than 2.6.27:
 
<console>
 
<console>
###i## gdisk -l /dev/sdb
+
###i## echo ">=sys-fs/udev-147" >> /etc/portage/package.mask
GPT fdisk (gdisk) version 0.6.13
+
###i## emerge -u udev
 
+
Partition table scan:
+
  MBR: protective
+
  BSD: not present
+
  APM: not present
+
  GPT: present
+
 
+
Found valid GPT with protective MBR; using GPT.
+
Disk /dev/sdb: 625142448 sectors, 298.1 GiB
+
Logical sector size: 512 bytes
+
Disk identifier (GUID): 67AC0F92-E033-4B53-B6C5-D99DD8F49D90
+
Partition table holds up to 128 entries
+
First usable sector is 34, last usable sector is 625142414
+
Partitions will be aligned on 2048-sector boundaries
+
Total free space is 3038 sectors (1.5 MiB)
+
 
+
Number  Start (sector)    End (sector)  Size      Code  Name
+
  1            2048          206847  100.0 MiB  0700  Linux/Windows data
+
  2          206848          207871  512.0 KiB  EF02  BIOS boot partition
+
  3          208896      625142414  298.0 GiB  FD00  Linux RAID
+
 
</console>
 
</console>
  
If you plan to use a raid-1 for installing only one partition (/dev/sdb3 in example) and, if successful, later add more to the mirror, issue something like:
+
This will also require a downgrade of lvm2, if you are using it. Version 2.02.68 is a good one to use:
 
<console>
 
<console>
###i## mdadm --create /dev/md0 --level=1 --raid-devices=2 missing /dev/sdb3
+
###i## echo ">=sys-fs/lvm2-2.02.69" >> /etc/portage/package.mask
 +
###i## emerge -u lvm2
 
</console>
 
</console>
  
If you prefer to add the two final destination devices to the array in the first place, issue something like:
+
Downgrade make to a version compatible with older kernel version:
 
<console>
 
<console>
###i## mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sda3 /dev/sdb3
+
###i## echo ">=sys-devel/make-3.82" > /etc/portage/package.mask
 +
###i## emerge -u make
 
</console>
 
</console>
  
If everything worked well, the arrays will start synchronising immediately. You can monitor this progress by looking at the contents of <code>/proc/mdstat</code>:
+
== Step 2: Install binary kernel ==
  
 +
The process for installing an RHEL5-based kernel with OpenVZ support has been drastically simplified. Simply perform the following steps:
 
<console>
 
<console>
###i## cat /proc/mdstat
+
###i## echo "sys-kernel/openvz-rhel5-stable binary" >> /etc/portage/package.use
Personalities : [raid1] [raid0] [raid6] [raid5] [raid4]
+
</console>
md2 : active raid1 sdb5[1] sda5[0]
+
      581595328 blocks [2/2] [UU]
+
        resync=DELAYED
+
  
md1 : active raid1 sdb4[1] sda4[0]
+
This will result in the kernel sources and a binary kernel and initrd being merged. Without <code>binary</code> in USE, only the sources will be merged. Then:
      41942976 blocks [2/2] [UU]
+
<console>
      [>....................]  resync =  1.6% (691456/41942976) finish=8.9min speed=76828K/sec
+
###i## emerge -av openvz-rhel5-stable
 +
</console>
  
md0 : active raid1 sdb1[1] sda1[0]
+
This will build and install a binary kernel image and initial RAM disk, and take care of installing all necessary dependencies like gcc-4.1.2. Once the binary kernel image and initrd is installed, configure <code>/etc/boot.conf</code> to find and boot the new kernel.
      511936 blocks [2/2] [UU]
+
  
unused devices: <none>
+
Note: you may need to temporarily modify your <code>CFLAGS</code> settings to ensure they are compatible with gcc-4.1 systems. In particular, <code>-march=native</code> is not recognized by the older gcc.
###i##
+
</console>
+
  
Now, that's awesome, isn't it? :)
+
[1] http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/i386-and-x86_002d64-Options.html#i386-and-x86_002d64-Options
Even more awesome is the fact that you can immediately start using your shiny new RAID. It will finish it's sync in the background while you do changes to its filesystem.
+
  
== Encrypting the raid-1 ==
+
== Step 3: Enable vz initscript ==
  
 +
When your system boots with OpenVZ support enabled, it will require <code>/etc/init.d/vz</code> to run:
 
<console>
 
<console>
###i## cryptsetup -c aes-xts-plain luksFormat /dev/md0
+
###i## rc-update add vz default
###i## cryptsetup luksOpen /dev/md0 dmcrypt_root
+
 
</console>
 
</console>
  
Further, all the same [http://docs.funtoo.org/Rootfs_over_encrypted_lvm as here]… The differences begin with the "Initramfs setup and configuration"
+
== Step 4: Edit boot.conf ==
  
To activate the raid-1 during boot to perform:
+
Update <code>/etc/boot.conf</code> to point to your new kernel, ie:
<pre>echo "Activating RAID device."
+
if [ ! -e '/etc/mdadm.conf' ]
+
then
+
echo "DEVICE /dev/sda[0-9] /dev/sdb[0-9] /dev/md[0-9]" > /etc/mdadm.conf
+
mdadm --examine --scan --config=/etc/mdadm.conf  >> /etc/mdadm.conf
+
mdadm --assemble --scan
+
fi</pre>
+
 
+
Or use [https://bitbucket.org/piotrkarbowski/better-initramfs better-initramfs] with raid-1 mdadm support
+
 
<console>
 
<console>
###i## git clone git@bitbucket.org:piotrkarbowski/better-initramfs.git
+
###i## nano /etc/boot.conf
 +
 
 +
boot {
 +
        generate grub
 +
        default kernel-openvz-rhel5-stable-x86_64-2.6.18-028stab089.1
 +
        timeout 3
 +
}
 +
 
 +
"Funtoo Linux with OpenVZ" {
 +
        kernel kernel-openvz[-v]
 +
        initrd initramfs-openvz[-v]
 +
        params += real_root=auto
 +
}
 
</console>
 
</console>
This script is well documented at it's GitHub overview site (which displays the documentation from README.rst).
+
Note that you must use the  
 +
<console>
 +
params += real_root=auto
 +
</console> option. This will automatically configure your boot loader to specify your root file system as the
 +
<console>
 +
real_root
 +
</console>
 +
to the initrd.
  
== Grub2 configuration ==
+
== Step 5: boot-update ==
  
Do not forget:
+
Now, simply run ''<code>boot-update</code>'' as root:
<pre>enc_root=/dev/md0</pre>
+
<console>
 +
###i## boot-update
 +
</console>
  
= Additional links =
+
<tt>boot-update</tt> should show the new kernel as being found and display it as the default
* [http://en.gentoo-wiki.com/wiki/RAID/Software RAID/Software]
+
selection for the next boot. You can now reboot your system and start using OpenVZ.
* [http://www.gentoo.org/doc/en/gentoo-x86+raid+lvm2-quickinstall.xml Gentoo Linux x86 with Software Raid and LVM2 Quick Install Guide]
+
  
 
[[Category:HOWTO]]
 
[[Category:HOWTO]]
 +
[[Category:Kernel]]

Revision as of 22:07, 14 January 2014

Contents

Introduction

This HOWTO will show you how to get a RHEL5-based OpenVZ kernel running on a Funtoo Linux system.

Step 1: Downgrade sys-fs/udev, sys-fs/lvm2

Downgrade udev to a version compatible with kernels previous than 2.6.27:

# echo ">=sys-fs/udev-147" >> /etc/portage/package.mask
# emerge -u udev

This will also require a downgrade of lvm2, if you are using it. Version 2.02.68 is a good one to use:

# echo ">=sys-fs/lvm2-2.02.69" >> /etc/portage/package.mask
# emerge -u lvm2

Downgrade make to a version compatible with older kernel version:

# echo ">=sys-devel/make-3.82" > /etc/portage/package.mask
# emerge -u make

Step 2: Install binary kernel

The process for installing an RHEL5-based kernel with OpenVZ support has been drastically simplified. Simply perform the following steps:

# echo "sys-kernel/openvz-rhel5-stable binary" >> /etc/portage/package.use

This will result in the kernel sources and a binary kernel and initrd being merged. Without binary in USE, only the sources will be merged. Then:

# emerge -av openvz-rhel5-stable

This will build and install a binary kernel image and initial RAM disk, and take care of installing all necessary dependencies like gcc-4.1.2. Once the binary kernel image and initrd is installed, configure /etc/boot.conf to find and boot the new kernel.

Note: you may need to temporarily modify your CFLAGS settings to ensure they are compatible with gcc-4.1 systems. In particular, -march=native is not recognized by the older gcc.

[1] http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/i386-and-x86_002d64-Options.html#i386-and-x86_002d64-Options

Step 3: Enable vz initscript

When your system boots with OpenVZ support enabled, it will require /etc/init.d/vz to run:

# rc-update add vz default

Step 4: Edit boot.conf

Update /etc/boot.conf to point to your new kernel, ie:

# nano /etc/boot.conf

boot {
        generate grub
        default kernel-openvz-rhel5-stable-x86_64-2.6.18-028stab089.1
        timeout 3
}

"Funtoo Linux with OpenVZ" {
        kernel kernel-openvz[-v]
        initrd initramfs-openvz[-v]
        params += real_root=auto
}

Note that you must use the

params += real_root=auto
option. This will automatically configure your boot loader to specify your root file system as the
real_root

to the initrd.

Step 5: boot-update

Now, simply run boot-update as root:

# boot-update

boot-update should show the new kernel as being found and display it as the default selection for the next boot. You can now reboot your system and start using OpenVZ.