Difference between revisions of "Creating System Rescue CD ZFS Modules"
Fearedbliss (Talk | contribs) (→Creating the SRM) |
Fearedbliss (Talk | contribs) (→Creating the SRM) |
||
| Line 90: | Line 90: | ||
<console> | <console> | ||
| − | octopus initrd # ls - | + | octopus initrd # ls -l |
| + | total 61 | ||
| + | -rw-r--r-- 1 root root 4603 Mar 4 00:49 CHANGES | ||
| + | -rw-r--r-- 1 root root 176 Dec 28 12:46 CREDITS | ||
| + | -rw-r--r-- 1 root root 16726 Dec 28 12:46 LICENSE | ||
| + | -rw-r--r-- 1 root root 1842 Mar 4 00:49 README | ||
| + | -rw-r--r-- 1 root root 2367 Feb 3 19:07 USAGE | ||
| + | -rwxr-xr-x 1 root root 1794 Mar 4 00:49 createInit | ||
| + | drwxr-xr-x 3 root root 5 Mar 4 00:49 files | ||
| + | drwxr-xr-x 3 root root 6 Mar 4 00:49 hooks | ||
| + | drwxr-xr-x 2 root root 5 Mar 4 00:49 resources | ||
</console> | </console> | ||
| Line 96: | Line 106: | ||
<console> | <console> | ||
| − | -----------------------------------| Bliss Initramfs Creator - v1.6.7| Author: Jonathan Vasquez <jvasquez1011@gmail.com>| Distributed under the MPLv2----------------------------------->>> Which initramfs would you like to generate:>> 1. ZFS>> 2. Encrypted ZFS (LUKS + ZFS)>> 3. More Options>> 4. Exit Program>>> Current choice [1]: ##i##3>>> More Options:>> 1. ZFS - System Rescue Module>> 2. Back>> 3. Exit Program>>> Current choice [1]: ##i##↵ | + | ----------------------------------- |
| − | >>> Creating a ZFS System Rescue Module!>>> Do you want to use the current kernel: 3.8.1-ALL? [Y/n]: n>>> Please enter the kernel name: ##i##3.4.32- | + | | Bliss Initramfs Creator - v1.6.7 |
| + | | Author: Jonathan Vasquez <jvasquez1011@gmail.com> | ||
| + | | Distributed under the MPLv2 | ||
| + | ----------------------------------- | ||
| + | >>> Which initramfs would you like to generate: | ||
| + | >> 1. ZFS | ||
| + | >> 2. Encrypted ZFS (LUKS + ZFS) | ||
| + | >> 3. More Options | ||
| + | >> 4. Exit Program | ||
| + | |||
| + | >>> Current choice [1]: ##i##3 | ||
| + | |||
| + | >>> More Options: | ||
| + | |||
| + | >> 1. ZFS - System Rescue Module | ||
| + | >> 2. Back | ||
| + | >> 3. Exit Program | ||
| + | |||
| + | >>> Current choice [1]: ##i##↵ | ||
| + | |||
| + | >>> Creating a ZFS System Rescue Module! | ||
| + | >>> Do you want to use the current kernel: 3.8.1-ALL? [Y/n]: ##i##n | ||
| + | >>> Please enter the kernel name: ##i##3.4.32-std341-amd64 | ||
| + | |||
| + | >>> Detected 64 bit platform | ||
| + | >>> Checking to see if modules directory exists for 3.4.32-std341-amd64... | ||
| + | >>> Creating ZFS System Rescue Module for 3.4.32-std341-amd64... | ||
| + | >>> Creating directory structure for initramfs... | ||
| + | >>> Checking preliminary binaries... | ||
| + | >>> Checking binaries... | ||
| + | >>> Using ZFS | ||
| + | >>> Checking modules... | ||
| + | >>> Copying binaries... | ||
| + | >>> Copying modules... | ||
| + | >>> Copying documentation... | ||
| + | >>> Copying udev rules... | ||
| + | >>> Compressing kernel modules... | ||
| + | >>> Getting dependencies... | ||
| + | >>> Copying dependencies... | ||
| + | >>> Configuring files... | ||
| + | >>> Creating and Packing SRM... | ||
| + | >>> Complete :) | ||
</console> | </console> | ||
| + | |||
| + | Now you should have two new files: | ||
| + | |||
| + | <console> | ||
| + | -rw-r--r-- 1 root root 78 Mar 9 22:04 zfs-3.4.32-std341-amd64.md5 | ||
| + | -rw-r--r-- 1 root root 2584576 Mar 9 22:04 zfs-3.4.32-std341-amd64.srm | ||
| + | </console> | ||
| + | |||
| + | Now all you need to do is put those two files in the root of your USB directory. | ||
== Using the prebuilt srm == | == Using the prebuilt srm == | ||
Revision as of 03:07, 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
Now it's time to gather the files and pack them in order to be an SRM. An SRM is nothing more than directory that has been compressed with squashfs. Thankfully I've (FearedBliss) written a script that will build it for you.
You will need to install sys-fs/squashfs-tools and have squashfs support compiled in your kernel.
These are the required settings in the kernel to work with squashfs stuff.
File Systems -> Miscellaneous Filesystems -> <*> SquashFS 4.0 - Squashed file system support [*] Squashfs XATTR support [*] Include support for ZLIB compressed file systems [*] Include support for LZO compressed file systems [*] Include support for XZ compressed file systems [ ] Use 4K device block size? [ ] Additional option for memory-constrained systems
Once all that is settled, clone my Bliss Initramfs Creator:
# git clone git://github.com/fearedbliss/Bliss-Initramfs-Creator.git
You should have the following directory layout inside the "Bliss-Initramfs-Creator" folder:
octopus initrd # ls -l total 61 -rw-r--r-- 1 root root 4603 Mar 4 00:49 CHANGES -rw-r--r-- 1 root root 176 Dec 28 12:46 CREDITS -rw-r--r-- 1 root root 16726 Dec 28 12:46 LICENSE -rw-r--r-- 1 root root 1842 Mar 4 00:49 README -rw-r--r-- 1 root root 2367 Feb 3 19:07 USAGE -rwxr-xr-x 1 root root 1794 Mar 4 00:49 createInit drwxr-xr-x 3 root root 5 Mar 4 00:49 files drwxr-xr-x 3 root root 6 Mar 4 00:49 hooks drwxr-xr-x 2 root root 5 Mar 4 00:49 resources
Then run it and follow the instructions for the kernel you want to make the srm for (In this case it's 3.4.35-std342-amd64):
----------------------------------- | Bliss Initramfs Creator - v1.6.7 | Author: Jonathan Vasquez <jvasquez1011@gmail.com> | Distributed under the MPLv2 ----------------------------------- >>> Which initramfs would you like to generate: >> 1. ZFS >> 2. Encrypted ZFS (LUKS + ZFS) >> 3. More Options >> 4. Exit Program >>> Current choice [1]: 3 >>> More Options: >> 1. ZFS - System Rescue Module >> 2. Back >> 3. Exit Program >>> Current choice [1]: ↵ >>> Creating a ZFS System Rescue Module! >>> Do you want to use the current kernel: 3.8.1-ALL? [Y/n]: n >>> Please enter the kernel name: 3.4.32-std341-amd64 >>> Detected 64 bit platform >>> Checking to see if modules directory exists for 3.4.32-std341-amd64... >>> Creating ZFS System Rescue Module for 3.4.32-std341-amd64... >>> Creating directory structure for initramfs... >>> Checking preliminary binaries... >>> Checking binaries... >>> Using ZFS >>> Checking modules... >>> Copying binaries... >>> Copying modules... >>> Copying documentation... >>> Copying udev rules... >>> Compressing kernel modules... >>> Getting dependencies... >>> Copying dependencies... >>> Configuring files... >>> Creating and Packing SRM... >>> Complete :)
Now you should have two new files:
-rw-r--r-- 1 root root 78 Mar 9 22:04 zfs-3.4.32-std341-amd64.md5 -rw-r--r-- 1 root root 2584576 Mar 9 22:04 zfs-3.4.32-std341-amd64.srm
Now all you need to do is put those two files in the root of your USB directory.
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 :)