You are not logged in.

#1 2016-05-23 17:18:54

Schonka
Member
Registered: 2016-05-20
Posts: 5

Serial console in early GRUB 2

Hello,

###
my previous Thread got deleted, because I used Parabola. This time I used Arch.
###

I encrypted my whole /, so I have to type my disk passphrase twice during boot. Once for GRUB to be able to decrypt the kernel and the initial ramdisk and again, so that the initial ramdisk can decrypt /.
I won't have physical access to the machine in the future, but I can use the serial console. I configured it, but it doesn't work in early GRUB yet, it only works after I typed the first passphrase.

I edited /etc/default/grub, generated the grub configuration file, and installed grub on sda and sdb. This is my /etc/default/grub:


GRUB_DEFAULT=0
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="Arch"
GRUB_CMDLINE_LINUX_DEFAULT=""
GRUB_CMDLINE_LINUX="cryptdevice=UUID=ffe69500-33a8-4989-8ca3-ea1a7eafa33c:cryptroot console=ttyS0,57600"
GRUB_PRELOAD_MODULES="part_msdos lvm"
GRUB_GFXMODE=auto
GRUB_GFXPAYLOAD_LINUX=keep
GRUB_DISABLE_RECOVERY=true
GRUB_TERMINAL=serial
GRUB_ENABLE_CRYPTODISK=y
GRUB_SERIAL_COMMAND="serial --speed=57600 --unit=0 --word=8 --parity=no --stop=1"


As far as I understand, grub-install generates the i386 image, which is copied to the very first blocks of the HDD. So if grub-install uses /etc/default/grub it should already enable the serial console for the i386-pc image.

This is my grub.cfg: http://pastebin.com/gE9gEFuP

Can you help me getting GRUB to talk to the serial console in its earlierst stage?

Thanks in Advance
Schonka

Offline

#2 2016-05-23 17:36:04

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 16,282

Re: Serial console in early GRUB 2

Schonka wrote:

my previous Thread got deleted, because I used Parabola. This time I used Arch.

I am skeptical.  I hope I am wrong.

Did you follow this guide? https://wiki.archlinux.org/index.php/wo … al_console
What type of hardware is used for your serial port? What does it show up in /dev as?

Last edited by ewaller (2016-05-23 17:37:48)


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#3 2016-05-23 18:33:17

Schonka
Member
Registered: 2016-05-20
Posts: 5

Re: Serial console in early GRUB 2

Sadly you are not wrong sad
https://bbs.archlinux.org/viewtopic.php?pid=1628750
Parabola = Arch, imo

Yes, i followed the guide. Thats why I included
GRUB_TERMINAL=serial
GRUB_SERIAL_COMMAND="serial [...]"
and added console=ttyS0,57600 to
GRUB_CMDLINE_LINUX_DEFAULT=

In /dev it's ttyS0.

I just found this in dmesg
[    0.955749] 00:01: ttyS0 at I/O 0x3f8 (irq = 4, base_baud = 115200) is a 16550A
I will try 115200 as baud rate, maybe that helps.

EDIT: Changing the baud rate resulted in broken symbols being put out. I think the parameters are correct, considering they work as soon as the kernel is loaded.

Last edited by Schonka (2016-05-23 18:51:08)

Offline

#4 2016-05-23 18:57:25

JohnBobSmith
Member
From: Canada
Registered: 2014-11-29
Posts: 804

Re: Serial console in early GRUB 2

Schonka wrote:

...
Parabola = Arch, imo
...

Doh! How can a derivative (derivative?) possibly be the same thing as the original (Arch) ! They are NOT the same, and I believe there is even a wiki entry as to why derivatives/whatever are not supported because they change a great deal of things regular Arch users cannot (and should not) be held accountable for. I hope that makes sense.

On another note, why are you using tty50? In my limited experience with GRUB and tty's, that doesn't make much sense at a first glance. What may be needed, however, is to see if there is an early hook or something of the sorts with mkinitcpio.

Good luck with your project smile

EDIT: And in case you haven't looked through the wiki already: https://wiki.archlinux.org/index.php/wo … al_console

Last edited by JohnBobSmith (2016-05-23 18:59:30)


I have been diagnosed with Bipolar Disorder. As it turns out what I thought was once my greatest enemy is now my greatest strength is still my greatest enemy...
As of October 2018, I no longer feel disabled. I never thought this day would come. Go me. smile

Offline

#5 2016-05-23 19:05:21

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 16,282

Re: Serial console in early GRUB 2

I had no doubt that the thread had been closed, it is our policy..  My skepticism is whether you made the change to Arch.  But, I decided to provide the benefit of doubt, I hope I am not disappointed.
Parabola is a fine distribution with a noble cause.  I would encourage anyone seeking assistance with Parabola to seek help their to help strengthen that community.  But, it is not Arch.  And that is also our policy.  Enough said.

You talk of broken symbols.  Does that mean you are seeing garbled characters on your serial terminal?   Without setting up grub and the serial terminal, can you just use a redirect to send data and have it displayed.  For instance, try:  sudo bash -c "ls -l / > /dev/ttyS0

Last edited by ewaller (2016-05-23 22:01:26)


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#6 2016-05-23 19:40:49

Schonka
Member
Registered: 2016-05-20
Posts: 5

Re: Serial console in early GRUB 2

Of course I made the switch to arch. As soon as I know what configuration option I was missing, I will change back to parabola. Just take a look at my grub.cfg... The effort of faking this seems unreasonable for me.

Yes garbled characters. I changed the baud rate back to 57600 and the serial console works again. I will try redirecting as you explained, when I have time again. I am still at work right now.

Offline

#7 2016-05-23 19:58:21

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 16,282

Re: Serial console in early GRUB 2

Wait, I missed that the serial terminal works after boot.  So, the issue is in Grub itself.  I looked at your config file, but did not see any effects of the /etc/default/grub file.  Did you rebuild the config file using grub-mkconfig -o /boot/grub/grub.cfg?

Of course I made the switch to arch. As soon as I know what configuration option I was missing, I will change back to parabola. Just take a look at my grub.cfg... The effort of faking this seems unreasonable for me.

Perhaps I am jaded. The moderation team has had more than one person pull that on us.  One person even hand edited the kernel name in the output logs.  They missed the fact that the accompanying date stamps were not consistent with our build dates.


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#8 2016-05-23 20:26:07

Schonka
Member
Registered: 2016-05-20
Posts: 5

Re: Serial console in early GRUB 2

I understand you guys being distrustful in that case. Maybe I will create an account for you to check that its really arch now (via ssh), but I wont have access to my machine until ~16 hours from now.

Yes I generated the config file again after editding default/grub. Well, how could I have missed that... I will edit grub.cfg tomorrow, and grub-install afterwards.

Sorry if my english is wonky, I am not a native speaker smile

Offline

#9 2016-05-23 21:52:21

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 20,477
Website

Re: Serial console in early GRUB 2

Thanks for your understanding Schonka.  Seeing now that this is not a parabola specific issue, I'd be happy to offer help if I were qualified - unfortunately I have no experience with Grub2.  If you are willing to set up arch just to figure this out, I hope someone here can help.

As for your English, it looks very good to me.  I would not have guessed you were not a native speaker.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#10 2016-05-23 23:36:35

frostschutz
Member
Registered: 2013-11-15
Posts: 648

Re: Serial console in early GRUB 2

It's entirely possible that grub2 just doesn't support this feature... cryptodisk /boot support is a bit of a hack really, the GRUB_ENABLE_CRYPTODISK= setting is handled as a special case [in util/config.c], but there is no such treatment for GRUB_TERMINAL(_INPUT/OUTPUT). And in util/grub-install.c [which I blindly assume is responsible for installing the grub core image that doesn't get encrypted because it's the only place that has have_cryptodisk handling code] there is various code that "pushes" various modules to handle encryption, file systems, raid etc. but no code to push the module for serial terminal. So I assume the serial only ever comes up after grub reads the grub.cfg which specifies serial output, but for that to happen with encrypted /boot you have to decrypt first so...

Maybe you could patch grub's util/grub-install.c and all it would take to make it work is another push call for the serial module. Or maybe not.

I don't really see the point in encrypting /boot.

Offline

#11 2016-05-24 00:46:13

R00KIE
Forum Moderator
From: Between a computer and a chair
Registered: 2008-09-14
Posts: 4,734

Re: Serial console in early GRUB 2

I don't have much experience with grub2 and serial but there is one thing I find strange, why go for 57600 or 115200 baud if you can use 9600 which is the default for lots of things (and probably better tested)? If you have quiet as one of the kernel parameters it should not make things too slow.


R00KIE
Tm90aGluZyB0byBzZWUgaGVyZSwgbW92ZSBhbG9uZy4K

Offline

#12 2017-01-08 10:21:09

Natanji
Member
Registered: 2009-09-22
Posts: 128

Re: Serial console in early GRUB 2

Just wanted to come back to this thread; I had the exact same problem as you, and did a writeup on how to fix it over on my blog. Hope that helps anyone finding this. https://natanji.wordpress.com/2017/01/0 … l-console/

Offline

#13 2017-01-08 12:27:28

R00KIE
Forum Moderator
From: Between a computer and a chair
Registered: 2008-09-14
Posts: 4,734

Re: Serial console in early GRUB 2

@Natanji
That is information that would be best put in the wiki instead of coming here reviving an old thread and shamelessly promoting your blog.

Since this qualifies as necro-bumping I'm closing this thread.


R00KIE
Tm90aGluZyB0byBzZWUgaGVyZSwgbW92ZSBhbG9uZy4K

Offline

Board footer

Powered by FluxBB