Hi all,

I have a small server (5.4-current, more or less, dmesg and other pertinent details follow) in an office acting as firewall/samba server. We are trying to use an external USB hard drive as a backup. Because these are windows folk and because this is a server with 512M of ram and their backup needs aren't that great, that 1TB external drive has one 50GB ms-dos partion at i, the rest of the drive is unused. Hotplugd is setup to automagically mount the drive, when it is inserted. But since I have no way (that I know of anyway) to cleanly umount the drive if it is just yanked out while mounted, when the backup script starts if it doesn't find the drive mounted it tries to fsck-msdos's it first and then mount it.

What I'm finding is that when the server tries to fsck_msdos the msdos partition, it will more often that not bring the server down. It doesn't panic but it gets so resource starved that it is, for all intents and purposes, locked up--I can't even ssh into it.

Does an ms-dos file system require far more than the 1MB of ram per 1 GB of disk space that http://openbsd.org/faq/faq14.html#LargeDrive suggests?

More generally, does mount return specific error codes that I can catch in a script when it fails to successfully mount a partition? I read the mount.c and mount_msdos.c source but I didn't find a specific set of error codes like I found in fsck_msdos.c. Other than bail out of the backup script and call for help instead of locking the server up I'm not sure what I could do with that error code but can't hurt to know them, if they exist, either.

Thanks!

Jeff Ross

dmesg:

