October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
VGSources
Blog

How to Manage RAID Arrays with mdadm on Ubuntu 22.04

Learn how to create and manage Linux software RAID with mdadm on Ubuntu 22.04, monitor resyncs, replace failed members, safely grow arrays and dismantle them without touching the wrong disk.
Length11 min Posted Quest giverVGSources Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

mdadm is Ubuntu 22.04’s command-line tool for creating and maintaining Linux software RAID (MD) arrays. A safe workflow is: install and verify mdadm, confirm which disks are empty, create the appropriate RAID level, monitor the initial resync, save the array definition in /etc/mdadm/mdadm.conf, and keep a tested backup outside the array. When a member fails, mark it failed, remove it, add a compatible replacement, and watch the rebuild. Capacity changes require an mdadm reshape first and a filesystem resize afterward.

The commands below use an example array named data. Replace example devices such as /dev/sdb with the devices you have positively identified. Running a create, format, or superblock command on the wrong disk can destroy data.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What mdadm manages—and what RAID does not protect

mdadm manages Linux kernel MD devices. In create mode it writes a RAID superblock to each component device, starts the array, and begins an initial resynchronization. The array can normally be used while that resync runs, although intensive workloads make the process slower and increase exposure while redundancy is being established.

RAID provides availability when a disk fails; it is not a backup. Accidental deletion, filesystem corruption, malware, theft, fire, and a failed reshape can affect every member. Keep a separate, tested backup before creating an array and before any replacement or reshape operation.

#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter | 4Pack Type C Female to A Male Cable Converter for Apple Duo 17 16 15 14 Plus,iWatch Watch 12 11 10,iPad 9 8 Air,Airpods 5 4
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

The Ubuntu Jammy man page identifies the packaged release as mdadm 4.2-0ubuntu2 (Ubuntu/Canonical, accessed 2026). Command behavior can differ with later Ubuntu updates, so check the local man page with man mdadm when an option is unfamiliar.

Choose a RAID level before touching the disks

Usable capacity is based on the smallest member in a conventional array. Mixing substantially different sizes wastes the excess on larger disks. The failure counts below describe the normal layout, not every possible failure pattern.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Level Minimum disks Approximate usable capacity Simultaneous disk failures tolerated Performance and rebuild considerations Best fit
RAID0 2 Sum of all members 0 Excellent sequential and parallel throughput; one failure loses the entire array and there is no rebuild protection. Temporary or reproducible data where speed matters more than availability.
RAID1 2 Capacity of one member (with equal-sized disks) Usually 1 in a two-disk mirror Reads can be served from either copy; writes go to both. Rebuilds are straightforward but copy the complete mirror. Small arrays that prioritize simple redundancy and fast recovery.
RAID5 3 (Number of disks − 1) × smallest disk 1 Parity provides good capacity efficiency. Writes incur parity work, and a second failure during rebuild is fatal to the array. Capacity-conscious workloads with a single-disk failure requirement and a strong backup.
RAID6 4 (Number of disks − 2) × smallest disk 2 Dual parity tolerates two failures, but writes and rebuilds require more computation and I/O than RAID5. Larger arrays where rebuild exposure is a major concern.
RAID10 4, normally an even number About half of raw capacity At least one; more are possible if they are in different mirrors Mirroring plus striping gives strong read/write performance and generally shorter, less parity-intensive rebuilds. The exact failure tolerance depends on which members fail. Databases, virtual machines, and other workloads that value predictable I/O and redundancy.

RAID level alone does not determine safety. Disk quality, controller or backplane behavior, workload, monitoring, and the time required to obtain a replacement all matter. For a home server, RAID1 or RAID10 is often easier to recover than parity RAID; for a larger set of disks, RAID6 can provide more failure margin than RAID5.

Install mdadm and verify the package

  1. Refresh Ubuntu’s package metadata:

    sudo apt update
  2. Install mdadm:

    sudo apt install mdadm

    Ubuntu may ask whether arrays should be started automatically during boot. Automatic assembly is normally appropriate for a persistent data array; you can review the resulting configuration later.

  3. Confirm the installed version:

    mdadm --version

    On the Jammy package documented above, the relevant version is mdadm 4.2-0ubuntu2. If the command is missing, the installation did not complete successfully.

Identify unused disks without destroying existing data

Before creating anything, map Linux device names to physical disks. Device names can change after hardware or boot-order changes, so record model, serial, and size as well as the name.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINTS,UUID,MODEL,SERIAL

Only select devices that you have confirmed are the intended members. Every selected disk or partition must be unused and unmounted. Check each candidate individually:

lsblk /dev/sdb
findmnt /dev/sdb

If a filesystem is mounted, unmount it before proceeding:

sudo umount /dev/sdb1

The create operation writes RAID metadata and can destroy prior contents. Do not use a disk containing an operating-system partition, a swap area, or irreplaceable files unless you have deliberately backed it up and understand the consequence. For predictable replacement later, use the same partitioning scheme and partition type on every member; whole-disk members are also possible, but you must be consistent when adding replacements.

Rank #2
Sale
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

Create the array

The general create syntax is:

