Difference between pages "Linux Containers/pt-br" and "ZFS as Root Filesystem"

From Funtoo
< Linux Containers(Difference between pages)
Jump to navigation Jump to search
 
 
Line 1: Line 1:
== Status ==
== Introduction ==


Como no kernel Linux 3.1.5, o LXC é útil por isolar seus próprios trabalhos de outros. Ele não está pronto ainda para isolar potencialmente usuários de outros ou do sistema hóspede (host). Para uma solução de containers mais madura, que é apropriada para ambientes de hospedagem, veja [[OpenVZ]].
This tutorial will show you how to install Funtoo on ZFS (rootfs). This tutorial is meant to be an "overlay" over the [[Funtoo_Linux_Installation|Regular Funtoo Installation]]. Follow the normal installation and only use this guide for steps 2, 3, and 8.


Containers LXC ainda não possui seu próprio sistema de atualização, e eles veem tudo que está na saída {{c|dmesg}} no host, entre outras coisas. Mas em geral, a tecnologia funciona.
=== Introduction to ZFS ===


== Informações Básicas ==
Since ZFS is a new technology for Linux, it can be helpful to understand some of its benefits, particularly in comparison to BTRFS, another popular next-generation Linux filesystem:


* On Linux, the ZFS code can be updated independently of the kernel to obtain the latest fixes. btrfs is exclusive to Linux and you need to build the latest kernel sources to get the latest fixes.


* Linux Containers são baseados em:
* ZFS is supported on multiple platforms. The platforms with the best support are Solaris, FreeBSD and Linux. Other platforms with varying degrees of support are NetBSD, Mac OS X and Windows. btrfs is exclusive to Linux.
** Kernel namespaces para isolamento de recursos
** CGroups para limitação e contabilidade de recursos


{{Package|app-emulation/lxc}} é a ferramenta userspace para os Linux containers
* ZFS has the Adaptive Replacement Cache replacement algorithm while btrfs uses the Linux kernel's Last Recently Used replacement algorithm. The former often has an overwhelmingly superior hit rate, which means fewer disk accesses.


== Grupos de controle (Control groups) ==
* ZFS has the ZFS Intent Log and SLOG devices, which accelerates small synchronous write performance.


* Control groups (cgroups) no kernel desde o 2.6.24
* ZFS handles internal fragmentation gracefully, such that you can fill it until 100%. Internal fragmentation in btrfs can make btrfs think it is full at 10%. Btrfs has no automatic rebalancing code, so it requires a manual rebalance to correct it.
** Permite agregação de tarefas e seus filhos (children)
** Subsystems (cpuset, memory, blkio,...)
** accounting - para medir a quantidade de recursos que certos sistemas utilizam
** resource limiting (limitante de recurso) - grupos podem ser configurados para não excederem um determinado limite de memória
** prioritization (priorização) - alguns grupos podem ter uma fatia maior do CPU
** control - freezing/unfreezing (congelamento/descongelamento) de cgroups, checkpointing (ponto de verificação) e restarting (reinicialização)
** No disk quota limitation ( -> image file, LVM, XFS, directory tree quota,...) [sem limitação de cota de disco (-> arquivo imagem, LVM, XFS, cota de arvore de diretório)]


== Subsystems ==
* ZFS has raidz, which is like RAID 5/6 (or a hypothetical RAID 7 that supports 3 parity disks), except it does not suffer from the RAID write hole issue thanks to its use of CoW and a variable stripe size. btrfs gained integrated RAID 5/6 functionality in Linux 3.9. However, its implementation uses a stripe cache that can only partially mitigate the effect of the RAID write hole.
<br>
 
{{console|body=
* ZFS send/receive implementation supports incremental update when doing backups. btrfs' send/receive implementation requires sending the entire snapshot.
###i## cat /proc/cgroups
 
subsys_name hierarchy num_cgroups enabled
* ZFS supports data deduplication, which is a memory hog and only works well for specialized workloads. btrfs has no equivalent.
cpuset
 
cpu
* ZFS datasets have a hierarchical namespace while btrfs subvolumes have a flat namespace.
cpuacct
 
memory
* ZFS has the ability to create virtual block devices called zvols in its namespace. btrfs has no equivalent and must rely on the loop device for this functionality, which is cumbersome.
devices
 
freezer
The only area where btrfs is ahead of ZFS is in the area of small file
blkio
efficiency. btrfs supports a feature called block suballocation, which
perf_event
enables it to store small files far more efficiently than ZFS. It is
hugetlb
possible to use another filesystem (e.g. reiserfs) on top of a ZFS zvol
}}
to obtain similar benefits (with arguably better data integrity) when
dealing with many small files (e.g. the portage tree).
 
For a quick tour of ZFS and have a big picture of its common operations you can consult the page [[ZFS Fun]].
 
=== Disclaimers ===
 
{{fancywarning|This guide is a work in progress. Expect some quirks.
 
Today is 2015-05-12. ZFS has undertaken an upgrade - from 0.6.3 to 0.6.4. Please ensure that you use a RescueCD with ZFS 0.6.3. At present date grub 2.02 is not able to deal with those new ZFS parameters. If you want to use ZFS 0.6.4 for pool creation, you should use the compatability mode.
 
You should upgrade an existing pool only when grub is able to deal with - in a future version ... If not, you will not be able to boot into your system, and no rollback will help!
 
Please inform yourself!}}
 
{{fancyimportant|'''Since ZFS was really designed for 64 bit systems, we are only recommending and supporting 64 bit platforms and installations. We will not be supporting 32 bit platforms'''!}}
 
== Downloading the ISO (With ZFS) ==
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) ==
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 ==
 
{{fancywarning|'''When booting into the ISO, Make sure that you select the "Alternate 64 bit kernel (altker64)". The ZFS modules have been built specifically for this kernel rather than the standard kernel. If you select a different kernel, you will get a fail to load module stack error message.'''}}
 
== Creating partitions ==
There are two ways to partition your disk: You can use your entire drive and let ZFS automatically partition it for you, or you can do it manually.
 
We will be showing you how to partition it '''manually''' because if you partition it manually you get to create your own layout, you get to have your own separate /boot partition (Which is nice since not every bootloader supports booting from ZFS pools), and you get to boot into RAID10, RAID5 (RAIDZ) pools and any other layouts due to you having a separate /boot partition.
 
