📜 ⬆️ ⬇️

Installing FreeBSD on a server at Hetzner.de



After the disappointment in Serverloft, the search for the provider was actively continued, and after long discussions it was decided to stop at hetzner.de. There are some minor flaws, but overall the reviews about it are very positive. Of course, the requirement for servers 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 skim through the wiki article - everything seems to be clear. So, the server was purchased, scripts were 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, many perversions and a happy ending are present :)

')


Step 1: Preparation


Let's start with what Hetzner officially announces 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 the EQ6 (Core i7, 12Gb RAM, 2x1.5 TB HDD) that worked on MS-7032. Therefore, everything should be fine. You can check 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 transfer the server to 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 on the Rescue tab, select the OS (in our case, FreeBSD) and make a difficult choice between 32 and 64 bit. When you click on "Activate Rescue system" the system will issue a password - you need to save it. Now you need to restart the server (in the panel: Reset -> Execute a automatic hardware-reset) in order for it to enter Rescue mode at boot.

So, the server rebooted. Log in with the user root and the password saved from the admin panel. We see the invitation:

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

Welcome to mfsBSD, the memory based FreeBSD distribution.


We got a server running the mfsBSD distribution on it - a minimalistic distribution that runs completely from RAM. It would seem that it remains to run sysinstall, bloopers and damasks ... But there is a small (frankly - big) problem - the 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 partitioning. For us, this means the following - in order to be able to install the system - FreeBSD slices must already be present on the hard drives and the disk must be pre-partitioned. Therefore, you have to do it manually.

Step 3: Hard Tin as It Is


We look, what disks we have:

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


ad4 and ad6. We will install at first - ad4.
First wipe the zero sector and write the information that the FreeBSD slice will occupy the entire disk:

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


Don't be afraid of the “Class not found” error, just ignore it. Now install the loader and make a label for the slice:

rescue# bsdlabel -wB /dev/ad4s1

Now we have to edit the file, which describes the layout of the disk. 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:

setenv EDITOR /usr/bin/ee

So, edit the file:

rescue# bsdlabel -e /dev/ad4s1

The file looks like this (initially):

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


I found it right (for my tasks) to split the disk as follows:

/ - 10G
swap - 4196M
/ tmp - 10G
/ var - 500G
/ usr - everything else

Accordingly, the configuration was as follows:

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


Each letter means a section (they are created in an “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 the markup.
Save the file and go back to the console. Now, according to these settings, you need to create file systems on the disk:

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

If you want to use SoftUpdates, then add the -U flag after newfs when creating the necessary partitions.

Terrible tsiferki run, and in the end we get a disk with the file system ufs2. It would seem - "cheers, give sysinstall"? But no, we already have a partition /, but it belongs to mfsBSD. But we need the installation to go to a freshly broken disk, and not to the 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, you need to create folders for them there:

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


And now mounti:

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

And only now you can run sysinstall.

Step 4: Sysinstall? Oh yeah!


In sysinstall, we select the Custom installation. In it, first of all, go to Options and change the path for the installation — the “Install Path” parameter — in our case, instead of / there, you must specify / mnt. Label and Partition should not be touched, we have already done everything there. In Distributions, select Minimal - I still do not understand why, but this is what hetzner recommends in the wilds of my wiki. Next, select Media — where to install the system — and here we will have a pleasant surprise: Hetzner has FreeBSD installation images on the internal NFS server. 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

Specifying the NFS partition, select the 7th item “Commit” and the installation begins. After the installation is complete, you need to exit sysinstall, but it is still too early to reboot into the finished system ...

Step 5: And 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

The first thing you need to do is edit / etc / fstab and put the disk partitioning into it, which we did earlier so that all partitions are mounted at the start. Based on the configuration I made, I got the following / etc / fstab:

/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


Then, you need to rewrite the default kernel to the right place, otherwise the system will not find it when booting:

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

Now we need to set the network settings. See ifconfig, what kind of network card / subnet mask / gateway we have and edit rc.conf:

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


Also, we probably want DNS to work on the server. To do this, create /etc/resolv.conf and add to it:

# DNS hetzner.de
nameserver 213.133.98.98
nameserver 213.133.99.99
nameserver 213.133.100.100


It would be nice to think about how we will log in to the system. There are two options:

Unix way:

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

Dummy way:

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

I also set the "UseDNS" parameter to "no" in / etc / ssh / sshd_config, since I am annoyed by the delay in login to the system.

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

passwd

All set up is complete. Now you need to exit the keyboard (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, in a few minutes our server will load, configured with FreeBSD.

Step 6: Bonus Track


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

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

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

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

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


Now we start sysinstall, in it Configure -> Fdisk -> ad6 (or that disk which we want to use under backups). We indicate to 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, you need to mount the partition every time the server boots, add an entry to / etc / fstab:

/dev/ad6s1d /backups ufs rw 1 1

And connect it:

mount -a

Now, in “df -h” you can admire a large section / backups and start setting up backups.

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

Source: https://habr.com/ru/post/91429/


All Articles