# Files saved to USB have size 0.



## mikethe1wheelnut (May 21, 2022)

..need I say that this is a disaster?  To put it mildly?  The good news is that it's very likely that the files I'm looking for are also (almost certainly) saved elsewhere.  But still, absolutely truly nasty.  I no longer have BSD on any of my laptops.  ..I -have- been planing on putting it back on, using an alternate tutorial.  This.. this, justifiably, freaks me out.  What could cause this?  No, I haven't searched anywhere else to see if others have had this problem.  So this is almost just a straight-up rant.  Something of this magnitude shouldn't be a problem.  You shouldn't be able to -get- software that does this kind of thing.  This is BSD.  You're better than this.


----------



## obsigna (May 21, 2022)

Did you orderly remove the USB drive, after the files where copied and before removing it from the slot? Either on the command line using umount(8), or on any kind of DE, ejected the USB drive (similar like on Windows remove safely)?

In case not (or don’t know), the file system on the USB may be not consistent. In case it is UFS, run fsck(8) over it, and perhaps the data appears. Depending on the device identifier of the UFS volume the actual command may be: `# fsck -fy /dev/da0pX`. Replace X by the actual partition ID.


----------



## mikethe1wheelnut (May 21, 2022)

obsigna said:


> Did you orderly remove the USB drive, after the files where copied and before removing it from the slot? Either on the command line using umount(8), or on any kind of DE, ejected the USB drive (similar like on Windows remove safely)?
> 
> In case not (or don’t know), the file system on the USB maybe not consistent. In case it is UFS, run fsck(8) over it, and perhaps the data appears. Depending on the device identifier of the UFS volume the actual command may be: `# fsck -fy /dev/da0pX`. Replace X by the actual partition ID.



Many thanks for your response.  I'm assuming your instructions (# fsck -fy /dev/da0pX) are for bsd, not ubuntu (which I'm currently using).  I "wrote" this usb months ago.  Long enough that I have no memory exactly what I did.  I had a lot of trouble at the time, so this is really not that surprising.  (..did I really just say that?.. ..hehe..)  All that to say, I really can't give you more information until I decide to give bsd another try.  That might be this year, it's possible.  Until then, this post is here.. maybe it's presence will improve the universe in some way..  So ya, I've since found the file I was looking for on my other computer. I'm massively multiply backed up. (..wisdom bought with blood..)


----------



## zirias@ (May 21, 2022)

The operating system isn't too relevant for this issue: properly unmounting an external device before unplugging it is mandatory on _any_ OS. Sometimes, filesystems on external devices are mounted for synchronous operation (Windows is doing that, on *nix systems you can typically add the `sync` mount option to get the same behavior) in order to make data loss by forgetting to unmount unlikely. But this is no guarantee either, and it has a drawback: With every operation sent to the device "immediately", the I/O load is greatly increased (and even the device might be forced to do write cycles that could be avoided otherwise).


----------



## ralphbsz (May 23, 2022)

So, please begin by explaining what you did. Right now we only know "USB" and "file size 0". We don't know what kind of storage device it is (USB can be anything from a little memory stick to a big disk drive). We don't know what file system you use. We don't know how you mounted it. We don't know whether you correctly unmounted it before disconnecting it. We don't know how you wrote the data.

I can create lots of scenarios where the result you see is absolutely correct, and working as intended. In most of those scenarios, the user or sys admin did the wrong thing. So please give us more information, then we can perhaps help you diagnose what went wrong, and how to do better in the future.


----------



## grahamperrin@ (May 23, 2022)

obsigna said:


> … Replace `X` by the actual partition ID.



Also, let's not assume `0`. There might be multiple drives.


----------



## ayleid96 (May 23, 2022)

Also be sure to run `sync` command if you didn't already set that up in fstab.


----------



## msplsh (May 23, 2022)

mikethe1wheelnut said:


> .. maybe it's presence will improve the universe in some way


No.

* No FreeBSD version
* No mount commands
* No filesystem details
* No copy commands
* No unmount command


----------



## grahamperrin@ (May 23, 2022)

mikethe1wheelnut said:


> … I had a lot of trouble at the time, …



I've been there. I spent years avoiding USB flash drives because I couldn't remember how to handle them on FreeBSD. Things are (happily) different now.



mikethe1wheelnut said:


> Files saved to USB have size 0.



Were _all_ files zero bytes?


----------

