Find the answer to your Linux question:
Results 1 to 8 of 8
Hi! I have a USB drive which I use for backing up files with the help of grsync. Today, when I went to back up some files, rsync partially completed ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Oct 2011
    Posts
    5

    USB drive corrupted filesystem


    Hi! I have a USB drive which I use for backing up files with the help of grsync. Today, when I went to back up some files, rsync partially completed the operation before complaining that the file system was read only. I then attempted to delete the problem directory from the USB drive. Most of the files in the directory could be deleted OK but some could not due to a "read only file system" error. This led me to think the file system may be partially corrupted.

    Would it be quicker to repair the file system or to reformat the drive and re-backup my files? If repairing is the way to go how do I go about doing this?

    Thanks in advance!

  2. #2
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,390
    The first thing is to make sure, that the hardware is ok.

    As this is a usb drive, it may be possible that e.g. the power or usb cable has been disconnected while the drive was in operation.
    That is a scenario, where the hardware is ok and a fsck will be enough.

    Another scenario: the drive is physically corrupt.
    In that case it needs to be replaced and a new backup needs to be initialized with grsync.

    About testing:
    One way is to check the S.M.A.R.T. of the drive.
    If that shows good results, I would read/write a few tomes to it and watch dmesg and /var/log/messages
    You must always face the curtain with a bow.

  3. #3
    Just Joined!
    Join Date
    Oct 2011
    Posts
    5
    Thanks for the quick reply! I'm sorry for not being as clear as I should have in my OP. The drive is a FAT formatted 8GB pen drive/flash drive. Does that make a difference as to how best to proceed?

  4. #4
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,558
    1. NEVER backup Linux files to a FAT device. FAT is too unreliable for critical data storage needs and does not recover from errors very well. Reformat the device to use ext2/3/4 file systems instead.
    2. You might be able to fix the FAT file system with the dosfsck ("fsck -t vfat" and "fsck.vfat" are aliases for dosfsck) command, but make sure the device is unmounted first.
    3. After #2, you may have lost some files. Good luck with that!
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  5. #5
    Just Joined!
    Join Date
    Oct 2011
    Posts
    5
    Thanks for the advice Rubberman. I still have all the original files on my main hard drive so I will reformat the pen drive with ext as you suggest and back everything up again.

  6. #6
    Just Joined!
    Join Date
    Oct 2011
    Posts
    5
    Back again, sorry to be a nuisance! I formatted the flash drive with ext2 but now the owner of the drive has changed to root. Should I issue a chown command on the directory the drive gets mounted to or is there something else I need to do in order to mount the flash drive as a normal user?

  7. #7
    Just Joined!
    Join Date
    Oct 2011
    Posts
    22
    Quote Originally Posted by rockhopper7 View Post
    Should I issue a chown command on the directory the drive gets mounted to
    Yes, that's the way to do it. If you chown the mountpoint when the drive is mounted, it has the curious effect of "owning" the filesystem itself rather than the mountpoint. So, assuming you've mounted to /media/mountpoint, in a Linux distro that uses sudo:

    Code:
    sudo chown yourusername: /media/mountpoint
    Or, su to root, and:

    Code:
    chown yourusername: /media/mountpoint
    Substitute your account name for "yourusername" and don't forget the trailing colon. That sets ownership to your default group - a useful trick for avoiding keystrokes! If you have no files already saved on the pendrive, you don't need the -R recursive option, because you are owning the filesystem, not the files on it.

    Now - complication. Some distros (Ubuntu, Suse) set the UID of the first user to 1000, others to 500. So if you want to use that pendrive for different distros you may run into permissions problems yet again. One way round that would be to:

    Code:
    (sudo) chmod 777 /media/mountpoint
    But one disadvantage of 777 permissions is that it gives the world and its granny full access to your files.

  8. #8
    Just Joined!
    Join Date
    Oct 2011
    Posts
    5
    Thanks coffeecat that did the trick! Good to know about the UID issue too

Posting Permissions

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