Installing FreeBSD on a server in Hetzner.de



    After disappointment in Serverloft, the search for the provider was actively continued, and after much discussion it was decided to stop at hetzner.de. There are minor flaws, but overall reviews about it are very positive. Of course, the server requirement was the same - the ability to install FreeBSD. Officially, Hetzner does not support the automatic installation of FreeBSD, but the respected% username% suggested that they have a wiki article on installing FreeBSD using their Rescue system. I skimmed through the wiki article - everything seems to be clear. So, the server is purchased, scripts are prepared for the deployment of everything and everything, but ... It turned out that not everything is so simple ...

    Spoiler for those who are too lazy to read completely: there is no negative in the post, there are a lot of distortions and a happy ending :)




    Step 1: Preparation


    To begin with, what Hetzner officially declares to us - FreeBSD has been successfully tested on the following servers: EQ4, EQ6, EQ9, provided that they work on the following chipsets:

    * MSI K9AG Neo2 (MS-7368)
    * MSI K8T Neo2 - F (MS -7032)
    * MSI K8MM3-V (MS-7181)
    * MSI KA780G (MS-7551)
    * MSI K9NBPM2-FID (MS-7252)

    Operation of this OS on other servers is not guaranteed. I took EQ6 (Core i7, 12Gb RAM, 2x1.5 TB HDD), which worked on MS-7032. Therefore, everything should be fine. You can verify this case from under any pre-installed Linux using dmidecode:

    # dmidecode | grep-A 3 "DMI type 1,"
    Handle 0x0001, DMI type 1, 25 bytes
    System Information
    Manufacturer: MSI
    Product Name: MS-7032
    #


    Step 2: Save! ..


    First of all, you need to put the server in Rescue mode. To do this, log in to the control panel ( https://robot.your-server.de/server ), select Main functions -> Servers, click on the desired server in the list, and select the OS on the Rescue tab (in our case FreeBSD) and make a difficult choice between 32 and 64 bit. When you click on "Activate Rescue system", the system will generate a password - you need to save it. Now you need to restart the server (in the panel: Reset -> Execute a automatic hardware-reset) so that it enters Rescue mode at boot time.

    So, the server rebooted. We go with the root user and password saved from the admin panel. We see an invitation: We got a server with the mfsBSD distribution running on it

    FreeBSD 8.0-STABLE (GENERIC) #1: Tue Mar 9 12:36:22 UTC 2010

    Welcome to mfsBSD, the memory based FreeBSD distribution.


    - A minimalist distribution that works completely from RAM. It would seem - it remains to run sysinstall, tyap blunders and into the ladies ... But there is a small (frankly speaking, a big) problem - sysinstall in mfsBSD does not load in the early stages of init with the necessary flags, which means it does not have access to disk layout. For us, this means the following - in order to be able to install the system - FreeBSD'sh slices should already be present on the hard disks and the disk must be pre-marked. Therefore, you have to do it manually.

    Step 3: Hard Tin as it is


    We look at what drives we have: ad4 and ad6. We will install on the first - ad4. First, we wipe the zero sector and write information that the FreeBSD slice will occupy the entire disk: Do not be afraid of the “Class not found” error, just ignore it. Now install the bootloader and make a label for the slice: Now we have to edit the file that describes the disk layout. The file will open in the default editor - vi. If you are not very friendly with him, you can switch, for example, to the ee editor: So, we edit the file: The file looks like this (initially): I found it correct (for my tasks) to partition the disk as follows: / - 10G swap - 4196M / tmp - 10G / var - 500G

    rescue# ls /dev/ad*
    /dev/ad4 /dev/ad4s1 /dev/ad4s1a /dev/ad4s1b /dev/ad6 /dev/ad6s1 /dev/ad6s2 /dev/ad6s3
    rescue#





    rescue# fdisk -BI /dev/ad4
    ******* Working on device /dev/ad4 *******
    fdisk: Class not found
    rescue#




    rescue# bsdlabel -wB /dev/ad4s1



    setenv EDITOR /usr/bin/ee



    rescue# bsdlabel -e /dev/ad4s1



    # /dev/ad4s1:
    8 partitions:
    # size offset fstype [fsize bsize bps/cpg]
    a: 2930277089 16 unused 0 0
    c: 2930277105 0 unused 0 0 # "raw" part, don't edit








    / usr - everything else

    Accordingly, the configuration was as follows: Each letter means a partition (they are created in the "alphabetical" order, that is, "a" will be physically closer to the beginning of the disk than "b"). Please note that the value “c:” is missing. If I remember correctly, it is reserved for the partition table itself and cannot be used in markup. Save the file and return back to the console. Now, according to these settings, you need to create file systems on the disk: If you want to use SoftUpdates, add the -U flag after newfs when creating the necessary partitions.

    # /dev/ad6s1:
    8 partitions:
    # size offset fstype [fsize bsize bps/cpg]
    a: 10G 16 4.2BSD 0 0
    b: 4196M * swap 0 0
    d: 10G * 4.2BSD 0 0
    e: 500G * 4.2BSD 0 0
    f: * * 4.2BSD 0 0





    newfs /dev/ad4s1a
    newfs /dev/ad4s1b
    newfs /dev/ad4s1d
    newfs /dev/ad4s1e
    newfs /dev/ad4s1f



    Scary tsiferki will run, and in the end we will get a disk with the ufs2 file system. It would seem - "cheers, give sysinstall"? But no, we already have a / partition, but it belongs to mfsBSD. And we need the installation to go to a freshly broken disk, and not to memory. The solution was found simple - mount the disk. Since we have already created the necessary partitions, we will mount them, say, in / mnt. To do this, create folders for them there: And now mount: And only now you can run sysinstall.

    mkdir /mnt/tmp
    mkdir /mnt/var
    mkdir /mnt/usr




    mount /dev/ad4s1a /mnt
    mount /dev/ad4s1d /mnt/tmp
    mount /dev/ad4s1e /mnt/var
    mount /dev/ad4s1f /mnt/usr



    Step 4: Sysinstall? Oh yeah!


    In sysinstall, we select Custom installation. In it, we first go to Options and change the installation path - the “Install Path” parameter - in our case, instead of / there, you need to specify / mnt. Label and Partition should not be touched, we have already done everything there. In Distributions, we select Minimal - I still don’t understand why, but so hetzner recommends it in the wilds of his wiki. Next, select Media - where to install the system from - and here we have a pleasant surprise: Hetzner has FreeBSD installation images on the internal NFS server. We select NFS and specify the address corresponding to the version we want to install:

    7.2-RELEASE - 32-bit - 213.133.99.100:/nfs/freebsd/7.2_32
    7.2-RELEASE - 64-bit - 213.133.99.100:/nfs/freebsd/7.2 _64
    7.3-RELEASE - 32-bit - 213.133.99.100:/nfs/freebsd/7.3_32
    7.3-RELEASE - 64-bit - 213.133.99.100:/nfs/freebsd/7.3_64
    8.0-RELEASE - 32-bit - 213.133.99.100:/nfs/freebsd/8.0_32
    8.0-RELEASE - 64-bit - 213.133.99.100: /nfs/freebsd/8.0_64

    After specifying the NFS partition, select the 7th item “Commit” and we begin the installation. After the installation is complete, you need to exit sysinstall, but it's too early to get into the finished system ...

    Step 5: Now the file ...


    Now you need to configure the installed OS.

    To do this, it is better to go to the file system of our OS:

    chroot /mnt

    First of all, you need to edit / etc / fstab and register the disk layout that we did before so that all partitions are mounted at startup. Based on the configuration I did, I got the following / etc / fstab: Then, we need to rewrite the default kernel to the right place, otherwise the system will not find it when loading: Now we need to set the network settings. We look ifconfig, what is our network card / subnet mask / gateway and edit rc.conf: Also, we probably want DNS to work on the server. To do this, create /etc/resolv.conf and add to it: It would be nice to think about how we will login to the system. There are two options:

    /dev/ad4s1a / ufs rw 1 1
    /dev/ad4s1b none swap sw 0 0
    /dev/ad4s1d /tmp ufs rw 1 1
    /dev/ad4s1e /var ufs rw 1 1
    /dev/ad4s1f /usr ufs rw 1 1




    cp -Rp /boot/GENERIC/* /boot/kernel/



    # Задаем хостнейм
    hostname="my.server.com"
    # Включаем SSH
    sshd_enable="YES"
    # Настраиваем сетевую карту re0
    ifconfig_re0="inet 1.1.1.1 netmask 255.255.255.0"
    # Настраиваем гейтвей
    defaultrouter="1.1.1.254"




    # DNS сервера hetzner.de
    nameserver 213.133.98.98
    nameserver 213.133.99.99
    nameserver 213.133.100.100




    Unix-way:

    Add the user to the system that will log in using adduser, and add it to the wheel group.

    Dummy-way:

    Allow root access via SSH (by default in FreeBSD, root cannot login remotely). To do this, set the "PermitRootLogin" parameter to "yes" in / etc / ssh / sshd_config.

    I also set / etc / ssh / sshd_config the UseDNS parameter to no, because I am annoyed by the delay when logging into the system.

    And finally, we change the root password to our own:

    passwd

    Everything, the configuration is completed. Now you need to exit the partition (Ctrl + D), unmount the partitions:

    umount /mnt/tmp
    umount /mnt/var
    umount /mnt/usr
    umount /mnt

    And restart the server:

    init 6

    If everything went well, after a few minutes our server will boot up with FreeBSD configured.

    Step 6: Bonus Track


    On the server that I installed there were two disks, during the installation I used only one. There are options with the second disk:

    1. Buy a hardware RAID controller and make RAID 1.
    2. Make software RAID 1.
    3. Use a second disk for backups.

    The first option does not change anything in this manual, you just need to buy a controller and assemble a raid before installation. The second option, having extensive experience with software raids and attempts to restore them, I found it useless. I implemented the third option, as follows:

    So that sysinstall can create partitions on the disk from under a running system, you need to change one parameter in sysctl (it changes dynamically):

    pluto# sysctl kern.geom.debugflags=16
    kern.geom.debugflags: 0 -> 16
    pluto#


    Now run sysinstall, in it Configure -> Fdisk -> ad6 (or the drive that we want to use for backups). Specify the slice to occupy the entire disk (A) and exit (Q). To the question about the bootloader we answer “Leave the Master Boot Record untouched”. Then we go to Label, create a partition (C), define a mount point for it (for example / backups), create a file system (W) and exit (Q).

    Of course, it is necessary that the partition is mounted at each server boot, add an entry in / etc / fstab:

    /dev/ad6s1d /backups ufs rw 1 1

    And connect it:

    mount -a

    Now, in “df -h” you can admire the large / backups partition and start configuring backups.

    PS When writing an article, Wiki Hetzner was used, and a couple of articles found in Google, however, they only helped to understand the direction - many of the described settings had to be recognized by the method of scientific poking. In principle, this material can be considered a step-by-step installation guide, after writing the article, I reinstalled my server again, copy-paste from this article - everything went smoothly.
    PPS Here is the end of the fairy tale, who scrolled - well done. Thanks for attention.

    Also popular now: