NAS RAID-1 Fail

This past weekend my media NAS server was intolerably slow. When I investigated, I found out that one of the RAID-1 partitions is experiencing read errors and is timing out. I decided to risk a reboot and to my surprise the RAID-1 partition did not recover with one fail drive, but mdstat recorded with an inactive status, something like this:

md2 : inactive sdc1[0](S)

After some Google search, I found that I had to do the following to resurrect the md2 device.

madam --stop /dev/md2
mdadm --assemble --force /dev/md2

This reactivated the md2 partition. I replaced the failed drive and re-added the new drive to the md2 device. The RAID-1 partition is now rebuilding.

The inactive state is a new experience for me, so this was a bit of a surprise.

During this exercise I also found out that the SATA connectors on my SATA add-on card were loose causing intermittent connections. I will have to find a way to address this in the future.

Media Server Upgrade

Two and half years ago, I performed a CPU and motherboard upgrade to my media server. You can read the account here.

Although the AMD Athlon 5350 APU was energy efficient, it proved to be under power for on demand video encoding when Plex wanted to transcode video for a player on a device that is not compatible with the playing video. For example, when an Apple TV (not 4K) wants to play 4K material from Plex on my media server, the server will have to transcode the 4K material to a compatible 1080p format. Unfortunately, this is very CPU intensive and if more than one person in the house hold is trying to do the same thing, which is not unheard of, this causes stuttered playback issues.

Given the choice between saving a few dollars a year versus usability, I choose usability. Therefore I started to research what I need for the upgrade. My goal is upgrade the system so that transcoding will not be an issue and I can also use the system for future video encoding of security camera footages. We can also use the system for background video encoding of family videos as well.

I continue to prefer the AMD brand, and decided on the following combo:

  • AMD Ryzen 5 2400G Processor with Radeon RX Vega 11 Graphics (YD2400C5FBBOX)
  • GIGABYTE B450 AORUS M Motherboard
  • Corsair Vengeance LPX 16GB (2x8GB) DDR4 DRAM 2666MHz (CMK16GX4M2A2666C16)

The above were all purchased through Amazon and cost me a grand total of $473.24. The AMD CPU was the most expensive part costing almost $190.

Taking out the old motherboard and CPU combo and replacing them with the new parts went smoothly. The side SATA connectors bucked against one of my HDD chassis so I opted not to use them, and decided to connect all of my RAID SATA connectors to the SATA accessory card that I purchased and discussed in this post.

Last time I did an upgrade like this, the Ubuntu operating system had no problems and booted without any issues. Unfortunately, this time is very different. After the machine posted, Ubuntu booted into a blank, black screen. After some research, I learned to reboot the Ubuntu kernel with the nomodeset option. I learned to press and hold the shift key so that I can select the desired kernel that I wanted via the GRUB menu, and I learned to press the ‘e’ key in the GRUB menu to modify the boot options. Finally pressing F10 to boot with the custom changes (effective for only one time).

The above trick got me a login prompt. After I gained access to the command prompt, I noticed that the kernel did not recognize any ethernet devices. I now have a machine that is not connected to the network. After some more Internet research I found out that the current 4.15 Linux Kernel that I have is insufficient to run on the Raven Ridge architecture, the AMD code name for the Zen CPU and Vega GPU combination on a single chip. I have to upgrade to the 4.18 Linux Kernel.

However I cannot upgrade through the Internet, because the machine is not on the Internet. I have to download the Debian packages on a USB stick with another machine and manually install them. At this point, I learned that you cannot simply download a single package for this. I had to decide whether to go with the Linux Mainline Kernel packages or go with the Ubuntu HWE (Hardware Enablement) packages. After reading through Ubuntu’s LTS Enablement Stack article, I decided to HWE packages. I found the linux-generic-hwe packages and their prerequisites on pkgs.org. This took several iterations as I did not get all the dependent packages on the first try.

Once all the packages were installed, the machine booted without the need for the nomodeset option. However, the internet interface device was still not there. I had to run the command netpath, to find out that new motherboard’s ethernet device’s logical name was em1. To register the new logical name, I had to edit /etc/network/interfaces file.

Finally, the machine booted with an active ethernet connection. As a sanity check, I executed:

sudo apt-get install --install-recommends linux-generic-hwe-18.04 

