Difference between pages "ZFS Install Guide" and "Install/ru/Partitioning"

(Difference between pages)
(Add filesystems to /etc/fstab)
 
(Подготовка жесткого диска)
 
Line 1: Line 1:
== Introduction ==
+
<noinclude>
 +
{{InstallPart|процесс разбиения диска и создания файловых систем}}
 +
</noinclude>
 +
=== Подготовка жесткого диска ===
  
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.
+
В этой части  мы научимся различным способам установки Funtoo Linux -- и загрузки с -- жесткого диска.
  
=== 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:
+
В прежние времена существовал лишь один способ загрузить PC-совместимый компьютер. Все наши дектопы и сервера имели стандартный PC BIOS, все наши харды использовали MBR и были разбиты используя схему разбивки MBR.  Вот как это все было и нам это нравилось!
  
* 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.
+
Затем появились EFI и UEFI, встроенные программы нового образца наряду со схемой разбивки GPT, поддерживающая диски размером более 2.2TБ. Неожиданно, нам стали доступны различные способы установки и загрузки Линукс систем . То, что было единым методом, стало чем-то более сложным.
  
* 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.
+
Воспользуемся моментом и рассмотрим доступные способы конфигурации жесткого диска для загрузки Funtoo Linux. Данное Руководство рекомендует способ "по-старинке" , загрузка BIOS и использование MBR. Данный способ работает (за исключением редких случаев) и всесторонне поддерживается. И в этом нет ничего плохого. Если Ваш жесткий диск 2TБ или меньшего размера это не является препятствием для использования всего дискового пространства.
  
* 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.
+
Но, бывают ситуации когда метод "по-старинке"  не является оптимальным. Если Ваш жесткий диск размером более 2TБ , MBR разбивка не сможет обеспечить доступ ко всему дисковому пространству.  Это одна из причин.  Вторая причина: существуют  "PC" системы, которые более не поддерживают  BIOS загрузку  и  форсируют UEFI загрузку. Из чувства сострадания к тем, кто попал в затруднение перед выбором, это Руководство также описывает установку и загрузку UEFI систем.
  
* ZFS has the ZFS Intent Log and SLOG devices, which accelerates small synchronous write performance.
+
Мы всё же рекомендуем разбивку "по-старинке". Загрузчик, который мы используем для загрузки Линукс в этом руководстве называется GRUB,  таки образом мы называем метод '''BIOS + GRUB (MBR)''' . Это традиционный способ установки на PC-совместимые компьютеры.
  
* 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.
+
Если Вам необходимо ипользвание UEFI для загрузки, мы советуем не использовать MBR вообще, ввиду того, что некоторые системы поддерживают MBR,  некоторые нет. Вместо, мы советуем использование UEFI  для загрузки GRUB, который, затем в свою очередь загрузит Линукс. Мы называем этот  метод как '''UEFI + GRUB (GPT)'''.
  
* 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.
+
И да, есть еще несколько способов, некоторые из них задокументированы в [[Boot Methods]] . Обычно мы рекомендуем  '''BIOS + GRUB (GPT)''' метод но он ограничивается не столь широкой поддержкой со стороны комплектующих.
  
* 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.
+
;Принцип 1 - "По-старинке": , то Вы используете BIOS,  и скорее всего Вы можете загрузить Funtoo Linux используя BIOS. Итак,  следуйте этому способу и используйте BIOS загрузку,  кроме случаев Вам по-какой либо причине необходим UEFI, например если размер жесткого диска >2.2TБ. В этом случае следуйте Принцип  2.
  
* ZFS datasets have a hierarchical namespace while btrfs subvolumes have a flat namespace.
+
;Принцип 2 - "Модерн":  Если Вы можете успешно загрузить System Rescue CD и видите черно-белое меню -- поздравления,  Ваша система поддерживает UEFI загрузку. Это значит, что Вы готовы установить Funtoo Linux к загрузке с помощью UEFI.  Ваша система также может поддерживать загрузку BIOS,  но попрбуйте UEFI для начала. Вы можете "покопаться" в настройках BIOS.
  