==== gdisk (GPT Style) ====
 
'''A Fresh Start''':
 
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.<br />
 
<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.}}


#cpuset    -> limita tarefas para CPU/CPUs específicos
Now that we have a clean drive, we will create the new layout.
#cpu        -> compartilhamento de CPU
#cpuacct    -> contabilização de CPU
#memory    -> limitação de contabilização de memória e de swap
#devices    -> lista de dispositivo negado ou permitido
#freezer    -> suspend/resume tarefas
#blkio      -> priorização I/O (weight, throttle, ...)
#perf_event -> suporte para monitoramento por-cpu por-cgroup [http://lwn.net/Articles/421574/ perf_events]
#hugetlb    -> recurso controlador do cgroup para páginas HugeTLB [http://lwn.net/Articles/499255/ hugetlb]


== Configurando o Host system do Funtoo ==
First open up the application:


=== Instale o LXC kernel ===
<console>
Qualquer kernel acima do 3.1.5 provavelmente funcionará. Pessoalmente, eu prefiro o {{Package|sys-kernel/gentoo-sources}} , uma vez que ele possui suporte para todos os namespaces sem sacrificar o suporte a xfs, FUSE ou NFS, por exemplo. Essas verificações foram introduzidas posteriormente, a partir do kernel 3.5, o que pode também significar que o namespace do usuário não está funcionando de forma otimizada.
# ##i##gdisk /dev/sda
</console>


* User namespace (EXPERIMENTAL) depende do EXPERIMENTAL e do UIDGID_CONVERTED
'''Create Partition 1''' (boot):
** config UIDGID_CONVERTED
<console>
*** True (verdadeiro) se todos os componentes de software selecionados forem conhecidos por terem uid_t and gid_t convertidos para kuid_t and kgid_t onde se apropriaram e são por outro lado seguros de utilizar com o user namespace.
Command: ##i##n ↵
**** Networking - depende do NET_9P = n
Partition Number: ##i##↵
**** Filesystems - 9P_FS = n, AFS_FS = n, AUTOFS4_FS = n, CEPH_FS = n, CIFS = n, CODA_FS = n, FUSE_FS = n, GFS2_FS = n, NCP_FS = n, NFSD = n, NFS_FS = n, OCFS2_FS = n, XFS_FS = n
First sector: ##i##↵
**** Opções de segurança (Security options) - Grsecurity - GRKERNSEC = n (se aplicável)
Last sector: ##i##+250M ↵
Hex Code: ##i##↵
</console>


** A partir do kernel 3.10.xx, todas as opções acima são seguras para se usar com User namespaces, excetuando XFS_FS. Consequentemente, com kernel >=3.10.xx, você deverá responder XFS_FS= n, caso queira suporte a User namespaces.
'''Create Partition 2''' (BIOS Boot Partition):
** Em seu diretório da fonte do kernel (kernel source directory), você deve verificar o init/Kconfig e descobrir o que UIDGID_CONVERTED depende
<console>Command: ##i##n
Partition Number: ##i##↵
First sector: ##i##↵
Last sector: ##i##+32M ↵
Hex Code: ##i##EF02 ↵
</console>


==== Configuração do kernel ====
'''Create Partition 3''' (ZFS):
Estas opções devem ser habilitadas em seu kernel para ser capaz de tirar o máximo proveito do LXC.
<console>Command: ##i##n ↵
Partition Number: ##i##↵
First sector: ##i##↵
Last sector: ##i##↵
Hex Code: ##i##bf00 ↵


* General setup
Command: ##i##p ↵
** CONFIG_NAMESPACES
*** CONFIG_UTS_NS
*** CONFIG_IPC_NS
*** CONFIG_PID_NS
*** CONFIG_NET_NS
*** CONFIG_USER_NS
** CONFIG_CGROUPS
*** CONFIG_CGROUP_DEVICE
*** CONFIG_CGROUP_SCHED
*** CONFIG_CGROUP_CPUACCT
*** CONFIG_CGROUP_MEM_RES_CTLR (em kernels superiores ao 3.6 essa opção é chamada de CONFIG_MEMCG)
*** CONFIG_CGROUP_MEM_RES_CTLR_SWAP (em kernels superiores ao 3.6 essa opção é chamada CONFIG_MEMCG_SWAP)
*** CONFIG_CPUSETS (on multiprocessor hosts)
* Networking support
** Networking options
*** CONFIG_VLAN_8021Q
* Device Drivers
** Character devices
*** Unix98 PTY support
**** CONFIG_DEVPTS_MULTIPLE_INSTANCES
** Network device support
*** Network core driver support
**** CONFIG_VETH
**** CONFIG_MACVLAN


Uma vez que você tenha o lxc instalado, você pode verificar seu kernel config com:
Number  Start (sector)    End (sector)  Size      Code  Name
{{console|body=
  1            2048          514047  250.0 MiB  8300  Linux filesystem
# ##i##CONFIG=/path/to/config /usr/sbin/lxc-checkconfig
  2          514048          579583  32.0 MiB    EF02  BIOS boot partition
}}
  3          579584      1953525134  931.2 GiB  BF00  Solaris root


=== Emerge lxc ===
Command: ##i##w ↵
{{console|body=
</console>
# ##i##emerge app-emulation/lxc
}}


=== Configure a Rede para o Container ===


Tipicamente, alguém utiliza uma ponte (bridge) para permitir que os containers conectem a rede. Esse é o modo de se fazer isso no Funtoo Linux:
=== Format your /boot partition ===


# crie uma bridge utilizando os Funtoo network configuration scripts. Nomeie a bridge com algo como {{c|brwan}} (using {{c|/etc/init.d/netif.brwan}}). Configure sua bridge pata ter um endereço IP.
<console>
# Faça a dua interface física, tal qual {{c|eth0}}, uma interface sem endereço de IP (utilize o template {{c|interface-noip}} do Funtoo.)
# ##i##mkfs.ext2 -m 1 /dev/sda1
# Torne o {{c|netif.eth0}} um slave de {{c|netif.brwan}} em {{c|/etc/conf.d/netif.brwan}}.
</console>
# Habilite sua nova rede já em bridge e certifique-se de que está funcionando corretamente no host.


