Difference between pages "Install ZFS root&boot File System" and "Translations:Install/38/pt-br"

(Difference between pages)
(Add zfs parameters to grub config)
 
(Created page with ";Princípio 1 - Old School: Se você conseguiu confiavelmente realizar o boot no System Rescue CD e ele mostra um menu inicial azul claro, você fez boot usando a BIOS, e é p...")
 
Line 1: Line 1:
== 0. Introduction ==
+
;Princípio 1 - Old School: Se você conseguiu confiavelmente realizar o boot no System Rescue CD e ele mostra um menu inicial azul claro, você fez boot usando a BIOS, e é provável que você possa portanto realizar o boot no Funtoo Linux usando a BIOS. Então, siga a forma old-school e use o boot por BIOS, "a não ser" que você tenha alguma razão para usar UEFI, como por exemplo, ter um disco de sistema com mais de 2.2TB. Nesse caso, veja o Princípio 2, pois o seu sistema pode também suportar boot UEFI.
 
+
ZFS seams to be one of the future filesystems. At the time of writing (31.08.2015) booting on ZFS is still a headache. Some linux distributions boot on ext2 partition and run zfs as rootfs like [[ZFS_Install_Guide]] and some are able to boot from zfs, some do support zfs only as a filesystem.
+
 
+
Funtoo linux supports ZFS as filesystem and as rootfs, however it does not support it as boot/grub filesystem. For easier search by search engines, it is referred to in this document as whole disk ZFS.
+
 
+
Funtoo linux uses the grub bootloader. So it has been not really understandable, why whole disk ZFS could not be supported by funtoo, as grub is able to do so. Or better, some linux distribution, using the grub bootloader run "whole disk ZFS". What they can, ... yes, we can! ... as well.
+
 
+
This guide is based on many trial and errors - caused by lack of knowledge - the actual [[ZFS_Install_Guide]] and a guide for whole disk ZFS for ubuntu. Ubuntu runs als grub bootloader, so some ideas are adapted from there.
+
 
+
=== Disclaimers ===
+
 
+
{{fancywarning|This guide is a working pretty well on one computer - that is mine! If it does not run on your's, or if it breaks on your's, than you should try to sort the issue out and report it to this page.
+
 
+
So, you may expect that it MAY work! ... and you should be aware that it MAY break your installation. This guide is not developed enough to ENSURE a stable production environment.
+
 
+
... however, I use it for that! ;-) - crazzy as I am.
+
}}
+
 
+
{{fancyimportant|ZFS will run properly only on 64Bit machines. If you plan to run ZFS with 32Bit, you may also try russian roulette with six bullets. The outcome is clear, and sure not that what you want!
+
 
+
Not covered in this Guide are:
+
 
+
- obvious steps from the regular funtoo installation guide [[Install]] and the ZFS installation guide [[ZFS_Install_Guide]]
+
 
+
- other partition layouts than GPT
+
 
+
- other kernel sources than gentoo-sources as debian-sources do not work for sure
+
 
+
- usb bootable whole disk ZFS devices (as they need a proper set of udev rules)
+
 
+
- and may be many items more ... ;-)}}
+
 
+
== 1. Preparations ==
+
In this section, we will prepare everything, to be used during system and boot loader installation.
+
 
+
=== Create an installation envirnment ===
+
To be able to install funtoo on zfs, we need a suitable installation environment. The next steps describe the setup:
+
 
+
==== Downloading the ISO (With ZFS) ====
+
 
+
This is a copy by the date of 31.08.2015 from the [[ZFS_Install_Guide]].
+
 
+
In order for us to install Funtoo on ZFS, you will need an environment that already provides the ZFS tools. Therefore we will download a customized version of System Rescue CD with ZFS included.
+
 
+
<pre>
+
Name: sysresccd-4.2.0_zfs_0.6.2.iso  (545 MB)
+
Release Date: 2014-02-25
+
md5sum 01f4e6929247d54db77ab7be4d156d85
+
</pre>
+
 
+
 
+
'''[http://ftp.osuosl.org/pub/funtoo/distfiles/sysresccd/ Download System Rescue CD with ZFS]'''<br />
+
 
