LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General > LinuxQuestions.org Member Success Stories
User Name
Password
LinuxQuestions.org Member Success Stories Just spent four hours configuring your favorite program? Just figured out a Linux problem that has been stumping you for months?
Post your Linux Success Stories here.

Notices


Reply
  Search this Thread
Old 10-29-2019, 01:28 AM   #1
kjensenxz
LQ Newbie
 
Registered: Nov 2018
Location: Carlsbad, NM
Distribution: Debian Sid
Posts: 1

Rep: Reputation: Disabled
Post "/dev/tty: No such device or address" on custom tiny Linux w/ BusyBox - WTF?


I've been working on a tiny Linux distro running just a minimal Linux kernel, BusyBox, and a custom init for a pseudo-embedded project for use exclusively under QEMU/KVM with serial console on stdio or a socket.

The init isn't that hard of a worker; it just mounts the necessary filesystems and runs /bin/sh as root. Come on now, it's a single-user system for a sandbox!

This project is something I've been working on off and on with little success, mostly because of an error I could not figure out kept getting in my way:
Code:
/bin/sh: can't access tty; job control turned off
#
Tonight, I picked back up. Same error. I built strace statically and loaded it into the initramfs. I straced.
Code:
# edited for formatting, /bin/sh printed inside of the strace
openat(AT_FDCWD, "/dev/tty", O_RDWR)    = -1 ENXIO (No such device or address)
ioctl(2, TCGETS, {B9600 opost isig icanon echo ...}) = 0
fcntl(2, F_DUPFD_CLOEXEC, 10)           = 10
ioctl(10, TIOCGPGRP, 0x7ffdb3288af4)    = -1 ENOTTY (Inappropriate ioctl for device)
write(2, "/bin/sh: ", 9)                = 9
write(2, "can't access tty; job control tu"..., 40) = 40
write(2, "\n", 1)
Uhhhh.... cat?
Code:
cat: can't open '/dev/tty': No such device or address
Okay, check the special file attributes. According to LFS, /dev/tty should be a character file with major 5 minor 1.
Code:
# ls -l /dev/tty
crw-rw-rw-    1 0        0           5,   0 Oct 29 05:49 /dev/tty
Okay, my kernel must be misconfigured. After searching for some time how to enable CONFIG_VIRTIO while using make xconfig (just use nconfig or menuconfig, it's so much better), confusing myself with config files, recompiling two or three times, naming & relocating the proper config, I enabled Unix98 and set CONFIG_VIRTIO=y. Oh wait, wrong config.

Also, I couldn't get virtio console to work for an additional half hour. Whatever, it probably won't change anything.

No change. WTF?

I was already typing a question here when I noticed the "Click Here to Find Similar Threads" button. Alright, fine. After reading and re-reading 3 of the relevant matches, some inittab and agetty stuff clicked in my head. /dev/tty is getty's job! (I guess.)

I went back to the drawing board, and decided to test getty before I posted. After fumbling over the way BusyBox wants the command line arguments in my fluster, I eloquently typed:

Code:
# getty -n -l /bin/sh 9600 ttyS0
and was greeted by
Code:
#
Almost two years of ignoring this and doing weird hacks to suppress the error from testing and light "production" (mostly using tail -f -n +2), I figured it out: just freaking use getty.

Thanks for being my rubber duck with advice, LQ.org! ...time to rewrite my init.
P.S., special thanks to greenleaf!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Tiny Core Linux 7.0 Enters Beta, Includes Linux Kernel 4.2.7, GCC 5.2 and BusyBox 1.24.1 LXer Syndicated Linux News 0 01-07-2016 07:51 AM
/dev/tty: No such device or address ? Answer Ram Kankanampati Linux - General 2 09-21-2011 03:55 AM
cpio: /dev/tty: No such device or address dougbourne Linux - Server 6 10-09-2008 12:28 PM
/dev/tty: No such device or address ? dkennedy Linux - General 2 08-01-2006 11:28 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General > LinuxQuestions.org Member Success Stories

All times are GMT -5. The time now is 01:08 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration