complicated downgrade

Valentin Nechayev netch at lucky.net
Fri Jul 18 02:12:54 PDT 2003


(Cc'ed to phk@ as to main GEOM and DEVFS developer; see corresponding
questions below.)

Hi,

I need to downgrade a remote FreeBSD system from 5.1-release to 4.8-release
remotely without any local help (except possible hitting Reset).
Don't ask why the collocation provider is too ugly and too far from me; it's
given and unchangeable. This system never was 4.* (began from 5.0-DP2).

I suppose the following algorith to have chance to succeed.
If anybody can check it and fix, please help.

1. Download 4.8-release and untar it to the separate tree in file system.

2. Remove all unneeded for this system (including modules, fore_dlnd,
   mount_portalfs and other unused programs) from directories placed
   on root fs; this is due to its small size (~64M).

3. Place directories for 4.8 as /bin4, /sbin4, /etc4, /boot4, /usr/lib4, etc.

4. Place kernel for this system as /kernel; add /kernel.GENERIC also.

5. Run MAKEDEV in /dev4 for all standard entries and entries for specific
   disks (/dev/ar0s1a, etc.)

6. Add minimal site-specific contents to /etc4, enough to boot and run sshd
to allow admin to enter. It includes master.passwd (with admin entry),
/etc/ssh/* (copied keys and configs), /etc/resolv.conf, /etc/rc.conf,
/etc/fstab, /etc/group (allowing su); what else?

7. (The most horrible step.)

   Goal is to have /dev on disk (not DEVFS!) appropriate for booting 4.8.
   Two alternatives are possible:

   7a.1. Patch kernel to disable GEOM's protection against writing to
        devices which is mounted or have mounted subparts.
        (Here is most foggy place: I don't know how to do it in such way
        as to disable rereading of disk structure on this place.)
   7a.2. Reboot with patched kernel.
   7a.3. Use a binary editor and renames root directory entries directly:
        /dev4 to /dev, /dev to /dev5. (If entry name length matters,
        use, e.g., de4 instead of dev4.)
   7a.4. Immediately reboot as to prevent namei subsystem damage.

   Result of all this is that devfs is mounted not over empty directory
   (or only with standard entries, without local specific disks), but over
   full working one.

   Alternative variant for step 7:

   7b. add code to /sbin/init before mounting devfs: remount root to rw,
       copy entries to it (/bin/cp -Rp). It will work if mount() allows
       remounting to rw without correct /dev entry (this may have problems,
       as I saw on 4.8). Reboot to run this code from init.

8. Disable all processes except sshd and run the following (saying generally):

   for D in /bin /sbin /etc /boot /usr/bin /usr/sbin /usr/lib /usr/libexec \
            /usr/libdata /usr/share /usr/local /var/db
   do
       mv ${D} ${D}5
       mv ${D}4 {D}
   done

9. Reboot and hope 4.8 will load and run.

I attached some local outputs to check for unexpectedness.


-netch-

root# less /var/run/dmesg.boot
Copyright (c) 1992-2003 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 5.1-RELEASE #1: Wed Jun 25 05:02:36 CDT 2003
    root@***.com:/usr/src/sys/i386/compile/TITAN
Preloaded elf kernel "/boot/kernel/kernel" at 0xc0438000.
Preloaded elf module "/boot/kernel/acpi.ko" at 0xc04380a8.
Timecounter "i8254"  frequency 1193182 Hz
CPU: AMD Duron(TM) MP Processor (1814.84-MHz 686-class CPU)
  Origin = "AuthenticAMD"  Id = 0x680  Stepping = 0
  Features=0x383fbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CM
OV,PAT,PSE36,MMX,FXSR,SSE>
  AMD Features=0xc0480000<MP,AMIE,DSP,3DNow!>
real memory  = 1073659904 (1023 MB)
avail memory = 1038475264 (990 MB)
Programming 24 pins in IOAPIC #0
IOAPIC #0 intpin 2 -> irq 0
FreeBSD/SMP: Multiprocessor System Detected: 2 CPUs
 cpu0 (BSP): apic id:  0, version: 0x00040010, at 0xfee00000
 cpu1 (AP):  apic id:  1, version: 0x00040010, at 0xfee00000
 io0 (APIC): apic id:  2, version: 0x00170011, at 0xfec00000
Pentium Pro MTRR support enabled
npx0: <math processor> on motherboard
npx0: INT 16 interface
acpi0: Other PM system enabled.
pcibios: BIOS version 2.10
Using $PIR table, 9 entries at 0xc00f2350
apm0: <APM BIOS> on motherboard
apm0: found APM BIOS v1.2, connected at v1.2
pcib0: <Host to PCI bridge> at pcibus 0 on motherboard
pci0: <PCI bus> on pcib0
IOAPIC #0 intpin 17 -> irq 2
agp0: <AMD 762 host to AGP bridge> port 0xe800-0xe803 mem 0xfb800000-0xfb800fff,
0xfc000000-0xfdffffff at device 0.0 on pci0
pcib1: <PCIBIOS PCI-PCI bridge> at device 1.0 on pci0
pci1: <PCI bus> on pcib1
IOAPIC #0 intpin 16 -> irq 5
pci1: <display, VGA> at device 5.0 (no driver attached)
isab0: <PCI-ISA bridge> at device 7.0 on pci0
isa0: <ISA bus> on isab0
atapci0: <AMD 768 UDMA100 controller> port 0xd800-0xd80f at device 7.1 on pci0
ata0: at 0x1f0 irq 14 on atapci0
ata1: at 0x170 irq 15 on atapci0
pci0: <bridge, PCI-unknown> at device 7.3 (no driver attached)
atapci1: <Promise PDC20271 UDMA133 controller> port 0xb000-0xb00f,0xb400-0xb403,
0xb800-0xb807,0xd000-0xd003,0xd400-0xd407 mem 0xed800000-0xed80ffff irq 2 at dev
ice 9.0 on pci0
ata2: at 0xd400 on atapci1
ata3: at 0xb800 on atapci1
pcib2: <PCIBIOS PCI-PCI bridge> at device 16.0 on pci0
pci2: <PCI bus> on pcib2
IOAPIC #0 intpin 19 -> irq 10
IOAPIC #0 intpin 18 -> irq 11
pci2: <serial bus, USB> at device 0.0 (no driver attached)
pci2: <multimedia, audio> at device 4.0 (no driver attached)
xl0: <3Com 3c905C-TX Fast Etherlink XL> port 0xa400-0xa47f mem 0xec800000-0xec80
007f irq 11 at device 5.0 on pci2
xl0: Ethernet address: 00:e0:18:99:db:5b
miibus0: <MII bus> on xl0
ukphy0: <Generic IEEE 802.3u media interface> on miibus0
ukphy0:  10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto
orm0: <Option ROMs> at iomem 0xd0000-0xd87ff,0xc0000-0xcc7ff on isa0
atkbdc0: <Keyboard controller (i8042)> at port 0x64,0x60 on isa0
atkbd0: <AT Keyboard> flags 0x1 irq 1 on atkbdc0
kbd0 at atkbd0
fdc0: <Enhanced floppy controller (i82077, NE72065 or clone)> at port 0x3f7,0x3f
0-0x3f5 irq 6 drq 2 on isa0
fdc0: FIFO enabled, 8 bytes threshold
fd0: <1440-KB 3.5" drive> on fdc0 drive 0
pmtimer0 on isa0
sc0: <System console> at flags 0x100 on isa0
sc0: VGA <16 virtual consoles, flags=0x300>
sio0 at port 0x3f8-0x3ff irq 4 flags 0x10 on isa0
sio0: type 16550A
sio1 at port 0x2f8-0x2ff irq 3 on isa0
sio1: type 16550A
vga0: <Generic ISA VGA> at port 0x3c0-0x3df iomem 0xa0000-0xbffff on isa0
unknown: <PNP0501> can't assign resources (port)
unknown: <PNP0501> can't assign resources (port)
unknown: <PNP0700> can't assign resources (port)
unknown: <PNP0303> can't assign resources (port)
Timecounters tick every 10.000 msec
ipfw2 initialized, divert disabled, rule-based forwarding enabled, default to ac
cept, logging disabled
ad4: 176700MB <IC35L180AVV207-1> [359010/16/63] at ata2-master UDMA100
ad6: 176700MB <IC35L180AVV207-1> [359010/16/63] at ata3-master UDMA100
acd0: CDROM <CDU5211> at ata0-master PIO4
ar0: 176700MB <ATA RAID1 array> [22526/255/63] status: READY subdisks:
 disk0 READY on ad4 at ata2-master
 disk1 READY on ad6 at ata3-master
SMP: AP CPU #1 Launched!
Opened disk ad4 -> 1
Opened disk ad4 -> 1
Opened disk ad4 -> 1
Opened disk ad4 -> 1
Opened disk ad6 -> 1
Opened disk ad6 -> 1
Mounting root from ufs:/dev/ar0s1a
WARNING: / was not properly dismounted
module_register: module cardbus/xl already exists!
Module cardbus/xl failed to register: 17
module_register: module pci/xl already exists!
Module pci/xl failed to register: 17
module_register: module xl/miibus already exists!
Module xl/miibus failed to register: 17

root# cat /etc/fstab
# Device                Mountpoint      FStype  Options         Dump    Pass#
/dev/ar0s1b             none            swap    sw              0       0
/dev/ar0s1a  /  ufs  noatime,rw  0  1
/dev/ar0s1f  /tmp  ufs  noatime,rw  0  2
/dev/ar0s1g  /usr  ufs  noatime,rw  0  2
/dev/ar0s1e  /var  ufs  noatime,rw  0  2
/dev/acd0c              /cdrom          cd9660  ro,noauto       0       0

root# kldstat
Id Refs Address    Size     Name
 1    7 0xc0100000 2ec044   kernel
 2    1 0xc03ed000 494d4    acpi.ko
 3    1 0xc6359000 a000     if_xl.ko




More information about the freebsd-hackers mailing list