Difference between pages "ZFS as Root Filesystem" and "Funtoo Linux First Steps"

From Funtoo
(Difference between pages)
Jump to navigation Jump to search
 
 
Line 1: Line 1:
== Introduction ==
If you are brand new to Gentoo Linux or Funtoo Linux, this page will help you to get familiar with your new system, and how it works.


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.
== Intro to Emerge: Installing an Editor ==


=== Introduction to ZFS ===
By default, Funtoo Linux has the <tt>nano</tt> and <tt>vi</tt> editors installed. <tt>nano</tt> is the default editor.


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:
If you are new to Funtoo Linux, you have probably heard about <tt>[[emerge]]</tt>, the Funtoo and Gentoo Linux command for installing packages from the Portage tree. Funtoo Linux has a git-based Portage tree, which is located at <tt>/usr/portage</tt> by default. It contains scripts called ''ebuilds'' that describe how to build and install packages from source. <tt>emerge</tt> is used to run these scripts and install packages, as follows:


* 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.
<console>
# ##i##emerge vim
</console>


* 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.
You can also see what packages ''would'' be installed, but not actually install them, by using the <tt>-p</tt>, or <tt>--pretend</tt> option:


* 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.
<console>
# ##i##emerge -p vim
</console>


* ZFS has the ZFS Intent Log and SLOG devices, which accelerates small synchronous write performance.
Another equally handy option is the <tt>-a</tt>, or <tt>--ask</tt> option, which will display the packages to be merged, and then ask for confirmation from you before continuing:


* 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.
<console>
# ##i##emerge -a emacs


* 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.
These are the packages that would be merged, in order:


* ZFS send/receive implementation supports incremental update when doing backups. btrfs' send/receive implementation requires sending the entire snapshot.
Calculating dependencies... done!
[ebuild  N    ] app-admin/eselect-emacs-1.13
[ebuild  N    ] net-libs/liblockfile-1.09
[ebuild  N    ] app-emacs/emacs-common-gentoo-1.3-r1  USE="-X -emacs22icons"
[ebuild  N    ] app-editors/emacs-23.4-r1  USE="alsa gif gpm jpeg png tiff xpm -X -Xaw3d (-aqua) -athena -dbus -gconf -gtk -gzip-el -hesiod -kerberos -livecd -m17n-lib -motif -sound -source -svg -toolkit-scroll-bars -xft"
[ebuild  N    ] virtual/emacs-23


* ZFS supports data deduplication, which is a memory hog and only works well for specialized workloads. btrfs has no equivalent.
Would you like to merge these packages? [Yes/No]  ##i##y
</console>


* ZFS datasets have a hierarchical namespace while btrfs subvolumes have a flat namespace.
In the above <tt>emerge</tt> output, you can see some text beginning with <tt>USE=</tt> on the <tt>app-editors/emacs</tt> line. This means that this package has a number of optional build-time features which can be controlled using Portage USE variables. These USE variables can be set globally by adding a line such as this to <tt>/etc/make.conf</tt>:


* 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.
<pre>
 
USE="gif jpeg png tiff xpm"
The only area where btrfs is ahead of ZFS is in the area of small file
</pre>
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 ===
If you go ahead and make these changes, and then run <tt>emerge -a emacs</tt> again, you will notice that several more dependencies will be pulled into the list of packages to be merged. You can control the footprint of your Funtoo Linux system (and avoid bloat) by enabling only the USE variables you need.


{{fancywarning|This guide is a work in progress. Expect some quirks.}}
Above, we enabled several USE variables globally in <tt>/etc/make.conf</tt>. It is also possible to enable USE variables on a per-package basis, and often times this is the best approach. If you wanted to enable <tt>gtk</tt> for emacs only, you would create the <tt>/etc/portage/package.use</tt> directory, and create an <tt>emacs</tt> file in it that contained the following:
{{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>
<pre>
Name: sysresccd-4.2.0_zfs_0.6.2.iso  (545 MB)
app-editors/emacs gtk
Release Date: 2014-02-25
md5sum 01f4e6929247d54db77ab7be4d156d85
</pre>
</pre>


Note that <tt>package.use</tt> can also be a file if you prefer. However, using an <tt>/etc/portage/package.use</tt> directory is recommended as it keeps things better organized. The filenames you use inside the <tt>package.use</tt> directory do not impact Portage behavior and can be named whatever is convenient for you. You might want to put the settings above in a file called <tt>/etc/portage/package.use/editors</tt> if you have several USE settings that you use for editors.


'''[http://ftp.osuosl.org/pub/funtoo/distfiles/sysresccd/ Download System Rescue CD with ZFS]'''<br />
See the [[emerge]] page for more information on various emerge command-line options and best practices.


== Creating a bootable USB from ISO (From a Linux Environment) ==
==== Default editor ====
After you download the iso, you can do the following steps to create a bootable USB:
 
Funtoo Linux also has a special meta-command called <tt>eselect</tt>, which can be used to set many default system settings. One of the things it is used for is to set the default editor used by things like <tt>crontab -e</tt>, etc that will automatically start an editor when run. Here is how to use <tt>eselect</tt> to change the default system editor:


<console>
<console>
Make a temporary directory
# ##i##eselect editor list
# ##i##mkdir /tmp/loop
Available targets for the EDITOR variable:
 
  [1]  /bin/nano
Mount the iso
  [2]  /bin/ed
# ##i##mount -o ro,loop /root/sysresccd-4.2.0_zfs_0.6.2.iso /tmp/loop
  [3]  /usr/bin/ex
 
  [4]  /usr/bin/vi
Run the usb installer
  [ ]  (free form)
# ##i##/tmp/loop/usb_inst.sh
# ##i##eselect editor set 4
Setting EDITOR to /usr/bin/vi ...
Run ". /etc/profile" to update the variable in your shell.
</console>
</console>


That should be all you need to do to get your flash drive working.
After logging in again, or typing <tt>source /etc/profile</tt> in the current shell, the new system editor will be active.
 
== 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.
Note that if you want to use vim instead of a vi through busybox you also need to run:
We will also assume that <tt>/dev/sda</tt> is the target drive.<br />


<console>
<console>
# ##i##sgdisk -Z /dev/sda
# ##i##eselect vi set vim
</console>
</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.}}
=== Profiles ===


Now that we have a clean drive, we will create the new layout.
You may have heard that Funtoo Linux and Gentoo Linux are metadistributions, which means that rather than being a one-size-fits-all kind of Linux, they allow you to customize your system to your liking. We have already taken a look at <tt>USE</tt> variables, and there are also various other settings that can affect the features that are installed when you emerge a package.


First open up the application:
In Funtoo Linux, we have a system of ''profiles'' which can be used to enable various useful settings at once. In fact, a number of profiles are already enabled on your system. For example, on my desktop system, typing <tt>eselect profile show</tt> produces the following output:


<console>
<console>
# ##i##gdisk /dev/sda
# ##i##eselect profile show
</console>
 
'''Create Partition 1''' (boot):
<console>
Command: ##i##n ↵
Partition Number: ##i##↵
First sector: ##i##↵
Last sector: ##i##+250M ↵
Hex Code: ##i##↵
</console>
 
'''Create Partition 2''' (BIOS Boot Partition):
<console>Command: ##i##n ↵
Partition Number: ##i##↵
First sector: ##i##↵
Last sector: ##i##+32M ↵
Hex Code: ##i##EF02 ↵
</console>
 
'''Create Partition 3''' (ZFS):
<console>Command: ##i##n ↵
Partition Number: ##i##↵
First sector: ##i##↵
Last sector: ##i##↵
Hex Code: ##i##bf00 ↵
 
Command: ##i##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: ##i##w ↵
##g##Currently set profiles:
</console>
    arch: gentoo:funtoo/1.0/linux-gnu/arch/x86-64bit
  build: gentoo:funtoo/1.0/linux-gnu/build/current
  flavor: gentoo:funtoo/1.0/linux-gnu/flavor/desktop
mix-ins: gentoo:funtoo/1.0/linux-gnu/mix-ins/gnome
mix-ins: gentoo:funtoo/1.0/linux-gnu/mix-ins/hardened




=== Format your /boot partition ===
##g##Automatically enabled profiles:
 
mix-ins: gentoo:funtoo/1.0/linux-gnu/mix-ins/print
<console>
mix-ins: gentoo:funtoo/1.0/linux-gnu/mix-ins/X
# ##i##mkfs.ext2 -m 1 /dev/sda1
mix-ins: gentoo:funtoo/1.0/linux-gnu/mix-ins/audio
mix-ins: gentoo:funtoo/1.0/linux-gnu/mix-ins/dvd
mix-ins: gentoo:funtoo/1.0/linux-gnu/mix-ins/media
mix-ins: gentoo:funtoo/1.0/linux-gnu/mix-ins/console-extras
</console>
</console>


