Difference between revisions of "Creating System Rescue CD ZFS Modules"

From Funtoo Linux
Jump to: navigation, search
(Creating the SRM)
(Creating the SRM has been moved.)
Line 1: Line 1:
 
This HOWTO will show you how to create your own zfs srm or download the prebuilt zfs srm module from my website.
 
This HOWTO will show you how to create your own zfs srm or download the prebuilt zfs srm module from my website.
  
== Creating the SRM ==
+
== Compiling a compatible kernel ==
  
 
'''Currently being rewritten.'''
 
'''Currently being rewritten.'''
Line 45: Line 45:
 
</console>
 
</console>
  
The Local version above will end up making the kernel modules directory be 3.4.35-std342-amd64.
+
The Local version above will end up making the kernel modules directory be 3.4.35-std342-amd64. The reason the kernel modules directory has to be equal to this is because our directory will be merged into the System Rescue CD later on, so the names need to be exactly the same so that the System Rescue CD system can find our kernel modules.
 +
 
 +
Now save and exit, and continue to build your kernel.
 +
 
 +
<console>
 +
# ##i##make bzImage modules
 +
# ##i##make modules_install
 +
</console>
 +
 
 +
{{fancynote|If you have multiple cores, do a make -j<# of processors+1> to build faster. Example: '''make -j9''' for an 8 core machine.}}
 +
 
 +
Once the kernel is installed, now you need to make the SRM.
 +
 
 +
== Creating the SRM ==
  
 
== Using the prebuilt srm ==
 
== Using the prebuilt srm ==

Revision as of 02:12, 10 March 2013

This HOWTO will show you how to create your own zfs srm or download the prebuilt zfs srm module from my website.

Contents

Compiling a compatible kernel

Currently being rewritten.

The first thing you need to do is decide for which version of System Rescue CD you will be building for. Each System Rescue CD version has a different set of kernels. Specifically each version has a Stable kernel and an Alternate Kernel. The stable kernels get minor version increments every release (Sometimes major ones but usually doesn't happen too quickly), the Alternate kernels tend to move up much faster. For example System Rescue CD had the following stable/alternate kernels:

Version Stable Alternate
3.4.2 3.4.35 3.7.10
3.4.1 3.4.32 3.7.9
3.4.0 3.4.30 3.7.8
3.3.0 3.4.27 3.7.4

Once you decide which version you want to use, you can go to http://kernel.sysresccd.org/ and pick the version you want. After you do this, download all the stuff in that directory and put them in their own folder (a work directory). The files that are named std-sources are the patches for the regular stable kernel, the patches named alt-sources are the patches for the alternate kernel. Once you have the patches, go to kernel.org and also download the initial release of the kernel sources you want. For example, if you want to build an srm for 3.4.2 which uses the 3.4.35 kernel, just download the 3.4 (3.4.0) kernel. You just need to download the initial release because one of the patches you downloaded earlier is the patch to update the 3.4.0 to 3.4.35.

Once you download the kernel you want, let's extract and patch it.

# tar xf linux-3.4.tar.bz2
# mv linux-3.4 linux-3.4.35-std342-amd64
# bzcat std-sources-3.4-01-stable-3.4.35.patch.bz2 | patch -p1 -d linux-3.4.35-std342-amd64
# bzcat std-sources-3.4-02-fc16.patch.bz2 | patch -p1 -d linux-3.4.35-std342-amd64
# bzcat std-sources-3.4-03-aufs.patch.bz2 | patch -p1 -d linux-3.4.35-std342-amd64

Once that is complete, you will need to get the kernel sources specifically for the kernel and architecture you want. The easiest way I found to do this was to download the System Rescue CD you want, and then boot it inside a VM. Once you are inside the VM, go to the /root directory, and it will be a file named kernel-<version>.conf. Copy this file over SSH and put it in a safe location. Also copy it over into the linux kernel directory and rename it to .config.

Once you copy the kernel config over, do a make menuconfig to begin. You will only need to change two settings inside the config, add the proper kernel name, and remove the old initramfs source files directory. This directory doesn't exist locally. This is a remnant of upstream's build process.

Follow the below tree structure, and make it equal to what is below:

General setup --->
 (-std342-amd64) Local version - append to kernel release

 [*] Initial RAM filesystem and RAM disk (initramfs/initrd) support  ()    Initramfs source file(s)

The Local version above will end up making the kernel modules directory be 3.4.35-std342-amd64. The reason the kernel modules directory has to be equal to this is because our directory will be merged into the System Rescue CD later on, so the names need to be exactly the same so that the System Rescue CD system can find our kernel modules.

Now save and exit, and continue to build your kernel.

# make bzImage modules
# make modules_install

If you have multiple cores, do a make -j<# of processors+1> to build faster. Example: make -j9 for an 8 core machine.


Once the kernel is installed, now you need to make the SRM.

Creating the SRM

Using the prebuilt srm

Download the SRM

We will use version 3.3.0 as an example. For version 3.3.0, you will be downloading the 3.4.27 srm.

Click to view and download the list of System Rescue CD versions and available modules.

Extract the file you just downloaded by doing:

Create an empty directory, download the file, then extract it:

# mkdir temp && cd temp
# wget http://ftp.osuosl.org/pub/funtoo/distfiles/sysrescuecd/zfs-3.4.27-std330-amd64.tar.bz2
# tar xvf zfs-3.4.27-std330-amd64.tar.bz2

Extracting it should give you a directory layout that looks like this:

# ls -lh
total 2.5M
drwxr-xr-x 2 jon  jon  2 Jan 12 20:41     iso
-rwxr--r-- 1 jon  jon  1.5K Jan 12 20:31  make_iso.sh
drwxr-xr-x 2 jon  jon  4 Jan 12 19:44     srm
-rwxr--r-- 1 jon  jon  1.3K Jan 12 20:33  usb_inst.sh
-rwxr--r-- 1 jon  jon  294 Jan 12 20:05   vars.sh
-rw-r--r-- 1 root root 2.4M Jan 25 21:38  zfs-3.4.27-std330-amd64.tar.bz2

The layout is as follows:

  • iso - directory to place your system rescue cd iso in
  • make_iso.sh - A script to automatically recreate the system rescue cd iso with the zfs stuff included
  • srm - directory that has the srms
  • usb_inst.sh - Creates a new flash drive for you with system rescue cd and puts the srms in it
  • vars.sh - Variables (You don't need to worry about this).

Installing the SRM

There are a few ways to do this, you can either use one of the scripts, or you can do it manually.

Generating a new iso

If you just want to remake a new iso so that you can burn onto a cd or use in a virtual machine, just copy your iso over to the iso directory, and run the iso script. The new iso will be located in the iso directory as well with a -zfs ending.

If you don't have the iso generating tools installed, the script will stop and tell you what to install.

Creating a fresh usb

If you want to have zfs on a usb with system rescue cd, then put the iso in your iso dir, and then run the usb script. It will ask you what usb you want to format (This will delete everything), and then install system rescue cd onto it. Once that is done it will copy the zfs stuff over.

Manual installation onto a usb

Assuming that your installing to a flash drive and that the flash drive is mounted in /mnt

1. Mount your usb drive

# mount /dev/sdX# /mnt/usbstick

Where X# is the letter and number of your device. Immediately after you plug your usb in, type `dmesg | tail` in the console and you should see it.


2. Copy the zfs .srm and .md5 to /mnt/usbstick

# cp zfs-3.4.27-std330-amd64.srm zfs-3.4.27-std330-amd64.md5 /mnt/usbstick

If there are multiple kernel srms available for a System Rescue CD release, Only copy the srm for the kernel you will be booting.


3. List your /mnt directory and you should see something similar to the following in your /mnt

funtoo tmp # ls -lh /mnt
total 263M
drwxr-xr-x 3 root root 4.0K Jan  8 02:39 boot
drwxr-xr-x 2 root root 4.0K Jan  8 02:39 bootdisk
drwxr-xr-x 2 root root 4.0K Jan  8 02:39 bootprog
drwxr-xr-x 3 root root 4.0K Jan  8 02:39 efi
drwxr-xr-x 2 root root 4.0K Jan  8 02:39 ntpasswd
drwxr-xr-x 3 root root 4.0K Jan  8 02:40 syslinux
drwxr-xr-x 2 root root 4.0K Jan  8 02:49 sysrcd
-rwxr-xr-x 1 root root 260M Jan  8 02:39 sysrcd.dat
-rwxr-xr-x 1 root root   45 Jan  8 02:39 sysrcd.md5
drwxr-xr-x 2 root root 4.0K Jan  8 02:39 usb_inst
-rwxr-xr-x 1 root root  16K Jan  8 02:39 usb_inst.sh
-rwxr-xr-x 1 root root  877 Jan  8 02:39 usbstick.htm
-rwxr-xr-x 1 root root    6 Jan  8 02:39 version
-rwxr-xr-x 1 root root   62 Jan  8 02:50 zfs-3.4.27-std330-amd64.md5
-rwxr-xr-x 1 root root 2.4M Jan  8 02:50 zfs-3.4.27-std330-amd64.srm

Now unmount the and boot it into the machine that you want to use ZFS on.

# umount /mnt/usbstick

Booting into the correct kernel

If you are using the standard srm:

C) Standard 64bit kernel (rescue64) with more choice... >
1. SystemRescueCd with default options

If you are using the alternative srm:

E) Alternative 64bit kernel (altker64) with more choice... >
1. SystemRescueCd with default options

3. Run 'depmod' so that the new modules can be seen by the kernel. 4. Run 'modprobe -v zfs to load the modules.

# depmod
# modprobe -v zfs

You must run depmod. If you don't, then you will get failed to load the ZFS stack error! And after modprobe you can check with 'lsmod' if the 6 modules where loaded.


5. Use ZFS as usual. If you type zpool status and then type `dmesg | tail`,

you should see something that says:

ZFS: Loaded module v0.6.0-rc13, ZFS pool version 28, ZFS filesystem version 5

If you see the above, then the modules loaded successfully!

Enjoy System Rescue CD with ZFS :)

Personal tools
Namespaces

Variants
Actions
Categories
Toolbox
Stuff