WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: How to boot TC5 on mdadm RAID1 correctly?  (Read 3884 times)

Offline virtualbox

  • Newbie
  • *
  • Posts: 21
How to boot TC5 on mdadm RAID1 correctly?
« on: April 11, 2014, 04:30:58 AM »
Hi,

I have installed TC5 on software RAID1 with XFS filesystem (and Grub2).

Kernel and initrd boots fine but TCE folder does not get mapped, because it sits on RAID1. The RAID1 array doesn't get assembled. So this is my question: How to assemble mdadm RAID before home TCE folder gets mapped in boot process.

I have compiled kernel with software RAID support and remastered initrd to contain mdadm and raid-dm. So I want to have somewhere in boot process (way before bootsync for example) a possibility to add "mdadm --assemble /dev/md0 /dev/sda4 /dev/sdb4" for example.

I thougth that maybe the pretce bootcode is a way to go (and use the onpre.sh script to assemble nessesary RAID arrays), but I need to give the path as UUID not with /dev/sda4 or something like this.. But I checked the tc-config source and I don't think it would work with UUID as path.

Grub2 entry:
Code: [Select]
menuentry 'Tinycore Linux' {
load_video
gfxmode $linux_gfx_mode
insmod gzio
insmod part_msdos msdos
insmod diskfilter mdraid1x
insmod ext2
set root='mduuid/eea3afa37c26fba30153695473cb6fc7'
if [ x$feature_platform_search_hint = xy ]; then
  search --no-floppy --fs-uuid --set=root --hint='mduuid/eea3afa37c26fba30153695473cb6fc7'  c390bd7b-1490-41fb-aa7a-760046c06258
else
  search --no-floppy --fs-uuid --set=root c390bd7b-1490-41fb-aa7a-760046c06258
fi
linux /tce/boot/vmlinuz_reiser4_xfs_mdraid quiet noicons noswap syslog waitusb=0:UUID="c390bd7b-1490-41fb-aa7a-760046c06258" tce=UUID="c390bd7b-1490-41fb-aa7a-760046c06258" xvesa=1400x900x32
initrd /tce/boot/core_mdadm.gz
}

Code: [Select]
$ uname -a
Linux 3.8.13-tinycore #8 SMP Tue Mar 4 11:54:42 UTC 2014 i686 GNU/Linux

Code: [Select]
$ version
5.1

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11044
Re: How to boot TC5 on mdadm RAID1 correctly?
« Reply #1 on: April 11, 2014, 05:40:59 AM »
You can easily do it all in bootsync.sh, as there's nothing special about the boot script. You can call tce-setup any time to load extensions.

So in bootsync you would assemble, call tce-setup, and perhaps other things. You would also add the "base" bootcode for a small speedup, avoiding the tce scan.
The only barriers that can stop you are the ones you create yourself.

Offline virtualbox

  • Newbie
  • *
  • Posts: 21
Re: How to boot TC5 on mdadm RAID1 correctly?
« Reply #2 on: April 11, 2014, 06:41:16 AM »
Thanks curaga for your quick reply, I really appreciate it!

Your thoughts resonate well, I will give it a try and get back with results..

Offline gerald_clark

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 4254
Re: How to boot TC5 on mdadm RAID1 correctly?
« Reply #3 on: April 11, 2014, 08:43:24 AM »

Offline virtualbox

  • Newbie
  • *
  • Posts: 21
Re: How to boot TC5 on mdadm RAID1 correctly?
« Reply #4 on: April 11, 2014, 09:07:19 AM »
I described the process in http://wiki.tinycorelinux.net/wiki:pretce

Hi gerald_clark!

Well.. I did think to use this pretce approach.. but I can't give 'sda1' or something like that for pretce to work with, because I have all partitions on whether RAID 1 or RAID0. And the partition with tce dir is on RAID1. Would something like this work in grub2: pretce=md0/pre? I think it would not work, but I haven't tried it. Also it's better to use UUID like I have in grub.cfg, because md0, md1 etc tends to change over time.

UUID c390bd7b-1490-41fb-aa7a-760046c06258 is the RAID1 partition, where tce folder is. If I could point pretce boot code to look into c390bd7b-1490-41fb-aa7a-760046c06258 partition, where onpre.sh script is, I can assemble arrays in that script.