=== Create the zpool ===
In case you're curious, these various profile settings live within <tt>/usr/portage/profiles</tt> -- in the listing above, the <tt>gentoo:</tt> prefix refers to this portage profile directory. You can find the profile settings for <tt>gentoo:funtoo/1.0/linux-gnu/mix-ins/X</tt> by looking in <tt>/usr/portage/profiles/funtoo/1.0/linux-gnu/mix-ins/X</tt>, for example.
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>


=== Create the zfs datasets ===
Under the list of <tt>Currently set profiles</tt>, you'll see that I have an <tt>x86-64bit</tt> arch profile. In Funtoo Linux, ''all'' systems have a single arch profiled defined, and this is where settings specific to your system architecture are defined. In addition, I have a build profile of ''current''. All Funtoo Linux systems have a single build profile defined, and this tells Portage what masks to apply to the Portage tree -- in other words, what selection of packages you will have available to emerge. If you are using funtoo-stable, your build profile will be ''stable'' and you will have a more limited set of packages that you can merge by default -- the stable set.
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>.


<console>
You will also see that I have a ''flavor'' profile. Unlike the ''arch'' and ''build'' profiles, which should not be changed, you can choose another flavor if you want. In fact, we encourage you to do so. The ''flavor'' is used to define the general type of system you are creating. You can only have one flavor profile enabled, and since this command was run on a desktop-type system, I have enabled the ''desktop'' flavor. This enables a variety of settings, primarily USE flags, suitable for desktop systems.
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
You'll also see that I have a couple of ''mix-ins'' enabled. In Funtoo Linux, you can have zero or more mix-ins enabled -- I have ''gnome'' enabled, which sets various settings that are optimal for the use of the [[GNOME First Steps|GNOME]] desktop environment, and then I am also using the ''hardened'' mix-in, since I have set up a so-called "hardened" system with various protections against malicious attacks.
# ##i##zfs create -o mountpoint=/home tank/funtoo/home


Optional datasets: /usr/src, /usr/portage/{distfiles,packages}
{{Tip|Funtoo Linux now [[News:New_Media_Mix-ins|has enhanced Media mix-ins]] to help you easily get the level of media support you want for your system.}}
# ##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>


== Installing Funtoo ==
Then there's a list of automatically-enabled profiles. This shows you any profiles that are pulled in by the main profiles and mix-ins that are already enabled. As you can see, the ''print'', ''X'', ''audio'', ''dvd'', ''media'' and ''console-extras'' have been enabled, likely by the ''desktop'' flavor.


=== Pre-Chroot ===
For now, it is not necessary to get too deep into profiles, but if you are creating a desktop system, I suggest you set the ''desktop'' flavor. To do this, type <tt>eselect profile list</tt> and find the number to the left of <tt>funtoo/1.0/linux-gnu/flavor/desktop</tt>. Then, type the following command as the root user:


<console>
<console>
Go into the directory that you will chroot into
# ##i##eselect profile set-flavor 99
# ##i##cd /mnt/funtoo
 
Make a boot folder and mount your boot drive
# ##i##mkdir boot
# ##i##mount /dev/sda1 boot
</console>
</console>


[[Funtoo_Linux_Installation|Now download and extract the Funtoo stage3 ...]]
(Replace "99" with the number from the list)
 
Once you've extracted the stage3, do a few more preparations and chroot into your new funtoo environment:
 
<console>
Bind the kernel related directories
# ##i##mount -t proc none proc
# ##i##mount --rbind /dev dev
# ##i##mount --rbind /sys sys


Copy network settings
You will now have the ''desktop'' flavor set for your system. Type <tt>eselect profile show</tt> to see your new settings.
# ##i##cp -f /etc/resolv.conf etc


Make the zfs folder in 'etc' and copy your zpool.cache
=== Updating your system ===
# ##i##mkdir etc/zfs
# ##i##cp /etc/zfs/zpool.cache etc/zfs


Chroot into Funtoo
Sometimes, you may want to update the packages on your system. Often, this is done after you run <tt>emerge --sync</tt>, which will grab Portage tree updates from the main Funtoo Linux Portage tree:
# ##i##env -i HOME=/root TERM=$TERM chroot . bash -l
</console>


