[SOLVED] What do I need to boot from /dev/md0?

Post Reply
kbs1
Posts: 21
Joined: Sun Apr 26, 2015 2:17 am
languages_spoken: english, slovak, czech
ODROIDs: C1
Contact:

[SOLVED] What do I need to boot from /dev/md0?

Unread post by kbs1 » Thu May 28, 2015 4:32 pm

Whatever I try, the system never boots. I do not have a proper HDMI monitor, or there's no output (using HDMI to DVI cable). There IS output once the system is booted.

Anyways, I'm always only using SSH. Since I absolutely definitely can not find any guide on how to boot from md0 on C1, I've started writing my own. Step by step. I've even written my own update-initramfs.sh and update-kernel.sh scripts. I'm planning to use Debian Jessie only. 35+ hours over 4 weeks digging into this (not even an overestimate), I've run out of ideas.

Here's my WORK IN PROGRESS guide, on how to boot from md0. It does not work. The system boots right away if I use /dev/mmcblk0p2.

-------------------------------------

0. Build or download SD card image, burn it and insert it into your ODROID C1 ;-) [2]

1. Disable the usbmount-start service, as it might conflict with our desired USB disks usage as a md raid1 array.
insserv --remove usbmount-start
umount the disks if necessary
umount /dev/sda1
umount /deb/sdb1

2. Wipe out the USB disks you are going to use as the root filesystem. This ensures they contain nothing valid, and that mdadm (or kernel!!!) won't automatically assemble them at boot.

dd if=/dev/zero of=/dev/sda bs=16M
dd if=/dev/zero of=/dev/sdb bs=16M

To view your progress, use
kill -USR1 `pidof dd`

If you are certain there were no previous raid arrays on the disks, you can append count=10 to the above commands and have it done much quickier.

3. Resize your sd card partition to full size, to add room for new packages to be installed.

fdisk /dev/mmcblk0
type:
p, enter
Note the *start* od /dev/mmcblk0p2 partition, in my case it's 80325.
type:
d, enter, 2, enter
n, enter, enter, enter, type 80325 as start sector - CAREFUL: default is hihger, and if you make a mistake here, you'll destroy your filesystem!, enter, enter.
w, enter

reboot

resize2fs /dev/mmcblk0p2

4. See if /dev/md0 exists:
ls /dev/md0

If yes, try rm -fr /dev/md0, worked for me (funny), md0 was present even *AFTER* I completely wiped out the disks AND rebooted my system, nothing helped, cat /dev/md0 returned zero bytes, simply deleting the "file" afterward worked.
If simple remove operation fails, you have to erase the whole disks, repeat step 2 without count=10 argument.

5. Install mdadm.

apt-get install mdadm
answer ok, all

update-initramfs will complain about /boot mounted as read only. This is OK and is in accordance with our plans.

6. Partition your USB disks [1]

fdisk /dev/sda
type:
n, enter, enter, enter, enter, enter
t, enter, fd, enter
a, enter
w, enter

Repeat for /dev/sdb.

If you get this message for either /dev/sda or /dev/sdb saying:
Re-reading the partition table failed.: Device or resource busy
just complete the fdisk steps for both /dev/sda and /dev/sdb and reboot your system.

6. Initialise the array [1]

mdadm --zero-superblock /dev/sda1 /dev/sdb1

If you have thoroughly erased your disks, you will see messages like
mdadm: Unrecognised md component device - /dev/sdb1
These are OK and not to be worried about.

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

I chose superblock format 0.90, but it probably doesn't matter for our application, since we aren't booting *directly* from the USB disk (as for example BIOS / GRUB does on a standard PC). Rather we boot from a SD card, which loads the Kernel, which in turn runs the iniramfs, where md reads the disks. Therefore the superblock format does not matter much as md knows how to read both formats.

7. Configure mdadm [1]
cp /etc/mdadm/mdadm.conf /etc/mdadm/mdadm.conf_orig
mdadm --examine --scan >> /etc/mdadm/mdadm.conf
dpkg-reconfigure mdadm
answer all, yes, yes, root

This will configure our initramfs to properly start the md0 array, but will not build it.

8. Create the USB raid filesystem [1]
mkfs.ext4 /dev/md0
mkdir -p /media/md0
mount /dev/md0 /media/md0
cp -afxv / /media/md0

9. Append required initramfs modules into initramfs-tools/modules [1]
printf "\nraid1\nmd_mod\next4\n" >> /etc/initramfs-tools/modules

9. Update your initramfs using the initramfs-update.sh script.

10. Update your boot.ini
mount -o remount,rw /boot
nano /boot/boot.ini
replace setenv bootargs "console=ttyS0,115200n8 console=tty0 root=/dev/mmcblk0p2
with setenv bootargs "console=ttyS0,115200n8 console=tty0 root=/dev/md0
sync

11. Reboot into your new system! :)

References
[1] http://blog.drewwithers.com/2013/11/ras ... ition.html - I basically followed this giude for my Raspberry Pi 2. However for odroid, this was not applicable.
[2] http://forum.odroid.com/viewtopic.php?f=114&t=8084 - Minimal Debian Jessie / wheeze by Tomuta - thanks for your wonderful Debian Jessie minimal distribution.

--------------------------------------------

The only thing I might still later try is to compile RAID1 module into the kernel. Currently only MD is compiled in, which *SHOULD* be enough. But maybe it's not.

As for the command line, I've also tried this: https://github.com/rsyoung/odroid-x/blo ... ion/md.txt
It did not help. Command lines root=dev/md0 md=0 or root=/dev/md0 md=0,1,4,0,/dev/sda1,/dev/sdb1 do not boot.

Altering /etc/fstab to have /dev/md0 as / does not seem to have any effect at all on anything (seems like the root device is just selected at startup and that's it).

I'm clueless now. Why doesn't it boot? My update scripts are attached. They WORK. The system just never boots from md0. Any help would be much much appreciated.

THANKS A LOT! :))

.
Attachments

[The extension sh has been deactivated and can no longer be displayed.]

[The extension sh has been deactivated and can no longer be displayed.]

Last edited by kbs1 on Sun Jun 21, 2015 8:59 am, edited 1 time in total.

kbs1
Posts: 21
Joined: Sun Apr 26, 2015 2:17 am
languages_spoken: english, slovak, czech
ODROIDs: C1
Contact:

Re: What do I need to boot from /dev/md0?

Unread post by kbs1 » Fri May 29, 2015 10:23 am

Compiling raid1 module into the kernel did not help at all :( Still the same thing. Does anyone have any suggestions?

kbs1
Posts: 21
Joined: Sun Apr 26, 2015 2:17 am
languages_spoken: english, slovak, czech
ODROIDs: C1
Contact:

Re: What do I need to boot from /dev/md0?

Unread post by kbs1 » Sun May 31, 2015 12:40 pm

> I do not have a proper HDMI monitor, or there's no output
- There's no output. This is just horrendous. Mode just switches from 1280x720 to 1920x1280 and that's IT. Straight HDMI to a very modern 2015 LED Samsung TV.

kbs1
Posts: 21
Joined: Sun Apr 26, 2015 2:17 am
languages_spoken: english, slovak, czech
ODROIDs: C1
Contact:

Re: [SOLVED] What do I need to boot from /dev/md0?

Unread post by kbs1 » Sun Jun 21, 2015 9:00 am


Post Reply

Return to “Other OS”

Who is online

Users browsing this forum: No registered users and 1 guest