Ensuring that my new media server has all the required kernel packages. We are still not done. The IP address of the server has changed, because we now have a different MAC address, so the DHCP server provisioned a different IP. I tried to change the Unifi Controller to provision a static IP address to this new server but I was unsuccessful. I suspect that the new server is also running the Unifi Controller may have something to do with it. Since the IP address has changed, I needed to update the following configurations:

  • Firewall rules
  • Unifi Controller name space configurations
  • Samba configurations because we only allow for local machines to share

All of this took from 4:30pm to 11:00pm last night, 6.5 hours worth of hardware assembly, research with Google, trial and error, and finally success. I cannot imagine if Google and the super helpful community forums did not existed. Fingers crossed that the new media server will run smoothly.

More Home IT Upgrades

This past weekend I continued to upgrade our NAS server. Last weekend, I upgraded my raid array with an additional 8TB of mirrored storage. This yielded two old 4TB WD Blue HDD. I noticed that my case has a total of 9 internal storage bays. One was used by my 500GB SSD Boot Drive, and 6 were populated by HDD drives making up the current raid array. This means I have 2 more storage bays left. However these remaining bays were meant for 5.25″ storage devices like Optical Disc Players. For me to place my old 4TB WD Blue HDD into these bays, I will need a 5.25″ to 3.5″ bay converter. I had one, and purchased the other one on Amazon. I ended up buying the ORICO Aluminum 5.25 inch to 2.5 or 3.5 Inch Internal Hard Disk Drive Mounting Kit.

I also did not have enough SATA slots and purchased the IOCrest SI-PEX40071 SATA III 8 Port Controller Card. This card along with the 4 builtin SATA slots on the motherboard gave me enough SATA connections for my 9 drives.

Once I installed the old 4TB drives, I proceeded to create another md raid level 1 device and created a matching physical volume which I used to extend the current logical volume group. When the setup is completed, I ended up with a 20TB+ fully mirrored NAS server. I love LVM in combination of mdadm.

I figured while everything is fresh on my mind, I minus well proceed with the dreaded 16.04 to 18.04 Linux Ubuntu upgrade.

The upgrade was surprisingly very smooth. However the new version of OpenVPN caused some troubles. The new OpenVPN no longer works with my old PureVPN configuration files, because the certificate files that came from PureVPN used an outdated and deprecated hash algorithm. After getting the new configuration files from PureVPN, everything worked like a charm.

I also have to reinstall the Unifi Controller along with Let’s Encrypt certbot utility.

Super happy with the outcome and the upgrades should last another 2 to 3 years.

Two New 8TB Drive for Our NAS

Our NAS has run out of space again. I saw a deal that the Seagate IronWolf 8TB NAS Hard Drive was on sale at newegg for $309 CAD. I jumped at the chance and purchased two.

I am now following the same step as I outlined in this post. Replacing two old 4TB drives with these two new 8TB drives.

So far so good. Hopefully when all is said and done, my NAS will have a total of 18TB in a RAID 1 configuration of 6 hard drives in total. Two 4TB, two 6TB, and the two new 8TB.

I noticed that I could fit two more drives in my chassis and may decide to re-add the two old 4 TB back in, but first I’ll have to check if my power supply can handle the demand.

I really like this mdadm and LVM setup.

Update: After 2 mdadm syncs, each of which was around 8 hours, and a pvresize that also took another 5 hours. I had to convert the filesystem from 32 bits to 64 bits using these very helpful instructions. Only after I converted to 64 bits can I then expand the existing filesystem to more than 16TB. It was a learning and yet rewarding experience. Next step is to reuse the 2 old 4TB drives in the same chassis and add them to the logical volume.

Linux LVM Super Simple to Expand

During the Boxing Day sales event of 2017, I purchased a couple of Seagate Barracuda ST4000DM004 (4TB) hard drives. The intention is to expand our main home network storage, which is a network accessible / attached storage (NAS) managed by our Linux server using mdadm and Logical Volume Manager (LVM).

However I procrastinated until this weekend and finally performed the upgrade. The task went smoothly without any hiccups. I have to give due credit to the following site: https://raid.wiki.kernel.org/index.php/Growing. It really provided very detail information for me to follow. It was a great help.

