Back to Home

ArchLinux - Software RAID

ArchLinux · SSD · RAID

ArchLinux - Software RAID

    Recently I bought myself two Kingmax SMP35 SSDs with a capacity of 60 GB each. On them, my father and I washed down the hardware RAID 1 using the motherboard and put the Eight (Windows). They spat and demolished. I decided to try the RAID array in Linux and my choice fell on arch (this is the less studied distr from all that I used). There will be no pictures under the cut, but I will upload the conclusions of the programs (:

    Hardware RAID vs. Software RAID


    You probably already prepared for the test with a bunch of details, buns and gingerbread cookies? However, everything is much simpler - the hardware array is not perceived in the archive as an array. That’s all. So, we sculpt software. Tests are conducted on the latest release of arch with the installation script pacstrap . I will not give the entire installation process, but I will keep the chronology and try to convey it to you.

    Go!


    We boot from the installation (s) disk (flash drive). To begin with, we look at the output of the fdisk program in order to navigate the "tins."
    fdisk -l
    Disk /dev/sda: 60.0 GB, 60022480896 bytes
    81 heads, 63 sectors/track, 22973 cylinders, total 117231408 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x2d5689a5
       Device Boot      Start         End      Blocks   Id  System
    /dev/sda1            2048   117231407    58614680   fd  Linux raid autodetect
    Disk /dev/sdb: 60.0 GB, 60022480896 bytes
    81 heads, 63 sectors/track, 22973 cylinders, total 117231408 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x0009e9af
       Device Boot      Start         End      Blocks   Id  System
    /dev/sdb1            2048   117231407    58614680   fd  Linux raid autodetect
    Disk /dev/sdc: 515 MB, 515899392 bytes
    64 heads, 32 sectors/track, 492 cylinders, total 1007616 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x25086445
       Device Boot      Start         End      Blocks   Id  System
    /dev/sdc1   *           0      757759      378880   17  Hidden HPFS/NTFS
    Disk /dev/sdc1: 387 MB, 387973120 bytes
    64 heads, 32 sectors/track, 370 cylinders, total 757760 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x25086445
         Device Boot      Start         End      Blocks   Id  System
    /dev/sdc1p1   *           0      757759      378880   17  Hidden HPFS/NTFS
    Disk /dev/mapper/arch_root-image: 707 MB, 707788800 bytes
    255 heads, 63 sectors/track, 86 cylinders, total 1382400 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk /dev/mapper/arch_lib-modules: 98 MB, 98566144 bytes
    255 heads, 63 sectors/track, 11 cylinders, total 192512 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk /dev/mapper/arch_usr-share: 438 MB, 438304768 bytes
    255 heads, 63 sectors/track, 53 cylinders, total 856064 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes

    We find our SSDs (if you still haven't created partitions, it's time. I used the Linux RAID Auto partition type, the code is fd)
    Next, we create our software array:

    mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sda1 /dev/sdb1


    I created a mirrored array, so the "level" is 1, and depending on the number of sections in the array you change - -raid-devices

    We answer in the affirmative if we really want to create an array. Done! It remains only to create a file system and mount the partition for installing the system:
    mkfs.ext4 /dev/md0
    mount /dev/md0 /mnt

    I created an ext4 file system , but you can create another. To see a list of all available fs write mkfs. and press tab.

    System Installation and Bootloader Configuration


    According to the official manual, we put the system to the item “Installing the bootloader” . The whole problem is that rude first does not support booting from a RAID array, but the second can do this. Therefore we write
    pacstrap /mnt grub2-bios

    Next, follow the same manual to the item "Creating ramdisk'a . " The order is a little different.
    grub-mkconfig -o /boot/grub/grub.cfg
    grub-install /dev/sda
    grub-install /dev/sdb
    mdadm --examine --scan >> /etc/mdadm.conf

    First, we generate a rough config, then put it on all the tins in the array, and then generate the config of the array itself. Next, add the array hook to the ramdisk config
    nano /etc/mkinitcpio.conf
    ищем HOOKS="что-то там" и пишем в конец mdadm
    У меня строка такая:
    HOOKS="base udev autodetect pata scsi sata filesystems usbinput fsck mdadm"

    Next, generate a ramdisk
    mkinitcpio -p linux

    If Custom /etc/mdadm.conf file will be used in initramfs for assembling arrays appears on the screen , then this means that everything is fine (:
    Exit chroot , unmount the partition and reboot. After loading, check the disks via fdisk -l
    fdisk -l
    
    Disk /dev/sda: 60.0 GB, 60022480896 bytes
    81 heads, 63 sectors/track, 22973 cylinders, total 117231408 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x2d5689a5
       Device Boot      Start         End      Blocks   Id  System
    /dev/sda1            2048   117231407    58614680   fd  Linux raid autodetect
    Disk /dev/sdb: 60.0 GB, 60022480896 bytes
    81 heads, 63 sectors/track, 22973 cylinders, total 117231408 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x0009e9af
       Device Boot      Start         End      Blocks   Id  System
    /dev/sdb1            2048   117231407    58614680   fd  Linux raid autodetect
    Disk /dev/md0: 60.0 GB, 59987787776 bytes
    2 heads, 4 sectors/track, 14645456 cylinders, total 117163648 sectors
    Units = sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes

    Where md0 is the RAID array from which the system was loaded

    That's all! (: Good luck and good luck in your endeavors!

    Thanks to sergeyotro for correcting a semantic error

    Read Next