0

First off; I am sorry if my title is incorrect, but I didn't want to "clutter" it too much.

I am creating a bash script which is used to install various servers based on CentOS 6 and CentOS 7 with hardware raid and software RAID 1. So far I am doing pretty well. CentOS 6 (hardware RAID and software RAID 1) is completely done.

However I am now experiencing an issue re-installing a CentOS 7 through a kickstart file which has already software RAID 1 installed on it. For a pre-installed hardware RAID this is not an issue, as I can use "set root='hd0,gpt2'" in my script.

I think I need to use (on a CentOS 7 with software RAID 1) the "set root='mduuid/950f53e3b96cf5bbde74b5665f8d124c'" option, correct (first question)?

So I tried the following on the server (sorry not a clean code writer whatsoever):

tmpraid=$(cat grub.cfg | grep -e 'set root=' | head -1)
tmpraid2="${tmpraid::-1}"
tmpraid3=${tmpraid2//set root=\'/}

This results in the following output on the test server: mduuid/950f53e3b96cf5bbde74b5665f8d124c

However when I put this to use in my script, like this:

ssh root@192.168.0.1 "tmpraid=$(cat /boot/grub2/grub.cfg | grep -e 'set root=' | head -1)"
ssh root@192.168.0.1 "tmpraid2="${tmpraid::-1}""
ssh root@192.168.0.1 "tmpraid3=${tmpraid2//set root=\'/}"

It will output: cat: /boot/grub2/grub.cfg: No such file or directory

I am guessing it's trying to run this command on the current server instead of the target server?

Now as for my questions.

  1. Is using the "mduuid"-line correct for booting the kickstart through GRUB2 correct? Or is there a different way?
  2. Why is it saying "No such file or directory" in bash?
  3. Perhaps there is a better / cleaner way to get the "mduuid"-line from the target server?

I hope explained everything detailed enough to receive some help or advice with the above. If not, do not hesitate to ask me. Thank you kindly in advance.

//edit

Well I managed to get the the script working. Had to make some changes after doing a lot of searching and experimenting. Maybe there is an easier way to achieve this kickstart, but if no one explains, I will be trying with this.

    ssh root@$nodeIP "wget http://192.50.100.200/files/getgrub -O /root/getgrub"
    ssh root@$nodeIP "chmod +x /root/getgrub"
    ssh root@$nodeIP "sh /root/getgrub"
    getgrub=$(ssh root@$nodeIP "sh /root/getgrub")

The result is finally stored in getgrub. So I can experiment with that.

HudsonHawk
  • 103
  • 2
  • 14
  • Why are you trying to get this piece of text at all? – Michael Hampton Sep 25 '19 at 17:12
  • As mentioned in my post, I am need it to re-kickstart an existing CentOS 7 server based on software RAID1 without any human interference... – HudsonHawk Sep 25 '19 at 17:15
  • But what are you doing with this UUID? If you just reinstall a system you'll make a new software RAID with a different UUID anyway, so I don't understand why you want the old one? – Michael Hampton Sep 25 '19 at 17:18
  • Because it needs to boot from it. Doesn't it? If there is no UUID, it will not find the software RAID the boot files are and will throw an error or kernel panic. Maybe I am thinking to difficult and there is an easier way? – HudsonHawk Sep 25 '19 at 17:25
  • The installer will generate the GRUB configuration and put in the UUID of the new RAID array that it creates. It doesn't need anyone's help to figure out what that UUID is. – Michael Hampton Sep 25 '19 at 17:27
  • In order to run the installer it would need access to vmlinuz and initrd, right. But how can it be accessed if it cannot find that the software RAID 1 array?! – HudsonHawk Sep 25 '19 at 17:29
  • Are you saying that you put the installer's files on the existing RAID array, and not on something reasonable like a USB stick, DVD image or network share? – Michael Hampton Sep 25 '19 at 17:31
  • Yes, because I though this was easier. I do use a PXE server. After re-reading your reply. Maybe this is better (feel free to correct): https://pastebin.com/H9sx7gjj – HudsonHawk Sep 25 '19 at 17:47
  • Usually in this case you'd serve the installation media via HTTP along with the kickstart .ks file itself. – Michael Hampton Sep 25 '19 at 17:49
  • Didn't I do that in that example on pastebin? – HudsonHawk Sep 25 '19 at 18:01
  • Your pastebin doesn't say anything about where you are serving the vmlinuz and initrd files from. – Michael Hampton Sep 25 '19 at 18:21
  • method=http://192.100.150.200/centos7 – HudsonHawk Sep 25 '19 at 18:22

0 Answers0