<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Jaspal Chauhan</title>
    <description>The latest articles on DEV Community by Jaspal Chauhan (@jaspalch).</description>
    <link>https://dev.to/jaspalch</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F579360%2F85b89fd3-8048-4e33-802a-4a8b2b820114.png</url>
      <title>DEV Community: Jaspal Chauhan</title>
      <link>https://dev.to/jaspalch</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jaspalch"/>
    <language>en</language>
    <item>
      <title>Building a Home Server [0]: Hardware, Linux Installation, and Initial Configuration</title>
      <dc:creator>Jaspal Chauhan</dc:creator>
      <pubDate>Tue, 16 Feb 2021 07:07:41 +0000</pubDate>
      <link>https://dev.to/jaspalch/building-a-home-server-0-hardware-linux-installation-and-initial-configuration-500i</link>
      <guid>https://dev.to/jaspalch/building-a-home-server-0-hardware-linux-installation-and-initial-configuration-500i</guid>
      <description>&lt;h1&gt;
  
  
  Intro
&lt;/h1&gt;

&lt;p&gt;Hi! In this series of posts, I'll bring you along on my journey to setup a home server. I intend to use this server for file sharing/backup, hosting &lt;code&gt;git&lt;/code&gt; repos, and various other services. The main applications I have in mind right now are Nextcloud, Gitlab, Pi-hole, and Prometheus/Grafana. Since I'm planning to run everything under Docker, it should be relatively easy to add more services on demand.&lt;/p&gt;

&lt;h1&gt;
  
  
  Hardware
&lt;/h1&gt;

&lt;p&gt;So...I have a bad habit of rebuilding my gaming PC somewhat often. However, this means I have a lot of spare parts for the server! &lt;/p&gt;

&lt;h2&gt;
  
  
  Parts List:
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;CPU:&lt;/strong&gt; AMD Ryzen 2700X&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CPU Cooler&lt;/strong&gt;: Noctua NH-D15 chromax.Black&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Motherboard:&lt;/strong&gt;: Asus ROG Strix X470-F&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;RAM:&lt;/strong&gt; 4x8GB G.SKILL Trident RGB DDR4-3000&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Boot Drive:&lt;/strong&gt; Samsung 980 PRO 500 GB NVMe SSD&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Storage Drives:&lt;/strong&gt; | 2x Seagate BarraCuda 8TB HDD (will be run in RAID 1)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Graphics Card:&lt;/strong&gt; EVGA GTX 1080 Reference (needed since no onboard CPU graphics)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Power Supply:&lt;/strong&gt; EVGA SuperNOVA G1 80+ GOLD 650W&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Case:&lt;/strong&gt; NZXT H500i&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Case Fans:&lt;/strong&gt; 2x be quiet! Silent Wings 3 140mm&lt;/p&gt;



&lt;p&gt;For my use case, consumer grade hardware should suffice. Also, I can't decide whether 8TB of storage is overkill or not enough! Guess we'll find out...&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg3l6pfeovrcv22igh4eg.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg3l6pfeovrcv22igh4eg.jpg" alt="drive cage" width="800" height="1066"&gt;&lt;/a&gt;Drive cage containing the two Seagate 8TB HDDs &lt;/p&gt;

&lt;p&gt;Assembling the server was straightforward aside from one minor hiccup with the fans. I had to replace one of the two 140mm fans on the CPU cooler with a 120 mm one since my RAM sticks were too tall. Damn those RGB heat spreaders! &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4ul3x91stsr7xvq26bus.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4ul3x91stsr7xvq26bus.jpg" alt="server" width="800" height="600"&gt;&lt;/a&gt;The server in all of its post-gaming glory&lt;/p&gt;

&lt;h1&gt;
  
  
  Initial Installation
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Linux Distribution
&lt;/h2&gt;

&lt;p&gt;I've chosen to use Ubuntu Server for the OS since it's one of the most popular server distributions. I'm more familiar with CentOS, but given &lt;a href="https://blog.centos.org/2020/12/future-is-centos-stream/" rel="noopener noreferrer"&gt;the recent shift in that project&lt;/a&gt;, Ubuntu seems to be a more stable alternative.&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating and Booting into the Ubuntu Install Media
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Download the &lt;a href="https://ubuntu.com/download/server" rel="noopener noreferrer"&gt;Ubuntu Server ISO&lt;/a&gt; from the official website.&lt;/li&gt;
&lt;li&gt;Flash the ISO onto a USB drive (&lt;a href="https://www.balena.io/etcher/" rel="noopener noreferrer"&gt;balenaEtcher&lt;/a&gt; is a good tool for this).&lt;/li&gt;
&lt;li&gt;Plug the USB drive into the server and boot into the install media.

&lt;ul&gt;
&lt;li&gt;Ensure that the server has an Internet connection so that packages and updates can be downloaded during the install. Ethernet is preferred for ease of use and stability.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;NOTE:&lt;/strong&gt; You may have to change BIOS settings if the server doesn't boot into the USB automatically. Refer to your motherboard's docs for more information.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  Installation Process
&lt;/h2&gt;

&lt;p&gt;The &lt;a href="https://ubuntu.com/tutorials/install-ubuntu-server#1-overview" rel="noopener noreferrer"&gt;official installation guide&lt;/a&gt; documents the process well, so I won't list all the steps here. Here are some steps I want to emphasize:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Configure storage&lt;/strong&gt;: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Make sure that you select the correct disk to install the OS on. For me, the OS disk will be the Samsung 500GB NVMe SSD (this will vary depending on your specific hardware configuration). &lt;/li&gt;
&lt;li&gt;I'm choosing to configure the two storage disks later manually.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Profile setup&lt;/strong&gt;: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The username and password created in this step will be used to login to the server after installation, so keep note of them! &lt;/li&gt;
&lt;li&gt;The newly created user will have &lt;code&gt;sudo&lt;/code&gt; privileges.&lt;/li&gt;
&lt;li&gt;I'm using &lt;code&gt;positron&lt;/code&gt; as the hostname for my server, in case you see it later.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;SSH Setup&lt;/strong&gt;: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Make sure to install OpenSSH so you can login to the machine remotely. &lt;/li&gt;
&lt;li&gt;You can also choose to import SSH keys from Github/Launchpad. If you do this, it's better to disable password authentication for SSH since it won't be needed. If anything goes wrong, you can always login to the server directly as long as you have physical access.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Snaps&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;I'm not installing any extra packages during the install since I'll do that later using Ansible.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After the installer does its thing, reboot the server and login with the username and password you created earlier.&lt;/p&gt;

&lt;h1&gt;
  
  
  Initial Configuration
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Remote Login
&lt;/h2&gt;

&lt;p&gt;Get the IP address of the server so we can login remotely:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;jaswraith@positron:~$ ip addr
1: lo: &amp;lt;LOOPBACK,UP,LOWER_UP&amp;gt; mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: enp7s0: &amp;lt;BROADCAST,MULTICAST,UP,LOWER_UP&amp;gt; mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 04:92:26:c0:e1:28 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.140/24 brd 192.168.1.255 scope global dynamic enp7s0
       valid_lft 85934sec preferred_lft 85934sec
    inet6 fe80::692:26ff:fec0:e128/64 scope link 
       valid_lft forever preferred_lft forever
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The IPv4 address for interface &lt;code&gt;enp7s0&lt;/code&gt; is the first part of the &lt;code&gt;inet&lt;/code&gt; field: &lt;code&gt;192.168.1.140&lt;/code&gt;. Your server's interface name might be different depending on your networking hardware.&lt;/p&gt;

&lt;p&gt;Now we can login from a different machine using &lt;code&gt;ssh&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;jaswraith@photon[~]=&amp;gt; ssh jaswraith@192.168.1.140
Welcome to Ubuntu 20.04.2 LTS (GNU/Linux 5.4.0-65-generic x86_64)

...

jaswraith@positron:~$ 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note that I didn't have to enter my password since: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;I imported my public SSH key from Github during installation.&lt;/li&gt;
&lt;li&gt;I have the corresponding private key on my laptop (&lt;code&gt;photon&lt;/code&gt;) under &lt;code&gt;/home/jaswraith/.ssh/id_ed25519&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I'm adding the entry &lt;code&gt;192.168.1.140 positron&lt;/code&gt; to &lt;code&gt;/etc/hosts&lt;/code&gt; on my laptop so I can login using the hostname instead of the IP address:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;jaswraith@photon[~]=&amp;gt; cat /etc/hosts
# Static table lookup for hostnames.
# See hosts(5) for details.
127.0.0.1   localhost
::1         localhost
127.0.1.1   photon.localdomain  photon

192.168.1.140   positron
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The network router on the local network needs to be configured to reserve the server's IP address so that it doesn't change after a reboot. My router is running &lt;a href="https://dd-wrt.com/" rel="noopener noreferrer"&gt;dd-wrt&lt;/a&gt;, so I'll use that as an example (refer to your own router's documentation on how to set a non-expiring DHCP lease).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;dd-wrt&lt;/strong&gt; specific steps:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Navigate to &lt;code&gt;192.168.1.1&lt;/code&gt; in a browser&lt;/li&gt;
&lt;li&gt;Click on the "Services" tab&lt;/li&gt;
&lt;li&gt;Under the "DHCP Server" section, click on "Add" under "Static Leases"&lt;/li&gt;
&lt;li&gt;Enter the server's MAC address, IP address, and hostname (you can get this info from the router's "Status" page or by running &lt;code&gt;ip addr&lt;/code&gt; on the server). Leave the "Client Lease Expiration" field blank so that the DHCP lease never expires. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj4er51xsdddp1azqgur1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj4er51xsdddp1azqgur1.png" alt="dd-wrt" width="800" height="368"&gt;&lt;/a&gt;Adding a non-expiring DHCP lease for the server on dd-wrt&lt;/p&gt;

&lt;h2&gt;
  
  
  System Upgrade
&lt;/h2&gt;

&lt;p&gt;Upgrade all installed packages on the server using &lt;code&gt;apt&lt;/code&gt;    :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;jaswraith@positron:~$ sudo apt update
Hit:1 http://us.archive.ubuntu.com/ubuntu focal InRelease
...
Reading package lists... Done
Building dependency tree
Reading state information... Done
13 packages can be upgraded. Run 'apt list --upgradable' to see them.

jaswraith@positron:~$ sudo apt upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following packages will be upgraded:
  dirmngr friendly-recovery gnupg gnupg-l10n gnupg-utils gpg gpg-agent gpg-wks-client gpg-wks-server gpgconf gpgsm gpgv open-vm-tools
13 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 3,133 kB of archives.
After this operation, 114 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 gpg-wks-client amd64 2.2.19-3ubuntu2.1 [97.6 kB]

...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;apt update&lt;/code&gt; downloads the latest package information from all configured sources on the server. It also informs you how many packages can be upgraded.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;apt upgrade&lt;/code&gt; actually upgrades the packages.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Storage Drive Configuration
&lt;/h2&gt;

&lt;p&gt;Time for the fun stuff, let's configure those storage drives!&lt;/p&gt;

&lt;p&gt;Check if the drives are recognized by the system with &lt;code&gt;lsblk&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;jaswraith@positron:~$ sudo lsblk
NAME                      MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
loop0                       7:0    0  55.4M  1 loop /snap/core18/1944
loop1                       7:1    0  31.1M  1 loop /snap/snapd/10707
loop2                       7:2    0  69.9M  1 loop /snap/lxd/19188
sda                         8:0    0   7.3T  0 disk 
sdb                         8:16   0   7.3T  0 disk 
nvme0n1                   259:0    0 465.8G  0 disk 
├─nvme0n1p1               259:1    0   512M  0 part /boot/efi
├─nvme0n1p2               259:2    0     1G  0 part /boot
└─nvme0n1p3               259:3    0 464.3G  0 part 
  └─ubuntu--vg-ubuntu--lv 253:0    0   200G  0 lvm  /
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The two storage drives are listed as &lt;code&gt;sda&lt;/code&gt; and &lt;code&gt;sdb&lt;/code&gt;. &lt;strong&gt;NOTE:&lt;/strong&gt; Drive names can be different depending on the type and amount of drives in your system.&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating a RAID Array
&lt;/h3&gt;

&lt;p&gt;I'm going to run the two storage drives in a &lt;a href="https://en.wikipedia.org/wiki/Standard_RAID_levels#RAID_1" rel="noopener noreferrer"&gt;RAID 1 array&lt;/a&gt;. Essentially, the two drives will be exact copies of one another and can act as a single device on the system. If one drive happens to fail, the data is still accessible from the good drive. The array can be repaired by replacing the bad drive and running a few commands. The downside is that the array can only be as large as the smallest member disk (8TB in my case).&lt;/p&gt;

&lt;p&gt;On Linux, &lt;a href="https://en.wikipedia.org/wiki/Mdadm" rel="noopener noreferrer"&gt;&lt;code&gt;mdadm&lt;/code&gt;&lt;/a&gt; is the utility used to manage software RAID arrays. Use the following command to create the array &lt;code&gt;md0&lt;/code&gt; from the two disks:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;jaswraith@positron:~$ sudo mdadm --create --verbose /dev/md0 --level=1 --raid-devices=2 /dev/sda /dev/sdb
mdadm: Note: this array has metadata at the start and
    may not be suitable as a boot device.  If you plan to
    store '/boot' on this device please ensure that
    your boot-loader understands md/v1.x metadata, or use
    --metadata=0.90
mdadm: size set to 7813894464K
mdadm: automatically enabling write-intent bitmap on large array
Continue creating array? yes
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; Make sure you use the correct drive names and &lt;strong&gt;DON'T&lt;/strong&gt; use the OS drive! &lt;/p&gt;

&lt;p&gt;Check that the array was successfully created:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;jaswraith@positron:~$ sudo mdadm -D /dev/md0
/dev/md0:
           Version : 1.2
     Creation Time : Tue Feb 16 02:51:43 2021
        Raid Level : raid1
        Array Size : 7813894464 (7451.91 GiB 8001.43 GB)
     Used Dev Size : 7813894464 (7451.91 GiB 8001.43 GB)
      Raid Devices : 2
     Total Devices : 2
       Persistence : Superblock is persistent

     Intent Bitmap : Internal

       Update Time : Tue Feb 16 02:56:33 2021
             State : clean, resyncing 
    Active Devices : 2
   Working Devices : 2
    Failed Devices : 0
     Spare Devices : 0

Consistency Policy : bitmap

     Resync Status : 0% complete

              Name : positron:0  (local to host positron)
              UUID : dfe41661:16eb9d7f:ed891288:904746b0
            Events : 58

    Number   Major   Minor   RaidDevice State
       0       8        0        0      active sync   /dev/sda
       1       8       16        1      active sync   /dev/sdb

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The resync process is going to take a &lt;strong&gt;loooong&lt;/strong&gt; time. We can track the progress by running &lt;code&gt;watch cat /proc/mdstat&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;jaswraith@positron:~$ watch cat /proc/mdstat

Every 2.0s: cat /proc/mdstat                                                                                   positron: Tue Feb 16 03:03:05 2021

Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
md0 : active raid1 sdb[1] sda[0]
      7813894464 blocks super 1.2 [2/2] [UU]
      [&amp;gt;....................]  resync =  1.4% (116907456/7813894464) finish=739.5min speed=173457K/sec
      bitmap: 59/59 pages [236KB], 65536KB chunk

unused devices: &amp;lt;none&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;740 minutes?! This is going to take over &lt;strong&gt;12 hours&lt;/strong&gt;!&lt;/p&gt;

&lt;p&gt;We can tweak some kernel parameters with &lt;code&gt;sysctl&lt;/code&gt; to make this go faster:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;jaswraith@positron:~$ sudo sysctl -w dev.raid.speed_limit_min=100000
dev.raid.speed_limit_min = 100000
jaswraith@positron:~$ sudo sysctl -w dev.raid.speed_limit_max=500000
dev.raid.speed_limit_max = 500000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or I guess not...turns out that the reported speed of ~170000K/s is right around the documented read speed for my Seagate drives (190MB/s). Fortunately, we can still write to the &lt;code&gt;md0&lt;/code&gt; device during this process.&lt;/p&gt;

&lt;h3&gt;
  
  
  Configuring the &lt;code&gt;md0&lt;/code&gt; Array
&lt;/h3&gt;

&lt;p&gt;Use &lt;code&gt;mkfs&lt;/code&gt; to format &lt;code&gt;md0&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;jaswraith@positron:~$ sudo mkfs.ext4 -F /dev/md0
mke2fs 1.45.5 (07-Jan-2020)
/dev/md0 contains a ext4 file system
        created on Tue Feb 16 04:07:25 2021
Creating filesystem with 1953473616 4k blocks and 244187136 inodes
Filesystem UUID: 3e8
b5548-14c5-4fac-8e90-98cdbd71123f
Superblock backups stored on blocks: 
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
        4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, 
        102400000, 214990848, 512000000, 550731776, 644972544, 1934917632

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (262144 blocks): done
Writing superblocks and filesystem accounting information: done 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; The &lt;code&gt;-F&lt;/code&gt; flag is needed since &lt;code&gt;md0&lt;/code&gt; is not a partition on a block device. &lt;/p&gt;

&lt;p&gt;I opted to use the classic &lt;code&gt;ext4&lt;/code&gt; filesystem type instead of other ones (&lt;code&gt;xfs&lt;/code&gt;, &lt;code&gt;zfs&lt;/code&gt;, etc.).&lt;/p&gt;

&lt;p&gt;In order to use the newly created filesystem, we have to mount it. Create a mountpoint with &lt;code&gt;mkdir&lt;/code&gt; and use &lt;code&gt;mount&lt;/code&gt; to mount it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;jaswraith@positron:~$ sudo mkdir -p /data
jaswraith@positron:~$ sudo mount /dev/md0 /data
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Confirm that the filesystem has been mounted:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;jaswraith@positron:~$ df -h /data
Filesystem      Size  Used Avail Use% Mounted on
/dev/md0        7.3T   93M  6.9T   1% /data
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;/etc/mdadm/mdadm.conf&lt;/code&gt; file needs to be edited so that the array is automatically assembled after boot. We can redirect the output of &lt;code&gt;mdadm --detail --scan --verbose&lt;/code&gt; using &lt;code&gt;tee -a&lt;/code&gt; to accomplish this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;jaswraith@positron:~$ sudo mdadm --detail --scan --verbose | sudo tee -a /etc/mdadm/mdadm.conf 
ARRAY /dev/md0 metadata=1.2 name=positron:0 UUID=dfe41661:16eb9d7f:ed891288:904746b0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Confirm that the &lt;code&gt;md0&lt;/code&gt; array configuration has been added to the end of &lt;code&gt;/etc/mdadm/mdadm.conf&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;jaswraith@positron:~$ cat /etc/mdadm/mdadm.conf 
# mdadm.conf
#
# !NB! Run update-initramfs -u after updating this file.
# !NB! This will ensure that initramfs has an uptodate copy.
#
# Please refer to mdadm.conf(5) for information about this file.

...

ARRAY /dev/md0 level=raid1 num-devices=2 metadata=1.2 name=positron:0 UUID=dfe41661:16eb9d7f:ed891288:904746b0
   devices=/dev/sda,/dev/sdb
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We also need to regenerate the initramfs image with our RAID configuration:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;jaswraith@positron:~$ sudo update-initramfs -u
update-initramfs: Generating /boot/initrd.img-5.4.0-65-generic
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The last step is to add an entry for &lt;code&gt;md0&lt;/code&gt; in &lt;code&gt;/etc/fstab&lt;/code&gt; so that the array is automatically mounted after boot:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;jaswraith@positron:~$ echo '/dev/md0 /data ext4 defaults,nofail,discard 0 0' | sudo tee -a /etc/fstab
/dev/md0 /data ext4 defaults,nofail,discard 0 0

jaswraith@positron:~$ cat /etc/fstab
# /etc/fstab: static file system information.

...

/dev/md0 /data ext4 defaults,nofail,discard 0 0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note that I used the same mountpoint for &lt;code&gt;md0&lt;/code&gt; that was created eariler (&lt;code&gt;/data&lt;/code&gt;).&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;So we've completed the intial setup of the server and created a RAID 1 array for storage. This server looks ready to run some services! Stay tuned for the next post where we'll define and run those services using Docker and Ansible.&lt;/p&gt;

</description>
      <category>linux</category>
      <category>ubuntu</category>
      <category>systems</category>
    </item>
  </channel>
</rss>
