CodeRef
CodeRef
  • Software
    • VSCode
  • Midjourney_AI
    • Midjourney Cheat Sheet
  • aws
    • S3 Reference
    • Services
  • bash
    • .bashrc File Contents
    • CAN
    • _System Config File Locations
    • argument-length-limits
    • Conditionals
    • Data Structures
    • File Permissions
    • File Syncing
    • File System
    • Functions
    • General
    • Loops
    • My Functions
    • Networking
    • Number Operations
    • OpenVPN
    • Operators
    • Resource Management
    • Serial RS232
    • Spinning Wheel Animation
    • SSH
    • Text Operations
    • Environment Variables
  • cpp
    • ChatGPT | Pointers vs. References
    • arrays
    • Classes
    • Data Types / Structures
    • Enumerated Classes
    • Exception Handling
    • Function Objects
    • Functions
    • I/O
    • Loops
    • Macros
    • Namespaces
    • New Features
    • Pointers
    • Scope
    • Smart Pointers
    • Raw String Literals
    • Style Guide
    • Switch Case
    • Templating
    • How to Use tinyxml2
    • Useful Libraries
    • google-test
    • Conditionals
    • Rule of Three/Five
    • Optional Parameters
    • Keywords
    • Filesystem
    • Random
    • Casting
    • tools
  • git
    • Code Review Dependency Strategy
    • Git Bisect Guide
    • Git Reference
    • removing-cherry-picks
    • Useful Tools
    • Graphite Reference
  • js
    • functions
    • Javascript Reference
  • linux
    • Display
    • Dual Boot with Windows
    • File System
    • NVIDIA
    • Sending/Receiving TCP/UDP Messages in Ubuntu
    • dynamically_linked_binaries
  • markdown
    • Images
    • obsidian-reference
  • python
    • Classes
    • Exceptions
    • Functions
    • Operations
    • Python Reference
    • unittest_command-line-args
    • unittest_magicmock_GPT
    • unittest_mock
    • unittest_printing
    • unittest_subtest
    • useful-stuff
    • jupyter
    • poetry
  • ros
    • _ROS Cheat Sheet
    • Create New Workspace
    • Install ROS
    • Node Sample - Listener
    • Node Sample - Talker
    • Node Template
    • Setup
    • urdf
  • excel
    • excel-reference
  • windows
    • File System
    • WSL - Windows Subsystem for Linux
    • WSL
  • software_engineering
    • uncle_bob_lectures
      • Overview
      • Lesson 01 - Notes
  • web
    • Front End
    • Hugo
    • new_frontend_tools
  • sql
    • cheatsheet
Powered by GitBook
On this page
  • Mounting File Systems
  • RAID
  • Create RAID Array Using 'mdadm'
  • 1. Create RAID Container
  • 2. Create RAID Volume
  • 3. Create 'mdadm.conf' File
  • 4. Update 'mdadm' to use 'mdadm.conf' File
  • 5. Create a Mount Point for the RAID Array and Save it in the '/etc/fstab' File
  • 6. Update Permissions to be able to read and write from the RAID drive
  • Get Information About RAID Array
  • Remove RAIDs that were Previously Created
  • Restart a RAID that was Previously Running
  1. linux

File System

Last updated 2 years ago

Mounting File Systems

  • Usually you don't need to add lines for disks into /etc/fstab

  • The OS will detect and mount the drives automatically, or let the user mount them

  • You only need to try adding lines to /etc/fstab if the OS doesn't see the drive at all, but it does show up in "lsblk"

  • BE CAREFUL - if you add a line to /etc/fstab and then change the disk partitioning or structure in any way, the system will not be able to mount it on startup and Linux could fail to boot.

    • In my case, I created a hardware RAID after adding the individual HDD's as separate lines to /etc/fstab, causing Ubuntu not to boot (or boot into emergency mode)

    • You might see a message "booting into emergency mode" when it fails to boot.

  • The solution is to delete any lines you added from /etc/fstab and it should boot again.