sudo mdadm --create /dev/md/<name> --level=<level> --raid-devices=<n> <devices>

For example, a four-disk RAID10 using whole disks could be:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo mdadm --create /dev/md/data --level=10 --raid-devices=4 /dev/sdb /dev/sdc /dev/sdd /dev/sde

A two-disk mirror would use:

sudo mdadm --create /dev/md/data --level=1 --raid-devices=2 /dev/sdb /dev/sdc

For RAID5 or RAID6, specify at least three or four members respectively:

sudo mdadm --create /dev/md/data --level=5 --raid-devices=3 /dev/sdb /dev/sdc /dev/sdd
sudo mdadm --create /dev/md/data --level=6 --raid-devices=4 /dev/sdb /dev/sdc /dev/sdd /dev/sde

Read the confirmation carefully. mdadm will warn that the devices contain data or that the array is being created with a particular metadata format. Confirm only after checking the device list. The kernel starts the initial resync immediately; do not power off the machine or disconnect members during this operation.

Use partitions when your design requires them

If you created matching partitions, pass those partitions rather than the whole disks, for example:

sudo mdadm --create /dev/md/data --level=1 --raid-devices=2 /dev/sdb1 /dev/sdc1

A replacement must then provide a compatible partition such as /dev/sdd1. A whole-disk array and a partition-member array are different layouts; do not casually substitute one for the other.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Monitor resync and inspect health

Use /proc/mdstat for a quick, continuously updated view:

cat /proc/mdstat

Typical output identifies the array, level, active members, recovery or resync percentage, estimated time, and current speed. A line showing all expected members in brackets and a state such as [UU] indicates that a two-member mirror currently has both members present. A missing position, such as [_U], indicates degradation.

For detailed state, run:

sudo mdadm --detail /dev/md/data

Check these fields:

  • State: clean means no pending synchronization is reported; active means the device is running. degraded, recovering, or resyncing requires attention.
  • Raid Devices and Active Devices: compare the expected count with the active count.
  • Failed Devices and Removed Devices: a nonzero value identifies a member that needs investigation.
  • Update Time and events: useful when comparing member metadata during recovery.
  • Rebuild or resync progress: avoid rebooting or removing hardware until the operation has completed unless the machine is in an emergency.

Run the detail command again after a resync finishes. A healthy array is not merely one that is mounted; all expected members should be active and the state should no longer be degraded.

Make the array assemble after reboot

Save the array’s identity in mdadm’s configuration and rebuild the initial RAM filesystem so early boot can discover it:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter | 85W Max PD, 2 USB 3.0 & 1 USBC Data Ports, SD/TF Card Reader, for Laptops/Mac and Other Type C Devices (Charger Not Included)
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
sudo mdadm --detail --scan

Review the output, then append the correct array definition:

sudo mdadm --detail --scan | sudo tee -a /etc/mdadm/mdadm.conf
sudo update-initramfs -u

If the file already contains an ARRAY line for the same array, edit the file instead of creating duplicate entries. Confirm the saved definition with:

grep -E '^(ARRAY|HOMEHOST|DEVICE)' /etc/mdadm/mdadm.conf

After the array is assembled, create a filesystem if it is new. This step destroys any remaining data on the assembled device:

sudo mkfs.ext4 /dev/md/data

Create a mount point and mount it:

sudo mkdir -p /srv/data
sudo mount /dev/md/data /srv/data

For persistent mounting, obtain the filesystem UUID and add that UUID to /etc/fstab rather than relying on a potentially changing device name:

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo blkid /dev/md/data

Test the entry before rebooting:

sudo mount -a

A filesystem is a separate layer from RAID. mdadm can report a clean array while the filesystem still needs repair, and expanding the array does not automatically expand the filesystem.

Replace a failed member safely

Start by confirming the failure in detail output and in the kernel log. Do not remove a disk merely because one transient read error appeared; verify which physical device corresponds to the failed Linux name.

sudo mdadm --detail /dev/md/data
lsblk -o NAME,SIZE,MODEL,SERIAL,MOUNTPOINTS

Mark and remove the failed member

If mdadm has not already marked it failed, mark the exact member:

sudo mdadm /dev/md/data --fail /dev/sdb

Then remove it from the active configuration:

sudo mdadm /dev/md/data --remove /dev/sdb

For a partition-member array, use the partition name, such as /dev/sdb1. If the device is physically dead, the fail step may report that it is already faulty; verify that the detail output now lists it as failed or removed.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Install and prepare a compatible replacement

Choose replacement media at least as large as the member being replaced. Match the interface and, where practical, the sector size and partition layout. If the original member used a partition, copy the partition table to the new disk using a method appropriate to your environment, then verify the resulting partition size before adding it. Never copy a partition table without checking which disk is source and which is destination.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

After the replacement appears under the expected device name, confirm that it is not mounted and contains no data you need. For a whole-disk array:

sudo mdadm /dev/md/data --add /dev/sdb

For a partition-member array:

sudo mdadm /dev/md/data --add /dev/sdb1

mdadm starts a rebuild when the member is accepted. Monitor both views:

watch cat /proc/mdstat
sudo mdadm --detail /dev/md/data

