I create a snapshot of my qcow2 image file like
qemu-img -c before_update Server_sda_qcow2.img
After I have updated the system and everything is working well. I will
write the snapshot back to the base file and delete the snapshot.
I tried
qemu-img -a before_update Server_sda_qcow2.img
But it seems that it won't work.
How can I archieve this with qemu-img?
I solved the problem by myself:
In my case I only need to delete the snapshot with:
qemu-img -d before_update Server_sda_qcow2.img
When I will bring the base file back to the snapshot I have to do:
qemu-img -a before_update Server_sda_qcow2.img
Related
I am trying to convert a raw image file to a qcow2 with luks encryption.And I searched a lot, mostly it use the "-o encryption=on",but it will removed in future in qemu-img tools.
I am using the qemu-img 2.8 version,I try this command:
qemu-img convert --object secret,data=123456,id=sec0 -O luks -o key-secret=sec0 raw.img demo.luks
qemu-img: Could not open 'demo.luks': Parameter 'key-secret' is required for cipher
Is there someone know how to fix this issue?And if this luks encryption qcow2 is create successfully,Is is nessery to change the qemu-system-x86-64 paramter to run this image?
Unfortunately the 'convert' command in qemu-img does not support the syntax required to output luks format images, in any released QEMU version.
It current GIT master, there's a slight improvement - you can now use LUKS images as the target provided that you pre-create the LUKS image. First use 'qemu-img create' to create an empty luks image with no data written, then convert to it.
First I have some random qcow2 image I previously created
$ qemu-img create -f qcow2 demo.qcow2 10M
I've used it in a guest or otherwise written data to it, and now want to convert to luks. First I must create a luks image the exact same size:
$ qemu-img create -f luks --object secret,data=123,id=sec0 \
-o key-secret=sec0 demo.luks 10M
Now I can extract the data from the qcow2 image, writing it into the luks image:
$ qemu-img convert --target-image-opts \
--object secret,data=123,id=sec0 -f qcow2 demo.qcow2 -n \
driver=luks,file.filename=demo.luks,key-secret=sec0
NB, as mentioned above this is functionality only in GIT master right now from
commit 305b4c60f200ee8e6267ac75f3f5b5d09fda1079
Author: Daniel P. Berrange <berrange#redhat.com>
Date: Mon May 15 17:47:11 2017 +0100
qemu-img: introduce --target-image-opts for 'convert' command
So the first release this will be available in is the next QEMU 2.10 release.
I'm learning data analysis in Zeppelin, I'm a mechanical engineer so this is outside my expertise.
I am trying to download two csv files using a file that contains the urls, test2.txt. When I run it I get no output, but no error message either. I've included a link to a screenshot showing my code and the results.
When I go into Ambari Sandbox I cannot find any files created. I'm assuming the directory the file is in is where the csv files will be downloaded too. I've tried using -P as well with no luck. I've checked in man wget but it did not help.
So I have several questions:
How do I show the output from running wget?
Where is the default directory that wget stores files?
Do I need additional data in the file other than just the URLs?
Screenshot: Code and Output for %sh
Thanks for any and all help.
%sh
wget -i /tmp/test2.txt
%sh
# list the current working directory
pwd # output: home/zeppelin
# make a new folder, created in "tmp" because it is temporary
mkdir -p /home/zeppelin/tmp/Folder_Name
# change directory to new folder
cd /home/zeppelin/tmp/Folder_Name
# transfer the file from the sandbox to the current working directory
hadoop fs -get /tmp/test2.txt /home/zeppelin/tmp/Folder_Name/
# download the URL
wget -i test2.txt
I am trying to move gitlab-ce 8.5 source base to gitlab-ce 8.15 omnibus. We were using MySQL in source base but now we have to use thepsql with gitlab-ce omnibus`. When I was trying to take a backup so it was failing due to some empty repo.
Question: Is it any alternative way to move source base to omnibus with full backup?
I have moved gitlab from source base to the omnibus. You can use below link to convert db dump from MySQL to psql.
https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/update/mysql_to_postgresql.md
I have created a zip file of repos manually & copied to the gitlab omnibus server & restore it on /var/opt/gitlab/git-data/repository/.
After these steps, copy the below script on /var/opt/gitlab/git-data/xyz.sh & executed for updating the hooks.
#!/bin/bash
for i in repositories/* ; do
if [ -d "$i" ]; then
for o in $i/* ; do
if [ -d "$i" ]; then
rm "$o/hooks"
# change the paths if required
ln -s "/opt/gitlab/embedded/service/gitlab-shell/hooks" /var/opt/gitlab/git-data/"$o"/hooks
echo "HOOKS CHANGED ($i/$o)"
fi
done
fi
done
Note: Repos permission should be git:git
Some useful commands during the migration:
sudo gitlab-ctl start postgres **to start the Postgres service only**
sudo gitlab-psql **to use the gitlab bundle postgres.**
Feel free to comment if you face 5xx errors code on gitlab page.
If you look at dockerfiles the often contains lines like this:
sed 's/main$/main universe/' -i /etc/apt/sources.list
I think it is difficult to set up things like this.
Is it possible to launch a default OS image, then enter it interactive with a shell, do some modifications, and then print out the diff (filesystem diff)?
The diff should be used as the dockerfile to recreating the image.
But maybe I am missing something, since I am new to docker.
You can create docker images several ways.
I tend to have two windows open when I create a new docker image. One for my docker run -i -t centos bash, where I am writing all my commands to get it the way I want, and the other one with the Dockerfile, so I can put in whatever I do.
When it comes to config files, I am putting them in the files/folders that matches the one on the image.
Example, if I change /etc/something/file.conf, I will create the file in etc/something/file.conf in the same directory as my Dockerfile, and then use Dockers ADD command to add it whenever I do a build.
This works perfectly, since I can have all this in a git repository with a README.md containing the info I need for running/building the image.
The other thing you can do is to is to run docker ps -a after you are done with the changes you wanted to create an image on, and get the docker ID of the image of the container you just configured. You can tag this new image, or start it with docker run abc0123 bash just like you would a normal docker image.
The problem with this is that you wont be able to easily build it next time without bringing the whole image.
Dockerfiles with ADD is the way to go!
If you do not want to run sed (which is used to preserve the default file and of minimal changes to it), you can simply ADD the modifies file.
For that you can docker run -it --rm thebaseimage /bin/sh (or any other shell that is provided) and edit it in place. Then just copy it outside the container (or docker export it) and use it on your build.
The downside of ADD vs RUN sed… is that, if something changes in a new version of your base image, you will overwrite those changes.
The Dockerfile is (mostly) equivalent to a series of docker run and docker commit commands. You wouldn't want to look at the docker diff to see what files changed -- you'd want to see what docker run commands had occurred. You could get these from your host shell history and process these into a Dockerfile.
I have a qemu qcow2 disk snapshot dev.img that is based off a backing file dev.bak.
How can I merge both into a standalone devplus.img, while leaving dev.bak as it is?
I got some help from the qemu mailing list:
First copy the original base file to your standalone image file:
cp dev.bak devplus.img
Then "rebase" the image file that was backed off the original file so that it uses the new file:
qemu-img rebase -b devplus.img dev.img
Then you can commit the changes in the dev file back into the new base:
qemu-img commit dev.img
Now you can use devplus.img as a standalone image file and get rid of dev.img if you wish, leaving the original dev.bak intact and not corrupting any other images that were based off it.
qemu-img convert -O qcow2 dev.img devplus.img
This detects that dev.img is based off dev.bak and creates a standalone devplus.img.