=== In Chroot ===
Sync your tree
<console>
<console>
# ##i##emerge --sync
# ##i##emerge --sync
</console>


=== Add filesystems to /etc/fstab ===
>>> Starting git pull...
remote: Counting objects: 1791, done.       
remote: Compressing objects: 100% (206/206), done.       
remote: Total 980 (delta 811), reused 931 (delta 764)       
Receiving objects: 100% (980/980), 185.04 KiB, done.
Resolving deltas: 100% (811/811), completed with 754 local objects.
From git://github.com/funtoo/experimental-mini-2011
  7a17140..b836bc8  funtoo.org -> origin/funtoo.org
Updating 7a17140..b836bc8
Fast-forward
>>> Git pull in /usr/portage successful


Before we continue to compile and or install our kernel in the next step, we will edit the <tt>/etc/fstab</tt> file because if we decide to install our kernel through portage, portage will need to know where our <tt>/boot</tt> is, so that it can place the files in there.  
* IMPORTANT: 1 news items need reading for repository 'gentoo'.
* Use eselect news to read news items.


Edit <tt>/etc/fstab</tt>:
#
</console>


<pre>
You may also want to update your system after you have changed USE flag settings. To take advantage of the USE flags you have just enabled, it's necessary to recompile everything that includes them.
# <fs>                  <mountpoint>    <type>          <opts>          <dump/pass>


/dev/sda1              /boot          ext2            defaults        0 2
Below, you'll find a recommended <tt>emerge</tt> command for updating your entire system. The <tt>-a</tt> option will cause <tt>emerge</tt> to prompt you for confirmation before starting the merge:
/dev/zvol/tank/swap    none            swap            sw              0 0
</pre>
 
== Kernel Configuration ==
...wip
 
== 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>
<console>
# ##i##emerge zfs
# ##i##emerge -auDN world
</console>
</console>


Check to make sure that the zfs tools are working. The <code>zpool.cache</code> file that you copied before should be displayed.
<tt>-u</tt> tells <tt>emerge</tt> to update any already-installed but out-of-date packages that we specify on the command-line. The <tt>-D</tt> option tells <tt>emerge</tt> to perform a ''deep'' dependency tree graph, so it will include sub-dependencies of packages that we have specified on the command line as well. This allows <tt>emerge</tt> to perform as thorough an update of your system as possible.  


<console>
The <tt>-N</tt> (<tt>--newuse</tt>) option tells Portage to check for any new USE flags that have been enabled or disabled, and rebuild packages so that all USE flags are set as currently defined in <tt>/etc/make.conf</tt> and <tt>/etc/portage/package.use</tt>.
# ##i##zpool status
# ##i##zfs list
</console>


If everything worked, continue.
<tt>world</tt> is a "meta-package" or "package set" which includes every package that you have manually installed plus all packages in the system set. It's important to note that whenever you ask <tt>emerge</tt> to install anything, such as <tt>metalog</tt> or <tt>vim</tt>, those packages will be automatically added to the world package set. In this way, <tt>emerge</tt> learns what packages you care about and want to keep updated. If you want to see what's in your world package set, take a look at <tt>/var/lib/portage/world</tt>:


== Create the initramfs ==
=== genkernel ===
Install genkernel and run it:
<console>
<console>
# ##i##emerge genkernel
# ##i##cat /var/lib/portage/world
app-editors/vim
app-portage/eix
app-portage/gentoolkit
dev-vcs/git
net-misc/bridge-utils
net-misc/dhcpcd
net-misc/keychain
sys-apps/gptfdisk
sys-apps/pciutils
sys-devel/bc
sys-fs/reiserfsprogs
sys-kernel/vanilla-sources
</console>


You only need to add --luks if you used encryption
Also note that some packages may have been added to the world set by Metro when your stage3 tarball was built.
# ##i##genkernel --zfs --luks initramfs
</console>


== Installing & Configuring the Bootloader ==
==== Updating a few packages ====


=== GRUB 2  ===
If we simply wanted to rebuild a few packages to reflect updated USE flag settings, we could specify it instead of <tt>world</tt>. Be sure to include the <tt>-N</tt> option:
<console>
# ##i##emerge grub
</console>


Now install grub to the drive itself (not a partition):
<console>
<console>
# ##i##grub-install /dev/sda
# ##i##emerge -auDN vim emacs
</console>
</console>


