Page 1 of 3 123 LastLast
Results 1 to 10 of 25

Thread: Files gone from USB after unmounting

  1. #1
    Join Date
    Dec 2015
    Beans
    52

    Files gone from USB after unmounting

    I am trying to copy files to a USB.

    I copy the files (seemingly successfully), but once I unmount, they're gone.

    It's a FAT32 drive according to fdisk and I mount it with
    Code:
    sudo mount -t vfat /dev/sdb1 /tmp/usb -o uid=1000,gid=1000,utf8,dmask=027,fmask=137
    .

    I sync and then unmount, but if I remount it, I don't see the files.

    I don't believe it makes any difference, but for completeness, this is on an Ubuntu server installation over ssh.

    I'm about out of ideas, so if anyone has any, it would be appreciated.

  2. #2
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    20,491
    Distro
    Ubuntu Mate 16.04 Xenial Xerus

    Re: Files gone from USB after unmounting

    dmask=027,fmask=137
    are wrong. 4 octal characters are required. Probably want to start with fmask=0002,dmask=0002 on Ubuntu systems, though you can use fmask=0007,dmask=0007 if you like.

  3. #3
    Join Date
    Dec 2015
    Beans
    52

    Re: Files gone from USB after unmounting

    Oh ok, I'll give that a try, thanks.

    I found the values I was using on this page: https://help.ubuntu.com/community/Mount/USB#Using_mount

  4. #4
    Join Date
    Dec 2015
    Beans
    52

    Re: Files gone from USB after unmounting

    Quote Originally Posted by TheFu View Post
    Probably want to start with fmask=0002,dmask=0002
    I tried with these permissions, but unfortunately the issue persists.

    I encounter no errors or permission issues when I copy the files over (and didn't with the previous permissions either).

    I see the directory with ls after copying, but once I unmount and remount the drive, I no longer see it.

    I don't think it's the case, but could it have something to do with the mount location? Is it because I am mounting it in /tmp?

    Or should I mount the drive with sync?

    EDIT:

    Ran fsck both before and after copying, removed dirty bit and corrected cluster summary both times, but no luck
    Last edited by robo731; 3 Weeks Ago at 12:35 PM. Reason: Add additional troubleshooting step taken (fsck)

  5. #5
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    20,491
    Distro
    Ubuntu Mate 16.04 Xenial Xerus

    Re: Files gone from USB after unmounting

    Vaguely remember a problem when people used usbmount first causing some conflicts.
    After you mount the storage, check the real mount options used - the mount command will show those for all mounted storage.

    Using fsck on Linux to fix broken FAT32 is not likely to actually work. Connect to Windows and run chkdsk or/and scandisk to fix FAT32 or exFAT or NTFS issues. Don't use Linux to fix Windows file systems. The most we can hope for from Linux is that once a device stops working, that Linux will allow access to the files to get the data off, maybe.

    Similarly, for Linux file systems, don't use Windows tools to try an fix stuff. It won't.

    I haven't used vfat in some time - perhaps a year - but my last working autofs configuration was this:
    Code:
    /etc/auto.misc:/misc/16G  -nodev,nosuid,timeout=2,fstype=vfat,uid=1000,gid=1000 LABEL=16G
    That would turn into a mount command like this:
    Code:
    sudo mount  -t vfat    -o nodev,nosuid,timeout=2,uid=1000,gid=1000     LABEL=16G      /misc/16G
    My umask is 0002, so that would be picked up by the mount command. For temporary storage, I prefer to mount using the LABEL option, not UUID or device. As a human, I remember labels better, though with autofs, I actually don't need to know any of that once it is setup. Just plug the flash drive in, wait 5 seconds for the OS via udev to see the new storage connection, then simply access the storage ....
    cd /misc/16G/ and use as normal. autofs will automatically remove the mount when all files become unused on it for a few minutes. I use df -Th to verify the mount it gone before pulling the usb device out.

    But whether we use LABEL, UUID or the device partition with the file system, shouldn't matter at all.

    What may matter is which OS release are you running? My systems with USB ports are all 16.04.6 The problem could be release or kernel specific.

  6. #6
    Join Date
    Nov 2008
    Location
    Metro Boston
    Beans
    15,105
    Distro
    Kubuntu 20.04 Focal Fossa

    Re: Files gone from USB after unmounting

    Unless you need to use this drive on Windows machines, I suggest formatting it to ext4.
    Code:
    sudo mkfs -t ext4 /dev/sdb1
    If you need to convert it back to FAT32 in the future, reformat it again with
    Code:
    sudo mkfs -t vfat /dev/sdb1
    Also, always cleanly unmount the device with
    Code:
    eject /dev/sdb
    You might or might not need to use "sudo" with that command depending on how the device is mounted.
    Last edited by SeijiSensei; 3 Weeks Ago at 07:00 PM.
    If you ask for help, do not abandon your request. Please have the courtesy to check for responses and thank the people who helped you.

    Blog · Linode System Administration Guides · Android Apps for Ubuntu Users

  7. #7
    Join Date
    Jun 2019
    Location
    Dirndl-land
    Beans
    469
    Distro
    Lubuntu 20.04 Focal Fossa

    Re: Files gone from USB after unmounting

    Quote Originally Posted by robo731 View Post
    I don't think it's the case, but could it have something to do with the mount location? Is it because I am mounting it in /tmp?
    /tmp is the last place I'd mount storage, it has some unique properties:

    https://www.tldp.org/LDP/Linux-Files.../html/tmp.html

    Try mounting under /media instead, that would be the obvious place.
    Last edited by ml9104; 3 Weeks Ago at 07:20 PM.

  8. #8
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    20,491
    Distro
    Ubuntu Mate 16.04 Xenial Xerus

    Re: Files gone from USB after unmounting

    For flash storage, the f2fs file system is pretty awesome. Fast and avoids writes. Performance comparisions show it is usually faster than ext4.

    As long as the system isn't rebooted while the mount under /tmp/ happens, i wouldn't be too concerned.
    However, /mnt/ is there specifically to be used as a temporary work area for stuff like this.

  9. #9
    Join Date
    Dec 2015
    Beans
    52

    Re: Files gone from USB after unmounting

    The options shown by mount all look good, they match what I expect.

    I gave the configuration shared by TheFu a try, but no luck.

    Also tried mounting to /mnt.

    I do not eject, but I do umount.

    Unfortunately I do need to use this drive with Windows, so ext4 is not a good option. I'd like to leave formatting as a last resort.

    First I will try to repair the drive on Windows and report back.

  10. #10
    Join Date
    Apr 2007
    Beans
    2,877
    Distro
    Ubuntu

    Re: Files gone from USB after unmounting

    Make sure your file system is healthy and consistent in the first place before copying files to it. Ubuntu works perfectly fine with an error free fat32 file system. The issues you see may have been due to the file system being corrupt.

Page 1 of 3 123 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •