On Mon, Jul 10, 2017 at 01:30:36PM -0500, Tim Chase wrote:
> On 2017-07-05 21:38, Jason wrote:
> > > - create a file such as "mail.img" on your FAT partition, format
> > > it as something smarter (e.g. ext{2,3,4}, UFS or ZFS), and mount
> > > it as a loop-back/memory-disk, to which you can then use rsync to
> > > that loopback device.  This allows for actual sym-links and
> > > hard-links which rsync can use for deduplication (using the
> > > --link-dest option[1])  
> >
> > An interesting suggestion but a little above my head, I fear.
> 
> The specifics would be OS-dependent, but the general gist would be
> something like the following:
> 
> 1) make a DOS-friendly-named "mail.img" file to act as a virtual disk.
> I'm specifying 100MB here, but choose a value appropriate for you
> 
>   $ MAILIMG=/mnt/fatusb/mail.img
>   $ MOUNTPOINT=/mnt/mailbackup/
>   $ mkdir -p ${MOUNTPOINT}
>   $ truncate -s 100MB ${MAILIMG}
> 
> 2) make a filesystem on it and get the system to recognize it as a
> device.  On Linux, that might looks something like:
> 
>   $ /sbin/mkfs.ext4 ${MAILIMG}
>   # DEVICE=/dev/loop0
>   # losetup ${DEVICE} disk.img
> 
> On FreeBSD for UFS, you'd create a memory disk and format it:
> 
>   $ su -
>   # MD_IDX=0
>   # mdconfig -f ${MAILIMG} -u ${MD_IDX}   # create md${MD_IDX}
>   # gpart create -s gpt md${MD_IDX}       # set up GPT partitioning
>   # gpart add -t freebsd-ufs md${MD_IDX}  # create a partition in that
>   # DEVICE=/dev/md${MD_IDX}p1
>   # newfs ${DEVICE}                       # format it with UFS
> 
> 3) mount the loopback/memory-disk device someplace:
> 
>   # mount ${DEVICE} ${MOUNTPOINT}
> 
> 4) use the device mount-point for your backup, such as
> 
>   $ rsync -avr ~/Mail/ ${MOUNTPOINT}
> 
> 5) unmount it:
> 
>   # umount ${DEVICE}
> 
> 6) destroy the loopback device:
> 
>   On Linux:
>   # losetup -d ${DEVICE}
> 
>   On FreeBSD:
>   # mdconfig -d -u ${MD_IDX}
> 
> 
> Once you have the disk-image file, you can skip the
> partitioning/formatting commands (gpart/mkfs.ext4/newfs) and just
> create the device (losetup/mdconfig), mount, use, unmount, and
> destroy the device.  Linux's mount(1) even knows about loop-back
> devices so you can just create/mount in one step, and
> unmount/destroy in one step:
> 
>   # mount -o loop ${MAILIMG} ${MOUNTPOINT}
>   use the disk
>   # umount ${MOUNTPOINT}

Intriguing, I might need to try this sometime. Nice to know of this
option; it might come in useful someday.

> 
> There may be a simpler way of doing it on FreeBSD, but I just use the
> mdconfig/mount/use/umount/mdconfig-d sequence and it Works For Me(tm)
> 
> You might also be able to use some nice ZFS functionality if it was
> available, but that is a little more convoluted (importing/exporting
> pools in particular).
> 
> Sorry if that's more complicated/convoluted than you want, but it
> does give you "full Unix-like filesystem functionality on a
> DOS-formatted USB drive".
> 
> -tkc
> 
> 
Thanks!
-- 
Jason

Reply via email to