2

in Windows we have vhd virtual hard disk and on top of that we have a differencing vhd, where there is a static parent vhd and a child vhd.

what is the equivalent technology in linux and how to create a differencing file (file system) and how to mount it in command line?

3
  • 2
    What is a differencing file system, a snapshot? Nov 26, 2017 at 18:37
  • 1
    where there is a base file system (a snapshot image) and an additional file (file system) which contains all the changes on top of the snapshot. then the operating system combines the two and mount it as one image
    – Six Tram
    Nov 26, 2017 at 18:46
  • 1) people tend to use the "loop device", this works only with raw format images (which may be "sparse files"). There's not so much support for actually mounting other formats except via VMs (libguestfs lets you do it, but I'm 99% sure it is always implemented by spinning up a VM). 2) the equivalent would be to use a device-mapper snapshot using loop devices - this should work fine, it's not particularly common though. On Linux you might have to be a bit more thoughtful about mountable snapshots of disk image files, and whether there are alternatives that might be more convenient.
    – sourcejedi
    Nov 26, 2017 at 20:08

2 Answers 2

2

If I understand the description of "differencing VHD" correctly, the Linux equivalent is the overlay filesystem.

It consists of an upper and a lower layer, where the upper layer (containing the "differences") is overlaid on the lower layer (the "base file system"). Often the lower layer is read-only, and this is a popular way to manage the root file system on embedded systems, e.g. routers (where the lower layer is additionally compressed).

1

Some filesystems (like btrfs) have integrated snapshots.

There are snapshots on the block device level, too. They are provided by the devoce mapper. The easiest way to use them is to use LVM (logical volume manager, man 8 lvm). LVM can create COW volumes (even change their size) and thus store the snapshot across a reboot.

You can merge a snapthot into its origin volume in order to restore the inital state. You can also write to the snapshot without affecting the origin volume.

4
  • That seems to be different: BTFRS snapshot always contain the whole filesystem (possibly shared), never differences, and one snapshot cannot be used to "modify" another snapshot.
    – dirkt
    Nov 27, 2017 at 21:28
  • @dirkt I may have misunderstood the question but snapshots store differences only. They are not directly accessible with each kind of snapshot but e.g. btrfs snapshots can show you what has been changed (btrfs subvolume find-new). Nov 27, 2017 at 21:58
  • LiveCD/LiveDVD distros work this way as well, wiht a squashed FS on the disc and then as changes are made while the system runs it writes the overlay to RAM
    – ivanivan
    Nov 27, 2017 at 22:24
  • Last time I looked at BTRSS, all snapshots were "identical" - you have a BTree with shared nodes, and if you compare the BTrees of two subvolumes, of course you can see what has changed (just look at which nodes are no longer shared). But the subvolume still stores the whole BTree; if you delete the original subvolume, you'll still be able to use the changed subvolume, just the nodes are now unshared. OTOH, the Linux overlay FS and the "differencing VHD" don't have the complete FS in the child/upper layer: If you delete the parent/lower layer, the whole thing becomes unusable.
    – dirkt
    Nov 28, 2017 at 8:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .