I use a tool named virt-sparsify to free disk space a qcow2 image file occupies.
It works and the file becomes a sparse file.
root#ubuntu:/test# ls -lsh test.qcow2
8.7G -rw-r--r-- 1 root root 15G Jan 19 11:05 test.qcow2
As shown above, the disk size allocated for the file is smaller than its actual size. It means there are “holes” in the file. Now I want to remove these holes inside it. Does anyone know how to achieve this purpose?
You can't really "take away" the sparse flag.
Tools try to help by keeping the flag alive e.g. cp when copying.
You can easily get a non-sparse version of that file via
cp --sparse=never test.qcow2 test-nosparse.qcow2
The same way you can make a partially zeroed out file a sparse file
cp --sparse=always file.qcow2 file-sparse.qcow2
See "sparse" in man cp
Related
I'm new to octave, and want to run a few commands on startup automatically every time it opens.
I typed "help startup" and saw "Octave uses the file ".octaverc". I did a bit of searching online at https://www.math.utah.edu/docs/info/octave_4.html, and saw the .octaverc file should be in the following path:
OCTAVE_HOME/lib/octave/VERSION/startup/octaverc
PROBLEM:
In that directory I don't have a startup folder, only "oct" and "site". I do see hidden files, which was my first thought since the file begins with "." character. So I then used Agent Ransack in the directory, and still nothing came up.
QUESTION:
1) Do I have to make the startup folder and octaverc file myself?
2) If so, does one, both or none have to be hidden?
3) Can it be a txt file, or does it have a special extension?
4) Do I just type the commands straight into the file or is there special formatting?
NOTE:
In case I'm going about this the wrong way, there are the operations I'd like to have run on startup:
PS1('>> '), addpath('D:\Users\Me\Desktop'), clc
Thanks ahead of time for the help!!
Possible locations (and their differences) for octaverc files are specified in the documentation.
In short, these are, from more general to specific:
octave-home/share/octave/site/m/startup/octaverc (most generic, for entire system)
octave-home/share/octave/version/m/startup/octaverc (to cover for more than one octave versions installed on the system, possibly requiring different startup scripts)
~/.octaverc (where ~ is unix-speak for a user's home directory -- covering for user-specific startup files)
.octaverc files in any directory, creating specific startup conditions for specific directories
octaverc files are effectively simple script files that are executed from most generic to most specific each time octave starts. Therefore, in the presence of conflicting commands, the more specific file can effectively be used to override the more generic behaviour.
Octave also supports (but does not recommend) the use of the startup.m file, for matlab compatibility.
You might also want to check out pathdef and savepath as well.
As a more general tip, if you ever want to search for a specific keyword from the documentation (e.g. octaverc), you can type this kind of search query in duckduckgo (or google):
octaverc site:https://octave.org/doc/interpreter/
(or just download the documentation as pdf and search the pdf)
Found the solution, the file was in the following path:
OCTAVE_HOME/share/octave/site/m/startup
to find out where OCTAVE_HOME is for you, just type "OCTAVE_HOME" into your Octave command line window.
ANSWERS:
1) You do not have to make a startup octaverc file yourself
2) The file is actually not hidden, so it should be easy to find given you're looking in the right place.
3) The file doesn't have an extension. It's just octaverc.
4) Under the last line of the existing file, you can just append commands as you would type them at the Octave command line window.
the last(7.3.0) octave version placed HERE:/ does not find the THERE:/openEMS/matlab directory even it is already loaded with octaverc or addpath. It keeps looking into the work dir where openEMS is not placed and does not recognize, for instance, the 'physical_constants.m' file.
I would like to create an nmap that would first cd to a particular directory and then edit a file in that directory. For instance, this would allow me to open a LaTeX file and edit it, but then exit from that file and be in the directory to pull up the pdf file that LaTeX created. I have tried the following:
nmap b :cd /path/to/directory/ <cr> :edit file.tex
This almost works and will suffice if it is the only way to do it. What happens is that the left pane changes to the correct directory and the file is opened in the right pane. Then when I quit I only need to move between panes to get to the other files. However, it would be simpler/cleaner if I could get both commands to happen in the same pane.
Is this possible?
Thanks
The reason why two commands happen in different panes is that RHS of your mapping contains a space in normal mode (right after <cr>). You should either remove it or don't switch between modes at all by performing two commands in a row (which should be separated by a bar/pipe):
nnoremap b :cd /path/to/directory/ | edit file.tex<cr>
I'm trying to get proper html output from gcovr when source file is located relative from my root directory.
For example (I will mention two cases where gcovr works, and where it has problems):
CASE:1 - gcovr works without problems
My root directory is structured as follow,after I run gcovr from root with --html --html-details
source/myfile.c
obj/myfile.o, myfile.gcda, myfile.gcno, myfile.c.gcov
gcovr_reports/report.html, report_myfile.html
So everything is ok, and I have the html general report(report.html) as well as the detailed report (report_myfile.html).
CASE:2 - gcovr is not working properly
My root directory is structured as follow,after I run gcovr from root with --html --html-details)
../../../Common/Source/myfile.c
obj/Common/Source/myfile.o, myfile.gcda,myfile.gcno,^#^#^#Common#Source#gcovmyfile.gcov
gcovr_reports/report.html, report.C
Now as you can see, gcovr generates the "report.C" file within the gcovr_report/ directory
Also the general html report (report.html) with the summary is created, but not the detailed one of my source file "myfile.c" .
When I look into the obj directory it creates the following file (as you can see below):
^#^#^#Project#Common#Source#myfile.c.gcov
When I take a look into
^#^#^#Project#Common#Source#myfile.c.gcov,
the path is resolved as follow:
Source:../../../Project/Common/Source/myfile.c
but it should be:
Source:../../../../../../../Project/Common/Source/myfile.c
The gcovr command is:
C:\Python34\Scripts\gcovr -v -b -r C:\Project\UnitTests\myModule\module1 -- object-directory C:\Project\UTests\myModule\module1\test-obj\Common\Source -- html --html-details -o govr_report\report.html
Any idea what I'm doing wrong?
Gcovr filters the coverage data to only show files within your project, as determined by the -r root or any --filters.
Project: C:\Project\UnitTests\myModule\module1
File: ..\..\..\Common\Source\myfile.c
The file is not within the project, so it is excluded. This is usually what you want, because the coverage of any libraries you use tends to be irrelevant.
When this is wrong, you can take over filtering and define your own --filters. You can define multiple filters, and any one must match. To disable filters entirely, use an empty filter --filter "".
Filters are regexes that are matched against the absolute source file path.
Unfortunately, filters are currently broken for Windows. It is not possible to write filters that match multiple directories, unless your working directory is a parent directory of all target directories. For example, you could go to C:\ and use the following filters:
--filter Project\\UnitTests\\myModule\\module1\\
--filter Common\\Source\\
This will change in a future version of gcovr, so please try to avoid filters that contain backslashes as path separators.
Update: Since gcovr version 4, all filters MUST use forward slashes for path separators, even on Windows. See Using Filters in the Gcovr User Guide for details.
If I did : qsub myscript.sh
Then it creates in the script path: myscript.sh.e12 and myscript.sh.o12 files.
But if I do : qsub -o /tmp/my.out myscript.sh
Then there is nothing in /tmp and in the script path only the myscript.sh.e12 file.
The output file is lost during the move. I don't know why.
I also tried with #PBS -o in pbs file but same result.
Thanks for your help.
Torque 2.5.7
RHEL 6.2
short answer: don't write output to /tmp/, write to some space you own, preferably with a unique path.
long answer: /tmp/ is ambiguous. Remember: the whole point of using a distributed resource manager is to run a job over multiple, or at least multiply assignable, compute resources. But each such device will almost certainly have its own /tmp/, and
you have no way of knowing to which one your job was written
you may have no rights on the arbitrary_device:/tmp/ on which one your job was written
So don't write output to /tmp/.
Can I change the directory where lxc containers are initialized and kept? Now they are created under /var/cache/lxc, and I would like to have them in another directory, on another partition where I have more space. Changint the mounting point of the partition is not an option as it's already used for something else.
Yes you can. The /var/cache/lxc prefix is hardcoded into every /usr/share/lxc/templates/ template. You can change the path over there.
In case you're building LXC from sources, then the path is actually #LOCALSTATEDIR#/cache/lxc/ where #LOCALSTATEDIR# is by default --prefix= + /var or --localstatedir you pass to ./configure.
As for /var/lib/lxc, the default path to containers, specific container, and path to container's dir type of datastore could be configured at multiple levels:
lxc.lxcpath in /etc/lxc/lxc.conf, consult man lxc.system.conf for details.
lxc-* tools accepts -P flag to specify alternate container path.
lxc-create -B dir backing store has optional --dir ROOTFS flag.
Also, I highly recommend a series of blog posts by Stéphane Graber and Containers storage specifically.
The least painful would be probably just mount -o bind a directory on the partition with space to /var/lib/lxc or /var/lib/lxd whichever is your case. This works from /etc/fstab too.
For debian template (and some others) you can use environment variable, for example:
LXC_CACHE_PATH=/usr/share/lxc/cache