Find the answer to your Linux question:
Results 1 to 6 of 6
I'm trying to backup my linux server to a remote computer - but the remote computer is running windows. So I set up a sparse file on an NTFS drive, ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Mar 2010
    Posts
    16

    loop device with sparse file on NTFS over Samba


    I'm trying to backup my linux server to a remote computer - but the remote computer is running windows. So I set up a sparse file on an NTFS drive, built and ext3 filesystem on it, and mount it as a loop device over samba. It appears to work - it gives no errors and lets me add and delete files and folder. But after unmounting and remounting the device, most often it reverts back to the way it was right after mounting it the last time - new files created are not there, and files that were deleted are still there.

    Does anyone have any idea what is going on? Is there something that I need to flush when I unmount? To mount and unmount I use the following code:

    To Mount:
    mount -t smbfs //RemoteWindowsMachine/RemoteFolder /mnt/backupsamba
    losetup /dev/loop0 /mnt/backupsamba/BackupExt2.img
    mount -t ext3 /dev/loop0 /mnt/remotebackup

    To Unmount:
    umount /mnt/remotebackup
    losetup -d /dev/loop0
    umount /mnt/backupsamba

    Thanks!

  2. #2
    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,525
    First, use the cifs file system, instead of smbfs when mounting a windows share. It is more up-to-date and reliable. Second, you might need to sync your file systems before running [I][osetup -d /dev/loop0/I] - I'm not sure it writes buffered data before closing it down. Third, you might try creating the BackupExt2.img file (presize it with dd if=/dev/zero of=/mnt/backupsamba/BackupExt2.img count=numblocks first, then format it with mkfs -t type /dev/loop0, then mount it with mount -t type /dev/loop0 mount-point. You should then be able to write your data to the mount-point. Here is a section of the losetup man page that addresses this:
    Code:
           The following commands can be used as an example of using the loop device.
    
                  # dd if=/dev/zero of=/file bs=1k count=100
                  # losetup -e des /dev/loop0 /file
                  Password:
                  Init (up to 16 hex digits):
                  # mkfs -t ext2 /dev/loop0 100
                  # mount -t ext2 /dev/loop0 /mnt
                   ...
                  # umount /dev/loop0
                  # losetup -d /dev/loop0
    It shows using an encrypted volume, which you don't need to do, but it may be useful for security purposes.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  3. #3
    Just Joined!
    Join Date
    Mar 2010
    Posts
    16

    Thanks for the advice . . . any more?

    Thanks for the advice. I had created the file in a similar manner - I did it on the windows machine using cygwin. I made a sparse file, however - so maybe there's some conflict there. I formatted it using mke2fs.

    I tried using cifs, but I get the same results - I can mount it, add files, delete file, but then when I unmount and remount, some of the files are gone, and some that should be gone because I deleted them are still there ???

    Anyone have any idea what's up?

  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,525
    Did you sync before unmounting the volumes (loop and cifs)?
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  5. #5
    Just Joined!
    Join Date
    Mar 2010
    Posts
    16

    Thanks Rubberman

    I had assumed that umount would sync before unmounting - I've never had problems mounting and unmounting filesystems before. But it looks like running sync before unmounting the loopback device does the trick. I think that solved the problem. Thanks a ton!

  6. #6
    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,525
    I think there were just too many levels of redirection here. If you unmount hardware devices, then they get sync'd. However, if you unmount a loop device I'm not so sure. As the old saying goes, better safe than sorry!
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Posting Permissions

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