OpenBSD 5.4-current (GENERIC) #153: Mon Nov 18 20:44:38 MST 2013
dera...@i386.openbsd.org:/usr/src/sys/arch/i386/compile/GENERIC
cpu0: Intel(R) Pentium(R) 4 CPU 2.80GHz ("GenuineIntel" 686-class) 2.80 GHz
cpu0: FPU,V86,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,DTES64,MWAIT,DS-CPL,CNXT-ID,xTPR,PERF
real mem  = 534769664 (509MB)
avail mem = 514199552 (490MB)
mainbus0 at root
bios0 at mainbus0: AT/286+ BIOS, date 03/21/05, BIOS32 rev. 0 @ 0xfd71c, SMBIOS rev. 2.31 @ 0xef7d0 (57 entries)
bios0: vendor IBM version "2AKT49AUS" date 03/21/2005
bios0: IBM 8187WQM
acpi0 at bios0: rev 0
acpi0: sleep states S0 S1 S3 S4 S5
acpi0: tables DSDT FACP TCPA APIC BOOT
acpi0: wakeup devices USB1(S3) USB2(S3) USB3(S3) USB4(S3) USBE(S3) SLOT(S5) KBC_(S3) COMA(S5) COMB(S5)
acpitimer0 at acpi0: 3579545 Hz, 24 bits
acpimadt0 at acpi0 addr 0xfee00000: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: apic clock running at 133MHz
ioapic0 at mainbus0: apid 1 pa 0xfec00000, version 20, 24 pins
acpiprt0 at acpi0: bus 0 (PCI0)
acpiprt1 at acpi0: bus 3 (SLOT)
acpiprt2 at acpi0: bus -1 (AGP_)
acpicpu0 at acpi0
acpitz0 at acpi0: critical temperature is 90 degC
acpibtn0 at acpi0: PWRB
bios0: ROM list: 0xc0000/0xa600 0xca800/0x1000 0xcb800/0x1000 0xe0000/0x10000!
pci0 at mainbus0 bus 0: configuration mode 1 (bios)
pchb0 at pci0 dev 0 function 0 "Intel 82865G Host" rev 0x02
vga1 at pci0 dev 2 function 0 "Intel 82865G Video" rev 0x02
intagp0 at vga1
agp0 at intagp0: aperture at 0xf0000000, size 0x8000000
inteldrm0 at vga1
drm0 at inteldrm0
No connectors reported connected with modes
Cannot find any crtc or sizes - going 1024x768
inteldrm0: 1024x768
wsdisplay0 at vga1 mux 1: console (std, vt100 emulation)
wsdisplay0: screen 1-5 added (std, vt100 emulation)
uhci0 at pci0 dev 29 function 0 "Intel 82801EB/ER USB" rev 0x02: apic 1 int 16 uhci1 at pci0 dev 29 function 1 "Intel 82801EB/ER USB" rev 0x02: apic 1 int 19 uhci2 at pci0 dev 29 function 2 "Intel 82801EB/ER USB" rev 0x02: apic 1 int 18 uhci3 at pci0 dev 29 function 3 "Intel 82801EB/ER USB" rev 0x02: apic 1 int 16 ehci0 at pci0 dev 29 function 7 "Intel 82801EB/ER USB2" rev 0x02: apic 1 int 23
usb0 at ehci0: USB revision 2.0
uhub0 at usb0 "Intel EHCI root hub" rev 2.00/1.00 addr 1
ppb0 at pci0 dev 30 function 0 "Intel 82801BA Hub-to-PCI" rev 0xc2
pci1 at ppb0 bus 3
fxp0 at pci1 dev 8 function 0 "Intel PRO/100 VE" rev 0x02, i82562: apic 1 int 20, address 00:11:25:25:01:26
inphy0 at fxp0 phy 1: i82562ET 10/100 PHY, rev. 0
skc0 at pci1 dev 10 function 0 "D-Link DGE-530T A1" rev 0x11, Yukon (0x1): apic 1 int 22
sk0 at skc0 port A: address 00:13:46:72:39:e0
eephy0 at sk0 phy 0: 88E1011 Gigabit PHY, rev. 3
ichpcib0 at pci0 dev 31 function 0 "Intel 82801EB/ER LPC" rev 0x02
pciide0 at pci0 dev 31 function 1 "Intel 82801EB/ER IDE" rev 0x02: DMA, channel 0 configured to compatibility, channel 1 configured to compatibility
wd0 at pciide0 channel 0 drive 0: <WDC WD400BB-23DEA0>
wd0: 16-sector PIO, LBA, 38162MB, 78156288 sectors
wd0(pciide0:0:0): using PIO mode 4, Ultra-DMA mode 5
atapiscsi0 at pciide0 channel 1 drive 0
scsibus0 at atapiscsi0: 2 targets
cd0 at scsibus0 targ 0 lun 0: <TSSTcorp, DVD-ROM TS-H352C, IB01> ATAPI 5/cdrom removable
cd0(pciide0:1:0): using PIO mode 4, Ultra-DMA mode 2
pciide1 at pci0 dev 31 function 2 "Intel 82801EB SATA" rev 0x02: DMA, channel 0 configured to native-PCI, channel 1 configured to native-PCI
pciide1: using apic 1 int 18 for native-PCI interrupt
wd1 at pciide1 channel 0 drive 0: <Hitachi HDT725025VLA380>
wd1: 16-sector PIO, LBA48, 238475MB, 488397168 sectors
wd1(pciide1:0:0): using PIO mode 4, Ultra-DMA mode 6
ichiic0 at pci0 dev 31 function 3 "Intel 82801EB/ER SMBus" rev 0x02: apic 1 int 17
iic0 at ichiic0
spdmem0 at iic0 addr 0x50: 512MB DDR SDRAM non-parity PC2700CL2.5
auich0 at pci0 dev 31 function 5 "Intel 82801EB/ER AC97" rev 0x02: apic 1 int 17, ICH5 AC97
ac97: codec id 0x41445374 (Analog Devices AD1981B)
ac97: codec features headphone, 20 bit DAC, No 3D Stereo
audio0 at auich0
usb1 at uhci0: USB revision 1.0
uhub1 at usb1 "Intel UHCI root hub" rev 1.00/1.00 addr 1
usb2 at uhci1: USB revision 1.0
uhub2 at usb2 "Intel UHCI root hub" rev 1.00/1.00 addr 1
usb3 at uhci2: USB revision 1.0
uhub3 at usb3 "Intel UHCI root hub" rev 1.00/1.00 addr 1
usb4 at uhci3: USB revision 1.0
uhub4 at usb4 "Intel UHCI root hub" rev 1.00/1.00 addr 1
isa0 at ichpcib0
isadma0 at isa0
com0 at isa0 port 0x3f8/8 irq 4: ns16550a, 16 byte fifo
pckbc0 at isa0 port 0x60/5
pckbd0 at pckbc0 (kbd slot)
pckbc0: using irq 1 for kbd slot
wskbd0 at pckbd0: console keyboard, using wsdisplay0
pcppi0 at isa0 port 0x61
spkr0 at pcppi0
lpt0 at isa0 port 0x378/4 irq 7
npx0 at isa0 port 0xf0/16: reported by CPUID; using exception 16
fdc0 at isa0 port 0x3f0/6 irq 6 drq 2
fd0 at fdc0 drive 0: 1.44MB 80 cyl, 2 head, 18 sec
mtrr: Pentium Pro MTRR support, 8 var ranges, 88 fixed ranges
umass0 at uhub0 port 5 configuration 1 interface 0 " Gigaware" rev 2.00/1.00 addr 2
umass0: using SCSI over Bulk-Only
scsibus1 at umass0: 2 targets, initiator 0
sd0 at scsibus1 targ 1 lun 0: <, Gigaware, 1.02> SCSI2 0/direct removable serial.0781555f23189CA2C5F5
sd0: 3815MB, 512 bytes/sector, 7813120 sectors
umass1 at uhub0 port 6 configuration 1 interface 0 " Gigaware" rev 2.00/1.00 addr 3
umass1: using SCSI over Bulk-Only
scsibus2 at umass1: 2 targets, initiator 0
sd1 at scsibus2 targ 1 lun 0: <, Gigaware, 1.02> SCSI2 0/direct removable serial.0781555f70189CA25D47
sd1: 3815MB, 512 bytes/sector, 7813120 sectors
umass2 at uhub0 port 8 configuration 1 interface 0 "TOSHIBA External USB 3.0" rev 2.10/0.00 addr 4
umass2: using SCSI over Bulk-Only
scsibus3 at umass2: 2 targets, initiator 0
sd2 at scsibus3 targ 1 lun 0: <TOSHIBA, External USB 3.0, 0> SCSI4 0/direct fixed serial.0480010030815000028F
sd2: 953869MB, 512 bytes/sector, 1953525168 sectors
vscsi0 at root
scsibus4 at vscsi0: 256 targets
softraid0 at root
scsibus5 at softraid0: 256 targets
root on sd0a (d36dc7ed8f563826.a) swap on sd0b dump on sd0b
WARNING: / was not properly unmounted