=== boot-update ===
== Useful applications for daily usage ==
boot-update comes as a dependency of grub2, so if you already installed grub, it's already on your system!


==== Genkernel ====
Here are some other packages you may want to consider installing via <tt>emerge</tt>:
If your using genkernel you must add 'real_root=ZFS=<root>' and 'dozfs' to your params.
Example entry for <code>/etc/boot.conf</code>:


{{file|name=/etc/boot.conf|desc= |body=
;<tt>app-misc/screen</tt>: Allows you to have persistent login sessions.
"Funtoo ZFS" {
;<tt>app-misc/tmux</tt>: Similar to <tt>screen</tt> -- some people prefer it.
        kernel kernel[-v]
;<tt>app-admin/sudo</tt>: Grant root privileges to selected users and command combinations.
        initrd initramfs-genkernel-x86_64[-v]
;<tt>sys-process/htop</tt>: Colorful and informative text-based process list.
        params real_root=ZFS=tank/funtoo/root
;<tt>sys-process/glances</tt>: Similar to htop, includes disc I/O and network I/O in display.
        params += dozfs=force
;<tt>app-portage/eix</tt>: Quick portage package search
}
;<tt>app-portage/gentoolkit</tt>: Portage utils
}}
;<tt>app-misc/mc</tt>: GNU Midnight Commander is a text based file manager --- some will recall <tt>MS-DOS XtreeGold</tt>
 
;<tt>app-text/wgetpaste</tt>: Command-line interface to various pastebins; very useful in providing info along with bugs reports
After editing /etc/boot.conf, you just need to run boot-update to update grub.cfg
;<tt>net-irc/irssi</tt>: A modular textUI IRC client with IPv6 support; a powerful tool to get help from Funtoo Community on IRC channel. Nice companion to <tt>app-text/wgetpaste</tt>


<console>
<console>
###i## boot-update
# ##i##emerge --jobs app-misc/screen sudo htop eix gentoolkit app-misc/mc wgetpaste net-irc/irssi
</console>
</console>


== Final configuration ==
=== Creating a user account ===
=== Add the zfs tools to openrc ===
<console># ##i##rc-update add zfs boot</console>


=== Clean up and reboot ===
It's a good idea to create a normal user account that you can use for general Linux tasks. Before rebooting, create a user account for everyday use. Adjust the groups in the example below to match your needs. Some of them may not exist yet on your system. Replace "<tt><user_name></tt>" with the name you're going to use for your everyday user. The "<tt>-m</tt>" option instructs <tt>useradd</tt> to create a home directory for your user. See <tt>man useradd</tt> for more info.
We are almost done, we are just going to clean up, '''set our root password''', and unmount whatever we mounted and get out.


<console>
<console>
Delete the stage3 tarball that you downloaded earlier so it doesn't take up space.
# ##i##useradd -m -g users -G audio,video,cdrom,wheel <user_name>
# ##i##cd /
# ##i##rm stage3-latest.tar.xz
 
Set your root password
# ##i##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
# ##i##exit
 
Unmount all the kernel filesystem stuff and boot (if you have a separate /boot)
# ##i##umount -l proc dev sys boot
 
Turn off the swap
# ##i##swapoff /dev/zvol/tank/swap
 
Export the zpool
# ##i##cd /
# ##i##zpool export tank
 
Reboot
# ##i##reboot
</console>
</console>
 
Don't forget to set a password for your new user:
{{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.'''}}
 
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:
<console>
<console>
# ##i##zpool import -f -R /mnt/funtoo tank
# ##i##passwd <user_name>
# ##i##chroot /mnt/funtoo bash -l
# ##i##passwd
# ##i##exit
# ##i##zpool export -f tank
# ##i##reboot
</console>
</console>


=== Create initial ZFS Snapshot ===
== Installing a graphical environment ==
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:
<console># ##i##zfs snapshot -r tank@install</console>
 
To see if your snapshot was taken, type:
<console># ##i##zfs list -t snapshot</console>
 
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>


{{fancyimportant|'''For a detailed overview, presentation of ZFS' capabilities, as well as usage examples, please refer to the [[ZFS_Fun|ZFS Fun]] page.'''}}
If you intend on using your Funtoo Linux installation for more than system administration, chances are you're going to want to have a GUI (graphical user interface). In the past, setting one up involved wading through text files and man pages. Thanks to modern tools like udev this is no longer the case.


