Difference between pages "Funtoo Profiles/sk" and "User:Pytony/Home Server Journey"

From Funtoo
(Difference between pages)
Jump to navigation Jump to search
(Created page with "Kedysi museli používateľia pridávať veľké množstvo nastavení do {{c|/etc/make.conf}}, aby si prispôsobili svoje Gentoo a Funtoo systémy, čo robilo na...")
 
(completed day 8)
 
Line 1: Line 1:
{{#widget:AddThis}}
== Home Server Journey ==
<languages/>
Táto stránka obsahuje informácie o systéme profilov vo Funtoo Linuxe -- ako fungujú, ktoré profily sú k dispozícii a ako používat [[#Using epro|{{c|epro}}]] na nastavenie a zmenu profilov.


== Typy profilov ==
=== Day 0 ===


Kedysi museli používateľia pridávať veľké množstvo nastavení do [[Make.conf|{{c|/etc/make.conf}}]], aby si prispôsobili svoje Gentoo a Funtoo systémy, čo robilo nastavenie operačného systému naročnejším, než by to malo byť. V Gentoo Linuxe je možné definovať iba jeden "systémový profil". Think of a system profile as the default settings that Portage uses for building everything on your system. Rather than a single profile, Funtoo Linux uses multiple sub-profiles, and moves many types of settings that are normally stored in {{c|/etc/make.conf}} into the profile system. The following profile types are available in Funtoo Linux:
I am thinking about setting up a local server that would mainly serve as a NAS but also provide some other services I could reach at home or from my office or anywhere else. I also would like to use it as a media center to bind any audio source (jack, bluetooth, inner storage, USB peripherals, network, ...) to the amplifier. Most services (especially those I'm not gonna be the only user) would be controllable via a mobile-friendly web interface.


{{TableStart}}
This is the base idea for this beginning journey. :)
{{2ColHead|Sub-Profile Type|Description}}
{{2Col|{{c|arch}}|Typically {{c|x86-32bit}} or {{c|x86-64bit}}, this defines the processor type and support of your system. This is defined when your stage was built and should not be changed.}}
{{2Col|{{c|build}}|Defines whether your system is a {{c|current}}, {{c|stable}} or {{c|experimental}} build. {{c|current}} systems will have newer packages unmasked than {{c|stable}} systems. This is defined when your stage is built and is typically not changed.}}
{{2Col|{{c|subarch}}|Defines CPU optimizations for your system. The subarch is set at the time the stage3 is built, but can be changed later to better settings if necessary. Be sure to pick a setting that is compatible with your CPU.}}
{{2Col|{{c|flavor}}|Defines the general type of system, such as {{c|server}} or {{c|desktop}}, and will set default USE flags appropriate for your needs.}}
{{2Col|{{c|mix-ins}}|Defines various optional settings that you may be interested in enabling.}}
{{TableEnd}}


{{Note|Flavors can (and often do) inherit settings from other flavors and mix-ins. Mix-ins can also inherit settings from other mix-ins. For example, {{c|X}} is inherited by {{c|gnome}}. The {{c|epro}} tool will show both as being enabled so there are no surprises.}}
=== Day 1 ===


=== Using epro ===
Time to find the hardware... My main criteria were the price, the size of the case and power consumption. In order to satisfy these criteria I decided to look for a mini-ITX motherboard with integrated CPU and supplied through ATX. My other criteria for the motherboard were:


{{c|epro show}} will display the current profile settings on your system:
* At least 1 HDMI output (ideally 2)
{{console|body=
* At least 1 optical S/PDIF output
# ##i## epro show
* At least 4 SATA III ports (ideally 6)
* At least 1 Ethernet 1Gbps controller
* Ideally some PCI slots
* Ideally hardware RAID support
 
Originally, I chose the [http://www.asrock.com/mb/Intel/N3700-ITX/ ASRock N3700-ITX] but it was not in stock and procurement was unknown. I decided to wait but finally I found the [http://www.asrock.com/mb/Intel/N3150-ITX/ ASRock N3150-ITX] which was $30 cheaper and very close to my original choice. One thing I especially appreciated with these motherboards is that the processor is fanless, which I think is good for power consumption and silence.
 
For this kind of server I don't think RAM is essential so I just took 2×2GB [http://www.crucial.com/usa/en/ct25664bf160b Crucial CT25664BF160B].
 
For the storage, I first thought about 3 or 4 HDD in RAID 5 or 6. But I remembered my price criteria and decided to start with 1×2To HDD and add some more in the future. I chose [http://www.wdc.com/en/products/products.aspx?id=780 WD Green WD20EZRX] (mainly because there was $20 off as it was a reconditioned product).


=== ##g##Enabled Profiles##!g##: ===
I wanted a silent modular 350-450W power supply at least 80Plus Gold certified. The choice was quite limited and I found myself with a [http://www.corsair.com/en-us/cs-series-modular-cs450m-450-watt-80-plus-gold-certified-psu Corsair CS450M].


        arch: ##c## x86-64bit
Finally, I looked for a small case, ideally white in order to break with all that black furniture and stuff in my living room, and not ugly. My choice fell on a [http://www.coolermaster.com/case/mini-itx/elite-120-advanced-white/ Cooler Master Elite 120 Advanced white].
      build: ##c## current
    subarch: ##c## intel64-haswell
      flavor: ##c## desktop
    mix-ins: ##c## gnome


=== Day 2 ===


=== ##g##All inherited flavors from desktop flavor##!g##: ===
My excitation when I received all that stuff quickly dissipated when I realized the stand-off screws were missing in the case. Without them I was unable to set up the motherboard.


                    ##c##workstation##!c## (from desktop flavor)
=== Day 3 ===
                            ##c##core##!c## (from workstation flavor)
                        ##c##minimal##!c## (from core flavor)


=== ##g##All inherited mix-ins from desktop flavor##!g##: ===
A week later I received the missing screws I had requested. Still I could assemble my server. I originally planned a fanless system, but I noticed there were two fans in the case, so I plugged them, just in case.


                              ##c##X##!c## (from workstation flavor)
The first time I turned on the computer, nothing happened. :( When checking again the cable connections, I noticed I plugged the system panel header on the COM port header by mistake while I rearranged the cables in the case. Fortunately this didn't damage any component, and everything worked fine the second time I turned on the computer.
                          ##c##audio##!c## (from workstation flavor)
                            ##c##dvd##!c## (from workstation flavor)
                          ##c##media##!c## (from workstation flavor)
      ##c##mediadevice-audio-consumer##!c## (from media mix-in)
                ##c##mediadevice-base##!c## (from mediadevice-audio-consumer mix-in)
      ##c##mediadevice-video-consumer##!c## (from media mix-in)
                ##c##mediadevice-base##!c## (from mediadevice-video-consumer mix-in)
        ##c##mediaformat-audio-common##!c## (from media mix-in)
          ##c##mediaformat-gfx-common##!c## (from media mix-in)
        ##c##mediaformat-video-common##!c## (from media mix-in)
                  ##c##console-extras##!c## (from workstation flavor)
                          ##c##print##!c## (from desktop flavor)
}}
To view all available sub-profile settings, use {{c|epro list}}:
{{console|body=# ##i## epro list}}
Enabled profiles will be highlighted in cyan. Directly enabled profiles will be in bold and have an asterisk {{c|*}} appended. Sub-profiles enabled via inheritance will be highlighted.


==== Usage Examples ====
=== Day 4 ===


{{TableStart}}
Now it's time to install the best GNU/Linux distribution in the world: Funtoo. =)
{{2Col|Add the mix-ins {{c|gnome}} and {{c|kde}}|{{console|body=# ##i## epro mix-ins +gnome +kde}}}}
{{2Col|Remove a mix-in, for example {{c|gnome}}|{{console|body=# ##i## epro mix-ins -gnome}}}}
{{2Col|Change the profile arch to x86-64bit|{{console|body=# ##i## epro arch x86-64bit}}}}
{{2Col|Change the subarch to {{c|generic_64}}|{{console|body=# ##i## epro subarch generic_64}}}}
{{2Col|Change the system flavor|{{console|body=# ##i## epro flavor desktop}}}}
{{2Col|Get JSON output of profile settings|{{console|body=# ##i## epro show-json}}}}
{{2Col|Get current sub-profile setting in text form|{{console|body=# ##i## epro get [profiletype]}}}}
{{TableEnd}}


== Flavors ==
I wanted to try ZFS and build my own initramfs for the first time. But I also wanted to get it working as soon as possible. So I decided to stick with the [[ZFS Install Guide]] and use genkernel to configure the kernel and initramfs. Knowing that this doesn't prevent me from building alternate kernel/initramfs later.


A system can have only one flavor profile enabled at a time. The following flavors are available:
Bleh, got a kernel panic after reboot. =( I think there is a couple of things I've done wrong:


{{TableStart}}
* I didn't boot sysresccd via UEFI, though I partitioned my disk using `gdisk`
{{2ColHead|Flavor|Description}}
* I didn't care about this warning "''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.''"
<tr><td>{{c|minimal}}</td><td>This contains the bare minimum settings for all Funtoo Linux flavors.</td></tr>
* I didn't care about this warning "''When booting into the ISO, Make sure that you select the "Alternate 64 bit kernel (altker64)".''".
<tr><td>{{c|core}}</td><td>The core flavor includes the minimal flavor, plus reasonable settings, and is used for the [[Funtoo_Linux_Installation#Installing_the_Stage_3_tarball|official stage3 downloads]].</td></tr>
<tr><td>{{c|server}}</td><td>In the future, the server flavor will include the core flavor, plus specific settings designed for servers. At the moment, it is equivalent to the core flavor.</td></tr>
<tr><td>{{c|workstation}}</td><td>The workstation flavor is a minimal desktop system. It includes the core flavor, plus these mix-ins: {{c|X}}, {{c|audio}}, {{c|dvd}}, {{c|media}} and {{c|console-extras}}.</td></tr>
<tr><td>{{c|desktop}}</td><td>The desktop flavor includes the common settings for any full-featured desktop system. It includes the {{c|workstation}} flavor plus {{c|printing}} support. The user is expected to further customize their system with a desktop environment of choice, such as KDE, GNOME, or XFCE, possibly by using a mix-in.</td></tr>
{{TableEnd}}


== Mix-ins ==
So let's try again with <code>funtoo-stable-hardened/pure64/generic_64-pure64</code> stage3 (nothing related to the kernel panic here, but I think this will be better than what I originally chose (<code>funtoo-current/pure64/intel64-silvermont-pure64</code>)).


A system can have any number of mix-ins enabled at a time. The following mix-ins are available:
And... it failed again. :) <code>grub-install: error: cannot find EFI directory</code>. I didn't to extensive researches about this error, I'm pretty sure this is due to something I've done wrong in the beginning. So I'm gonna start again. However I'll first try to do a "standard" installation. I thought about using LVM instead of ZFS (I also learned ZFS is a bit greedy in terms of RAM, so this is probably better anyway), but there is a couple of things that I am not used to: UEFI installation, initramfs, use of genkernel to build a kernel, ... I think the first thing to do is successfully building a system booting with UEFI.


{{TableStart}}
=== Day 5 ===
{{2ColHead|Mix-in|Description}}
{{2Col|{{c|audio}}|Enables core audio-related settings, currently related to ALSA.}}
{{2Col|{{c|console-extras}}|Enables things that are nice to have for console-only systems. Currently enabling gpm in USE.}}
{{2Col|{{c|dvd}}|USE settings related to optical drives -- CDR/DVD-ROM/RW use.}}
{{2Col|{{c|gnome}}|USE and package.use settings required to merge GNOME. Designed to be used with {{c|desktop}} or {{c|workstation}} flavor.}}
{{2Col|{{c|hardened}}|Enables hardened support.}}
{{2Col|{{c|kde}}|USE and package.use settings required to merge KDE. Designed to be used with {{c|desktop}} or {{c|workstation}} flavor.}}
{{2Col|{{c|media}}|USE settings related to audio/video media encoding. Can be for desktops or servers.}}
{{2Col|{{c|print}}|Enables printing capability.}}
{{2Col|{{c|vmware-guest}}|Settings related to using Funtoo Linux as a VMWare virtual machine guest.}}
{{2Col|{{c|X}}|Settings related to the X Window System and hardware support.}}
{{2Col|{{c|xfce}}|USE settings required for merging XFCE.}}
{{TableEnd}}


=== Media Device Mix-ins ===
OK, standard install worked with UEFI. I accidentally made <code>/boot</code> partition <code>ext2</code> instead of <code>vfat</code>, fortunately it was quite easy to fix afterwards. I think it's one of the mistakes I made in the previous installs. So let's try again taking especially care about UEFI things.


Media device mix-ins have been created to support media devices, including external and portable devices, and associated low-level hardware support and hardware-focused codecs. Media devices have been categorized into audio and video categories, and consumer and professional categories. "Consumer" devices are those devices that regular desktop users might typically use, while "professional" devices are those that professionals, hobbyists or enthusiasts would typically use. Here are the new mix-ins for media devices:
I made a 500MB EFI partition and all space left for ZFS:


{{TableStart}}
{{console|body=
{{2ColHead|Media Device Mix-in|Description}}
Disk /dev/sda: 3907029168 sectors, 1.8 TiB
<tr><td>{{c|mediadevice-base}}</td><td>Common, universally-supported media devices, like IEEE-1394 (Firewire), CDDA, CDIO. Other mediadevice mix-ins have this as a parent.</td></tr>
Logical sector size: 512 bytes
<tr><td>{{c|mediadevice-audio-consumer}}</td><td>Consumer audio devices, such as personal portable media players (iOS, iPod, etc.)</td></tr>
Disk identifier (GUID): E2066145-69F3-46DD-8329-6DC3D3094EB2
<tr><td>{{c|mediadevice-audio-pro}}</td><td>Pro audio support, such as JACK.</td></tr>
Partition table holds up to 128 entries
<tr><td>{{c|mediadevice-video-consumer}}</td><td>Consumer video support, such as DVD, Blu Ray, V4L</td></tr>
First usable sector is 34, last usable sector is 3907029134
<tr><td>{{c|mediadevice-video-pro}}</td><td>Pro video support, such as dv, dc1394.</td></tr>
Partitions will be aligned on 2048-sector boundaries
{{TableEnd}}
Total free space is 2014 sectors (1007.0 KiB)


=== Media Format Mix-ins ===
Number  Start (sector)    End (sector)  Size      Code  Name
  1            2048        1026047  500.0 MiB  EF00  EFI System
  2        1026048      3907029134  1.8 TiB    BF00  Solaris root
}}


Media format mix-ins have been created to support media formats for reading, writing, encoding and decoding images, audio and video. They have been organized into a "common" collection, for popular formats, and an "extra" collection, which is intended to include "everything else". Let's look at the new mix-ins:
And here is how I partitioned the system:


{{TableStart}}
{{console|body=
{{2ColHead|Media Format Mix-in|Description}}
root@sysresccd /root % mkfs.vfat -F 32 /dev/sda1
<tr><td>{{c|mediaformat-video-common}}</td><td>Common (ie. popular) video formats.</td></tr>
mkfs.fat 3.0.22 (2013-07-19)
<tr><td>{{c|mediaformat-video-extra}}</td><td>More esoteric video formats.</td></tr>
root@sysresccd /root % zpool create -f -o ashift=12 -o cachefile=/tmp/zpool.cache -O normalization=formD -m none -R /mnt/funtoo toast /dev/sda2
<tr><td>{{c|mediaformat-audio-common}}</td><td>Common (ie. popular) audio formats.</td></tr>
root@sysresccd /root % zfs create -p toast/funtoo
<tr><td>{{c|mediaformat-audio-extra}}</td><td>More esoteric audio formats.</td></tr>
root@sysresccd /root % cd /mnt
<tr><td>{{c|mediaformat-gfx-common}}</td><td>Common (ie. popular) graphics formats.</td></tr>
root@sysresccd /mnt % zfs create -o mountpoint=/ toast/funtoo/root
<tr><td>{{c|mediaformat-gfx-extra}}</td><td>More esoteric graphics formats.</td></tr>
root@sysresccd /mnt % zfs create -o mountpoint=/home toast/funtoo/home
{{TableEnd}}
root@sysresccd /mnt % zfs create toast/swap -V 8G -b 4K
root@sysresccd /mnt % mkswap /dev/toast/swap
Setting up swapspace version 1, size = 8388604 KiB
no label, UUID=dffed32f-f0f0-4e9c-b405-9a82b1e30805
root@sysresccd /mnt % swapon /dev/toast/swap
root@sysresccd /mnt % zfs create -o mountpoint=/opt toast/funtoo/opt
root@sysresccd /mnt % zfs create -o mountpoint=/usr toast/funtoo/usr
root@sysresccd /mnt % zfs create -o mountpoint=/var toast/funtoo/var
root@sysresccd /mnt % zfs create -o mountpoint=/tmp toast/funtoo/tmp
root@sysresccd /mnt % zfs create -o mountpoint=/var/tmp toast/funtoo/var/tmp
root@sysresccd /mnt % zfs create -o mountpoint=/var/portage/distfiles toast/funtoo/var/portage-distfiles
root@sysresccd /mnt % zfs create -o mountpoint=/var/portage/packages toast/funtoo/var/portage-packages
root@sysresccd /mnt % cd funtoo
root@sysresccd /mnt/funtoo % chmod 1777 var/tmp
root@sysresccd /mnt/funtoo % chmod 1777 tmp
}}


=== How to Use Media Mix-Ins ===
Obivously, not to forget the fstab:


Our existing {{c|media}} mix-in still exists, and is still pulled in by the {{c|desktop}} and {{c|workstation}} flavors automatically. It now includes the following parent mix-ins:
{{file|name=/etc/fstab|desc= |body=
# <fs>                  <mountpoint>    <type>          <opts>          <dump/pass>


* {{c|mediadevice-audio-consumer}}
/dev/sda1              /boot          vfat            defaults        0 2
* {{c|mediadevice-video-consumer}}
/dev/zvol/toast/swap    none            swap            defaults        0 0
* {{c|mediaformat-audio-common}}
}}
* {{c|mediaformat-gfx-common}}
* {{c|mediaformat-video-common}}


In addition, there is a new {{c|media-pro}} mix-in which needs to be enabled manually, which pulls in the following mix-ins:
And still kept <code>funtoo-stable-hardened/pure64/generic_64-pure64</code> build.


* {{c|mediadevice-audio-pro}}
Let's run <code>emerge -uDN --with-bdeps=y @world && genkernel kernel --no-clean --no-mountboot && emerge zfs</code> and go to sleep. :)
* {{c|mediadevice-video-pro}}


So typically, you would enable the {{c|desktop}} or {{c|workstation}} flavor, and if you need professional hardware support, you'd also enable the {{c|media-pro}} mix-in. If you needed any additional media formats support, you could enable one or more of the {{c|mediaformat-*-extra}} mix-ins to add the formats you needed. Of course, it's possible to enable only the specific mix-ins you need, and also complement these mix-ins with specific USE variable settings you might require.
=== Day 6 ===


=== How Profile Settings are Stored ===
Reboot... And... it worked :D Except that I forgot to setup my keymap and I had to type my password in qwerty while my keyboard is azerty. :P


Funtoo Linux stores its profile settings in the {{f|/etc/portage/make.profile/parent}} file. Typically, users don't need to modify this file, instead using {{c|ego}} and {{c|epro}} to make changes, but it can be handy to take a look at what the contents of the file look like. A simple server might have profile settings as follows:
I ran into troubles installing samba server. I didn't know if I should user <code>security = user</code> or <code>security = share</code>. Default was <code>user</code> (as well as most docs) but all docs mentioned <code>smbpasswd</code> utility to create new users, which was not provided by portage. Using <code>share</code> I could use smbclient to login but was unable to mount CIFS partitions. Finally, I figured out <code>security=share</code> was deprecated, so I duckducked "gentoo smbpassword" and found I had to use <code>pdbedit</code> rather than <code>smbpasswd</code>. Now it works fine.
{{file|name=/etc/portage/make.profile/parent|body=
 
gentoo:funtoo/1.0/linux-gnu/arch/x86-64bit
=== Day 7 ===
gentoo:funtoo/1.0/linux-gnu/build/current
 
gentoo:funtoo/1.0/linux-gnu/flavor/core
Today I tried to figure out how to control the fans. Unfortunately I could not find how to set fan speed from <code>sysfs</code>. On my other computer, I can do it within <code>/sys/class/hwmon/hwmon3/pwm[1-3]</code>. Unfortunately I have no such file available on the sysfs of my server. Maybe a missing configuration in the kernel, but this is the default debian-sources configuration. I would rather say my motherboard do not provide such interface to the OS. In the BIOS, I can configure the fans speed (from level 1 to level 9) but not turn them off. :/
}}
 
Profile settings for a desktop might look like this:
I monitored the temperature in normal usage and full CPU usage. With both fans at lowest speed level, the CPUs temperature stays between 30 and 40°C. When running a compilation that requires all processors working at 100%, the temperature rarely raises above 50°C. So I think I can remove both fans. I will try to do so, and keep monitoring the temperature.
{{file|name=/etc/portage/make.profile/parent|body=
 
gentoo:funtoo/1.0/linux-gnu/arch/x86-64bit
=== Day 8 ===
gentoo:funtoo/1.0/linux-gnu/build/current
 
gentoo:funtoo/1.0/linux-gnu/flavor/desktop
Time to get interested in ZFS properties... Oops, I just noticed I created datasets for <code>/var/portage/{distfiles,packages}</code> rather than <code>/usr/portage/{distfiles,packages}</code>.
gentoo:funtoo/1.0/linux-gnu/mix-ins/dvd
gentoo:funtoo/1.0/linux-gnu/mix-ins/media
}}
== History and Origins ==


This new system is really a completion of the original cascading profile design that was co-designed by Daniel Robbins and Seemant Kulleen and implemented by Seemant Kulleen as part of Portage. Funtoo Profiles designed to leverage the existing cascading profile system and provide something much more useable and maintainable for users and developers alike. Here are some of its benefits:
Let's change this :


* Fewer settings in <code>/etc/make.conf</code>. <code>CHOST</code> and <code>ARCH</code> no longer set in <code>/etc/make.conf</code>.
{{console|body=
* Separation of concerns -- arch, build, and flavor-related settings are organized together.
###i## zfs rename toast/funtoo/var/portage-distfiles toast/funtoo/usr/portage-distfiles
* User flexibility - any number of mix-ins can be enabled to tweak masks or USE settings as needed.
###i## zfs rename toast/funtoo/var/portage-packages toast/funtoo/usr/portage-packages
###i## zfs set mountpoint=/usr/portage/packages toast/funtoo/usr/portage-packages
###i## zfs set mountpoint=/usr/portage/distfiles toast/funtoo/usr/portage-distfiles
cannot mount '/usr/portage/distfiles': directory is not empty
property may be set but unable to remount filesystem
###i## mkdir /tmp/usr-portage-distfiles
###i## mv /usr/portage/distfiles/* /tmp/usr-portage-distfiles
###i## zfs mount toast/funtoo/usr/portage-distfiles
###i## mv /tmp/usr-portage-distfiles/* /usr/portage/distfiles
###i## zfs list
NAME                                USED  AVAIL  REFER  MOUNTPOINT
toast                              21.0G  1.76T  136K  none
toast/funtoo                        12.5G  1.76T  136K  none
toast/funtoo/home                    248K  1.76T  248K  /home
toast/funtoo/opt                    136K  1.76T  136K  /opt
toast/funtoo/root                    250M  1.76T  250M  /
toast/funtoo/tmp                    160K  1.76T  160K  /tmp
toast/funtoo/usr                    12.2G  1.76T  12.2G  /usr
toast/funtoo/usr/portage-distfiles  136K  1.76T  136K  /usr/portage/distfiles
toast/funtoo/usr/portage-packages    136K  1.76T  136K  /usr/portage/packages
toast/funtoo/var                    76.2M  1.76T  69.3M  /var
toast/funtoo/var/tmp                6.84M  1.76T  6.84M  /var/tmp
toast/swap                          8.50G  1.77T  1.32G  -
}}


{{note|See [[Custom Profiles]] for information on how to extend the profile system.}}
I also noticed there is a way to share datasets through samba. I tried to set up this feature but I couldn't get it work. I also ran into troubles trying to set default file mode to 0660 and directory mode to 0770 on samba shared folders. My personal station keeps creating files with mode 0640 and directories with mode 0750. This is really annoying that group does not have write access on a shared folder and setting <code>umask</code> in my zshrc is not satisfying either. I tried to setup ACL on the shared folder, but I can't get ACL working on the client side. I think I'll have to learn more about ACL and try again later.
[[Category:Funtoo features]]
[[Category:Portage]]
[[Category:HOWTO]]
[[Category:Official Documentation]]

Latest revision as of 17:14, September 13, 2015

Home Server Journey

Day 0

I am thinking about setting up a local server that would mainly serve as a NAS but also provide some other services I could reach at home or from my office or anywhere else. I also would like to use it as a media center to bind any audio source (jack, bluetooth, inner storage, USB peripherals, network, ...) to the amplifier. Most services (especially those I'm not gonna be the only user) would be controllable via a mobile-friendly web interface.

This is the base idea for this beginning journey. :)

Day 1

Time to find the hardware... My main criteria were the price, the size of the case and power consumption. In order to satisfy these criteria I decided to look for a mini-ITX motherboard with integrated CPU and supplied through ATX. My other criteria for the motherboard were:

  • At least 1 HDMI output (ideally 2)
  • At least 1 optical S/PDIF output
  • At least 4 SATA III ports (ideally 6)
  • At least 1 Ethernet 1Gbps controller
  • Ideally some PCI slots
  • Ideally hardware RAID support

Originally, I chose the ASRock N3700-ITX but it was not in stock and procurement was unknown. I decided to wait but finally I found the ASRock N3150-ITX which was $30 cheaper and very close to my original choice. One thing I especially appreciated with these motherboards is that the processor is fanless, which I think is good for power consumption and silence.

For this kind of server I don't think RAM is essential so I just took 2×2GB Crucial CT25664BF160B.

For the storage, I first thought about 3 or 4 HDD in RAID 5 or 6. But I remembered my price criteria and decided to start with 1×2To HDD and add some more in the future. I chose WD Green WD20EZRX (mainly because there was $20 off as it was a reconditioned product).

I wanted a silent modular 350-450W power supply at least 80Plus Gold certified. The choice was quite limited and I found myself with a Corsair CS450M.

Finally, I looked for a small case, ideally white in order to break with all that black furniture and stuff in my living room, and not ugly. My choice fell on a Cooler Master Elite 120 Advanced white.

Day 2

My excitation when I received all that stuff quickly dissipated when I realized the stand-off screws were missing in the case. Without them I was unable to set up the motherboard.

Day 3

A week later I received the missing screws I had requested. Still I could assemble my server. I originally planned a fanless system, but I noticed there were two fans in the case, so I plugged them, just in case.

The first time I turned on the computer, nothing happened. :( When checking again the cable connections, I noticed I plugged the system panel header on the COM port header by mistake while I rearranged the cables in the case. Fortunately this didn't damage any component, and everything worked fine the second time I turned on the computer.

Day 4

Now it's time to install the best GNU/Linux distribution in the world: Funtoo. =)

I wanted to try ZFS and build my own initramfs for the first time. But I also wanted to get it working as soon as possible. So I decided to stick with the ZFS Install Guide and use genkernel to configure the kernel and initramfs. Knowing that this doesn't prevent me from building alternate kernel/initramfs later.

Bleh, got a kernel panic after reboot. =( I think there is a couple of things I've done wrong:

  • I didn't boot sysresccd via UEFI, though I partitioned my disk using `gdisk`
  • I didn't care about this warning "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."
  • I didn't care about this warning "When booting into the ISO, Make sure that you select the "Alternate 64 bit kernel (altker64)".".

So let's try again with funtoo-stable-hardened/pure64/generic_64-pure64 stage3 (nothing related to the kernel panic here, but I think this will be better than what I originally chose (funtoo-current/pure64/intel64-silvermont-pure64)).

And... it failed again. :) grub-install: error: cannot find EFI directory. I didn't to extensive researches about this error, I'm pretty sure this is due to something I've done wrong in the beginning. So I'm gonna start again. However I'll first try to do a "standard" installation. I thought about using LVM instead of ZFS (I also learned ZFS is a bit greedy in terms of RAM, so this is probably better anyway), but there is a couple of things that I am not used to: UEFI installation, initramfs, use of genkernel to build a kernel, ... I think the first thing to do is successfully building a system booting with UEFI.

Day 5

OK, standard install worked with UEFI. I accidentally made /boot partition ext2 instead of vfat, fortunately it was quite easy to fix afterwards. I think it's one of the mistakes I made in the previous installs. So let's try again taking especially care about UEFI things.

I made a 500MB EFI partition and all space left for ZFS:

Disk /dev/sda: 3907029168 sectors, 1.8 TiB
Logical sector size: 512 bytes
Disk identifier (GUID): E2066145-69F3-46DD-8329-6DC3D3094EB2
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 3907029134
Partitions will be aligned on 2048-sector boundaries
Total free space is 2014 sectors (1007.0 KiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048         1026047   500.0 MiB   EF00  EFI System
   2         1026048      3907029134   1.8 TiB     BF00  Solaris root

And here is how I partitioned the system:

root@sysresccd /root % mkfs.vfat -F 32 /dev/sda1
mkfs.fat 3.0.22 (2013-07-19)
root@sysresccd /root % zpool create -f -o ashift=12 -o cachefile=/tmp/zpool.cache -O normalization=formD -m none -R /mnt/funtoo toast /dev/sda2
root@sysresccd /root % zfs create -p toast/funtoo
root@sysresccd /root % cd /mnt
root@sysresccd /mnt % zfs create -o mountpoint=/ toast/funtoo/root
root@sysresccd /mnt % zfs create -o mountpoint=/home toast/funtoo/home
root@sysresccd /mnt % zfs create toast/swap -V 8G -b 4K
root@sysresccd /mnt % mkswap /dev/toast/swap
Setting up swapspace version 1, size = 8388604 KiB
no label, UUID=dffed32f-f0f0-4e9c-b405-9a82b1e30805
root@sysresccd /mnt % swapon /dev/toast/swap
root@sysresccd /mnt % zfs create -o mountpoint=/opt toast/funtoo/opt
root@sysresccd /mnt % zfs create -o mountpoint=/usr toast/funtoo/usr
root@sysresccd /mnt % zfs create -o mountpoint=/var toast/funtoo/var
root@sysresccd /mnt % zfs create -o mountpoint=/tmp toast/funtoo/tmp
root@sysresccd /mnt % zfs create -o mountpoint=/var/tmp toast/funtoo/var/tmp
root@sysresccd /mnt % zfs create -o mountpoint=/var/portage/distfiles toast/funtoo/var/portage-distfiles
root@sysresccd /mnt % zfs create -o mountpoint=/var/portage/packages toast/funtoo/var/portage-packages
root@sysresccd /mnt % cd funtoo
root@sysresccd /mnt/funtoo % chmod 1777 var/tmp
root@sysresccd /mnt/funtoo % chmod 1777 tmp

Obivously, not to forget the fstab:

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

/dev/sda1               /boot           vfat            defaults        0 2
/dev/zvol/toast/swap    none            swap            defaults        0 0

And still kept funtoo-stable-hardened/pure64/generic_64-pure64 build.

Let's run emerge -uDN --with-bdeps=y @world && genkernel kernel --no-clean --no-mountboot && emerge zfs and go to sleep. :)

Day 6

Reboot... And... it worked :D Except that I forgot to setup my keymap and I had to type my password in qwerty while my keyboard is azerty. :P

I ran into troubles installing samba server. I didn't know if I should user security = user or security = share. Default was user (as well as most docs) but all docs mentioned smbpasswd utility to create new users, which was not provided by portage. Using share I could use smbclient to login but was unable to mount CIFS partitions. Finally, I figured out security=share was deprecated, so I duckducked "gentoo smbpassword" and found I had to use pdbedit rather than smbpasswd. Now it works fine.

Day 7

Today I tried to figure out how to control the fans. Unfortunately I could not find how to set fan speed from sysfs. On my other computer, I can do it within /sys/class/hwmon/hwmon3/pwm[1-3]. Unfortunately I have no such file available on the sysfs of my server. Maybe a missing configuration in the kernel, but this is the default debian-sources configuration. I would rather say my motherboard do not provide such interface to the OS. In the BIOS, I can configure the fans speed (from level 1 to level 9) but not turn them off. :/

I monitored the temperature in normal usage and full CPU usage. With both fans at lowest speed level, the CPUs temperature stays between 30 and 40°C. When running a compilation that requires all processors working at 100%, the temperature rarely raises above 50°C. So I think I can remove both fans. I will try to do so, and keep monitoring the temperature.

Day 8

Time to get interested in ZFS properties... Oops, I just noticed I created datasets for /var/portage/{distfiles,packages} rather than /usr/portage/{distfiles,packages}.

Let's change this :

root # zfs rename toast/funtoo/var/portage-distfiles toast/funtoo/usr/portage-distfiles
root # zfs rename toast/funtoo/var/portage-packages toast/funtoo/usr/portage-packages
root # zfs set mountpoint=/usr/portage/packages toast/funtoo/usr/portage-packages
root # zfs set mountpoint=/usr/portage/distfiles toast/funtoo/usr/portage-distfiles
cannot mount '/usr/portage/distfiles': directory is not empty
property may be set but unable to remount filesystem
root # mkdir /tmp/usr-portage-distfiles
root # mv /usr/portage/distfiles/* /tmp/usr-portage-distfiles
root # zfs mount toast/funtoo/usr/portage-distfiles
root # mv /tmp/usr-portage-distfiles/* /usr/portage/distfiles
root # zfs list
NAME                                 USED  AVAIL  REFER  MOUNTPOINT
toast                               21.0G  1.76T   136K  none
toast/funtoo                        12.5G  1.76T   136K  none
toast/funtoo/home                    248K  1.76T   248K  /home
toast/funtoo/opt                     136K  1.76T   136K  /opt
toast/funtoo/root                    250M  1.76T   250M  /
toast/funtoo/tmp                     160K  1.76T   160K  /tmp
toast/funtoo/usr                    12.2G  1.76T  12.2G  /usr
toast/funtoo/usr/portage-distfiles   136K  1.76T   136K  /usr/portage/distfiles
toast/funtoo/usr/portage-packages    136K  1.76T   136K  /usr/portage/packages
toast/funtoo/var                    76.2M  1.76T  69.3M  /var
toast/funtoo/var/tmp                6.84M  1.76T  6.84M  /var/tmp
toast/swap                          8.50G  1.77T  1.32G  -

I also noticed there is a way to share datasets through samba. I tried to set up this feature but I couldn't get it work. I also ran into troubles trying to set default file mode to 0660 and directory mode to 0770 on samba shared folders. My personal station keeps creating files with mode 0640 and directories with mode 0750. This is really annoying that group does not have write access on a shared folder and setting umask in my zshrc is not satisfying either. I tried to setup ACL on the shared folder, but I can't get ACL working on the client side. I think I'll have to learn more about ACL and try again later.