# Single user mode via telnet



## sharty (Feb 2, 2013)

I have a device that was built upon FreeBSD 7.0-RELEASE-p2 #0 that provides traffic filtering and limiting. The company that I purchased it from is no longer in business. I have received a few emails from them for support issues but all have been very spotty.

Recently the user web interfaces stopped functioning. When I looked at the boot logs I see it is requesting that I run fsck on the disk system.  The problem is that I am 150 miles away from the server. I only have access to it via telnet. My goal is to have the server switch modes without rebooting and maintain the telnet connection or to create an environment where it reboots into single user mode by default and supports telnet.

Is it possible to accomplish this? I should add here that while I have tinkered with various UNIX flavors over the years I am by no means fluent in their use. I am at this point referring to the FreeBSD manual for syntax and command functionality in almost everything I do.


----------



## wblock@ (Feb 2, 2013)

I don't know if that will work in single user mode.

A fairly common way of doing that is with a serial-to-IP device.  For example, http://www.perle.com/products/Serial-to-Ethernet.shtml.  This would use FreeBSD's capacity for a serial console.  Another computer onsite could also be used: ssh(1) to it, then run cu(1) to connect to the appliance.

Of course that would depend on being able to configure the appliance to use a serial console.  If that's not possible, there are network devices that do similar functions, only with keyboard and video cables that connect directly to the remote system and transfer both video output and keyboard input over IP.  As far as the appliance is concerned, a keyboard and monitor are directly connected.


----------



## sharty (Feb 3, 2013)

*Next step*

I have given up on the thought of getting single user mode to come through my telnet connection without being on-site to add some hardware. The KVM switch and serial port of a PC to the console port are all workable ideas next time I make the 150 mile drive to be with the server.

I have asked a local person with little knowledge to plug in a keyboard and monitor to the computer.  From my previous posting I should add that this is a generic Intel based computer that is running FreeBSD on it and then loads up some applications. It is not really a packaged appliance. I believe all of the softrware is public domain.  

I was able to get to single user mode and accepted the default shell. All of the posting I have read in the archives stated the next step was to simply type:  fsck -y
and let it run. I received a no such command error instead. I can see the file sitting in /sbin. I can move to that directory. When I type:  fsck -y  it does not find nor executre the command.

What am I missing?


----------



## wblock@ (Feb 3, 2013)

Please name the appliance system, someone may have more specific knowledge about it.

At a single user mode prompt, the command to check and repair filesystems is:
`# fsck -tufs -y`


----------



## jalla (Feb 3, 2013)

sharty said:
			
		

> What am I missing?



The path, most likely. Try `/sbin/fsck -y`


----------



## AlexJ (Feb 4, 2013)

If there is a sign of corrupted files, I would use statically compiled [cmd=]/rescue/fsck -y[/cmd]

I had once a corrupted /lib/libc.so.7 that prevented running /sbin/fsck and "/rescue/*" was a real rescue for me.


----------



## sharty (Feb 4, 2013)

*fsck appears to run with no output or change to disks*

I attempted all three of the suggested fsck(8) command lines.  The line by itself failed.  It could not find fsck(8). The commands: /sbin/fsck -y and /rescue/fsck -y executed and returned immediately to a # prompt with no messages.

I am copying the output from dmesg(8) in the hopes it shows more to an experienced person. The server box was configured by a group out of Wisconsin making a product called TUNA (the ultimate network applicance). What I purchased was some take off on it that the key component is Qos.  It is running on a recycled dual xenon (dual core) processor with 4Gb RAM and a 3 disk RAID5 configuration.  Its purpose is to manage bandwidth. It was designed to work in a bridging mode so that it did not change the IP or MAC address of the packet originator.


```
[qos@SAM ~]$ dmesg
Copyright (c) 1992-2008 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
        The Regents of the University of California. All rights reserved.
FreeBSD is a registered trademark of The FreeBSD Foundation.
FreeBSD 7.0-RELEASE-p2 #0: Sat Jul 12 14:18:46 CDT 2008
    root@qos-1:/usr/src/sys/i386/compile/qos-1
Timecounter "i8254" frequency 1193182 Hz quality 0
CPU: Intel(R) Xeon(TM) CPU 2.66GHz (2658.10-MHz 686-class CPU)
  Origin = "GenuineIntel"  Id = 0xf27  Stepping = 7
  Features=0xbfebfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,C
MOV,PAT,PSE36,CLFLUSH,DTS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE>
  Features2=0x4400<CNXT-ID,xTPR>
  Logical CPUs per core: 2
real memory  = 4026466304 (3839 MB)
avail memory = 3941871616 (3759 MB)
ACPI APIC Table: <INTEL  SWV25   >
FreeBSD/SMP: Multiprocessor System Detected: 4 CPUs
 cpu0 (BSP): APIC ID:  0
 cpu1 (AP): APIC ID:  1
 cpu2 (AP): APIC ID:  6
 cpu3 (AP): APIC ID:  7
ioapic0 <Version 2.0> irqs 0-23 on motherboard
ioapic1 <Version 2.0> irqs 24-47 on motherboard
ioapic2 <Version 2.0> irqs 48-71 on motherboard
lapic0: Forcing LINT1 to edge trigger
kbd1 at kbdmux0
hptrr: HPT RocketRAID controller driver v1.1 (Jul 12 2008 14:18:26)
acpi0: <INTEL SWV25> on motherboard
ACPI Warning (dswload-0794): Type override - [DEB_] had invalid type (Integer) f
or Scope operator, changed to (Scope) [20070320]
ACPI Warning (dswload-0794): Type override - [MLIB] had invalid type (Integer) f
or Scope operator, changed to (Scope) [20070320]
ACPI Warning (dswload-0794): Type override - [DATA] had invalid type (String) fo
r Scope operator, changed to (Scope) [20070320]
ACPI Warning (dswload-0794): Type override - [SIO_] had invalid type (String) fo
r Scope operator, changed to (Scope) [20070320]
ACPI Warning (dswload-0794): Type override - [LEDP] had invalid type (String) fo
r Scope operator, changed to (Scope) [20070320]
ACPI Warning (dswload-0794): Type override - [GPEN] had invalid type (String) fo
r Scope operator, changed to (Scope) [20070320]
ACPI Warning (dswload-0794): Type override - [GPST] had invalid type (String) fo
r Scope operator, changed to (Scope) [20070320]
ACPI Warning (dswload-0794): Type override - [WUES] had invalid type (String) fo
r Scope operator, changed to (Scope) [20070320]
ACPI Warning (dswload-0794): Type override - [WUSE] had invalid type (String) fo
r Scope operator, changed to (Scope) [20070320]
ACPI Warning (dswload-0794): Type override - [SBID] had invalid type (String) fo
r Scope operator, changed to (Scope) [20070320]
ACPI Warning (dswload-0794): Type override - [SWCE] had invalid type (String) fo
r Scope operator, changed to (Scope) [20070320]
acpi0: [ITHREAD]
acpi0: Power Button (fixed)
Timecounter "ACPI-fast" frequency 3579545 Hz quality 1000
acpi_timer0: <24-bit timer at 3.579545MHz> port 0x408-0x40b on acpi0
acpi_ec0: <Embedded Controller: GPE 0x8> port 0xca6,0xca7 on acpi0
cpu0: <ACPI CPU> on acpi0
p4tcc0: <CPU Frequency Thermal Control> on cpu0
cpu1: <ACPI CPU> on acpi0
p4tcc1: <CPU Frequency Thermal Control> on cpu1
cpu2: <ACPI CPU> on acpi0
p4tcc2: <CPU Frequency Thermal Control> on cpu2
cpu3: <ACPI CPU> on acpi0
p4tcc3: <CPU Frequency Thermal Control> on cpu3
pcib0: <ACPI Host-PCI bridge> port 0xcf8-0xcff on acpi0
pci0: <ACPI PCI bus> on pcib0
pci0: <unknown> at device 0.1 (no driver attached)
pcib1: <ACPI PCI-PCI bridge> at device 3.0 on pci0
pci2: <ACPI PCI bus> on pcib1
pcib2: <ACPI PCI-PCI bridge> at device 29.0 on pci2
pci4: <ACPI PCI bus> on pcib2
ahd0: <Adaptec AIC7902 Ultra320 SCSI adapter> port 0x3800-0x38ff,0x4000-0x40ff m
em 0xfe9e0000-0xfe9e1fff irq 50 at device 7.0 on pci4
ahd0: [ITHREAD]
aic7902: Ultra320 Wide Channel A, SCSI Id=7, PCI-X 67-100Mhz, 512 SCBs
ahd1: <Adaptec AIC7902 Ultra320 SCSI adapter> port 0x3000-0x30ff,0x3400-0x34ff m
em 0xfe9f0000-0xfe9f1fff irq 49 at device 7.1 on pci4
ahd1: [ITHREAD]
aic7902: Ultra320 Wide Channel B, SCSI Id=7, PCI-X 67-100Mhz, 512 SCBs
pcib3: <ACPI PCI-PCI bridge> at device 31.0 on pci2
pci3: <ACPI PCI bus> on pcib3
em0: <Intel(R) PRO/1000 Network Connection Version - 6.7.3> port 0x2040-0x207f m
em 0xfe6c0000-0xfe6dffff irq 30 at device 7.0 on pci3
em0: Ethernet address: 00:07:e9:24:17:6a
em0: [FILTER]
em1: <Intel(R) PRO/1000 Network Connection Version - 6.7.3> port 0x2000-0x203f m
em 0xfe6e0000-0xfe6fffff irq 31 at device 7.1 on pci3
em1: Ethernet address: 00:07:e9:24:17:6b
em1: [FILTER]
pci0: <unknown> at device 3.1 (no driver attached)
pci0: <serial bus, USB> at device 29.0 (no driver attached)
pci0: <serial bus, USB> at device 29.1 (no driver attached)
pcib4: <ACPI PCI-PCI bridge> at device 30.0 on pci0
pci1: <ACPI PCI bus> on pcib4
vgapci0: <VGA-compatible display> port 0x1000-0x10ff mem 0xfd000000-0xfdffffff,0
xfe3f0000-0xfe3f0fff irq 17 at device 12.0 on pci1
isab0: <PCI-ISA bridge> at device 31.0 on pci0
isa0: <ISA bus> on isab0
pci0: <mass storage, ATA> at device 31.1 (no driver attached)
pci0: <serial bus, SMBus> at device 31.3 (no driver attached)
atkbdc0: <Keyboard controller (i8042)> port 0x60,0x64 irq 1 on acpi0
atkbd0: <AT Keyboard> irq 1 on atkbdc0
kbd0 at atkbd0
atkbd0: [GIANT-LOCKED]
atkbd0: [ITHREAD]
sio0: <16550A-compatible COM port> port 0x3f8-0x3ff irq 4 flags 0x10 on acpi0
sio0: type 16550A
sio0: [FILTER]
sio1: <16550A-compatible COM port> port 0x2f8-0x2ff irq 3 on acpi0
sio1: type 16550A
sio1: [FILTER]
orm0: <ISA Option ROMs> at iomem 0xc0000-0xc7fff,0xc8000-0xc97ff,0xc9800-0xcafff
,0xe4000-0xe7fff pnpid ORM0000 on isa0
sc0: <System console> at flags 0x100 on isa0
sc0: VGA <16 virtual consoles, flags=0x300>
vga0: <Generic ISA VGA> at port 0x3c0-0x3df iomem 0xa0000-0xbffff on isa0
WARNING: ZFS is considered to be an experimental feature in FreeBSD.
Timecounters tick every 1.000 msec
ipfw2 initialized, divert loadable, rule-based forwarding disabled, default to a
ccept, logging unlimited
hptrr: no controller detected.
Waiting 5 seconds for SCSI devices to settle
ZFS filesystem version 6
ZFS storage pool version 6
da0 at ahd1 bus 0 target 0 lun 0
da0: <FUJITSU MAS3367NP 0104> Fixed Direct Access SCSI-3 device
da0: 320.000MB/s transfers (160.000MHz DT, offset 127, 16bit)
da0: Command Queueing Enabled
da0: 35068MB (71819496 512 byte sectors: 255H 63S/T 4470C)
da1 at ahd1 bus 0 target 1 lun 0
da1: <FUJITSU MAS3367NP 0104> Fixed Direct Access SCSI-3 device
da1: 320.000MB/s transfers (160.000MHz DT, offset 127, 16bit)
da1: Command Queueing Enabled
da1: 35068MB (71819496 512 byte sectors: 255H 63S/T 4470C)
da2 at ahd1 bus 0 target 2 lun 0
da2: <FUJITSU MAS3367NP 0104> Fixed Direct Access SCSI-3 device
da2: 320.000MB/s transfers (160.000MHz DT, offset 127, 16bit)
da2: Command Queueing Enabled
da2: 35068MB (71819496 512 byte sectors: 255H 63S/T 4470C)
da3 at ahd1 bus 0 target 3 lun 0
da3: <FUJITSU MAS3367NP 0104> Fixed Direct Access SCSI-3 device
da3: 320.000MB/s transfers (160.000MHz DT, offset 127, 16bit)
da3: Command Queueing Enabled
da3: 35068MB (71819496 512 byte sectors: 255H 63S/T 4470C)
lapic6: Forcing LINT1 to edge trigger
SMP: AP CPU #2 Launched!
SMP: AP CPU #1 Launched!
SMP: AP CPU #3 Launched!
Trying to mount root from zfs:tank/root
WARNING: R/W mount of /bootdir denied.  Filesystem is not clean - run fsck
bridge0: Ethernet address: 82:2a:93:3d:06:ef
em1: link state changed to UP
em0: link state changed to UP
bridge0: promiscuous mode enabled
WARNING: R/W mount of /bootdir denied.  Filesystem is not clean - run fsck
pid 904 (ntpd), uid 0: exited on signal 11 (core dumped)
[qos@SAM ~]$
```


----------



## wblock@ (Feb 4, 2013)

It's root on ZFS, no wonder fsck(8) did not work.


----------



## kpa (Feb 5, 2013)

That's not a pure ZFS on root set up but a one where /bootdir is mounted from an UFS filesystem (The system /boot -directory is a symbolic link to /bootdir/boot). The same UFS filesystem is used for booting because FreeBSD 7.0 did not (afaik) support booting directly from a ZFS pool.

It's that UFS filesystem that needs fsck(8) to clear up the error.


----------



## SirDice (Feb 5, 2013)

Keep in mind that FreeBSD 7.0 has been end-of-life since April 2009.

http://www.freebsd.org/security/#unsup


----------



## sharty (Feb 6, 2013)

So, would the correct command be: /sbin/fsck  /boot -y

I am aware that the version of FreeBSD on this computer is old.  The person who created it said it would be impossible to do an upgrade on the system to the latest version without re-creating all of it.  Since I do not know what he customized in making it I do not know what to look for.  I am concerned that unless the upgrade program ran intself with little user prompting I would never get it running again.


----------



## SirDice (Feb 6, 2013)

Just don't hook it up to the internet. There have been several security issues, none of them fixed in 7.0. So it's only a matter of time before it gets hacked.


----------