== Troubleshooting ==
Unlike most operating systems, Funtoo does not ship with a GUI pre-installed. If you've used Windows or Mac OS, you'd also know that their interfaces cannot be replaced easily. With Linux, the opposite is true -- you are free to choose from a huge selection of GUIs. From window managers such as Blackbox, IceWM, and xmonad, to fully-featured desktop environments like GNOME and KDE, the possibilities are vast in number.


=== Starting from scratch ===
The first step in setting up a graphical environment is to set up the [[X Window System]]. Then, you will be able to install the graphical environment of your choice. [[GNOME First Steps|GNOME]] is a popular option for new users.
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:
 
<console>
Destroy the pool and any snapshots and datasets it has
# ##i##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.
# ##i##mkfs.ext2 /dev/sda1
# ##i##sgdisk -Z /dev/sda
</console>
 
Now start the guide again :).


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

Revision as of 19:28, January 12, 2015

If you are brand new to Gentoo Linux or Funtoo Linux, this page will help you to get familiar with your new system, and how it works.

Intro to Emerge: Installing an Editor

By default, Funtoo Linux has the nano and vi editors installed. nano is the default editor.

If you are new to Funtoo Linux, you have probably heard about emerge, the Funtoo and Gentoo Linux command for installing packages from the Portage tree. Funtoo Linux has a git-based Portage tree, which is located at /usr/portage by default. It contains scripts called ebuilds that describe how to build and install packages from source. emerge is used to run these scripts and install packages, as follows:

root # emerge vim

You can also see what packages would be installed, but not actually install them, by using the -p, or --pretend option:

root # emerge -p vim

Another equally handy option is the -a, or --ask option, which will display the packages to be merged, and then ask for confirmation from you before continuing:

root # emerge -a emacs

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild  N     ] app-admin/eselect-emacs-1.13 
[ebuild  N     ] net-libs/liblockfile-1.09 
[ebuild  N     ] app-emacs/emacs-common-gentoo-1.3-r1  USE="-X -emacs22icons" 
[ebuild  N     ] app-editors/emacs-23.4-r1  USE="alsa gif gpm jpeg png tiff xpm -X -Xaw3d (-aqua) -athena -dbus -gconf -gtk -gzip-el -hesiod -kerberos -livecd -m17n-lib -motif -sound -source -svg -toolkit-scroll-bars -xft" 
[ebuild  N     ] virtual/emacs-23 

Would you like to merge these packages? [Yes/No]  y

In the above emerge output, you can see some text beginning with USE= on the app-editors/emacs line. This means that this package has a number of optional build-time features which can be controlled using Portage USE variables. These USE variables can be set globally by adding a line such as this to /etc/make.conf:

USE="gif jpeg png tiff xpm"

If you go ahead and make these changes, and then run emerge -a emacs again, you will notice that several more dependencies will be pulled into the list of packages to be merged. You can control the footprint of your Funtoo Linux system (and avoid bloat) by enabling only the USE variables you need.

Above, we enabled several USE variables globally in /etc/make.conf. It is also possible to enable USE variables on a per-package basis, and often times this is the best approach. If you wanted to enable gtk for emacs only, you would create the /etc/portage/package.use directory, and create an emacs file in it that contained the following:

app-editors/emacs gtk

Note that package.use can also be a file if you prefer. However, using an /etc/portage/package.use directory is recommended as it keeps things better organized. The filenames you use inside the package.use directory do not impact Portage behavior and can be named whatever is convenient for you. You might want to put the settings above in a file called /etc/portage/package.use/editors if you have several USE settings that you use for editors.

See the emerge page for more information on various emerge command-line options and best practices.

Default editor

Funtoo Linux also has a special meta-command called eselect, which can be used to set many default system settings. One of the things it is used for is to set the default editor used by things like crontab -e, etc that will automatically start an editor when run. Here is how to use eselect to change the default system editor:

root # eselect editor list
Available targets for the EDITOR variable:
  [1]   /bin/nano
  [2]   /bin/ed
  [3]   /usr/bin/ex
  [4]   /usr/bin/vi
  [ ]   (free form)
root # eselect editor set 4
Setting EDITOR to /usr/bin/vi ...
Run ". /etc/profile" to update the variable in your shell.

After logging in again, or typing source /etc/profile in the current shell, the new system editor will be active.

Note that if you want to use vim instead of a vi through busybox you also need to run:

