1

I use Slackware 14.2 (with kernel 4.4.14-smp) on sda and I'm trying to create the RAID 1 with additional sdb. I'm using the VM VirtualBox.

First, I have cleaned the sdb:

dd if=/dev/zero of=/dev/sdb bs=8M count=1000

and copied the sda's partitions to sdb:

sfdisk -d /dev/sda | sfdisk /dev/sdb

Next, I've changed the type of partitions to "Linux raid autodetect":

Device     Boot     Start       End   Sectors Size Id Type
/dev/sda1            2048   8390655   8388608   4G 82 Linux swap
/dev/sda2  *      8390656 113248255 104857600  50G 83 Linux
/dev/sda3       113248256 209715199  96466944  46G  5 Extended
/dev/sda5       113250304 144707583  31457280  15G 83 Linux
/dev/sda6       144709632 176166911  31457280  15G 83 Linux
/dev/sda7       176168960 209715199  33546240  16G 83 Linux

and

Device     Boot     Start       End   Sectors Size Id Type
/dev/sdb1            2048   8390655   8388608   4G fd Linux raid autodetect
/dev/sdb2  *      8390656 113248255 104857600  50G fd Linux raid autodetect
/dev/sdb3       113248256 209715199  96466944  46G  5 Extended
/dev/sdb5       113250304 144707583  31457280  15G fd Linux raid autodetect
/dev/sdb6       144709632 176166911  31457280  15G fd Linux raid autodetect
/dev/sdb7       176168960 209715199  33546240  16G fd Linux raid autodetect

For each partition (md1,md2,md5,md6,md7), I did next:

mdadm --create /dev/md1 --level=1 --metadata=0.90 --raid-disk=2 missing /dev/sdb1

and made filesystems on created arrays:

mkswap /dev/md1
mkreiserfs -fq /dev/md2
mkreiserfs -fq /dev/md5
mkreiserfs -fq /dev/md6
mkreiserfs -fq /dev/md7

saved the raid configuration:

mdadm --examine --scan >> /etc/mdadm.conf

Next, /etc/fstab and /etc/mtab were edited by replacing sdaX->mdX and the initial ramdisk were prepared:

mkinitrd -c -k 4.4.14-smp -f reiserfs -r /dev/md2 -m reiserfs:dm-raid -u -o /boot/initrd_raid.gz

Configured the grub:

cp /etc/grub.d/40_custom /etc/grub.d/09_swraid1_setup
#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
menuentry 'Slackware-14.2 GNU/Linux' --class slackware-14.2 --class gnu-linux --class os {
    insmod mdraid09
    insmod mdraid1x
    insmod gzio
    insmod part_msdos
    insmod reiserfs
    set root='md2,msdos2'
    echo    'Loading Linux 4.4.14-smp ...'
    linux   /boot/vmlinuz-huge-smp-4.4.14-smp root=/dev/md2 ro
    echo    'Loading inital ramdisk ...'
    initrd  /boot/initrd_raid.gz
}

I have edited the /etc/default/grub by uncomment:

GRUB_TERMINAL=console
GRUB_DISABLE_LINUX_UUID=true

Finally:

grub-mkconfig -o /boot/grub/grub.cfg

And data were copied from sda to sdb (cp -dpRx / /mnt/md2 and etc.).

GRUB was installed:

grub-install /dev/sda/
grub-install /dev/sdb/

Output at loading:

Loading Linux 4.4.14-smp ...
error: disk 'md0,msdos2' not found.
Loading inital ramdisk ...
error: you need to load the kernel first.

The question is: which modules should I add to initrd and how should I config the grub?

UPD: /etc/grub.d/09_swraid1_setup was edited:

...
set root='md/md2'
...
initrd  /boot/initrd.gz

/etc/mkinitrd.conf was added to create initrd image:

# mkinitrd.conf.sample
# See "man mkinitrd.conf" for details on the syntax of this file
#
#SOURCE_TREE="/boot/initrd-tree"
#CLEAR_TREE="0"
OUTPUT_IMAGE="/boot/initrd.gz"
KERNEL_VERSION="$(uname -r)"
#KEYMAP="us"
MODULE_LIST="reiserfs"
#LUKSDEV="/dev/sda2"
#LUKSKEY="LABEL=TRAVELSTICK:/keys/alienbob.luks"
ROOTDEV="/dev/md2"
ROOTFS="reiserfs"
RESUMEDEV="/dev/md1"
RAID="1"
#LVM="0"
UDEV="1"
#MODCONF="0"
WAIT="5"

and initrd image was created with:

mkinitrd -F

after updating grub (grub-mkconfig -o /boot/grub/grub.cfg and grub-install /dev/sda, grub-install /dev/sdb) , system was rebooted sucessfully. After that, sda's partitions type was changed to Linux raid autodetect and partitions were added to array:

mdadm --add /dev/md1 /dev/sda1
mdadm --add /dev/md2 /dev/sda2
mdadm --add /dev/md5 /dev/sda5
mdadm --add /dev/md6 /dev/sda6
mdadm --add /dev/md7 /dev/sda7

Now, the system booting with two disk is succesfull,but when I remove one of disks and try to boot, I get that:

/boot/initrd.gz: Loading kernel modules from initrd image:
insmod /lib/modules/4.4.14-smp/kernel/fs/reiserfs/reiserfs.ko
modprobe: ERROR: could not insert 'reiserfs': Device or resource busy
Trying to resume from /dev/md1
[    12.529675] PM: Starting manual resume from disk
[    12.552222] REISERFS warning (device md2): sh-2006 read_super_block: bread failed (dev md2, block 2, size 4096)
[    12.557432] REISERFS warning (device md2): sh-2006 read_super_block: bread failed (dev md2, block 16, size 4096)
mount: mounting /dev/md2 on /mnt failed: Invalid argument
ERROR: No /sbin/init found on rootdev (or not mounted). Trouble ahead.

Now, question is: how to boot the system without one of disks?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.