Also I do not want to load some additional extension, because I have all those needed remastered into initrd. I just need to put the raid assembling stuff somewhere into the boot process (also so that I do not break the 'good habits' in TC), so that tce would mapped correctly after boot up.

gerald_clark, maybe you can give me some more specific hints as how could I get this working with pretce. I have used pretce in past successfully to automatically load hardware raid in server, but in that case I did put the pre folder into USB stick, so it could be read whether the RAID arrays are assembled or not. But I do not want to do it this way this time.
« Last Edit: April 11, 2014, 09:10:09 AM by virtualbox »

Offline gerald_clark

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 4254
Re: How to boot TC5 on mdadm RAID1 correctly?
« Reply #5 on: April 11, 2014, 09:24:31 AM »
You don't boot off a RAID 1.  You boot off one of the members of the RAID 1.
The initrd is loaded into RAM, and core then runs from RAM.
It must assemble the RAID array ( using pretce ) before the assembled drives are scanned for the TCE directory.

Offline virtualbox

  • Newbie
  • *
  • Posts: 21
Re: How to boot TC5 on mdadm RAID1 correctly?
« Reply #6 on: April 11, 2014, 10:01:03 AM »
Yes I get that what you mean.. that I assemble the drives before drives are scanned..

..but what I don't get is what do you mean by I boot off one of the members of the RAID 1.

When I first created the RAID1 array for tce folder, I did create unformatted partitions with exactly the same sizes. Then I did mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sda4 /dev/sdb4 etc.. And after that I partitioned /dev/md0 for tce.

How do I supposed to boot off one of the members of the RAID 1.. as they do not contain any filesystem as is.. only RAID partitions..

Thanks!

Offline gerald_clark

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 4254
Re: How to boot TC5 on mdadm RAID1 correctly?
« Reply #7 on: April 11, 2014, 10:13:14 AM »
Make sure the partitions you are building the raid on are flagged as type 'fd'.
You should not be partitioning md0. You should just make your filesystem on it.
If you want to split the RID up into several filesystems, I recommend you use LVM.

Offline virtualbox

  • Newbie
  • *
  • Posts: 21
Re: How to boot TC5 on mdadm RAID1 correctly?
« Reply #8 on: April 13, 2014, 05:35:57 AM »
I have partitioned with the flag 'fd00' (Linux RAID). 10GB partition on each disk for RAID1.
Then mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sda4 /dev/sdb4 etc
And finally I make a filesystem on md0 (not partition), so I have in the end >9GB ext4 in RAID1 for example..

But if you say 'You boot off one of the members of the RAID 1', I still don't get it. Please, can you be more specific as I'm very new in SW raid and booting from it.

Both RAID1 members (/dev/sda4 and /dev/sdb4 or whatever) have no filesystem on it to boot, just the 10GB partitions where RAID1 sits. How am I supposed to boot from one of the members in this case?

================================================

curaga explanation seems more logical, because that way I AM BOOTING FROM RAID1 (where tce home folder is). I boot with base flag to skip tce home scanning, assemble RAID1 in bootsync and mount, call tce-setup to scan tce home and get the boot going..
Somehow GRUB2 manages to delegate boot to RAID1 (with the module mdraid1x I guess) and get kernel and initrd from it (see my first post with grub.cfg). But if kernel has started and extracted initrd, there is no way that without assembling RAID1 to mount the RAID1 filesystem with tce home folder on board, or is there?
« Last Edit: April 13, 2014, 05:55:03 AM by virtualbox »

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11044
Re: How to boot TC5 on mdadm RAID1 correctly?
« Reply #9 on: April 13, 2014, 06:16:47 AM »
Gerald is the expert here, I will defer to him.
The only barriers that can stop you are the ones you create yourself.

Offline virtualbox

  • Newbie
  • *
  • Posts: 21
Re: How to boot TC5 on mdadm RAID1 correctly?
« Reply #10 on: April 13, 2014, 07:31:11 AM »
Thanks curaga!

I managed to get your suggestion to work:

- boot with BASE flag
- assemble RAID1 in bootsync:
      mdadm --assemble /dev/md0 /dev/sda4 /dev/sdb4
      sleep <sec> (I have to put sleep in because otherwise /dev/md0 would not be available)
      tce-setup

I hope that gerald_clark would show me some light here as to how get the same goal with different approach. Recreating RAID arrays is no problem, if it's nessesary..
« Last Edit: April 13, 2014, 07:33:03 AM by virtualbox »