Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have Windows 7 installed on one of my disks. I want to boot this Windows system in my Xen HVM, but I do not want the changes to be permanent. So I want to create a snapshot of my Windows 7 partition. I checked with LVM, but it seems LVM can only create snapshot for LV it created. I am looking for a more general snapshot method.

share|improve this question
add comment

2 Answers 2

up vote 2 down vote accepted

You can use the lower level dmsetup command to direct the kernel device mapper to create a snapshot. If you are otherwise using LVM aside from the Windows partition, then create a logical volume to use as the backing store of the snapshot.

lvcreate -n store -L 10g vg
echo 0 `blockdev --getsz /dev/sda1` snapshot-origin /dev/sda1 | dmsetup create origin
echo 0 `blockdev --getsz /dev/sda1` snapshot /dev/mapper/origin /dev/mapper/vg-store N 128 | dmsetup create snap

Now you can point xen to /dev/mapper/snap instead of /dev/sda1 and any changes it makes will be discarded when you finish and use dmsetup remove to remove the snap and origin devices, and lvremove to remove the store volume.

If you aren't using LVM then you will need another partition or loop device to use as the backing store instead.

share|improve this answer
    
Thanks a lot. I tried to google about dmsetup snapshot, but I can only find articles talking about dmsetup in general. Do you happen to know where I can find detailed description about the snapshot feature of dmsetup? –  davidshen84 Mar 30 '12 at 1:59
    
@davidshen84, In the kernel source tree under Documentation/device-mapper/snapshot.txt. –  psusi Mar 30 '12 at 13:41
add comment

LiveCDs tend to do something like this. They have a read-only image from the CDROM and then overlay with a RAMdisk.

The filesystem in question is UnionFS. An alternative would be AuFS, but they should both be easy.

I'd tinker with it in a VM first before running it against something you care about.

share|improve this answer
1  
UnionFS and AuFS both work by implementing a copy-on-write. Also they dont work with block devices, only filesystems. –  Patrick Mar 29 '12 at 3:20
    
I checked both, none is applicable. KVM supports snapshot itself. I wish Xen has a similar feature. –  davidshen84 Mar 29 '12 at 7:38
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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