Home Server Upgrade - Lessons Learned - Converting Live RAID and Resizing Encrypted Partitions


Recommended Posts

So I just finished upgrading the storage in my home server and I learned a few lessons that I thought I would share with you guys, so that hopefully some of you might find it useful at a later date.  I recorded a lot of it and plan on writing it up in a blog and making a YouTube video about it.  If/when I do, I'll edit this post with links to those items.

 

First off, my server is running Debian 10 Linux in a headless state; no GUI installed, which means 99% of my management is done via SSH unless there's some kind of a problem that prevents it from booting so that I have to physically go connect a monitor to it, so everything I did was done via the command line.  It "was" using two 12TB WD Gold drives in Linux software RAID 1 (mdadm).  I created a partition with a specific sector count on each of those drives about 1GB less than the total capacity of the drives, and then added that partition as the RAID member.  That way if I ever replaced a drive with one of a different model and the capacities were "slightly" off, it wouldn't be an issue.  When creating the actual data partition on the RAID device, I encrypted the partition so that if I ever had to RMA a drive, nobody would be able to retrieve sensitive or personal information from the drive at a later date, especially since RAID 1 has a complete copy of everything on both drives, so one drive is enough to recover everything.  The partition didn't used to be encrypted until I had my first drive failure and realized I was about to ship a drive with lots of personal files through the US Postal Service, and that in all likelihood they would refurbish the drive and resell it with the same platters inside since I'm pretty sure it was just the read head that died.  I managed to get the drive working long enough to run shred on it for about 90% of the drive (which was fine because it wasn't 90% full) before shipping it off, but after that I decided to encrypt the partition.

 

We started approaching the 12TB limit recently, and I decided that the easiest course of action would be to buy one additional drive and switch to RAID 5; which would double our storage capacity to 24TB and still allow us to lose one drive without losing any data.  I have a separate off-site backup drive, so we're talking strictly about what's physically inside the server.  My only concern was, I really didn't want to delete my RAID group and re-make it if I didn't have to.  I have the backup, but it would have taken over 24 hours to restore from the backup since it's a USB external drive; and that would have left us without Nextcloud and Plex for that entire time (I make heavy use of Nextcloud and my kids and nieces/nephews love Plex), plus that would mean that until it was finished, I would only have one complete copy of my data, and I'd just have to hope my backup drive didn't die during the restoration.

 

As it turns out, if you're using Linux software RAID (mdadm), a two disk RAID 1 can be directly converted to a degraded two disk RAID 5, at which point you just add the third disk so that it's no longer in a degraded state.  All you have to do is run:

mdadm /dev/mdfoo --grow --level=5

mdadm --grow /dev/mdfoo --add /dev/foo --raid-devices=3

 

The cool thing about this was that even though the reshape took almost two days, my data was accessible during that time, so we were still able to continue using the various services on the server.  On top of that, once it was done, it automatically grew the array as a whole to the proper new size of 24TB, although I had read that in some cases you might need to do that part manually.  The server obviously runs on an UPS, so if there had been a power outage or flicker during the process, it wouldn't have bothered anything.  I even rebooted the server once during the reshaping process and it just picked up where it left off once it was back up and running.

 

My next issue was that, even after the many hours it took to reshape the array into a proper RAID 5 that spanned all three disks, the actual data partition on it was still only 12TB.  The partition was encrypted, so my next task was to resize that partition to take advantage of the increased capacity of the RAID pool.

 

After doing some reading and experimenting in a VM, I discovered that once the reshape was done, all I had to do was unmount and luksClose the encrypted partition, then unlock it again with luksOpen, and LUKS automatically extended the LUKS device to fill the new capacity of the RAID array.  Then I just had to do a filesystem check on the data partition with:

e2fsck -f /dev/mapper/somedrive

 

Then resize the partition with:

resize2fs /dev/mapper/somedrive

 

Resizing the partition itself only took a couple of minutes.

 

So what I've learned from all this is that, if you don't care to do some reading, Linux disk management via the terminal is incredibly powerful and flexible.  I was able to convert a software RAID 1 directly to a software RAID 5, and then resize an encrypted partition on that RAID 5 group, all without losing any data.  Obviously I updated my backup drive before starting the process, just in case.  I'm just incredibly grateful that it all went off without a hitch, which isn't always the case when it comes to technology, so I thought I would share my little learning experience in case it helps or entertains some of you.

image.png.cb88547fc278323e6c777d0ead2690e0.png

Edited by Gerowen
  • Like 2

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Floorp 11.29.0 by Razvan Serea Floorp is a cutting-edge web browser that combines the trusted foundation of Mozilla's Firefox with a unique Japanese perspective, offering users an exceptional online experience. This open-source browser prioritizes privacy, customization, and security. Floorp is transparent, with no user tracking or data sharing, and it's completely open source. With a strict no-tracking policy and full transparency, your personal information remains private. As an open-source project, Floorp not only shares its source code but also its build environment, inviting users to contribute and build their unique versions. The regular updates, based on Firefox ESR, ensure that you always have the latest features and security enhancements. Get to the point with Floorp Lightning's minimalism With a keen eye on user preferences, Floorp is gearing up to launch "Floorp Lightning," a streamlined and performance-focused browser, harkening back to the fundamentals of web browsing. This browser has undergone a meticulous transformation, shedding more than 80% of the features that characterized its predecessor. What remains are only the high-demand functionalities within the Floorp ecosystem. The result is a sleek, lean, and swift web browser optimized for maximum efficiency. In the ever-accelerating digital world, "Floorp Lightning" is poised to offer users a refreshingly nimble and responsive browsing experience, set to debut in beta mode this November. Floorp key features: Strong Tracking Protection: Floorp offers robust tracking protection, safeguarding users from malicious tracking and fingerprinting on the web. Flexible Layout: Customize Floorp's layout to your heart's content, including moving the tab bar, hiding the title bar, and more for a personalized browsing experience. Switchable Design: Choose from five distinct designs for the Floorp interface, and even switch between OS-specific designs for a unique look Regular Updates: Based on Firefox ESR, Floorp receives updates every four weeks, ensuring up-to-date security even before Firefox's releases. No User Tracking: Floorp prioritizes user privacy by abstaining from collecting personal information, tracking users, or selling user data, with no affiliations with advertising companies. Completely Open Source: The full source code for Floorp is open to the public, allowing transparency and enabling anyone to explore and build their own version. Dual Sidebar: Floorp features a versatile built-in sidebar for webpanels and browsing tools, making it perfect for multitasking and quick access to bookmarks, history, and websites. Flexible Toolbar & Tab Bar: Customize your browser with Tree Style Tabs, vertical tabs, and bookmark bar modifications, catering to both beginners and experts in customization. User-Centric Web Experience: Floorp prioritizes user privacy and collaboratively blocks harmful trackers. Floorp 11.29.0 changelog: Security fixes Download: Floorp 64-bit | 85.2 MB (Open Source) Links: Floorp Website | Github Website | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • "ethical", what an interesting term. Subjectively objective but objectively subjective. I argue there are very few "ethics" in copyright. Hell, I see very few applications of true ethics in anything. I see a great deal of unethical actions being done under the guise of ethics however. How unethical... I greatly prefer open source LLMs. Copyright ethics are mickey mouse deep.
    • How do you propose anyone govern who can use what online without completely destroying online privacy? Protip: You can't, so you shouldn't. I'm sorry, but I don't think of the children, that's their parents jobs. If their parents fail them, that's on them. Tough luck.
  • Recent Achievements

    • Collaborator
      fernan99 earned a badge
      Collaborator
    • Collaborator
      MikeK13 earned a badge
      Collaborator
    • One Month Later
      Alexander 001 earned a badge
      One Month Later
    • One Month Later
      Antonio Barboza earned a badge
      One Month Later
    • Week One Done
      Antonio Barboza earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      591
    2. 2
      ATLien_0
      225
    3. 3
      Michael Scrip
      167
    4. 4
      Xenon
      139
    5. 5
      +FloatingFatMan
      128
  • Tell a friend

    Love Neowin? Tell a friend!