# Apparent crash when creating lots of files on UFS



## ctengel (Mar 11, 2012)

*EDIT* Since I first posted I've gained some clarity on the specific issue.  It seems to have nothing specific to do with pkg_add or tar, but rather just creating lots of files quickly. See below.

Hi,

As has been mentioned in my other threads I am very much a n00b to FreeBSD, but not to Unix. I am running an amd64 system; I just recently did a fresh FreeBSD 9.0 RELEASE install from CD. I set up some ZFS filesystems manually, and installed ports.txz, docs.txz, src.txz manually into there. I went to then try to install the handbook via package add, and the system seemed to crash.  I don't really need to install the handbook, but I'm afraid this is indicative of a bigger problem.


```
# uname -a
FreeBSD fortitudo 9.0-RELEASE FreeBSD 9.0-RELEASE #0: Tue Jan  3 07:46:30 UTC 2012     root@farrell.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  amd64
# mount
/dev/ada0p2 on / (ufs, local, journaled soft-updates)
devfs on /dev (devfs, local, multilabel)
fzf0/fbsd90a/ports on /usr/ports (zfs, local, nfsv4acls)
fzf0/fbsd90a/doc/papers on /usr/share/doc/papers (zfs, local, nfsv4acls)
fzf0/fbsd90a/doc/psd on /usr/share/doc/psd (zfs, local, nfsv4acls)
fzf0/fbsd90a/doc/smm on /usr/share/doc/smm (zfs, local, nfsv4acls)
fzf0/fbsd90a/doc/usd on /usr/share/doc/usd (zfs, local, nfsv4acls)
fzf0/fbsd90a/src on /usr/src (zfs, local, nfsv4acls)
/dev/cd0 on /mnt (cd9660, local, read-only)
# pkg_add -vnr en-freebsd-doc
scheme:   [ftp]
user:     []
password: []
host:     [ftp.freebsd.org]
port:     [0]
document: [/pub/FreeBSD/ports/amd64/packages-9.0-release/Latest/en-freebsd-doc.tbz]
---> ftp.freebsd.org:21
looking up ftp.freebsd.org
connecting to ftp.freebsd.org:21
<<< 220 Welcome to freebsd.isc.org.
>>> USER anonymous
<<< 331 Please specify the password.
>>> PASS chris@fortitudo
<<< 230 Login successful.
>>> PWD
<<< 257 "/"
>>> CWD pub/FreeBSD/ports/amd64/packages-9.0-release/Latest
<<< 250 Directory successfully changed.
>>> MODE S
<<< 200 Mode set to S.
>>> TYPE I
<<< 200 Switching to Binary mode.
setting passive mode
>>> PASV
<<< 227 Entering Passive Mode (204,152,184,73,86,187).
opening data connection
initiating transfer
>>> RETR en-freebsd-doc.tbz
<<< 150 Opening BINARY mode data connection for en-freebsd-doc.tbz (42538534 bytes).
Fetching ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-9.0-release/Latest/en-freebsd-doc.tbz...x +CONTENTS
x +COMMENT
x +DESC
x +MTREE_DIRS
x share/doc/freebsd/en_US.ISO8859-1/articles/5-roadmap/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/bsdl-gpl/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/building-products/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/casestudy-argentina.com/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/checkpoint/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/committers-guide/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/compiz-fusion/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/console-server/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/contributing-ports/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/contributing/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/contributors/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/cups/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/custom-gcc/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/cvs-freebsd/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/cvsup-advanced/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/dialup-firewall/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/diskless-x/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/euro/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/explaining-bsd/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/fbsd-from-scratch/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/filtering-bridges/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/fonts/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/formatting-media/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/freebsd-questions/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/freebsd-update-server/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/geom-class/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/gjournal-desktop/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/hats/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/hubs/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/ipsec-must/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/laptop/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/ldap-auth/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/linux-comparison/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/linux-emulation/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/linux-users/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/mailing-list-faq/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/mh/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/multi-os/article.html
```

