Difference between revisions of "User:Pytony/Home Server Journey"

From Funtoo
Jump to: navigation, search
(Started day 8)
(Day 8)
Line 135: Line 135:
###i## zfs rename toast/funtoo/var/portage-distfiles toast/funtoo/usr/portage-distfiles
###i## zfs rename toast/funtoo/var/portage-distfiles toast/funtoo/usr/portage-distfiles
###i## zfs rename toast/funtoo/var/portage-packages toast/funtoo/usr/portage-packages
###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
###i## zfs set mountpoint=/usr/portage/distfiles toast/funtoo/usr/portage-distfiles
cannot mount '/usr/portage/distfiles': directory is not empty
cannot mount '/usr/portage/distfiles': directory is not empty
property may be set but unable to remount filesystem
property may be set but unable to remount filesystem
###i## zfs set mountpoint=/usr/portage/packages toast/funtoo/usr/portage-packages
###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
###i## zfs list
NAME                                USED  AVAIL  REFER  MOUNTPOINT
NAME                                USED  AVAIL  REFER  MOUNTPOINT

Revision as of 13:37, September 12, 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:

# <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  -