How to Make a Copy of a Virtual Disk (vDisk)?
Question
I would like to make a copy of a virtual disk and move it to an external drive. Is this possible?
Environment
KVM
OnApp Storage
Answer
- Go to the VS disks page to get the identifier for the VS disk. It gives the identifier
wjtgsfuyxapb3k
. Go to the compute resource or backup server and get the ID of the server you are on:
[root@ ~]# onappstore getid ipaddr= result=SUCCESS uuid=2868323073 completion_time=0
CODEOnline the VS disk using its identifier and the server ID you are on as frontend:
onappstore online uuid=wjtgsfuyxapb3k frontend_uuid=2868323073
CODEMap partitions of this VS disk, if needed (the identifier for the data store is required):
kpartx -a -v -p X /dev/iyrdh2t6lwkgcz/wjtgsfuyxapb3k
CODEThis should give you a disk, such as
wjtgsfuyxapb3kX1
.
Now you have the VS disk at/dev/mapper/wjtgsfuyxapb3kX1
and can perform tasks on it. For example, you can runfsck
on it:fsck -fy /dev/mapper/wjtgsfuyxapb3kX1
CODEOR
Mount it and transfer the files:mount /dev/mapper/wjtgsfuyxapb3kX1
CODEAfter you are done with the disk, you need to undo the steps. First, umount the disk if it is mounted, etc. Unmap the disk:
kpartx -d -v -p X /dev/iyrdh2t6lwkgcz/wjtgsfuyxapb3k
CODEOffline the disk:
onappstore offline uuid=wjtgsfuyxapb3k
CODE
Alternative Process
If the virtual server is on, create a snapshot and gain access to it as in the example below:
[root@ ~]# onappstore snapshot uuid=wjtgsfuyxapb3k
result=SUCCESS uuid=b6yj75n1kz3wog completion_time=6
[root@ ~]# onappstore getid
ipaddr= result=SUCCESS uuid=2868323073 completion_time=0
[root@ ~]# onappstore online uuid=b6yj75n1kz3wog frontend_uuid=2868323073
result=SUCCESS completion_time=11
[root@ ~]# kpartx -a -v -p X /dev/iyrdh2t6lwkgcz/b6yj75n1kz3wog
add map b6yj75n1kz3wogX1 (253:69): 0 41942912 linear /dev/iyrdh2t6lwkgcz/b6yj75n1kz3wog 128
Now you are ready to use the disk:
[root@ ~]# mkdir -p /mnt/snapshot_live_disk
[root@ ~]# mount /dev/mapper/b6yj75n1kz3wogX1 /mnt/snapshot_live_disk/
[root@ ~]# ls /mnt/snapshot_live_disk/
bin boot cgroup dev etc home lib lib64 lost+found media mnt opt proc root sbin selinux srv sys tmp usr var
As you are done, you need to clean up the mount
:
[root@ ~]# umount /mnt/snapshot_live_disk/
[root@ ~]# rmdir /mnt/snapshot_live_disk/
Offline and remove the snapshot:
[root@ ~]# kpartx -d -v -p X /dev/iyrdh2t6lwkgcz/b6yj75n1kz3wog
del devmap : b6yj75n1kz3wogX1
[root@ ~]# onappstore offline uuid=b6yj75n1kz3wog
result=SUCCESS completion_time=6
[root@ ~]# onappstore delete uuid=b6yj75n1kz3wog
result=SUCCESS completion_time=9
[root@ ~]#