+
==== Creating a bootable USB from ISO (From a Linux Environment) ====
+
 
+
This is a copy by the date of 31.08.2015 from the [[ZFS_Install_Guide]].
+
 
+
After you download the iso, you can do the following steps to create a bootable USB:
+
 
+
<console>
+
Make a temporary directory
+
# ##i##mkdir /tmp/loop
+
 
+
Mount the iso
+
# ##i##mount -o ro,loop /root/sysresccd-4.2.0_zfs_0.6.2.iso /tmp/loop
+
 
+
Run the usb installer
+
# ##i##/tmp/loop/usb_inst.sh
+
</console>
+
 
+
That should be all you need to do to get your flash drive working.
+
 
+
==== Booting the ISO ====
+
While booting the above mentioned iso image - you should use exactly that one, unless you are writing another guide - you shoud use the option '''E) Alternative 64bit kernel (altker64) with more choice...'''. 64Bit, as mentioned above.
+
 
+
On the next page you should select '''7. SystemRecsueCd with the default graphic environment'''. The system will come up with a small graphical environment and some tools. One of them is a graphical version of GParted, which will be used in this guide.
+
 
+
=== Preparing the harddrives ===
+
 
+
The preparation of the harddrives envolves the following steps:
+
 
+
==== Cleaning the disks ====
+
This guide was developed using GPT partition layout. Any other layout type is not included here.
+
 
+
All below this note is a copy by the date of 31.08.2015 from the respective section of the [[ZFS_Install_Guide]].
+
 