Agora você será capaz de configurar LXC para adicionar automaticamente sua interface ethernet virtual do container para criar uma bridge quando ele inicializar, que a conectará a sua rede.
=== Create the zpool ===
We will first create the pool. The pool will be named  <code>tank</code>. Feel free to name your pool as you want.  We will use <code>ashift=12</code> option  which is used for a hard drives with a 4096 sector size.
<console># ##i##  zpool create -f -o ashift=12 -o cachefile=/tmp/zpool.cache -O normalization=formD -m none -R /mnt/funtoo tank /dev/sda3 </console>


==Definindo um LXC Container do Funtoo Linux ==
=== Create the zfs datasets ===
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 as examples ones: <code>/home</code>,  <code>/usr/src</code>, and <code>/usr/portage</code>. 


Aqui estão os passos necessários para por o Funtoo Linux para funcionar <i>dentro de</i> um container. Os passos abaixo mostram como definir um container utilizando um template OpenVZ existente do Funtoo Linux. Agora é possível também utilizar o [[Metro]] para consruir um diretamente um tarball do lxc container, que salvará sua configuração manual e fornecerá um arquivo {{c|/etc/fstab.lxc}} que você pode utilizar para o seu host container config. Veja [[Metro Recipes]] para informações de como utilizar o Metro para gerar um lxc container.
<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


=== Criar e configurar um Container Filesystem ===
Optional, but recommended datasets: /home
# ##i##zfs create -o mountpoint=/home tank/funtoo/home


# Inicie o Funtoo LXC template, e desempacote-o em um diretório tal qual {{c|/lxc/funtoo0/rootfs/}}
Optional datasets: /usr/src, /usr/portage/{distfiles,packages}
# Crie um arquivo {{c|/lxc/funtoo0/fstab}} vazio
# ##i##zfs create -o mountpoint=/usr/src tank/funtoo/src
# Certifique-se de que a linha {{c|c1}} não está comentada (habilitada) e da linha {{c|c2}} à linha {{c|c6}} estão desabilitadas em {{c|/lxc/funtoo0/rootfs/etc/inittab}}
# ##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>


Isso é quase tudo o que você precisa para ter o container filesystem pronto para iniciar.
== Installing Funtoo ==


=== Crie os Arquivos de Configuração do Container ===
=== Pre-Chroot ===


Crie os seguintes arquivos:
<console>
Go into the directory that you will chroot into
# ##i##cd /mnt/funtoo


==== {{c|/lxc/funtoo0/config}} ====
Make a boot folder and mount your boot drive
# ##i##mkdir boot
# ##i##mount /dev/sda1 boot
</console>


[[Funtoo_Linux_Installation|Now download and extract the Funtoo stage3 ...]]


e crie também o link simbólico a partir de
==== {{c|/lxc/funtoo0/config to /etc/lxc/funtoo0/config }} ====
{{console|body=
###i## install -d /etc/lxc/funtoo0
###i## ln -s /lxc/funtoo0/config /etc/lxc/funtoo0/config
}}