RAID

  • UBUNTU DOES NOT LIKE RAID ARRAYS CREATED BY THE INTEL HARDWARE RAID BOARD

    • Intel RST (Rapid Storage Technology) - hardware RAID driver

    • This is strange because I booted from a Lubuntu live USB and it saw the hardware RAID just fine

    • But for whatever reason, Ubuntu 22.04 didn't see the original hardware RAID that was there, and I can't get it to see a new one that I reformat and set up with the Intel hardware.

    • Creating the Intel hardware RAID causes corruption in the first HDD's backup GPT table, which throws a warning in "sudo fdisk -l"

    • When trying to add the hardware RAID into /etc/fstab and mounting it, it throws errors "wrong fs type, bad option, bad superblock, missing codepage or helper program, or other error." Or, "can't read superblock on /dev/…"

    • Clearly the hardware RAID board is modifying the first HDD's partition table in a way that Ubuntu doesn't like.

  • Rather than use the hardware RAID, better to use mdadm to make a Linux software RAID.

  • sudo apt install mdadm

  • man mdadm

  • Mdadm cheat sheet |

  • Intel RST in Linux Guide |

    • Contains error in RAID container create command - list of devices must come immediately after "-n 3" option

    • There are numerous errors in the code snippets in this document

  • mdadm guide |

  • RAID comparison table |

Create RAID Array Using 'mdadm'

1. Create RAID Container

2. Create RAID Volume

3. Create 'mdadm.conf' File

# By default, root doesn't have a password in Ubuntu. Set one as follows.
sudo passwd root
# Must be root for this command - sudo is insufficient
su
mdadm --detail --scan >> /etc/mdadm/mdadm.conf

# Remove this line if it is in the file
name=[devicename]:[x]  # Line format
name=ubuntu-test:0     # Line example

4. Update 'mdadm' to use 'mdadm.conf' File

# Update mdadm to use new mdadm.conf file.
sudo update-initramfs -u

5. Create a Mount Point for the RAID Array and Save it in the '/etc/fstab' File

# Open fstab file.
sudo vim /etc/fstab
# Add the following line (example):
/dev/md0 [path_to_mount_point] ext4 defaults 1 2
# More example fstab file contents for regular individual drives:
/dev/sda1 /media/1TB_CH0 exfat defaults 1 2
/dev/sdb1 /media/1TB_CH1 exfat defaults 1 2

6. Update Permissions to be able to read and write from the RAID drive

# These are recommended but don't always work:
sudo chown [user] [mount path]
sudo chown oakdell /media/oakdell/nas
# Add these options to /etc/fstab.
# There is no group "users" in Ubuntu by default,
# but one could be created for this purpose.
/dev/md0 /media/username/nas exfat defaults,uid=oakdell,gid=users,dmask=0007,fmask-0117 1 2

# These options also work (if current user is member of group,
# don't need uid). However, for some reason this results
# in deleted files not going to the trash, but being
# permanently deleted with a warning.
/dev/md0 /media/oakdell/nas exfat defaults,gid=oakdell,dmask=0007,fmask-0117 1 2

Get Information About RAID Array

# Display information about the RAID metadata
# format used by mdadm on the current system platform.
mdadm -–detail-platform
# Display RAID metadata format for a specific RAID array.
mdadm --detail /dev/md0
# Get RAID config information for a single disk in the array.
sudo mdadm -E /dev/sda
# See which RAID arrays are currently running.
cat /proc/mdstat
# Show real-time updates of the mdstat file to track progress.
watch -d cat /proc/mdstat

Remove RAIDs that were Previously Created

cat /proc/mdstat
# Do this for each one listed
sudo mdadm --stop /dev/md126
# Do this for each one listed
sudo mdadm --remove /dev/md1

sudo mdadm --zero-superblock /dev/sda /dev/sdb
lsblk
cat /proc/mdstat

Restart a RAID that was Previously Running

sudo mdadm --assembly /dev/md0

Great article |

List of options for fstab entries |

Meaning of "major" and "minor" |

Guide |

Mdadm Cheat Sheet
Intel® Rapid Storage Technology (Intel® RST) in Linux*
How to Set Up RAID in Linux
RAID level comparison table
fstab mount options for umask, fmask, dmask for ntfs with noexec
Fstab File ( /etc/fstab ) Entry Options in Linux
https://www.linuxquestions.org/questions/linux-general-1/detailed-information-about-mdadm-output-781033/
Removal of mdadm RAID Devices – How to do it quickly?