One major concern I had was whether I can do this without any data loss, and a question of how much down time would this upgrade require.

I had a logical volume, named /dev/airvideovg2/airvideo, consisted of 100% usage of a volume group which was made up of three RAID-1 multiple devices (md). Since I ran out of physical drive bays, to perform the upgrade, I had to effectively replace 2 older drives which were 2TB in size with the newer 4TB drives. The old drives were Western Digital WDC WD20EZRX-00D8PB0 (2TB). I can use these old drives for other needs.

First I had to find the md containing the 2TB pair in RAID-1 (mirror) configuration. I did this with a combination of lsblk and mdadm commands. For example:

$ lsblk
NAME                       MAJ:MIN RM  SIZE RO TYPE  MOUNTPOINT
sdb                          8:0    0  1.8T  0 disk
└─sdb1                       8:1    0  1.8T  0 part
  └─md2                      9:3    0  1.8T  0 raid1
    └─airvideovg2-airvideo 252:0    0   10T  0 lvm   /mnt/airvideo

$ sudo mdadm --detail /dev/md2
/dev/md2:
        Version : 1.2
  Creation Time : Sat Nov 12 18:01:36 2016
     Raid Level : raid1
     Array Size : 1906885632 (1725.90 GiB 2000.65 GB)
  Used Dev Size : 1906885632 (1725.90 GiB 2000.65 GB)
   Raid Devices : 2
  Total Devices : 2
    Persistence : Superblock is persistent

  Intent Bitmap : Internal

    Update Time : Sun Mar 11 09:12:05 2018
          State : clean 
 Active Devices : 2
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 0

           Name : avs:2  (local to host avs)
           UUID : 3d1afb64:878574e6:f9beb686:00eebdd5
         Events : 55191

    Number   Major   Minor   RaidDevice State
       2       8       81        0      active sync   /dev/sdf1
       3       8       17        1      active sync   /dev/sdb1

I found that I needed to replace /dev/md2 which consisted of two /dev/sdf1 and /dev/sdb1 partitions. These partitions belonged respectively to the old WD drives. I have 6 hard drives in the server chassis, so I needed to get the serial number of the drives to ensure that I was swapping the right one. I used the hdparm command to get serial number of /dev/sdb and /dev/sdf. For example:

$ sudo hdparm -i /dev/sdb

/dev/sdb:

 Model=WDC WD20EZRX-00D8PB0, FwRev=0001, SerialNo=WD-WCC4M4UDRZLD
 Config={ HardSect NotMFM HdSw>15uSec Fixed DTR>10Mbs RotSpdTol>.5% }
 RawCHS=16383/16/63, TrkSize=0, SectSize=0, ECCbytes=0
 BuffType=unknown, BuffSize=unknown, MaxMultSect=16, MultSect=off
 CurCHS=16383/16/63, CurSects=16514064, LBA=yes, LBAsects=7814037168
 IORDY=on/off, tPIO={min:120,w/IORDY:120}, tDMA={min:120,rec:120}
 PIO modes:  pio0 pio1 pio2 pio3 pio4 
 DMA modes:  mdma0 mdma1 mdma2 
 UDMA modes: udma0 udma1 udma2 udma3 udma4 udma5 *udma6 
 AdvancedPM=no WriteCache=enabled
 Drive conforms to: unknown:  ATA/ATAPI-4,5,6,7

 * signifies the current active mode

Before I physically replace the drives, I must first remove them from the md device by doing the following.

sudo mdadm -f /dev/md2 /dev/sdb1
sudo mdadm -r /dev/md2 /dev/sdb1

After swapping out only one of the drives, and replaced it with a new one, I rebooted the machine. I first have to partitioned the new drive using the parted command.

sudo parted /dev/sdb

Once within parted, execute the following commands to create a single partition using the whole drive.

mklabel gpt
mkpart primary 2048s 100%

I learned that I can only start at sector 2048 to achieve optimal alignment. Once I created the /dev/sdb1 partition, I have to add it back into the RAID.

sudo mdadm --add /dev/md2 /dev/sdb1

As soon as the new partition with the new drive was added into the RAID, a drive resynchronization begins automatically. The resync took more than 3 hours. Once the resync is completed, I did the same thing with the remaining old drive in the RAID, and performed another resync. This time from the first new drive to the second new drive. After another 3+ hours, we can now grow the RAID device.