{{note| Daniel Robbins precisa atualizar esse config para ficar mais alinhado com o http://wiki.progress-linux.org/software/lxc/ -- Esse config aparenta ter permissões de node de dispositivo boa, refinado entre outras coisas. // nota de Havis para Daniel, esse config já é superior.}}
{{fancynote|It is trully recommended to use the current version and generic64. That reduces the risk of a broken build.  


After successfull ZFS installation and successfull first boot, the kernel may be changed using the <code> eselect profile set ... </code> command. If you create a snapshot before, you may allways come back to your previous installation, with some simple steps ... (rollback your pool and in the worst case configure and install the bootloader again)}}


Leia "man 5 lxc.conf" , para obter mais informações sobre o arquivo de configuração do linux container.
<pre>
## Container
lxc.utsname                            = funtoo0
lxc.rootfs                              = /lxc/funtoo0/rootfs/
lxc.arch                                = x86_64
#lxc.console                            = /var/log/lxc/funtoo0.console  # uncomment if you want to log containers console
lxc.tty                                = 6  # if you plan to use container with physical terminals (eg F1..F6)
#lxc.tty                                = 0  # set to 0 if you dont plan to use the container with physical terminal, also comment out in your containers /etc/inittab  c1 to c6 respawns (e.g. c1:12345:respawn:/sbin/agetty 38400 tty1 linux)
lxc.pts                                = 1024




## Capabilities
Once you've extracted the stage3, do a few more preparations and chroot into your new funtoo environment:
lxc.cap.drop                            = audit_control
lxc.cap.drop                            = audit_write
lxc.cap.drop                            = mac_admin
lxc.cap.drop                            = mac_override
lxc.cap.drop                            = mknod
lxc.cap.drop                            = setfcap
lxc.cap.drop                            = setpcap
lxc.cap.drop                            = sys_admin
#lxc.cap.drop                            = sys_boot # capability to reboot the container
#lxc.cap.drop                            = sys_chroot # required by SSH
lxc.cap.drop                            = sys_module
#lxc.cap.drop                            = sys_nice
lxc.cap.drop                            = sys_pacct
lxc.cap.drop                            = sys_rawio
lxc.cap.drop                            = sys_resource
lxc.cap.drop                            = sys_time
#lxc.cap.drop                            = sys_tty_config # required by getty


## Devices
<console>
#lxc.cgroup.devices.allow              = a # Allow access to all devices
Bind the kernel related directories
lxc.cgroup.devices.deny                = a # Deny access to all devices
# ##i##mount -t proc none proc
# ##i##mount --rbind /dev dev
# ##i##mount --rbind /sys sys


# Allow to mknod all devices (but not using them)
Copy network settings
lxc.cgroup.devices.allow                = c *:* m
# ##i##cp -f /etc/resolv.conf etc
lxc.cgroup.devices.allow                = b *:* m


lxc.cgroup.devices.allow                = c 1:3 rwm # /dev/null
Make the zfs folder in 'etc' and copy your zpool.cache
lxc.cgroup.devices.allow                = c 1:5 rwm # /dev/zero
# ##i##mkdir etc/zfs
lxc.cgroup.devices.allow                = c 1:7 rwm # /dev/full
# ##i##cp /tmp/zpool.cache etc/zfs
lxc.cgroup.devices.allow                = c 1:8 rwm # /dev/random
lxc.cgroup.devices.allow                = c 1:9 rwm # /dev/urandom
#lxc.cgroup.devices.allow                = c 4:0 rwm # /dev/tty0 ttys not required if you have lxc.tty = 0
#lxc.cgroup.devices.allow                = c 4:1 rwm # /dev/tty1 devices with major number 4 are "real" tty devices
#lxc.cgroup.devices.allow                = c 4:2 rwm # /dev/tty2
#lxc.cgroup.devices.allow                = c 4:3 rwm # /dev/tty3
lxc.cgroup.devices.allow                = c 5:0 rwm # /dev/tty
lxc.cgroup.devices.allow                = c 5:1 rwm # /dev/console
lxc.cgroup.devices.allow                = c 5:2 rwm # /dev/ptmx
lxc.cgroup.devices.allow                = c 10:229 rwm # /dev/fuse
lxc.cgroup.devices.allow                = c 136:* rwm # /dev/pts/* devices with major number 136 are pts
lxc.cgroup.devices.allow                = c 254:0 rwm # /dev/rtc0


## Limits#
Chroot into Funtoo
lxc.cgroup.cpu.shares                  = 1024
# ##i##env -i HOME=/root TERM=$TERM chroot . bash -l
lxc.cgroup.cpuset.cpus                = 0        # limits container to CPU0
</console>
lxc.cgroup.memory.limit_in_bytes      = 512M
lxc.cgroup.memory.memsw.limit_in_bytes = 1G
#lxc.cgroup.blkio.weight                = 500      # requires cfq block scheduler


## Filesystem
{{fancynote|How to create zpool.cache file?}}
#containers fstab should be outside it's rootfs dir (e.g. /lxc/funtoo0/fstab is ok, but /lxc/funtoo0/rootfs/etc/fstab is wrong!!!)
If no <code>zpool.cache</code> file is available, the following command will create one:
#lxc.mount                              = /lxc/funtoo0/fstab     
<console>
# ##i##zpool set cachefile=/etc/zfs/zpool.cache tank
</console>


#lxc.mount.entry is prefered, because it supports relative paths
{{:Install/PortageTree}}
lxc.mount.entry                        = proc proc proc nosuid,nodev,noexec  0 0
lxc.mount.entry                        = sysfs sys sysfs nosuid,nodev,noexec,ro 0 0
lxc.mount.entry                        = devpts dev/pts devpts nosuid,noexec,mode=0620,ptmxmode=000,newinstance 0 0
lxc.mount.entry                        = tmpfs dev/shm tmpfs nosuid,nodev,mode=1777 0 0
lxc.mount.entry                        = tmpfs run tmpfs nosuid,nodev,noexec,mode=0755,size=128m 0 0
lxc.mount.entry                        = tmpfs tmp tmpfs nosuid,nodev,noexec,mode=1777,size=1g 0 0


##Example of having /var/tmp/portage as tmpfs in container
=== Add filesystems to /etc/fstab ===
#lxc.mount.entry                        = tmpfs var/tmp/portage tmpfs defaults,size=8g,uid=250,gid=250,mode=0775 0 0
##Example of bind mount
#lxc.mount.entry                        = /srv/funtoo0 /lxc/funtoo0/rootfs/srv/funtoo0 none defaults,bind 0 0


## Network
Before we continue to compile and or install our kernel in the next step, we will edit the <code>/etc/fstab</code> file because if we decide to install our kernel through portage, portage will need to know where our <code>/boot</code> is, so that it can place the files in there.
lxc.network.type                        = veth
lxc.network.flags                      = up
lxc.network.hwaddr                      = #put your MAC address here, otherwise you will get a random one
lxc.network.link                        = br0
lxc.network.name                        = eth0
#lxc.network.veth.pair                  = veth-example
</pre>


Leia "man 7 capabilities" para obter mais informações sobre compatibilidades no Linux.
Edit <code>/etc/fstab</code>:


Acima, utilize o comando a seguir para gerar um MAC randômico (random MAC) para o {{c|lxc.network.hwaddr}}:
{{file|name=/etc/fstab|desc= |body=
# <fs>                  <mountpoint>    <type>          <opts>          <dump/pass>


{{console|body=
/dev/sda1              /boot          ext2            defaults        0 2
###i## openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//'
}}
}}


É uma boa ideia atribuir um endereço MAC estático para o seu container utilizar {{c|lxc.network.hwaddr}}. Caso não, LXC will auto-gerará um novo MAC randômico toda vez que seu container inicializar, o qual pode confundir o equipamento de rede que espera que os endereços MAC permaneça constante.
== Building kernel, initramfs and grub to work with zfs==
=== Install genkernel and initial kernel build ===
 
We need to build a genkernel initially:
<console>
# ##i##emerge genkernel
 
Build initial kernel (required for checks in sys-kernel/spl and sys-fs/zfs):
# ##i##genkernel kernel --no-clean --no-mountboot
 
</console>
 
=== Installing the ZFS userspace tools and kernel modules ===
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. The <code>zpool.cache</code> file that you copied before should be displayed.
 
<console>
# ##i##zpool status
# ##i##zfs list
</console>
 
Add the zfs tools to openrc.
<console># ##i##rc-update add zfs boot</console>
 
If everything worked, continue.
 
=== Install GRUB 2 ===
 
Install grub2:
<console>
# ##i##echo "sys-boot/grub libzfs -truetype" >> /etc/portage/package.use
# ##i##emerge grub
</console>
 
Now install grub to the drive itself (not a partition):
<console>
# ##i##grub-install /dev/sda
</console>
 
=== Emerge genkernel and initial kernel build ===
Install genkernel using:
<console>
# ##i##echo "sys-kernel/genkernel zfs" >> /etc/portage/package.use
# ##i##emerge genkernel
 
Build now kernel and initramfs with --zfs
# ##i##genkernel all --zfs --no-clean --no-mountboot --callback="emerge @module-rebuild"
</console>
 


Pode acontecer de caso para caso que você não seja capaz de inicializar seu LXC Container com o endereço MAC gerado; então, para todos esse que tiverem esse problema, aqui está um pequeno script que conecta seu IP para o container com o endereço MAC. Apenas salve o código a seguir assim {{c|/etc/lxc/hwaddr.sh}}, torne-o executável e execute-o assim {{c|/etc/lxc/hwaddr.sh xxx.xxx.xxx.xxx}} onde xxx.xxx.xxx.xxx representa o IP do seu Container. <br>{{c|/etc/lxc/hwaddr.sh}}:
{{fancynote|During the build, ZFS configurations should be observed.


<pre>
If the build breaks, restart it again.}}
#!/bin/sh
IP=$*
HA=`printf "02:00:%x:%x:%x:%x" ${IP//./ }`
echo $HA
</pre>


==== {{c|/lxc/funtoo0/fstab}} ====
=== Configuring the Bootloader ===
{{fancynote| é preferível ter entradas mount diretamente no arquivo config ao invés do fstab separado:}}
Edite arquivo {{c|/lxc/funtoo0/fstab}}:
<pre>
none /lxc/funtoo0/dev/pts devpts defaults 0 0
none /lxc/funtoo0/proc proc defaults 0 0
none /lxc/funtoo0/sys sysfs defaults 0 0
none /lxc/funtoo0/dev/shm tmpfs nodev,nosuid,noexec,mode=1777,rw 0 0
</pre>


== LXC Networking ==
Using the genkernel you must add 'real_root=ZFS=<root>' and 'dozfs' to your params.
*veth - Ethernet Virtual (bridge)
Edit the  entry for <code>/etc/boot.conf</code>:
*vlan - Interface da vlan (requer dispositivo capaz de utilizar a vlan tagging)
*macvlan (mac-address baseado na lan tagging virtual) possui 3 modos:
**private
**vepa (Virtual Ethernet Port Aggregator)
**bridge
*phys - NIC hospede (host) dedicado
[https://blog.flameeyes.eu/2010/09/linux-containers-and-networking Linux Containers and Networking]


Habilita roteamento no host:
{{file|name=/etc/boot.conf|desc= |body=
Por padrão, o Linux workstations e servidores possuem o IPv4 forwarding desabilitado.
"Funtoo ZFS" {
{{console|body=
        kernel kernel[-v]
###i## echo "1" > /proc/sys/net/ipv4/ip_forward
        initrd initramfs-genkernel-x86_64[-v]
###i## cat /proc/sys/net/ipv4/ip_forward
        params real_root=ZFS=tank/funtoo/root
# 1
        params += dozfs=force
}
}}
}}


== Initializing and Starting the Container ==
The command <code>boot-update</code> should take care of grub configuration:
 
<console>
Install boot-update (if it is missing):
###i##emerge boot-update


You will probably need to set the root password for the container before you can log in. You can use chroot to do this quickly:
Run boot-update to update grub.cfg
###i##boot-update
</console>


{{console|body=
{{fancynote|If <code>boot-update</code>fails, try this:
###i## chroot /lxc/funtoo0/rootfs
<console>
(chroot) ###i## passwd
# ##i##grub-mkconfig -o /boot/grub/grub.cfg
New password: XXXXXXXX
</console>
Retype new password: XXXXXXXX
passwd: password updated successfully
(chroot) ###i## exit
}}
}}
Now you should have a new installation of the kernel, initramfs and grub which are zfs capable. The configurtion files should be updated, and the system should come up during the next reboot.
{{fancynote|If The <code>luks</code> integration works basically the same way.}}


Now that the root password is set, run:
== Final configuration ==
=== Clean up and reboot ===
We are almost done, we are just going to clean up, '''set our root password''', and unmount whatever we mounted and get out.


{{console|body=
<console>
###i## lxc-start -n funtoo0 -d
Delete the stage3 tarball that you downloaded earlier so it doesn't take up space.
}}
# ##i##cd /
# ##i##rm stage3-latest.tar.xz


The {{c|-d}} option will cause it to run in the background.
Set your root password
# ##i##passwd
>> Enter your password, you won't see what you are writing (for security reasons), but it is there!


To attach to the console:
Get out of the chroot environment
# ##i##exit


{{console|body=
Unmount all the kernel filesystem stuff and boot (if you have a separate /boot)
###i## lxc-console -n funtoo0
# ##i##umount -l proc dev sys boot
}}


You should now be able to log in and use the container. In addition, the container should now be accessible on the network.
Turn off the swap
# ##i##swapoff /dev/zvol/tank/swap


To directly attach to container:
Export the zpool
# ##i##cd /
# ##i##zpool export tank


{{console|body=
Reboot
###i## lxc-attach -n funtoo0
# ##i##reboot
}}
</console>


To stop the container:
{{fancyimportant|'''Don't forget to set your root password as stated above before exiting chroot and rebooting. If you don't set the root password, you won't be able to log into your new system.'''}}


{{console|body=
and that should be enough to get your system to boot on ZFS.
###i## lxc-stop -n funtoo0
}}


Ensure that networking is working from within the container while it is running, and you're good to go!
== After reboot ==
== Starting LXC container during host boot ==


# You need to create symlink in {{c|/etc/init.d/}} to {{c|/etc/init.d/lxc}} so that it reflects your container.
=== Forgot to reset password? ===
# {{c|ln -s /etc/init.d/lxc /etc/init.d/lxc.funtoo0}}
==== System Rescue CD ====
# now you can add {{c|lxc.funtoo0}} to default runlevel
If you aren't using bliss-initramfs, then you can reboot back into your sysresccd and reset through there by mounting your drive, chrooting, and then typing passwd.
# {{c|rc-update add lxc.funtoo0 default}}
{{console|body=
###i## rc
* Starting funtoo0 ...                  [ ok ]
}}
== LXC Bugs/Missing Features ==


This section is devoted to documenting issues with the current implementation of LXC and its associated tools. We will be gradually expanding this section with detailed descriptions of problems, their status, and proposed solutions.
Example:
<console>
# ##i##zpool import -f -R /mnt/funtoo tank
# ##i##chroot /mnt/funtoo bash -l
# ##i##passwd
# ##i##exit
# ##i##zpool export -f tank
# ##i##reboot
</console>


=== reboot ===
=== Create initial ZFS Snapshot ===
Continue to set up anything you need in terms of /etc configurations. Once you have everything the way you like it, take a snapshot of your system. You will be using this snapshot to revert back to this state if anything ever happens to your system down the road. The snapshots are cheap, and almost instant.


* Por padrão, o lxc não possui suporte a reiniciar um container. Ele simplesmente parará e o host não saberá inicializá-lo.
To take the snapshot of your system, type the following:
* Se você quiser que o seu to reinicialize de forma agradável, você precisa da capacidade sys_boot (comente lxc.cap.drop = sys_boot no seu container config)
<console># ##i##zfs snapshot -r tank@install</console>


=== PID namespaces ===
To see if your snapshot was taken, type:
<console># ##i##zfs list -t snapshot</console>


Process ID namespaces are functional, but the container can still see the CPU utilization of the host via the system load (ie. in {{c|top}}).
If your machine ever fails and you need to get back to this state, just type (This will only revert your / dataset while keeping the rest of your data intact):
<console># ##i##zfs rollback tank/funtoo/root@install</console>


=== /dev/pts newinstance ===
{{fancyimportant|'''For a detailed overview, presentation of ZFS' capabilities, as well as usage examples, please refer to the [[ZFS_Fun|ZFS Fun]] page.'''}}


* Some changes may be required to the host to properly implement "newinstance" {{c|/dev/pts}}. See [https://bugzilla.redhat.com/show_bug.cgi?id=501718 This Red Hat bug].
== Troubleshooting ==


=== lxc-create and lxc-destroy ===
=== Starting from scratch ===
If your installation has gotten screwed up for whatever reason and you need a fresh restart, you can do the following from sysresccd to start fresh:


* LXC's shell scripts are badly designed and are sure way to destruction, avoid using lxc-create and lxc-destroy.
<console>
Destroy the pool and any snapshots and datasets it has
# ##i##zpool destroy -R -f tank


=== network initialization and cleanup ===
This deletes the files from /dev/sda1 so that even after we zap, recreating the drive in the exact sector
position and size will not give us access to the old files in this partition.
# ##i##mkfs.ext2 /dev/sda1
# ##i##sgdisk -Z /dev/sda
</console>


* If used network.type = phys after lxc-stop the interface will be renamed to value from lxc.network.link. It supposed to be fixed in 0.7.4, happens still on 0.7.5 - http://www.mail-archive.com/lxc-users@lists.sourceforge.net/msg01760.html
Now start the guide again :).


* Re-starting a container can result in a failure as network resource are tied up from the already-defunct instance: [http://www.mail-archive.com/lxc-devel@lists.sourceforge.net/msg00824.html]


=== graceful shutdown ===
=== Starting again reusing the same disk partitions and the same pool ===


* To gracefully shutdown a container, it's init system needs to properly handle kill -PWR signal
If your installation has gotten screwed up for whatever reason and you want to keep your pole named tank than you should boou into the Rescue CD / USB as done before.
* For funtoo/gentoo make sure that you have:
** pf:12345:powerwait:/sbin/halt
** in your containers /etc/inittab
* For debian/ubuntu make sure that you have:
** pf::powerwait:/sbin/shutdown -t1 -a -h now
** in your container /etc/inittab
** and also comment out other line starting with pf:powerfail (such as pf::powerwait:/etc/init.d/powerfail start) <- these are used if you have UPS monitoring daemon installed!
* /etc/init.d/lxc seems to have broken support for graceful shutdown (it sends proper signal, but then also tries to kill the init with lxc-stop)


=== funtoo ===
<console>import the pool reusing all existing datasets:
# ##i##zpool import -f -R /mnt/funtoo tank
</console>


* Our udev should be updated to contain {{c|-lxc}} in scripts. (This has been done as of 02-Nov-2011, so should be resolved. But not fixed in our openvz templates, so need to regen them in a few days.)
Now you should wipe the previous installation off:
* Our openrc should be patched to handle the case where it cannot mount tmpfs, and gracefully handle this situation somehow. (Work-around in our docs above, which is to mount tmpfs to {{c|/libexec/rc/init.d}} using the container-specific {{c|fstab}} file (on the host.)
* Emerging udev within a container can/will fail when realdev is run, if a device node cannot be created (such as /dev/console) if there are no mknod capabilities within the container. This should be fixed.
== References ==


* {{c|man 7 capabilities}}
<console>
* {{c|man 5 lxc.conf}}
let's go to our base installation directory:
== Links ==
# ##i##cd /mnt/funtoo


* There are a number of additional lxc features that can be enabled via patches: [http://lxc.sourceforge.net/patches/linux/3.0.0/3.0.0-lxc1/]
and delete the old installation:  
* [https://wiki.ubuntu.com/UserNamespace Ubuntu User Namespaces page]
# ##i##rm -rf *
* lxc-gentoo setup script [https://github.com/globalcitizen/lxc-gentoo on GitHub]
</console>


* '''IBM developerWorks'''
Now start the guide again, at "Pre-Chroot"
** [http://www.ibm.com/developerworks/linux/library/l-lxc-containers/index.html LXC: Linux Container Tools]
** [http://www.ibm.com/developerworks/linux/library/l-lxc-security/ Secure Linux Containers Cookbook]


* '''Linux Weekly News'''
** [http://lwn.net/Articles/244531/ Smack for simplified access control]


[[Category:Labs]]
[[Category:HOWTO]]
[[Category:HOWTO]]
[[Category:Virtualization]]
[[Category:Filesystems]]
[[Category:Featured]]
[[Category:Install]]
 
__NOTITLE__

Revision as of 15:57, May 13, 2015

Introduction

This tutorial will show you how to install Funtoo on ZFS (rootfs). This tutorial is meant to be an "overlay" over the Regular Funtoo Installation. Follow the normal installation and only use this guide for steps 2, 3, and 8.

Introduction to ZFS

Since ZFS is a new technology for Linux, it can be helpful to understand some of its benefits, particularly in comparison to BTRFS, another popular next-generation Linux filesystem:

  • On Linux, the ZFS code can be updated independently of the kernel to obtain the latest fixes. btrfs is exclusive to Linux and you need to build the latest kernel sources to get the latest fixes.
  • ZFS is supported on multiple platforms. The platforms with the best support are Solaris, FreeBSD and Linux. Other platforms with varying degrees of support are NetBSD, Mac OS X and Windows. btrfs is exclusive to Linux.
  • ZFS has the Adaptive Replacement Cache replacement algorithm while btrfs uses the Linux kernel's Last Recently Used replacement algorithm. The former often has an overwhelmingly superior hit rate, which means fewer disk accesses.
  • ZFS has the ZFS Intent Log and SLOG devices, which accelerates small synchronous write performance.
  • ZFS handles internal fragmentation gracefully, such that you can fill it until 100%. Internal fragmentation in btrfs can make btrfs think it is full at 10%. Btrfs has no automatic rebalancing code, so it requires a manual rebalance to correct it.
  • ZFS has raidz, which is like RAID 5/6 (or a hypothetical RAID 7 that supports 3 parity disks), except it does not suffer from the RAID write hole issue thanks to its use of CoW and a variable stripe size. btrfs gained integrated RAID 5/6 functionality in Linux 3.9. However, its implementation uses a stripe cache that can only partially mitigate the effect of the RAID write hole.
  • ZFS send/receive implementation supports incremental update when doing backups. btrfs' send/receive implementation requires sending the entire snapshot.
  • ZFS supports data deduplication, which is a memory hog and only works well for specialized workloads. btrfs has no equivalent.
  • ZFS datasets have a hierarchical namespace while btrfs subvolumes have a flat namespace.
  • ZFS has the ability to create virtual block devices called zvols in its namespace. btrfs has no equivalent and must rely on the loop device for this functionality, which is cumbersome.

The only area where btrfs is ahead of ZFS is in the area of small file efficiency. btrfs supports a feature called block suballocation, which enables it to store small files far more efficiently than ZFS. It is possible to use another filesystem (e.g. reiserfs) on top of a ZFS zvol to obtain similar benefits (with arguably better data integrity) when dealing with many small files (e.g. the portage tree).

For a quick tour of ZFS and have a big picture of its common operations you can consult the page ZFS Fun.

Disclaimers

   Warning

This guide is a work in progress. Expect some quirks.

Today is 2015-05-12. ZFS has undertaken an upgrade - from 0.6.3 to 0.6.4. Please ensure that you use a RescueCD with ZFS 0.6.3. At present date grub 2.02 is not able to deal with those new ZFS parameters. If you want to use ZFS 0.6.4 for pool creation, you should use the compatability mode.

You should upgrade an existing pool only when grub is able to deal with - in a future version ... If not, you will not be able to boot into your system, and no rollback will help!

Please inform yourself!

   Important

Since ZFS was really designed for 64 bit systems, we are only recommending and supporting 64 bit platforms and installations. We will not be supporting 32 bit platforms!

Downloading the ISO (With ZFS)

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.

Name: sysresccd-4.2.0_zfs_0.6.2.iso  (545 MB)
Release Date: 2014-02-25
md5sum 01f4e6929247d54db77ab7be4d156d85


Download System Rescue CD with ZFS

Creating a bootable USB from ISO (From a Linux Environment)

After you download the iso, you can do the following steps to create a bootable USB:

Make a temporary directory
root # mkdir /tmp/loop

Mount the iso
root # mount -o ro,loop /root/sysresccd-4.2.0_zfs_0.6.2.iso /tmp/loop

Run the usb installer
root # /tmp/loop/usb_inst.sh

That should be all you need to do to get your flash drive working.

Booting the ISO

   Warning

When booting into the ISO, Make sure that you select the "Alternate 64 bit kernel (altker64)". The ZFS modules have been built specifically for this kernel rather than the standard kernel. If you select a different kernel, you will get a fail to load module stack error message.

Creating partitions

There are two ways to partition your disk: You can use your entire drive and let ZFS automatically partition it for you, or you can do it manually.

We will be showing you how to partition it manually because if you partition it manually you get to create your own layout, you get to have your own separate /boot partition (Which is nice since not every bootloader supports booting from ZFS pools), and you get to boot into RAID10, RAID5 (RAIDZ) pools and any other layouts due to you having a separate /boot partition.

gdisk (GPT Style)

A Fresh Start:

First lets make sure that the disk is completely wiped from any previous disk labels and partitions. We will also assume that /dev/sda is the target drive.

root # sgdisk -Z /dev/sda
   Warning

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.

Now that we have a clean drive, we will create the new layout.

First open up the application:

root # gdisk /dev/sda

Create Partition 1 (boot):

Command: n ↵
Partition Number: 
First sector: 
Last sector: +250M ↵
Hex Code: 

Create Partition 2 (BIOS Boot Partition):

Command: n ↵
Partition Number: 
First sector: 
Last sector: +32M ↵
Hex Code: EF02 ↵

Create Partition 3 (ZFS):

Command: n ↵
Partition Number: 
First sector: 
Last sector: 
Hex Code: bf00 ↵

Command: p ↵

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048          514047   250.0 MiB   8300  Linux filesystem
   2          514048          579583   32.0 MiB    EF02  BIOS boot partition
   3          579584      1953525134   931.2 GiB   BF00  Solaris root

Command: w ↵


Format your /boot partition

root # mkfs.ext2 -m 1 /dev/sda1

Create the zpool

We will first create the pool. The pool will be named tank. Feel free to name your pool as you want. We will use ashift=12 option which is used for a hard drives with a 4096 sector size.

root #   zpool create -f -o ashift=12 -o cachefile=/tmp/zpool.cache -O normalization=formD -m none -R /mnt/funtoo tank /dev/sda3 

Create the zfs datasets

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 as examples ones: /home, /usr/src, and /usr/portage.

Create some empty containers for organization purposes, and make the dataset that will hold /
root # zfs create -p tank/funtoo
root # zfs create -o mountpoint=/ tank/funtoo/root

Optional, but recommended datasets: /home
root # zfs create -o mountpoint=/home tank/funtoo/home

Optional datasets: /usr/src, /usr/portage/{distfiles,packages}
root # zfs create -o mountpoint=/usr/src tank/funtoo/src
root # zfs create -o mountpoint=/usr/portage -o compression=off tank/funtoo/portage
root # zfs create -o mountpoint=/usr/portage/distfiles tank/funtoo/portage/distfiles
root # zfs create -o mountpoint=/usr/portage/packages tank/funtoo/portage/packages

Installing Funtoo

Pre-Chroot

Go into the directory that you will chroot into
root # cd /mnt/funtoo

Make a boot folder and mount your boot drive
root # mkdir boot
root # mount /dev/sda1 boot

Now download and extract the Funtoo stage3 ...


   Note

It is trully recommended to use the current version and generic64. That reduces the risk of a broken build.

After successfull ZFS installation and successfull first boot, the kernel may be changed using the eselect profile set ... command. If you create a snapshot before, you may allways come back to your previous installation, with some simple steps ... (rollback your pool and in the worst case configure and install the bootloader again)


Once you've extracted the stage3, do a few more preparations and chroot into your new funtoo environment:

Bind the kernel related directories
root # mount -t proc none proc
root # mount --rbind /dev dev
root # mount --rbind /sys sys

Copy network settings
root # cp -f /etc/resolv.conf etc

Make the zfs folder in 'etc' and copy your zpool.cache
root # mkdir etc/zfs
root # cp /tmp/zpool.cache etc/zfs

Chroot into Funtoo
root # env -i HOME=/root TERM=$TERM chroot . bash -l
   Note

How to create zpool.cache file?

If no zpool.cache file is available, the following command will create one:

root # zpool set cachefile=/etc/zfs/zpool.cache tank

Install/PortageTree

Add filesystems to /etc/fstab

Before we continue to compile and or install our kernel in the next step, we will edit the /etc/fstab file because if we decide to install our kernel through portage, portage will need to know where our /boot is, so that it can place the files in there.

Edit /etc/fstab:

   /etc/fstab
# <fs>                  <mountpoint>    <type>          <opts>          <dump/pass>

/dev/sda1               /boot           ext2            defaults        0 2

Building kernel, initramfs and grub to work with zfs

Install genkernel and initial kernel build

We need to build a genkernel initially:

root # emerge genkernel

Build initial kernel (required for checks in sys-kernel/spl and sys-fs/zfs):
root # genkernel kernel --no-clean --no-mountboot 

Installing the ZFS userspace tools and kernel modules

Emerge No results. This package will bring in No results, and No results as its dependencies:

root # emerge zfs

Check to make sure that the zfs tools are working. The zpool.cache file that you copied before should be displayed.

root # zpool status
root # zfs list

Add the zfs tools to openrc.

root # rc-update add zfs boot

If everything worked, continue.

Install GRUB 2

Install grub2:

root # echo "sys-boot/grub libzfs -truetype" >> /etc/portage/package.use
root # emerge grub

Now install grub to the drive itself (not a partition):

root # grub-install /dev/sda

Emerge genkernel and initial kernel build

Install genkernel using:

root # echo "sys-kernel/genkernel zfs" >> /etc/portage/package.use
root # emerge genkernel

Build now kernel and initramfs with --zfs
root # genkernel all --zfs --no-clean --no-mountboot --callback="emerge @module-rebuild"


   Note

During the build, ZFS configurations should be observed.

If the build breaks, restart it again.

Configuring the Bootloader

Using the genkernel you must add 'real_root=ZFS=<root>' and 'dozfs' to your params. Edit the entry for /etc/boot.conf:

   /etc/boot.conf
"Funtoo ZFS" {
        kernel kernel[-v]
        initrd initramfs-genkernel-x86_64[-v]
        params real_root=ZFS=tank/funtoo/root
        params += dozfs=force
}

The command boot-update should take care of grub configuration:

Install boot-update (if it is missing):
root #emerge boot-update

Run boot-update to update grub.cfg
root #boot-update
   Note

If boot-updatefails, try this:

root # grub-mkconfig -o /boot/grub/grub.cfg

Now you should have a new installation of the kernel, initramfs and grub which are zfs capable. The configurtion files should be updated, and the system should come up during the next reboot.

   Note

If The luks integration works basically the same way.

Final configuration

Clean up and reboot

We are almost done, we are just going to clean up, set our root password, and unmount whatever we mounted and get out.

Delete the stage3 tarball that you downloaded earlier so it doesn't take up space.
root # cd /
root # rm stage3-latest.tar.xz

Set your root password
root # passwd
>> Enter your password, you won't see what you are writing (for security reasons), but it is there!

Get out of the chroot environment
root # exit

Unmount all the kernel filesystem stuff and boot (if you have a separate /boot)
root # umount -l proc dev sys boot

Turn off the swap
root # swapoff /dev/zvol/tank/swap

Export the zpool
root # cd /
root # zpool export tank

Reboot
root # reboot
   Important

Don't forget to set your root password as stated above before exiting chroot and rebooting. If you don't set the root password, you won't be able to log into your new system.

and that should be enough to get your system to boot on ZFS.

After reboot

Forgot to reset password?

System Rescue CD

If you aren't using bliss-initramfs, then you can reboot back into your sysresccd and reset through there by mounting your drive, chrooting, and then typing passwd.

Example:

root # zpool import -f -R /mnt/funtoo tank
root # chroot /mnt/funtoo bash -l
root # passwd
root # exit
root # zpool export -f tank
root # reboot

Create initial ZFS Snapshot

Continue to set up anything you need in terms of /etc configurations. Once you have everything the way you like it, take a snapshot of your system. You will be using this snapshot to revert back to this state if anything ever happens to your system down the road. The snapshots are cheap, and almost instant.

To take the snapshot of your system, type the following:

root # zfs snapshot -r tank@install

To see if your snapshot was taken, type:

root # zfs list -t snapshot

If your machine ever fails and you need to get back to this state, just type (This will only revert your / dataset while keeping the rest of your data intact):

root # zfs rollback tank/funtoo/root@install
   Important

For a detailed overview, presentation of ZFS' capabilities, as well as usage examples, please refer to the ZFS Fun page.

Troubleshooting

Starting from scratch

If your installation has gotten screwed up for whatever reason and you need a fresh restart, you can do the following from sysresccd to start fresh:

Destroy the pool and any snapshots and datasets it has
root # zpool destroy -R -f tank

This deletes the files from /dev/sda1 so that even after we zap, recreating the drive in the exact sector
position and size will not give us access to the old files in this partition.
root # mkfs.ext2 /dev/sda1
root # sgdisk -Z /dev/sda

Now start the guide again :).


Starting again reusing the same disk partitions and the same pool

If your installation has gotten screwed up for whatever reason and you want to keep your pole named tank than you should boou into the Rescue CD / USB as done before.

import the pool reusing all existing datasets:
root # zpool import -f -R /mnt/funtoo tank

Now you should wipe the previous installation off:

let's go to our base installation directory:
root # cd /mnt/funtoo

and delete the old installation: 
root # rm -rf *

Now start the guide again, at "Pre-Chroot"