root # eselect vi set vim

Profiles

You may have heard that Funtoo Linux and Gentoo Linux are metadistributions, which means that rather than being a one-size-fits-all kind of Linux, they allow you to customize your system to your liking. We have already taken a look at USE variables, and there are also various other settings that can affect the features that are installed when you emerge a package.

In Funtoo Linux, we have a system of profiles which can be used to enable various useful settings at once. In fact, a number of profiles are already enabled on your system. For example, on my desktop system, typing eselect profile show produces the following output:

root # eselect profile show

root ##g##Currently set profiles:
    arch: gentoo:funtoo/1.0/linux-gnu/arch/x86-64bit
   build: gentoo:funtoo/1.0/linux-gnu/build/current
  flavor: gentoo:funtoo/1.0/linux-gnu/flavor/desktop
 mix-ins: gentoo:funtoo/1.0/linux-gnu/mix-ins/gnome
 mix-ins: gentoo:funtoo/1.0/linux-gnu/mix-ins/hardened


root ##g##Automatically enabled profiles: 
mix-ins: gentoo:funtoo/1.0/linux-gnu/mix-ins/print 
mix-ins: gentoo:funtoo/1.0/linux-gnu/mix-ins/X 
mix-ins: gentoo:funtoo/1.0/linux-gnu/mix-ins/audio 
mix-ins: gentoo:funtoo/1.0/linux-gnu/mix-ins/dvd 
mix-ins: gentoo:funtoo/1.0/linux-gnu/mix-ins/media 
mix-ins: gentoo:funtoo/1.0/linux-gnu/mix-ins/console-extras

In case you're curious, these various profile settings live within /usr/portage/profiles -- in the listing above, the gentoo: prefix refers to this portage profile directory. You can find the profile settings for gentoo:funtoo/1.0/linux-gnu/mix-ins/X by looking in /usr/portage/profiles/funtoo/1.0/linux-gnu/mix-ins/X, for example.

Under the list of Currently set profiles, you'll see that I have an x86-64bit arch profile. In Funtoo Linux, all systems have a single arch profiled defined, and this is where settings specific to your system architecture are defined. In addition, I have a build profile of current. All Funtoo Linux systems have a single build profile defined, and this tells Portage what masks to apply to the Portage tree -- in other words, what selection of packages you will have available to emerge. If you are using funtoo-stable, your build profile will be stable and you will have a more limited set of packages that you can merge by default -- the stable set.

You will also see that I have a flavor profile. Unlike the arch and build profiles, which should not be changed, you can choose another flavor if you want. In fact, we encourage you to do so. The flavor is used to define the general type of system you are creating. You can only have one flavor profile enabled, and since this command was run on a desktop-type system, I have enabled the desktop flavor. This enables a variety of settings, primarily USE flags, suitable for desktop systems.

You'll also see that I have a couple of mix-ins enabled. In Funtoo Linux, you can have zero or more mix-ins enabled -- I have gnome enabled, which sets various settings that are optimal for the use of the GNOME desktop environment, and then I am also using the hardened mix-in, since I have set up a so-called "hardened" system with various protections against malicious attacks.

   Tip

Funtoo Linux now [enhanced Media mix-ins] to help you easily get the level of media support you want for your system.

Then there's a list of automatically-enabled profiles. This shows you any profiles that are pulled in by the main profiles and mix-ins that are already enabled. As you can see, the print, X, audio, dvd, media and console-extras have been enabled, likely by the desktop flavor.

For now, it is not necessary to get too deep into profiles, but if you are creating a desktop system, I suggest you set the desktop flavor. To do this, type eselect profile list and find the number to the left of funtoo/1.0/linux-gnu/flavor/desktop. Then, type the following command as the root user:

root # eselect profile set-flavor 99

(Replace "99" with the number from the list)

You will now have the desktop flavor set for your system. Type eselect profile show to see your new settings.

Updating your system

Sometimes, you may want to update the packages on your system. Often, this is done after you run emerge --sync, which will grab Portage tree updates from the main Funtoo Linux Portage tree:

root # emerge --sync

>>> Starting git pull...
remote: Counting objects: 1791, done.        
remote: Compressing objects: 100% (206/206), done.        
remote: Total 980 (delta 811), reused 931 (delta 764)        
Receiving objects: 100% (980/980), 185.04 KiB, done.
Resolving deltas: 100% (811/811), completed with 754 local objects.
From git://github.com/funtoo/experimental-mini-2011
   7a17140..b836bc8  funtoo.org -> origin/funtoo.org