+
First lets make sure that the disk is completely wiped from any previous disk labels and partitions.
+
We will also assume that <tt>/dev/sda</tt> is the target drive.
+
<console>
+
# ##i##sgdisk -Z /dev/sda
+
</console>
+
{{fancywarning|This is a destructive operation and the program will not ask you for confirmation! Make sure you really don't want anything on this disk.}}
+
{{fancynote|Do not forget to run this command for each drive participating the new pool. In this guide a mirror pool is created and the devices <tt>/dev/sda</tt> and <tt>/dev/sdb</tt> are used.}}
+
==== Create a pool ====
+
In this section, we create a whole disk ZFS / <code>zpool</code>. For the convenience of this guide, a <code>mirror</code> pool with the name <code>tank</code> will be created and not mounted (option <code>-m none</code>). Single disk ZFS or even <code>zraid</code> could be used respectively.
+
 
+
The option <code>ashift=12</code> is set for hard drives with a 4096 sector size commonly used by SSD drives.
+
 
+
<console># ##i##  zpool create -f -o ashift=12 -m none -R /mnt/funtoo tank mirror /dev/sda /dev/sdb </console>
+
{{fancyimportant|Here we use the devices /dev/sda and /dev/sdb, and not the partitions as described in the [[ZFS_Install_Guide]]. The devices will be partitioned with a GPT partition label and the respective pool including the ZFS filesystems will be created in one step.
+
 
+
The cachefile is omitted, as it only speeds booting and unfortunately creates destructive issues while manipulating the pool later on.}}
+
{{fancynote|It is preferred to use /dev/disk/by-id/ ... Here it does not really matter, and at the important points we will use the reference to the drives by ID.}}
+
 
+
<code>zpool status</code> can be used to verify the pool.
+
 
+
==== Create the zfs datasets ====
+
 
+
This is a copy by the date of 31.08.2015 from the [[ZFS_Install_Guide]], unless the <code>root</code> dataset has been changed to <code>ROOT</code> to avoid confusions with the normal linux <code>root</code> home directory <code>/root</code>. 
+
 
+
We will now create some datasets. For this installation, we will create a small but future proof amount of datasets. We will have a dataset for the OS (/), and your swap. We will also show you how to create some optional datasets: <code>/home</code>,  <code>/usr/src</code>, and <code>/usr/portage</code>.  Notice, datasets are examples only and not strictly required.
+
 
+
<console>
+
Create some empty containers for organization purposes, and make the dataset that will hold /
+
# ##i## zfs create -p tank/funtoo
+
# ##i## zfs create -o mountpoint=/ tank/funtoo/ROOT
+
 
+
Optional, but recommended datasets: /home
+
# ##i## zfs create -o mountpoint=/home tank/funtoo/home
+
 
+
Optional datasets: /usr/src, /usr/portage/{distfiles,packages}
+
# ##i## zfs create -o mountpoint=/usr/src tank/funtoo/src
+
# ##i## zfs create -o mountpoint=/usr/portage -o compression=off tank/funtoo/portage
+
# ##i## zfs create -o mountpoint=/usr/portage/distfiles tank/funtoo/portage/distfiles
+
# ##i## zfs create -o mountpoint=/usr/portage/packages tank/funtoo/portage/packages
+
</console>
+
<code>df -k</code> can be used to verify the mountpoints.
+
 
+
==== Create empty snapshot of the pool (purely optional) ====
+
Expecting some trial and error during the system installation, a snapshot of the empty disks makes it easy to return this point ... of the game ...
+
<console># ##i##  zfs snapshot -r tank@000-empty_pool  </console>
+
<code>zfs list -t snapshot</code> allows to list the existing snapshots.
+
The rollback will be descibed further down in the troubleshooting guide...
+
 
+
==== Flag the bios_grub partition ====
+
The freshly created GPT partition tables of the devices used in the pool contains two partitions. The first and larger one contains the zfs filesystem, the second (number 9), <code>8.0MiB</code> in size, is reserved by Solaris (<code>BF07</code>).
+
 
+
We use now the graphical tool GParted selecting the partition 9 of each device and set the <code>bios_grub</code> flag. This action will add the flag and changes the partition type to BIOS boot partition (<code>EF02</code>).
+
 
+
This can be done by command line as well ...
+
 
+
=== 2. Basic Funtoo installation ===
+
Now the installation environment has been set up, and the harddrives laid out. The next step will be the basic funtoo installation according to the following steps:
+
 
+
==== Import the pool ====
+
For installation purpose, the pool created will be imported under the mountpoint <code>/mnt/funtoo</code>.
+
<code>ashift=12</code> option  which is used for a hard drives with a 4096 sector size.
+
<console># ##i##  zpool import -f -d /dev/disk/by-id -R /mnt/funtoo tank 
+
</console>
+
Using <code>zpool status</code> and / or <code>df -k</code> can be used to verify the pool and the mountpoint.
+
 
+
==== Change directory to the pool's root directory ====
+
Then we should change into the pool's mountpoint directory. At the same time this is the root directory of the intended funtoo installation. That is the directory where you will chroot into.
+
<console>
+
# ##i##cd /mnt/funtoo
+
</console>
+
 
+
==== Download and extract funtoo stage3 ====
+
 
+
It is strongly recommended to use the generic_64 funtoo stage 3 tarball, to avoid a broken build.
+
The download should be done using <code>wget</code>:
+
<console>
+
###i## wget http://build.funtoo.org/funtoo-current/x86-64bit/generic_64/stage3-latest.tar.xz
+
</console>
+
{{fancynote|A snapshot is recommended to allow the rollback to this stage.}}
+
The tarball should be extracted using the following command:
+
<console>
+
###i## tar xpf stage3-latest.tar.xz
+
</console>
+
{{Important|Omitting the option '''p''' will result in a broken system!}}
+
{{fancynote|More information could be found under [[Funtoo_Linux_Installation|Now download and extract the Funtoo stage3 ...]]}}
+
 
+
==== Bind the kernel related directories ====
+
<console>
+
# ##i##mount -t proc none proc
+
# ##i##mount --rbind /dev dev
+
# ##i##mount --rbind /sys sys
+
</console>
+
 
+
==== Copy network settings ====
+
<console>
+
# ##i##cp -f /etc/resolv.conf etc
+
</console>
+
 
+
==== zpool.cache ====
+
<code>zpool.cache</code> is omitted as described above.
+
 
+
==== Chroot into Funtoo ====
+
<console>
+
# ##i##env -i HOME=/root TERM=$TERM chroot . bash -l
+
</console>
+
{{fancynote|Using the graphical installation environment as described above, allows now to open several windows and changing the root into the chroot environment usind the following steps:
+
<console>
+
# ##i##cd /mnt/funtoo
+
# ##i##env -i HOME=/root TERM=$TERM chroot . bash -l
+
</console>
+
This allows you to prepare allready the next steps, while the previous is still busy.
+
}}
+
==== Setup portage ====
+
Now you should think a little about how to set up <code>MAKEOPTS</code>, <code>LINGUAS</code> and <code>VIDEO_CARDS</code> in your portage <code>make.conf</code> file.
+
==== Setup /etc/fstab ====
+
{{file|name=/etc/fstab|desc= |body=
+
# <fs>                  <mountpoint>    <type>          <opts>          <dump/pass>
+
 
+
tank/funtoo/ROOT              /          zfs            noatime        0 0
+
}}
+
==== Setup /etc/mtab ====
+
<code>zfs</code> and <code>zpool</code> will need it:
+
<console>
+
# ##i##grep -v rootfs /proc/mounts > /etc/mtab
+
</console>
+
 
+
==== Emerge portage tree ====
+
Before we install zfs and the bootchain, we should update our portage tree using:
+
<console>
+
# ##i##emerge --sync
+
</console>
+
==== Update the system ====
+
Now we will update the system using the following command:
+
<console>
+
# ##i##emerge --uaDN @world
+
</console>
+
{{fancynote|Here consider to make a snapshot, so we could rollback to a clean and updated system... This must be done outside the chroot environment, because here we still have no zfs / zpool installation.}}
+
==== Emerge genkernel ====
+
<code>genkernel</code> is the tool used by gentoo and funtoo to build kernel and initramfs from sources. it supports <code>zfs</code> for the <code>gentoo-sources</code> as mentioned above.
+
<console>
+
# ##i##emerge genkernel
+
</console>
+
==== Generate initial (unbootable) kernel ====
+
We need to build one first kernel. The <code>zfs</code> needs to find a valid kernel to configure itself properly.
+
<console>
+
# ##i##genkernel kernel
+
</console>
+
{{fancynote|No options are needed... And once the <code>genkernel</code> starts to build the kernel modules, the build may be interrupted with <code>ctrl c</code>. We have, what we need, and the system is still none-bootable.}}
+
{{fancynote|As we have done now some cpu consuming tasks, consider to make a snapshot, so we could rollback to a clean and updated system... This must be done outside the chroot environment, because here we still have no zfs / zpool installation.}}
+
==== The debian-sources ====
+
From mid 2015 on, funtoo comes with a debian kernel and initramfs preinstalled. At the same time it is configured for debian-sources.
+
Basically the debian distribution has a much better automatic hardware detection and configuration support. That is the advantage. The disadvantage is, we will have to recompile it, and it will take a long time!
+
So first of all, we may delete the preinstalled kernel and initramfs:
+
<console>
+
# ##i##rm /boot*
+
</console>
+
 
+
== 3. Add ZFS support ==
+
Now we will add the ZFS support to the basic funtoo system:
+
=== The debian-sources ===
+
Using the debian-sources we have to ensure that the following kernel configuration is set:
+
 
+
CONFIG_CALL_SYMS=y
+
 
+
CONFIG_PREEMPT_NONE=y
+
 
+
=== Installing the ZFS userspace tools ===
+
This is a nearly indetical copy by the date of 31.08.2015 from the [[ZFS_Install_Guide]].
+
Emerge {{Package|sys-fs/zfs}}. This package will bring in {{Package|sys-kernel/spl}}, and {{Package|sys-fs/zfs-kmod}} as its dependencies:
+
<console>
+
# ##i##emerge zfs
+
</console>
+
Check to make sure that the zfs tools are working.
+
<console>
+
# ##i##zpool status
+
# ##i##zfs list
+
# ##i##zfs list -t snapshot
+
</console>
+
{{fancynote|If /etc/mtab is missing, these two commands will complaine.
+
In that case solve that with:
+
<console>
+
# ##i##grep -v rootfs /proc/mounts > /etc/mtab
+
</console>}}
+
Add the zfs tools to openrc.
+
<console>
+
# ##i##rc-update add zfs-import boot
+
# ##i##rc-update add zfs-mount boot
+
# ##i##rc-update add zfs-share default
+
# ##i##rc-update add zfs-zed default
+
</console>
+
{{fancynote|A snapshot is recommended to allow the rollback to this stage. Now you can and should make the snapshot within the chroot environment.}}
+
 
+
=== Installing the ZFS initramfs, kernel and kernel modules  ===
+
Build now kernel and initramfs and kernel modules:
+
<console>
+
# ##i##genkernel all --zfs --no-clean --callback="emerge @module-rebuild"
+
</console>It looks like the following is working better <code>module-rebuild</code> is fetching <code>debian-sources</code> as well, and overwrites own configuration..
+
<console>
+
# ##i##genkernel all --zfs --no-clean --callback="emerge spl zfs-kmod zfs"
+
</console>
+
{{fancynote|To force to get a specific kernek configuration, you may use:
+
<console>
+
# ##i##genkernel all --zfs --no-clean --kerneldir=/usr/src/linux -- kernel-config=/usr/src/<path_to_config> --callback="emerge spl zfs-kmod zfs"
+
</console>
+
The result should be the same.}}
+
 
+
=== Emerge, install und configure grub bootloader ===
+
This section now describes how to setup our boot configuration to boot from and into the whole disk ZFS.
+
==== Emerge grub  ====
+
To emerge grub, we need to set some permanent USE flags first:
+
<console>
+
# ##i##echo "sys-boot/grub libzfs truetype" >> /etc/portage/package.use
+
# ##i##emerge grub
+
</console>
+
{{fancynote|Be aware that it is not <code>-truetype</code> but <code>truetype</code>. We will need some fonts to display the grub menu...}}
+
==== Check grub zfs support ====
+
The zfs support of grub may be checked by invoking <code>grub-probe</code>:
+
<console>
+
# ##i##grub-probe .
+
</console>
+
it should return <code>zfs</code> for a directory on the zfs filesystem.
+
 
+
==== Install grub into /boot/grub directory ====
+
The command <code>grub-install</code> is basically a script taking care off all installation issues. Presently we tweak it a little to do what we want. In the first step, it will be invoked as usual with standard parameters for only one pool device.
+
<console>
+
# ##i##grub-install /dev/sda
+
</console>
+
That will create the /boot/grub directory and installs grub into it.
+
It also installs the bootloader into the BIOS grub partition, which will be overwritten later on.
+
==== Add zfs parameters to grub config ====
+
Now we need to tell grub to use our whole disk zfs during boot time. That is done in two steps.
+
First we edit <code>/etc/default/grub</code>
+
 
+
{{file|name=/etc/default/grub|desc= |body=
+
GRUB_CMDLINE_LINUX="boot=zfs rpool=tank bootfs=tank/funtoo/ROOT"
+
}}
+
Thereafter we invoke <code>grub-mkconfig</code> to generate a new grub config file.
+
<console>
+
# ##i##grub-mkconfig -o /boot/grub/grub.cfg
+
</console>
+
 
+
==== Finally install the grub bootloader ====
+
As last step, we need to install the grub bootloader properly:
+
<console>
+
# ##i##grub-install $(readlink -f /dev/disk/by-id/...disk1)
+
# ##i##grub-install $(readlink -f /dev/disk/by-id/...disk2)
+
</console>
+
If all went through, without any error report, you have installed now a mirrored whole disk zpool, which may boot from any of the two disks. In any failure of one of the two disks, the system may be booted and recovered easily from the other one.
+
 
+
== 4. Final steps & cleanup ==
+
The final steps and the cleanup can be done according [[ZFS_Install_Guide]].
+
Further installation should be guided by [[Install]] and [[Funtoo_Linux_First_Steps]].
+
 
+
{{important|'''enjoy it!'''}}
+

Latest revision as of 14:52, September 14, 2015

Princípio 1 - Old School
Se você conseguiu confiavelmente realizar o boot no System Rescue CD e ele mostra um menu inicial azul claro, você fez boot usando a BIOS, e é provável que você possa portanto realizar o boot no Funtoo Linux usando a BIOS. Então, siga a forma old-school e use o boot por BIOS, "a não ser" que você tenha alguma razão para usar UEFI, como por exemplo, ter um disco de sistema com mais de 2.2TB. Nesse caso, veja o Princípio 2, pois o seu sistema pode também suportar boot UEFI.