Leave the system powered and the replacement connected until recovery completes. During a rebuild, the array has less failure tolerance and performance may be reduced. Investigate any second error immediately rather than assuming the first rebuild can continue safely.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Degraded RAID5 or RAID6 after an unclean stop

The Linux kernel RAID documentation warns that parity can be untrustworthy when a degraded RAID5 or RAID6 array starts after an unclean shutdown. Do not treat a degraded start as proof that every block is correct. Review member event counters, identify the most recent consistent set, and secure a backup or disk image before making a risky assembly decision.

In some recovery cases the documented assembly operation requires an explicit --force option. That option overrides mdadm’s normal safety refusal; it is not a repair command and should not be used routinely. Use it only after establishing which members belong to the same array and understanding that parity may need to be rebuilt:

sudo mdadm --assemble --force /dev/md/data /dev/sdb /dev/sdc /dev/sdd /dev/sde

Substitute the exact, verified member list and level for your array. If you cannot establish a consistent set, stop and restore from backup or obtain specialist recovery help. A forced assembly followed by writes can make later recovery harder.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Grow or reshape an array without losing data

mdadm’s --grow operation can reshape supported arrays, including adding capacity or changing the number of active RAID devices. The exact command depends on the current level, metadata, layout, and whether a replacement has first been added as a spare. Read the Jammy mdadm manual for the operation that matches your array instead of copying a command for a different level.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A typical capacity expansion sequence is:

  1. Take and verify a current backup. A reshape is a long, intensive operation; a power loss or second disk failure can leave a parity array unavailable.

  2. Add the new, compatible disk or partition as a spare:

    Best Value
    Sale
    Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display | 85W Max PD, 1 Powered USB-C 5Gbps & 2 Powered USB-A 3.0 5Gbps Data Ports, for MacBook Pro, MacBook Air, Dell and More (Black)
    • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
    • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
    • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
    • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
    • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
    sudo mdadm /dev/md/data --add /dev/sdf
  3. Increase the array’s device count with the appropriate grow command. For example, a four-member target count would be expressed as:

    sudo mdadm --grow /dev/md/data --raid-devices=4

    Use the actual target count and only after confirming that the array level supports the planned reshape.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  4. Monitor reshape progress:

    cat /proc/mdstat
    sudo mdadm --detail /dev/md/data
  5. After mdadm reports completion and the array is clean, expand the filesystem separately. For ext4:

    sudo resize2fs /dev/md/data

    Other filesystems have their own online or offline grow procedures; use the filesystem’s documentation and verify the mount state required by that tool.

  6. Check the resulting filesystem size and run an application-level sanity check before deleting the backup or considering the operation complete.

Do not assume that adding a disk alone increases usable space. Until the reshape and filesystem resize both finish, the extra media may be an unused spare or capacity that the filesystem cannot address.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Stop and dismantle an array

To retire an array, first stop applications and unmount every filesystem that uses it:

sudo umount /srv/data

Stop the MD device:

sudo mdadm --stop /dev/md/data

Remove or update its ARRAY entry in /etc/mdadm/mdadm.conf, then rebuild the initramfs if the configuration changed:

sudo update-initramfs -u

Only after confirming the correct member devices and preserving any needed data should you erase their mdadm metadata:

sudo mdadm --zero-superblock /dev/sdb /dev/sdc

Use partition names if the array used partitions. Zeroing the wrong disk can make another array unassemblable, so verify model, serial, and mount status immediately before running this command. Stopping an array does not itself erase data; formatting or zeroing the wrong device does.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Troubleshooting checklist

  • mdadm: device or resource busy: find mounts and holders with findmnt and lsblk; stop services and unmount the filesystem before creating, stopping, or removing a member.
  • A disk is absent from lsblk: check cabling, power, the enclosure or backplane, and kernel messages. mdadm cannot rebuild onto media the operating system cannot see.
  • The replacement is rejected as too small: compare exact usable sector counts, not just decimal capacity labels. A replacement must be at least as large as the member’s RAID partition.
  • The array assembles under an unexpected name: inspect sudo mdadm --detail --scan and /etc/mdadm/mdadm.conf; use the UUID-based array definition and update the initramfs.
  • The array remains degraded after adding a disk: check mdadm --detail for a rebuilding or spare state, and inspect /proc/mdstat for progress or a new read/write error.
  • Filesystem size did not increase: mdadm growth and filesystem growth are separate. Run the filesystem-specific resize command only after the array reshape is complete.
  • Performance drops during recovery: this is expected while parity or mirror data is copied. Avoid unnecessary heavy I/O, but do not interrupt recovery without understanding the failure risk.

Operational habits that prevent emergencies

  • Record each member’s serial number, slot, partition layout, RAID level, filesystem, and mount point.
  • Check /proc/mdstat and mdadm --detail after installation, replacement, reboot, and any storage alert.
  • Keep a compatible spare or a tested procurement path; rebuild exposure lasts until synchronization completes.
  • Test restoring files from the independent backup. A clean RAID state is not evidence that a backup exists.
  • Document the exact array UUID and the recovery procedure so another administrator can identify the right disk under pressure.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.