At work, we have an iMac (running OS X) that shares a partitioned hard drive over the network. I'd like to back up to my partition from my Linux machine. I've attempted connecting via cifs, then attempted to back up using backintime onto an encfs-encrypted volume. This throws up a whole lot of errors, and I assume that it is because cifs is unhappy with hard-links and other unix wizardry.

I seem to remember on OS X that you can create monolithic, encrypted disk images that you could then mount as a "local" (and hence file-system–agnostic) volume. This seems ideal. Hence, I'd connect to the remote volume via cifs, then "locally" mount the encrypted volume as ext4. Is there an equivalent in Linux?

1 Answer 1


Would be strange of that was possible in OS X but not with Linux. It's exactly the same:

cd /cifs/dir
dd if=/dev/zero of=encbackup.img bs=1M count=100 # 100 MiB size
sudo losetup /dev/loop0 /cifs/dir/encbackup.img # assuming loop0 is free
sudo cryptsetup luksFormat /dev/loop0
sudo cryptsetup luksOpen /dev/loop0 cr_cifs_backup
sudo mke2fs -j /dev/mapper/cr_cifs_backup
sudo mount -t ext3 /dev/mapper/cr_cifs_backup /where/ever

It probably makes sense from a performance perspective to create a second (much smaller) image locally (non-encrypted) and put the journal there (see man tune2fs, options -j and -J).

Edit 1:

The existing device is mounted the same way (just leaving out dd, luksFormat, and mke2fs):

sudo losetup /dev/loop0 /cifs/dir/encbackup.img # assuming loop0 is free
sudo cryptsetup luksOpen /dev/loop0 cr_cifs_backup
sudo mount -t ext3 /dev/mapper/cr_cifs_backup /where/ever

Edit 2:

To unmount:

sudo umount /where/ever
sudo cryptsetup luksClose cr_cifs_backup
sudo losetup -d /dev/loop0
  • Thanks. I'll give it a go in the next few days and accept if it works. I think I understand most of it, except the losetup part. What do I need to do to check if loop0 is free?
    – Sparhawk
    May 19, 2013 at 12:06
  • @Sparhawk losetup -a gives you all used loop devices. losetup /dev/loop tells you whether loop0 is free. You can use losetup --find to get a free one. May 19, 2013 at 18:42
  • Okay, so I got up to sudo cryptsetup luksOpen /dev/loop0 cr_cifs_backup and was told Device /dev/loop0 is not a valid LUKS device.
    – Sparhawk
    May 23, 2013 at 1:24
  • @Sparhawk That is very strange if the luksFormat command before did not return an error. You can also try isLuks and luksDump on the device. May 23, 2013 at 2:39
  • 2
    Sorry, my (stupid) mistake. luksFormat asked me to confirm with "uppercase yes", and I missed the "uppercase". I might file a bug report to make it clearer with "uppercase YES", though. :p
    – Sparhawk
    May 23, 2013 at 4:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.