jross@hnl:/home/jross $ sudo disklabel sd2
# /dev/rsd2c:
type: SCSI
disk: SCSI disk
label: External USB 3.0
duid: 9112cb1f2df4ff17
flags:
bytes/sector: 512
sectors/track: 63
tracks/cylinder: 255
sectors/cylinder: 16065
cylinders: 121601
total sectors: 1953525168
boundstart: 0
boundend: 1953525168
drivedata: 0

16 partitions:
#                size           offset  fstype [fsize bsize  cpg]
  c:       1953525168                0  unused
  i:        104858252           206848   MSDOS

hotplugd attach script

jross@hnl:/home/jross $ cat /etc/hotplug/attach
#!/bin/sh
DEVNAME=$2
logger DEVNAME = $DEVNAME

if [ $DEVNAME = sd2 ] ; then
disklabel=`/sbin/disklabel $DEVNAME 2>&1 | sed -n '/^duid: /s/^duid: //p'`
        logger $disklabel
        if [ $disklabel = "9112cb1f2df4ff17" ]; then
                logger mounting disk $disklabel
                mount -o nodev,nosuid /dev/"$DEVNAME"i /backup/flash
        fi
        if [ $disklabel = "1cd5d66293a5cd64" ]; then
                logger mounting disk $disklabel
                mount -o nodev,nosuid /dev/"$DEVNAME"i /backup/flash
        fi
        if [ $disklabel = "6c5c118fbe0385e8" ]; then
                logger mounting disk $disklabel
                mount -o nodev,nosuid /dev/"$DEVNAME"i /backup/flash
        fi
fi

Backup script:

jross@hnl:/home/jross $ cat /etc/scripts/rsync_to_flash.sh
#!/bin/sh
duid1=1cd5d66293a5cd64
duid2=6c5c118fbe0385e8
duid3=9112cb1f2df4ff17
ID=`disklabel sd2 | grep duid | cut -f2 -d " "`
if [ $ID != $duid1 -a $ID != $duid2 -a $ID != $duid3 ] ; then
        logger no backup disk found, aborting
        exit
else
        /sbin/mount | /usr/bin/grep -q sd2i
        if [ $? -eq 1 ] ; then
                echo not mounted, checking disk
                /sbin/fsck_msdos -py /dev/rsd2i
                ret=$?
                if [ $ret = 1 ] ; then
                        logger Boot block was modified
                fi
                if [ $ret = 2 ] ; then
                        logger Some directory was modified
                fi
                if [ $ret = 4 ] ; then
                        logger The FAT was modified
                fi
                if [ $ret = 8 ] ; then
                        logger Some unrecovered error remains
                        exit
                fi
                if [ $ret = 16 ] ; then
                        logger Some unrecoverable error remains
                        exit
                fi
                if [ $ret = 0 ] ; then
                        logger Check was OK
                fi
                sleep 5
                /sbin/mount -rw -o nodev,nosuid /dev/sd2i /backup/flash
        else
                echo mounted, skipping disk check
        fi
        echo starting rsync
/usr/local/bin/rsync -av --no-owner --no-group /samba1/shared/ /backup/flash/ /usr/local/bin/rsync -av --no-owner --no-group /samba1/accounting/ /backup/flash/ /usr/local/bin/rsync -av --no-owner --no-group /rsync/.Amanda/Tabs3 /backup/flash/ /usr/local/bin/rsync -av --no-owner --no-group /rsync/.Holly/Company /backup/flash/

        /sbin/umount /backup/flash
fi

Reply via email to