sudo mdadm --grow /dev/md2 --bitmap none
sudo mdadm --grow /dev/md2 --size max
sudo mdadm --wait /dev/md2
sudo mdadm --grow /dev/md2 --bitmap internal

The third command (–wait) took another 3+ hours to complete. After a full day of RAID resync, we now have the same /dev/md2 that is 4TB instead of 2TB in size. However the corresponding physical volume of LVM still needed to be resized. We did this with:

sudo pvresize /dev/md2

Once the physical volume is resized, we can then extend the logical volume to use up the remaining free space that we just added.

lvresize -l +100%FREE /dev/airvideovg2/airvideo

This took a few minutes but at least it was not 3+ hours.

Aside from the down time that I had to use to swap the hard drives, the logical volume was usable throughout the resynchronization and resizing process. This was impressive. However, now I have to take the volume offline by first umount the volume and changing it to inactive status.

sudo lvchange -an /dev/airvideovg2/airvideo

Note that I had stop the smbd and other services that was using the volume before I can unmount it.

The last step is to resize the file system of the logical volume, but before I can do that I was forced to perform a file system check.

e2fsck -f /dev/airvideovg2/airvideo
resize2fs -p /dev/airvideovg2/airvideo

I rebooted the machine to ensure all the new configurations held, and voila I upgraded my 8TB network attached storage to 10TB! Okay it was not super simple, but the upgrade process was pretty simple and painless. The down time was minimal. The LVM and mdadm guys did a really good job here.

Three Cheers for Software RAID

Last year, I built a NAS machine as referenced by my previous post here. This month, my media drive composed of an LVM logical volume of almost 5TB is almost filled.

This drive contains all purchased media and our home videos for Plex, as well as our time machine backups. To alleviate the storage shortage, I purchased two 4TB Western Digital WD40EFRX hard drives. This weekend I took the plunge and installed the two new drives into my NAS computer. In the spirit of the moment, without performing a backup, I proceeded to:

  • Use parted to partition the drives;
  • Use mdadm to create a RAID 1 device of the two drives;
  • Created a new LVM physical volume with the new RAID device;
  • Added the volume to the existing volume group;
  • Extend the logical volume to newly added 4TB;
  • and finally, Extend the ext4 file system to include the 4TB

In the end, I now have a near 9TB network drive that should last me for quite sometime.

In researching how to extend the logical volume, I also found out how I can upgrade my drives in my existing physical volumes to higher capacity drives without having to recopy everything to another drive first. This should come in handy in the future, because my NAS computer box has no more drive bays.

I know I probably should have taken a backup before this, but everything worked and I couldn’t be happier. Hurray, hurray, and hurray for software RAID.

Thank you Gigabyte and Western Digital

This morning I upgraded my media server. The server was running on a seven years old motherboard, Gigabyte GA-M61PME-S2P, and an AMD Athlon II X2 245 processor. The hard drive is the oldest, a Western Digital WDC WD800JB-00JJ 80GB hard drive that was released back in 2007. This makes the drive 9 years old! At the time of this update, all systems were nominal and operating without issues. Running Ubuntu 16.04.1 LTS (Xenial Xerus), next to my iMac, it was the lowest maintenance box I’ve ever put together.

The real reason for the upgrade is for me to reduce the power footprint of a box that is effectively running 7×24. Even when it was idling, the old components where clocking in at 100+ W of power usage.

I decided to replace the motherboard and cpu with an ASRock AM1H-ITX and a system on a chip AMD Athlon 5350 APU. I was able to get the system down to 55W. I also replaced the old WD800JB with a Seagate BarraCuda 7200.10 ST3500630AS 500GB hard drive, along with the existing 4 WD Green EZRX hard drives. A total of 5 traditional mechanical hard drives. Along with new Kingston HyperX Fury Black 8GB memory, this entire upgrade cost less than $220 CAD with taxes included.

I want to shoutout to Clonezilla. What an amazing job they did in creating a super simple piece of software to clone drives and partitions. Of course Linux is just so wonderful to work with. After changing the CPU and Motherboard, the original Ubuntu installation boot up and run without any major issues. The only wrinkle I had was the ethernet port that came with the new motherboard had a new logical name (enp3s0 vs eth0). Luckily, I know how to fix that. My LVM volume assembled without a hitch. Everything is now running fine with the new hardware and configuration.