* 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.
+
;What's the Big Difference between Old School and New School?: Here's the deal. If you go with old-school MBR partitions, your <code>/boot</code> partition will be an ext2 filesystem, and you'll use <code>fdisk</code> to create your MBR partitions. If you go with new-school GPT partitions and UEFI booting, your <code>/boot</code> partition will be a vfat filesystem, because this is what UEFI is able to read, and you will use <code>gdisk</code> to create your GPT partitions. And you'll install GRUB a bit differently. That's about all it comes down to, in case you were curious.
  
The only area where btrfs is ahead of ZFS is in the area of small file
+
;Also Note: To install Funtoo Linux to boot via the New School UEFI method, you must boot System Rescue CD using UEFI -- and see an initial black and white screen. Otherwise, UEFI will not be active and you will not be able to set it up!
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]].
+
{{Note|'''Some motherboards may appear to support UEFI, but don't.''' Do your research. For example, the Award BIOS in my Gigabyte GA-990FXA-UD7 rev 1.1 has an option to enable UEFI boot for CD/DVD. '''This is not sufficient for enabling UEFI boot for hard drives and installing Funtoo Linux.''' UEFI must be supported for both removable media (so you can boot System Rescue CD using UEFI) as well as fixed media (so you can boot your new Funtoo Linux installation.) It turns out that later revisions of this board (rev 3.0) have a new BIOS that fully supports UEFI boot.  This may point to a third principle -- know thy hardware.}}
  
=== Disclaimers ===
+
==== Old-School (BIOS/MBR) Method ====
  