And at that point the system reboots.  This has happened twice already.  I'm looking through /var/log to try to see what is going on but can't seem to find any pre-reboot messages. Without getting into a whole coredump analysis, does anyone have any ideas as to why this would happen? It just seems so bizarre to me.
Thanks!

PS: I attempted ftp'ing it manually and then installing it; this happened:


```
$ ftp ftp.freebsd.org
Trying 204.152.184.73:21 ...
Connected to ftp.freebsd.org.
220 Welcome to freebsd.isc.org.
Name (ftp.freebsd.org:chris): anonymous
331 Please specify the password.
Password: 
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> cd pub/FreeBSD/ports/amd64/packages-9.0-release/Latest
250 Directory successfully changed.
ftp> get en-freebsd-doc.tbz
local: en-freebsd-doc.tbz remote: en-freebsd-doc.tbz
229 Entering Extended Passive Mode (|||43585|).
150 Opening BINARY mode data connection for en-freebsd-doc.tbz (42538534 bytes).
100% |**********************************************************************************| 41541 KiB  173.50 KiB/s    00:00 ETA
226 Transfer complete.
42538534 bytes received in 03:59 (173.44 KiB/s)
ftp> quit
221 Goodbye.
# pkg_add -vn /home/chris/en-freebsd-doc.tbz
Requested space: 162M bytes, free space: 2572M bytes in /var/tmp/instmp.65KM0j
```
*CRASH*

PPS: Running without -n, still same problem.

PPPS:
`$ tar jtvf en-freebsd-doc.tbz`
works as expected.  I guess truthfully I don't know what pkg_add does other than untar some things...


----------



## ctengel (Mar 11, 2012)

OK I think I'm narrowing down that the issue is something to do with the untarring.

```
$ tar jxvf ../en-freebsd-doc.tbz 
x +CONTENTS
x +COMMENT
x +DESC
x +MTREE_DIRS
x share/doc/freebsd/en_US.ISO8859-1/articles/5-roadmap/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/bsdl-gpl/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/building-products/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/casestudy-argentina.com/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/checkpoint/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/committers-guide/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/compiz-fusion/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/console-server/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/contributing-ports/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/contributing/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/contributors/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/cups/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/custom-gcc/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/cvs-freebsd/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/cvsup-advanced/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/dialup-firewall/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/diskless-x/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/euro/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/explaining-bsd/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/fbsd-from-scratch/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/filtering-bridges/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/fonts/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/formatting-media/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/freebsd-questions/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/freebsd-update-server/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/geom-class/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/gjournal-desktop/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/hats/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/hubs/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/ipsec-must/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/laptop/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/ldap-auth/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/linux-comparison/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/linux-emulation/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/linux-users/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/mailing-list-faq/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/mh/article.html
x share/doc/freebsd/en_US.ISO8859-1/articles/multi-os/article.html
```
*CRASH*
So...it has something to do with actually extracting this tarfile.

I tried again, to untar it to a dataset within my ZFS filesystem, and it worked!
The many other distfiles (ports.txz, src.txz, docs.txz) I've untarred were all also onto ZFS datasets.

So the real question is, why would a non-privileged user untarring something into a UFS filesystem cause a sudden hard reset?


----------



## ctengel (Mar 12, 2012)

Is this a package issue?
Use of tar() to extract things is apparently causing my system to hard reset, and that is part of the base system.
(Although, to be honest I thought it was a package issue when I started it.)


----------



## ctengel (Mar 12, 2012)

And actually regardless of how this is best categorized: `$ while true; do mkdir a; cd a; touch b; done` crashes the box also. And stranger, none of the directories exist post crash. I am thinking there is an issue with the filesystem and/or underlying device. Any ideas of anything I should be looking at to troubleshoot?

I think this is reproducable every time I quickly try to create files. My instinct is it is hardware (cf card) but I was able to install base from CD no problems.


----------



## ctengel (Mar 12, 2012)

Things get weirder. I tried doing an fsck of the root filesystem. Figured it couldn't hurt with all those hard resets.  Turns out, all of a sudden, some directories from earlier failed tests all of a sudden appear!


----------