My next step in the coming months is to shop for a 500GB SSD. Perhaps I can find one during Cyber Monday or Black Friday sales. This should further reduce my power footprint and also increase my performance.

Home IT Improvements

Ubuntu AirVideo Server with NAS

Some people use their weekend for home renovation projects, I however used this particular weekend to perform some home information technology (IT) upgrades. My replacement iMac 27" Late 2012 model arrived this week, so after setting up this monstrosity of a machine, I am left with an extra box. An old Windows PC running Windows 7 with a very old AMD Athlon™ II X2 245 Processor along with 3GB of memory. Unfortunately the PC’s motherboard, a Gigabyte M61PME-S2P, is a three and half years old motherboard. It doesn’t even have gigabit ethernet on the board. Instead of having it sit around, I figured that it would be a good idea to try my hands on building a Linux file and media server.

I could do FreeNAS, but I wanted flexibility to run some additional software on the box in addition to just perform as a file server. We have many iOS mobile devices in the house, so I also decided to install Air Video Server on the machine. If you are not familiar with AirVideo, you are missing out. Check them out at http://www.inmethod.com. I ended up running Ubuntu Desktop 12.10 release as an experiment.

Here is a quick to do list that I set for myself:

  • Installed Ubuntu;
  • Consolidate old hard drives into a single volume for media storage;
  • Install samba to share the volume, so I can copy media to it from other computers in the house;
  • Install AirVideo server and configure it to serve media from the above volume;
  • Ensure all of the above works when we reboot the box

Installing the operating system from a USB key was a piece of cake. This weekend project also gave me the opportunity to hunt for old hard drives that have been sitting around dormant in my home office. I wanted to place all my old hard drives into this box, reborn as my new Air Video Server (I named it AVS for short). To my disappointment the old motherboard only allowed for two SATA drives, and one was already taken. Therefore, I could only repurpose one of three old drives that I have found.

Adding drives to the AVS box, forced me to dust off the webs from my Linux knowledge base. I had to re-familiarize with myself on the topic of how to use lshw to find out the hardware that is being installed on the system, and using fdisk to partition the drives properly. I had two old drives. The first a 300GB SATA drive, and the other a 320GB drive. I created a single primary partition on each drive.

Once I’m happy with the partitioning, I’m ready to create a software RAID array or volume using the mdadm utility ( http://en.wikipedia.org/wiki/Mdadm ). I used mdadm to combined the two drives into a single volume of RAID-0 of 600GB. I didn’t care about redundancy or backup, so I chose RAID-0 instead of RAID-1. I am thoroughly impressed by mdadm in its ability to handle drives of different models to accomplish this.

Now that I have an array device created, I have to create a file system using mkfs.ext4. The last time I created a Linux file system, we only had ext2. I then have to brush up on my mounting procedures and configure the mount points with /etc/fstab. The mounting configuration was an optional step, but I wanted to rename the default mount point that mdadm gave me. After some more permission related configurations, and the installation and configuration of samba on Ubuntu to share the mount point, I have a Network Attached Storage (NAS) that I can copy videos to.

The installation of AirVideo Server was super easy. Kudos to Sergio Rubio. I literally downloaded the Debian install package from https://launchpad.net/~rubiojr/+archive/airvideo and I was done. After quickly configuring the server by editing the AirVideoServerLinux.properties in /opt/airvideo-server, I manually run the AirVideo Server on the command line to see if it works with my iPad. This was a good moment, but I am not finished.

I needed to ensure that all the services related to this new AirVideo Server comes up when the machine is rebooted. This launched another journey down memory lane in terms of /etc/init.d. Again to my amazement, I simply searched init.d and airvideo on Google, which lead me to a post ( http://www.inmethod.com/forum/posts/list/3485.page ) with a ready made /etc/init.d shell script. After some minor adjustments, I was off to the races with a completed AirVideo Server using my old computer and hard drives.

Although Ubuntu has made great strides in making Linux easier to use, I had to do most of the above on the command line as I find the user interface of Ubuntu is still thwarted with many bugs. Creating something like this is still not for the faint of heart.