{{fancywarning|This guide is a work in progress. Expect some quirks.}}
+
{{Note|Use this method if you are booting using your BIOS, and if your System Rescue CD initial boot menu was light blue. If you're going to use the new-school method, [[#New-School (UEFI/GPT) Method|click here to jump down to UEFI/GPT.]]}}
{{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>
+
===== Preparation =====
Name: sysresccd-4.2.0_zfs_0.6.2.iso  (545 MB)
+
Release Date: 2014-02-25
+
md5sum 01f4e6929247d54db77ab7be4d156d85
+
</pre>
+
  
 
+
First, it's a good idea to make sure that you've found the correct hard disk to partition. Try this command and verify that <code>/dev/sda</code> is the disk that you want to partition:
'''[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>
 
<console>
Make a temporary directory
+
# ##i##fdisk -l /dev/sda
# ##i##mkdir /tmp/loop
+
  
Mount the iso
+
Disk /dev/sda: 640.1 GB, 640135028736 bytes, 1250263728 sectors
# ##i##mount -o ro,loop /root/sysresccd-4.2.0_zfs_0.6.2.iso /tmp/loop
+
Units = sectors of 1 * 512 = 512 bytes
 +
Sector size (logical/physical): 512 bytes / 512 bytes
 +
I/O size (minimum/optimal): 512 bytes / 512 bytes
 +
Disk label type: gpt
  
Run the usb installer
+
 
# ##i##/tmp/loop/usb_inst.sh
+
#         Start          End    Size  Type            Name
 +
1        2048  1250263694  596.2G  Linux filesyste Linux filesystem
 
</console>
 
</console>
  
That should be all you need to do to get your flash drive working.
+
Now, it's recommended that you erase any existing MBR or GPT partition tables on the disk, which could confuse the system's BIOS at boot time. We do this using <code>sgdisk</code>:
 +
{{fancywarning|This will make any existing partitions inaccessible! You are '''strongly''' cautioned and advised to backup any critical data before proceeding.}}
  
== Booting the ISO ==
+
<console>
 +
# ##i##sgdisk --zap-all /dev/sda
  
{{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 new GPT entries.
 +
GPT data structures destroyed! You may now partition the disk using fdisk or
 +
other utilities.
 +
</console>
  
== Creating partitions ==
+
This output is also nothing to worry about, as the command still succeded:
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.
+
<console>
 +
***************************************************************
 +
Found invalid GPT and valid MBR; converting MBR to GPT format
 +
in memory.
 +
***************************************************************
 +
</console>
  
==== gdisk (GPT Style) ====
+
===== Partitioning =====
  
'''A Fresh Start''':
+
Now we will use <code>fdisk</code> to create the MBR partition table and partitions:
 
+
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>
 
<console>
# ##i##sgdisk -Z /dev/sda
+
# ##i##fdisk /dev/sda
 
</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.}}
+
Within <code>fdisk</code>, follow these steps:
  
Now that we have a clean drive, we will create the new layout.
+
'''Empty the partition table''':
 
+
First open up the application:
+
  
 
<console>
 
<console>
# ##i##gdisk /dev/sda
+
Command (m for help): ##i##o ↵
 
</console>
 
</console>
  
 
'''Create Partition 1''' (boot):
 
'''Create Partition 1''' (boot):
 +
 
<console>
 
<console>
Command: ##i##n ↵
+
Command (m for help): ##i##n ↵
Partition Number: ##i##↵
+
Partition type (default p): ##i##↵
 +
Partition number (1-4, default 1): ##i##↵
 
First sector: ##i##↵
 
First sector: ##i##↵
Last sector: ##i##+250M ↵
+
Last sector: ##i##+128M
Hex Code: ##i##
+
 
</console>
 
</console>
  
'''Create Partition 2''' (BIOS Boot Partition):
+
'''Create Partition 2''' (swap):
<console>Command: ##i##n ↵
+
Partition Number: ##i##↵
+
First sector: ##i##↵
+
Last sector: ##i##+32M ↵
+
Hex Code: ##i##EF02 ↵
+
</console>
+
  
'''Create Partition 3''' (ZFS):
+
<console>
<console>Command: ##i##n ↵
+
Command (m for help): ##i##n ↵
Partition Number: ##i##↵
+
Partition type (default p): ##i##↵
 +
Partition number (2-4, default 2): ##i##↵
 
First sector: ##i##↵
 
First sector: ##i##↵
Last sector: ##i##↵
+
Last sector: ##i##+2G
Hex Code: ##i##bf00
+
Command (m for help): ##i##t ↵  
 
+
Partition number (1,2, default 2): ##i## ↵
Command: ##i##p
+
Hex code (type L to list all codes): ##i##82
 
+
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
+
 
</console>
 
</console>
  
 
+
'''Create the root partition:'''
=== Format your /boot partition ===
+
  
 
<console>
 
<console>
# ##i##mkfs.ext2 -m 1 /dev/sda1
+
Command (m for help): ##i##n ↵
 +
Partition type (default p): ##i##
 +
Partition number (3,4, default 3): ##i##↵
 +
First sector: ##i##↵
 +
Last sector: ##i##↵
 
</console>
 
</console>
  
=== Create the zpool ===
+
'''Verify the partition table:'''
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 ===
+
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>
 
<console>
Create some empty containers for organization purposes, and make the dataset that will hold /
+
Command (m for help): ##i##p
# ##i##zfs create -p tank/funtoo
+
# ##i##zfs create -o mountpoint=/ tank/funtoo/root
+
  
Optional, but recommended datasets: /home
+
Disk /dev/sda: 298.1 GiB, 320072933376 bytes, 625142448 sectors
# ##i##zfs create -o mountpoint=/home tank/funtoo/home
+
Units: sectors of 1 * 512 = 512 bytes
 +
Sector size (logical/physical): 512 bytes / 512 bytes
 +
I/O size (minimum/optimal): 512 bytes / 512 bytes
 +
Disklabel type: dos
 +
Disk identifier: 0x82abc9a6
  
Optional datasets: /usr/src, /usr/portage/{distfiles,packages}
+
Device    Boot    Start      End    Blocks  Id System
# ##i##zfs create -o mountpoint=/usr/src tank/funtoo/src
+
/dev/sda1          2048    264191    131072  83 Linux
# ##i##zfs create -o mountpoint=/usr/portage -o compression=off tank/funtoo/portage
+
/dev/sda2        264192  4458495  2097152  82 Linux swap / Solaris
# ##i##zfs create -o mountpoint=/usr/portage/distfiles tank/funtoo/portage/distfiles
+
/dev/sda3        4458496 625142447 310341976  83 Linux
# ##i##zfs create -o mountpoint=/usr/portage/packages tank/funtoo/portage/packages
+
 
</console>
 
</console>
  
== Installing Funtoo ==
+
'''Write the parition table to disk:'''
 
+
=== Pre-Chroot ===
+
  
 
<console>
 
<console>
Go into the directory that you will chroot into
+
Command (m for help): ##i##w
# ##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 ...]]
+
Your new MBR partition table will now be written to your system disk.
  
Once you've extracted the stage3, do a few more preparations and chroot into your new funtoo environment:
+
{{Note|You're done with partitioning! Now, jump over to [[#Creating filesystems|Creating filesystems]].}}
  
<console>
+
==== New-School (UEFI/GPT) Method ====
Bind the kernel related directories
+
# ##i##mount -t proc none proc
+
# ##i##mount --rbind /dev dev
+
# ##i##mount --rbind /sys sys
+
  
Copy network settings
+
{{Note|Use this method if you are booting using UEFI, and if your System Rescue CD initial boot menu was black and white. If it was light blue, this method will not work.}}
# ##i##cp -f /etc/resolv.conf etc
+
  
Make the zfs folder in 'etc' and copy your zpool.cache
+
The <tt>gdisk</tt> commands to create a GPT partition table are as follows. Adapt sizes as necessary, although these defaults will work for most users. Start <code>gdisk</code>:
# ##i##mkdir etc/zfs
+
# ##i##cp /etc/zfs/zpool.cache etc/zfs
+
  
Chroot into Funtoo
 
# ##i##env -i HOME=/root TERM=$TERM chroot . bash -l
 
</console>
 
 
=== In Chroot ===
 
Sync your tree
 
 
<console>
 
<console>
# ##i##emerge --sync
+
# ##i##gdisk
 
</console>
 
</console>
  
=== Add filesystems to /etc/fstab ===
+
Within <tt>gdisk</tt>, follow these steps:
  
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.
+
'''Create a new empty partition table''' (This ''will'' erase all data on the disk when saved):
 
+
Edit <code>/etc/fstab</code>:
+
 
+
{{file|name=/etc/fstab|desc= |body=
+
# <fs>                  <mountpoint>    <type>          <opts>          <dump/pass>
+
 
+
/dev/sda1              /boot          ext2            defaults        0 2
+
}}
+
 
+
== 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
+
Command: ##i##o ↵
 +
This option deletes all partitions and creates a new protective MBR.
 +
Proceed? (Y/N): ##i##y ↵
 
</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.
+
'''Create Partition 1''' (boot):
  
 
<console>
 
<console>
# ##i##zpool status
+
Command: ##i##n ↵
# ##i##zfs list
+
Partition Number: ##i##1 ↵
 +
First sector: ##i##↵
 +
Last sector: ##i##+500M ↵
 +
Hex Code: ##i##
 
</console>
 
</console>
  
If everything worked, continue.
+
'''Create Partition 2''' (swap):
  
== Create the initramfs ==
 
=== genkernel ===
 
Install genkernel and run it:
 
 
<console>
 
<console>
# ##i##emerge genkernel
+
Command: ##i##n ↵
 
+
Partition Number: ##i##2 ↵
You only need to add --luks if you used encryption
+
First sector: ##i##↵
# ##i##genkernel --zfs --luks initramfs
+
Last sector: ##i##+4G ↵
 +
Hex Code: ##i##8200 ↵
 
</console>
 
</console>
  
== Installing & Configuring the Bootloader ==
+
'''Create Partition 3''' (root):
  
=== GRUB 2  ===
 
 
<console>
 
<console>
# ##i##emerge grub
+
Command: ##i##n ↵
 +
Partition Number: ##i##3 ↵
 +
First sector: ##i##↵
 +
Last sector: ##i##↵##!i## (for rest of disk)
 +
Hex Code: ##i##
 
</console>
 
</console>
  
Now install grub to the drive itself (not a partition):
+
Along the way, you can type "<tt>p</tt>" and hit Enter to view your current partition table. If you make a mistake, you can type "<tt>d</tt>" to delete an existing partition that you created. When you are satisfied with your partition setup, type "<tt>w</tt>" to write your configuration to disk:
 +
 
 +
'''Write Partition Table To Disk''':
 +
 
 
<console>
 
<console>
# ##i##grub-install /dev/sda
+
Command: ##i##w ↵
 +
Do you want to proceed? (Y/N): ##i##Y ↵
 
</console>
 
</console>
  
=== boot-update ===
+
The partition table will now be written to disk and <tt>gdisk</tt> will close.
boot-update comes as a dependency of grub2, so if you already installed grub, it's already on your system!
+
  
==== Genkernel ====
+
Now, your GPT/GUID partitions have been created, and will show up as the following ''block devices'' under Linux:
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>/dev/sda1</tt>, which will be used to hold the <tt>/boot</tt> filesystem,
"Funtoo ZFS" {
+
* <tt>/dev/sda2</tt>, which will be used for swap space, and
        kernel kernel[-v]
+
* <tt>/dev/sda3</tt>, which will hold your root filesystem.
        initrd initramfs-genkernel-x86_64[-v]
+
        params real_root=ZFS=tank/funtoo/root
+
        params += dozfs=force
+
}
+
}}
+
  
After editing /etc/boot.conf, you just need to run boot-update to update grub.cfg
+
==== Creating filesystems ====
  
<console>
+
{{Note|This section covers both BIOS ''and'' UEFI installs. Don't skip it!}}
###i## boot-update
+
</console>
+
  
== Final configuration ==
+
Before your newly-created partitions can be used, the block devices need to be initialized with filesystem ''metadata''. This process is known as ''creating a filesystem'' on the block devices. After filesystems are created on the block devices, they can be mounted and used to store files.
=== Add the zfs tools to openrc ===
+
<console># ##i##rc-update add zfs boot</console>
+
  
=== Clean up and reboot ===
+
Let's keep this simple. Are you using old-school MBR partitions? If so, let's create an ext2 filesystem on /dev/sda1:
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##mkfs.ext2 /dev/sda1
# ##i##cd /
+
</console>
# ##i##rm stage3-latest.tar.xz
+
  
Set your root password
+
If you're using new-school GPT partitions for UEFI, you'll want to create a vfat filesystem on /dev/sda1, because this is what UEFI is able to read:
# ##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
+
<console>
# ##i##exit
+
# ##i##mkfs.vfat -F 32 /dev/sda1
 +
</console>
  
Unmount all the kernel filesystem stuff and boot (if you have a separate /boot)
+
Now, let's create a swap partition. This partition will be used as disk-based virtual memory for your Funtoo Linux system.
# ##i##umount -l proc dev sys boot
+
  
Turn off the swap
+
You will not create a filesystem on your swap partition, since it is not used to store files. But it is necessary to initialize it using the <code>mkswap</code> command. Then we'll run the <code>swapon</code> command to make your newly-initialized swap space immediately active within the live CD environment, in case it is needed during the rest of the install process:
# ##i##swapoff /dev/zvol/tank/swap
+
  
Export the zpool
+
<console>
# ##i##cd /
+
# ##i##mkswap /dev/sda2
# ##i##zpool export tank
+
# ##i##swapon /dev/sda2
 
+
Reboot
+
# ##i##reboot
+
 
</console>
 
</console>
  
{{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.'''}}
+
Now, we need to create a root filesystem. This is where Funtoo Linux will live. We generally recommend ext4 or XFS root filesystems. If you're not sure, choose ext4. Here's how to create a root ext4 filesystem:
  
and that should be enough to get your system to boot on ZFS.
+
<console>
 
+
# ##i##mkfs.ext4 /dev/sda3
== After reboot ==
+
</console>
  
=== Forgot to reset password? ===
+
...and here's how to create an XFS root filesystem, if you choose to use XFS:
==== 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##mkfs.xfs /dev/sda3
# ##i##chroot /mnt/funtoo bash -l
+
# ##i##passwd
+
# ##i##exit
+
# ##i##zpool export -f tank
+
# ##i##reboot
+
 
</console>
 
</console>
  
=== Create initial ZFS Snapshot ===
+
Your filesystems (and swap) have all now been initialized, so that that can be mounted (attached to your existing directory heirarchy) and used to store files. We are ready to begin installing Funtoo Linux on these brand-new filesystems.
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:
+
{{fancywarning|1=
<console># ##i##zfs snapshot -r tank@install</console>
+
When deploying an OpenVZ host, please use ext4 exclusively. The Parallels development team tests extensively with ext4, and modern versions of <code>openvz-rhel6-stable</code> are '''not''' compatible with XFS, and you may experience kernel bugs.
 +
}}
  
To see if your snapshot was taken, type:
+
==== Mounting filesystems ====
<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):
+
Mount the newly-created filesystems as follows, creating <code>/mnt/funtoo</code> as the installation mount point:
<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.'''}}
+
<console>
 +
# ##i##mkdir /mnt/funtoo
 +
# ##i##mount /dev/sda3 /mnt/funtoo
 +
# ##i##mkdir /mnt/funtoo/boot
 +
# ##i##mount /dev/sda1 /mnt/funtoo/boot
 +
</console>
  
== Troubleshooting ==
+
Optionally, if you have a separate filesystem for <code>/home</code> or anything else:
 
+
=== 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:
+
  
 
<console>
 
<console>
Destroy the pool and any snapshots and datasets it has
+
# ##i##mkdir /mnt/funtoo/home
# ##i##zpool destroy -R -f tank
+
# ##i##mount /dev/sda4 /mnt/funtoo/home
 
+
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>
 
</console>
  
Now start the guide again :).
+
If you have <code>/tmp</code> or <code>/var/tmp</code> on a separate filesystem, be sure to change the permissions of the mount point to be globally-writeable after mounting, as follows:
  
[[Category:HOWTO]]
+
<console>
[[Category:Filesystems]]
+
# ##i##chmod 1777 /mnt/funtoo/tmp
[[Category:Featured]]
+
</console>
[[Category:Install]]
+
 
+
__NOTITLE__
+

Revision as of 16:32, January 6, 2015


Note

This is a template that is used as part of the Installation instructions which covers: процесс разбиения диска и создания файловых систем. Templates are being used to allow multiple variant install guides that use most of the same re-usable parts.


Подготовка жесткого диска

В этой части мы научимся различным способам установки Funtoo Linux -- и загрузки с -- жесткого диска.

Введение

В прежние времена существовал лишь один способ загрузить PC-совместимый компьютер. Все наши дектопы и сервера имели стандартный PC BIOS, все наши харды использовали MBR и были разбиты используя схему разбивки MBR. Вот как это все было и нам это нравилось!

Затем появились EFI и UEFI, встроенные программы нового образца наряду со схемой разбивки GPT, поддерживающая диски размером более 2.2TБ. Неожиданно, нам стали доступны различные способы установки и загрузки Линукс систем . То, что было единым методом, стало чем-то более сложным.

Воспользуемся моментом и рассмотрим доступные способы конфигурации жесткого диска для загрузки Funtoo Linux. Данное Руководство рекомендует способ "по-старинке" , загрузка BIOS и использование MBR. Данный способ работает (за исключением редких случаев) и всесторонне поддерживается. И в этом нет ничего плохого. Если Ваш жесткий диск 2TБ или меньшего размера это не является препятствием для использования всего дискового пространства.

Но, бывают ситуации когда метод "по-старинке" не является оптимальным. Если Ваш жесткий диск размером более 2TБ , MBR разбивка не сможет обеспечить доступ ко всему дисковому пространству. Это одна из причин. Вторая причина: существуют "PC" системы, которые более не поддерживают BIOS загрузку и форсируют UEFI загрузку. Из чувства сострадания к тем, кто попал в затруднение перед выбором, это Руководство также описывает установку и загрузку UEFI систем.

Мы всё же рекомендуем разбивку "по-старинке". Загрузчик, который мы используем для загрузки Линукс в этом руководстве называется GRUB, таки образом мы называем метод BIOS + GRUB (MBR) . Это традиционный способ установки на PC-совместимые компьютеры.

Если Вам необходимо ипользвание UEFI для загрузки, мы советуем не использовать MBR вообще, ввиду того, что некоторые системы поддерживают MBR, некоторые нет. Вместо, мы советуем использование UEFI для загрузки GRUB, который, затем в свою очередь загрузит Линукс. Мы называем этот метод как UEFI + GRUB (GPT).

И да, есть еще несколько способов, некоторые из них задокументированы в Boot Methods . Обычно мы рекомендуем BIOS + GRUB (GPT) метод но он ограничивается не столь широкой поддержкой со стороны комплектующих.

Вопрос -- какой из методов использовать? Вот как.

Принцип 1 - "По-старинке"
, то Вы используете BIOS, и скорее всего Вы можете загрузить Funtoo Linux используя BIOS. Итак, следуйте этому способу и используйте BIOS загрузку, кроме случаев Вам по-какой либо причине необходим UEFI, например если размер жесткого диска >2.2TБ. В этом случае следуйте Принцип 2.
Принцип 2 - "Модерн"
Если Вы можете успешно загрузить System Rescue CD и видите черно-белое меню -- поздравления, Ваша система поддерживает UEFI загрузку. Это значит, что Вы готовы установить Funtoo Linux к загрузке с помощью UEFI. Ваша система также может поддерживать загрузку BIOS, но попрбуйте UEFI для начала. Вы можете "покопаться" в настройках BIOS.
What's the Big Difference between Old School and New School?
Here's the deal. If you go with old-school MBR partitions, your /boot partition will be an ext2 filesystem, and you'll use fdisk to create your MBR partitions. If you go with new-school GPT partitions and UEFI booting, your /boot partition will be a vfat filesystem, because this is what UEFI is able to read, and you will use gdisk to create your GPT partitions. And you'll install GRUB a bit differently. That's about all it comes down to, in case you were curious.
Also Note
To install Funtoo Linux to boot via the New School UEFI method, you must boot System Rescue CD using UEFI -- and see an initial black and white screen. Otherwise, UEFI will not be active and you will not be able to set it up!
Note

Some motherboards may appear to support UEFI, but don't. Do your research. For example, the Award BIOS in my Gigabyte GA-990FXA-UD7 rev 1.1 has an option to enable UEFI boot for CD/DVD. This is not sufficient for enabling UEFI boot for hard drives and installing Funtoo Linux. UEFI must be supported for both removable media (so you can boot System Rescue CD using UEFI) as well as fixed media (so you can boot your new Funtoo Linux installation.) It turns out that later revisions of this board (rev 3.0) have a new BIOS that fully supports UEFI boot. This may point to a third principle -- know thy hardware.

Old-School (BIOS/MBR) Method

Note

Use this method if you are booting using your BIOS, and if your System Rescue CD initial boot menu was light blue. If you're going to use the new-school method, click here to jump down to UEFI/GPT.

Preparation

First, it's a good idea to make sure that you've found the correct hard disk to partition. Try this command and verify that /dev/sda is the disk that you want to partition:

# fdisk -l /dev/sda

Disk /dev/sda: 640.1 GB, 640135028736 bytes, 1250263728 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: gpt


#         Start          End    Size  Type            Name
 1         2048   1250263694  596.2G  Linux filesyste Linux filesystem

Now, it's recommended that you erase any existing MBR or GPT partition tables on the disk, which could confuse the system's BIOS at boot time. We do this using sgdisk:

Warning

This will make any existing partitions inaccessible! You are strongly cautioned and advised to backup any critical data before proceeding.

# sgdisk --zap-all /dev/sda

Creating new GPT entries.
GPT data structures destroyed! You may now partition the disk using fdisk or
other utilities.

This output is also nothing to worry about, as the command still succeded:

***************************************************************
Found invalid GPT and valid MBR; converting MBR to GPT format
in memory. 
***************************************************************
Partitioning

Now we will use fdisk to create the MBR partition table and partitions:

# fdisk /dev/sda

Within fdisk, follow these steps:

Empty the partition table:

Command (m for help): o ↵

Create Partition 1 (boot):

Command (m for help): n ↵
Partition type (default p): 
Partition number (1-4, default 1): 
First sector: 
Last sector: +128M ↵

Create Partition 2 (swap):

Command (m for help): n ↵
Partition type (default p): 
Partition number (2-4, default 2): 
First sector: 
Last sector: +2G ↵
Command (m for help): t ↵ 
Partition number (1,2, default 2): 
Hex code (type L to list all codes): 82 ↵

Create the root partition:

Command (m for help): n ↵
Partition type (default p): 
Partition number (3,4, default 3): 
First sector: 
Last sector: 

Verify the partition table:

Command (m for help): p

Disk /dev/sda: 298.1 GiB, 320072933376 bytes, 625142448 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x82abc9a6

Device    Boot     Start       End    Blocks  Id System
/dev/sda1           2048    264191    131072  83 Linux
/dev/sda2         264192   4458495   2097152  82 Linux swap / Solaris
/dev/sda3        4458496 625142447 310341976  83 Linux

Write the parition table to disk:

Command (m for help): w

Your new MBR partition table will now be written to your system disk.

Note

You're done with partitioning! Now, jump over to Creating filesystems.

New-School (UEFI/GPT) Method

Note

Use this method if you are booting using UEFI, and if your System Rescue CD initial boot menu was black and white. If it was light blue, this method will not work.

The gdisk commands to create a GPT partition table are as follows. Adapt sizes as necessary, although these defaults will work for most users. Start gdisk:

# gdisk

Within gdisk, follow these steps:

Create a new empty partition table (This will erase all data on the disk when saved):

Command: o ↵
This option deletes all partitions and creates a new protective MBR.
Proceed? (Y/N): y ↵

Create Partition 1 (boot):

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

Create Partition 2 (swap):

Command: n ↵
Partition Number: 2 ↵
First sector: 
Last sector: +4G ↵
Hex Code: 8200 ↵

Create Partition 3 (root):

Command: n ↵
Partition Number: 3 ↵
First sector: 
Last sector:  (for rest of disk)
Hex Code: 

Along the way, you can type "p" and hit Enter to view your current partition table. If you make a mistake, you can type "d" to delete an existing partition that you created. When you are satisfied with your partition setup, type "w" to write your configuration to disk:

Write Partition Table To Disk:

Command: w ↵
Do you want to proceed? (Y/N): Y ↵

The partition table will now be written to disk and gdisk will close.

Now, your GPT/GUID partitions have been created, and will show up as the following block devices under Linux:

  • /dev/sda1, which will be used to hold the /boot filesystem,
  • /dev/sda2, which will be used for swap space, and
  • /dev/sda3, which will hold your root filesystem.

Creating filesystems

Note

This section covers both BIOS and UEFI installs. Don't skip it!

Before your newly-created partitions can be used, the block devices need to be initialized with filesystem metadata. This process is known as creating a filesystem on the block devices. After filesystems are created on the block devices, they can be mounted and used to store files.

Let's keep this simple. Are you using old-school MBR partitions? If so, let's create an ext2 filesystem on /dev/sda1:

# mkfs.ext2 /dev/sda1

If you're using new-school GPT partitions for UEFI, you'll want to create a vfat filesystem on /dev/sda1, because this is what UEFI is able to read:

# mkfs.vfat -F 32 /dev/sda1

Now, let's create a swap partition. This partition will be used as disk-based virtual memory for your Funtoo Linux system.

You will not create a filesystem on your swap partition, since it is not used to store files. But it is necessary to initialize it using the mkswap command. Then we'll run the swapon command to make your newly-initialized swap space immediately active within the live CD environment, in case it is needed during the rest of the install process:

# mkswap /dev/sda2
# swapon /dev/sda2

Now, we need to create a root filesystem. This is where Funtoo Linux will live. We generally recommend ext4 or XFS root filesystems. If you're not sure, choose ext4. Here's how to create a root ext4 filesystem:

# mkfs.ext4 /dev/sda3

...and here's how to create an XFS root filesystem, if you choose to use XFS:

# mkfs.xfs /dev/sda3

Your filesystems (and swap) have all now been initialized, so that that can be mounted (attached to your existing directory heirarchy) and used to store files. We are ready to begin installing Funtoo Linux on these brand-new filesystems.

Warning

When deploying an OpenVZ host, please use ext4 exclusively. The Parallels development team tests extensively with ext4, and modern versions of openvz-rhel6-stable are not compatible with XFS, and you may experience kernel bugs.

Mounting filesystems

Mount the newly-created filesystems as follows, creating /mnt/funtoo as the installation mount point:

# mkdir /mnt/funtoo
# mount /dev/sda3 /mnt/funtoo
# mkdir /mnt/funtoo/boot
# mount /dev/sda1 /mnt/funtoo/boot

Optionally, if you have a separate filesystem for /home or anything else:

# mkdir /mnt/funtoo/home
# mount /dev/sda4 /mnt/funtoo/home

If you have /tmp or /var/tmp on a separate filesystem, be sure to change the permissions of the mount point to be globally-writeable after mounting, as follows:

# chmod 1777 /mnt/funtoo/tmp