Updating 7a17140..b836bc8
Fast-forward
>>> Git pull in /usr/portage successful

 * IMPORTANT: 1 news items need reading for repository 'gentoo'.
 * Use eselect news to read news items.

root # 

You may also want to update your system after you have changed USE flag settings. To take advantage of the USE flags you have just enabled, it's necessary to recompile everything that includes them.

Below, you'll find a recommended emerge command for updating your entire system. The -a option will cause emerge to prompt you for confirmation before starting the merge:

root # emerge -auDN world

-u tells emerge to update any already-installed but out-of-date packages that we specify on the command-line. The -D option tells emerge to perform a deep dependency tree graph, so it will include sub-dependencies of packages that we have specified on the command line as well. This allows emerge to perform as thorough an update of your system as possible.

The -N (--newuse) option tells Portage to check for any new USE flags that have been enabled or disabled, and rebuild packages so that all USE flags are set as currently defined in /etc/make.conf and /etc/portage/package.use.

world is a "meta-package" or "package set" which includes every package that you have manually installed plus all packages in the system set. It's important to note that whenever you ask emerge to install anything, such as metalog or vim, those packages will be automatically added to the world package set. In this way, emerge learns what packages you care about and want to keep updated. If you want to see what's in your world package set, take a look at /var/lib/portage/world:

root # cat /var/lib/portage/world
app-editors/vim
app-portage/eix
app-portage/gentoolkit
dev-vcs/git
net-misc/bridge-utils
net-misc/dhcpcd
net-misc/keychain
sys-apps/gptfdisk
sys-apps/pciutils
sys-devel/bc
sys-fs/reiserfsprogs
sys-kernel/vanilla-sources

Also note that some packages may have been added to the world set by Metro when your stage3 tarball was built.

Updating a few packages

If we simply wanted to rebuild a few packages to reflect updated USE flag settings, we could specify it instead of world. Be sure to include the -N option:

root # emerge -auDN vim emacs

Useful applications for daily usage

Here are some other packages you may want to consider installing via emerge:

app-misc/screen
Allows you to have persistent login sessions.
app-misc/tmux
Similar to screen -- some people prefer it.
app-admin/sudo
Grant root privileges to selected users and command combinations.
sys-process/htop
Colorful and informative text-based process list.
sys-process/glances
Similar to htop, includes disc I/O and network I/O in display.
app-portage/eix
Quick portage package search
app-portage/gentoolkit
Portage utils
app-misc/mc
GNU Midnight Commander is a text based file manager --- some will recall MS-DOS XtreeGold
app-text/wgetpaste
Command-line interface to various pastebins; very useful in providing info along with bugs reports
net-irc/irssi
A modular textUI IRC client with IPv6 support; a powerful tool to get help from Funtoo Community on IRC channel. Nice companion to app-text/wgetpaste
root # emerge --jobs app-misc/screen sudo htop eix gentoolkit app-misc/mc wgetpaste net-irc/irssi

Creating a user account

It's a good idea to create a normal user account that you can use for general Linux tasks. Before rebooting, create a user account for everyday use. Adjust the groups in the example below to match your needs. Some of them may not exist yet on your system. Replace "<user_name>" with the name you're going to use for your everyday user. The "-m" option instructs useradd to create a home directory for your user. See man useradd for more info.

root # useradd -m -g users -G audio,video,cdrom,wheel <user_name>

Don't forget to set a password for your new user:

root # passwd <user_name>

Installing a graphical environment

If you intend on using your Funtoo Linux installation for more than system administration, chances are you're going to want to have a GUI (graphical user interface). In the past, setting one up involved wading through text files and man pages. Thanks to modern tools like udev this is no longer the case.

Unlike most operating systems, Funtoo does not ship with a GUI pre-installed. If you've used Windows or Mac OS, you'd also know that their interfaces cannot be replaced easily. With Linux, the opposite is true -- you are free to choose from a huge selection of GUIs. From window managers such as Blackbox, IceWM, and xmonad, to fully-featured desktop environments like GNOME and KDE, the possibilities are vast in number.

The first step in setting up a graphical environment is to set up the X Window System. Then, you will be able to install the graphical environment of your choice. GNOME is a popular option for new users.