lxc-snapshot fails with rc 1 for no apparent reason - snapshot

At my side lxc-snapshot fails, but does not tell anything.
Tried to Google for it, not found anything. All is for lxc snapshot (note the missing dash) which is something completely different.
Looked into manual, etc. nothing found.
strace is not telling anything either, it talks to the anonymous command socket, gets a response and fails
$ lxc-start b2
$ lxc-attach b2
#
So container is running. But snapshot does not work:
$ lxc-snapshot b2; echo $?
1
$ lxc-snapshot b2 -L
No snapshots
Problem exist on Debian Buster:
$ lxc-snapshot --version
3.0.3
$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 10 (buster)
Release: 10
Codename: buster
Problem exist on Ubuntu, too:
$ lxc-snapshot --version
4.0.2
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.1 LTS
Release: 20.04
Codename: focal
Container configuration:
lxc.include = /usr/share/lxc/config/common.conf
lxc.include = /usr/share/lxc/config/userns.conf
lxc.arch = linux64
lxc.uts.name = b2
lxc.rootfs.path = dir:/home/tino/.local/share/lxc/b2/rootfs
lxc.net.0.type = veth
lxc.net.0.link = lxcbr0
lxc.net.0.flags = up
lxc.net.0.hwaddr = 00:16:3e:d2:0e:02
lxc.idmap = u 0 638752 65536
lxc.idmap = g 0 638752 65536
What am I missing here? The questions are:
How to find/enable diagnostics?
Where is this documented?
What do I (perhaps) need in Container's config?
You can point to lxc, lxd or docker for diagnostic purpose. But please note that this question is not about them, it's precisely about the low level container commands like lxc-start and lxc-snapshot (note the dash).

The manual states:
-l, --logpriority=LEVEL
Set log priority to LEVEL. The default log priority is ERROR. Possible values
are : FATAL, CRIT, WARN, ERROR, NOTICE, INFO, DEBUG.
Note that this option is setting the priority of the events log in the alter‐
nate log file. It do not have effect on the ERROR events log on stderr.
This apparently is wrong. Logging to stderr is affected by -l and it isn't ERROR by default:
$ lxc-start b2
$ lxc-snapshot -lERROR b2 2>/dev/null; echo $?
1
$ lxc-snapshot -lERROR b2
lxc-snapshot: b2: lxccontainer.c: do_lxcapi_snapshot: 4190 Snapshot of directory-backed container requested
lxc-snapshot: b2: lxccontainer.c: do_lxcapi_snapshot: 4191 Making a copy-clone. If you do want snapshots, then
lxc-snapshot: b2: lxccontainer.c: do_lxcapi_snapshot: 4192 please create overlay clone first, snapshot that
lxc-snapshot: b2: lxccontainer.c: do_lxcapi_snapshot: 4193 and keep the original container pristine
lxc-snapshot: b2: lxccontainer.c: do_lxcapi_clone: 3809 error: Original container (b2) is running. Use --allowrunning if you want to force a snapshot of the running container.
lxc-snapshot: b2: lxccontainer.c: do_lxcapi_snapshot: 4199 Failed to clone of /home/tino/.local/share/lxc:b2
lxc-snapshot: b2: tools/lxc_snapshot.c: do_snapshot: 199 Error creating a snapshot
Hence, lxc-snapshot only works on stopped containers and you only see errors if you enable logging. On a stopped container it works:
$ lxc-stop b2
$ lxc-snapshot -n b2 -L
No snapshots
$ lxc-snapshot -n b2
$ lxc-snapshot -n b2 -L
snap0 (/home/tino/.local/share/lxc/b2/snaps) 2020:11:25 12:22:03
$ ls -al ~/.local/share/lxc/b2/snaps/snap0/
total 20
drwxrwx--- 3 638752 tino 4096 Nov 25 12:22 .
drwxr-xr-x 3 tino tino 4096 Nov 25 12:20 ..
-rw-rw---- 1 tino tino 1171 Nov 25 12:22 config
drwxr-xr-x 21 638752 638752 4096 Nov 24 20:01 rootfs
-rw-rw-r-- 1 tino tino 19 Nov 25 12:22 ts
$ cat ~/.local/share/lxc/b2/snaps/snap0/ts; echo
2020:11:25 12:22:03
Notes:
--allowrunning is not mentioned in the man page either
lxc-snapshot appears to mostly wrap rsync (in this case).
This solution was found by looking up the implementation of the snapshot function on GitHub and digging deeper and deeper and deeper, getting completely lost and finally giving up on this path. Then I wrote above Question, and, while doing that, I luckily stumbled over the solution myself. Don't Panic, sometimes the solution seems to be just to ask the right way.

Related

how to config u-boot for imx6?

When I am trying to make u-boot for apalis-aimx6-quad board, and below list is shows the details of my configuration:
CROSS_COMPILER = aarch64-unknown-linux-gnu
1.1 it already exported to path
1.2 menuconfig of the cross compiler remains as before.
Host Linux version = 5.4.0-109-generic #123~18.04.1-Ubuntu
version of the cross compiler : crosstool-ng-1.25-rc2
according to the mentioned software and hardware properties, I faced with the following error when i try to make the boot-loader for my board using u-boot:
cc1: error: bad value (‘generic-armv7-a’) for ‘-mtune=’ switch
cc1: note: valid arguments to ‘-mtune=’ switch are: nocona core2 nehalem corei7
westmere sandybridge corei7-avx ivybridge core-avx-i haswell core-avx2 broadwell
skylake skylake-avx512 bonnell atom silvermont slm knl intel x86-64 eden-x2
nano nano-1000 nano-2000 nano-3000 nano-x2 eden-x4 nano-x4 k8 k8-sse3 opteron
opteron-sse3 athlon64 athlon64-sse3 athlon-fx amdfam10 barcelona bdver1 bdver2 bdver3
bdver4 znver1 btver1 btver2 generic
scripts/Makefile.build:147: recipe for target 'lib/asm-offsets.s' failed
make[1]: *** [lib/asm-offsets.s] Error 1
Makefile:1965: recipe for target 'prepare0' failed
make: *** [prepare0] Error 2
what can be the error solution?
and the Second question is:
in the ./ct-ng list-samples what type of samples are suitable for my board?
CPU-NAME = NXP® i.MX 6Quad
CPU-TYPE : 4x Arm Cortex™-A9
CPU-CLOCK : 800MHz
FLOATING-POINT-UNIT : VFPv3
You are using the wrong compiler, i.e. the gcc from your Linux PC, this is why the error message is suggesting to use values such as corei7 for the -mtune option.
This being said, because your apalis-aimx6-quad SoC is a Cortex-A9,its architecture is Armv7-a and you therefore cannot use a compiler targeting the Armv8-a architecture, such as the aarch64-unknown-linux-gnu-gcc you are using. You should rather use, say, arm-unknown-linux-gnu-gcc or arm-none-eabi-gcc.I would strongly suggest to use an official Arm toolchain, such as this one (available here), for building u-boot, and to avoid using the latest 11.2 version: I have been unable to build u-boot when using it because of an internal compiler error.
You should use CROSS_COMPILE=, and not CROSS_COMPILER= in your build command,and this is the reason why you were using your system gcc instead of aarch64-unknown-linux-gnu-gcc for building u-boot.
Bottom line, your build command should be something like:
CROSS_COMPILE=arm-none-eabi- make mrproper apalis_imx6_defconfig all
After completion of the build command, you should see the u-boot artefacts:
ll u-boot*
-rwxrwxr-x 1 user user 4988448 May 13 07:56 u-boot*
-rw-rw-r-- 1 user user 569504 May 13 07:56 u-boot-dtb.bin
-rw-rw-r-- 1 user user 569568 May 13 07:56 u-boot-dtb.img
-rwxrwxr-x 1 user user 512920 May 13 07:56 u-boot-nodtb.bin*
-rw-rw-r-- 1 user user 639200 May 13 07:56 u-boot-with-spl.imx
-rw-rw-r-- 1 user user 569504 May 13 07:56 u-boot.bin
-rw-rw-r-- 1 user user 18081 May 13 07:55 u-boot.cfg
-rw-rw-r-- 1 user user 10858 May 13 07:55 u-boot.cfg.configs
-rw-rw-r-- 1 user user 56584 May 13 07:56 u-boot.dtb
-rw-rw-r-- 1 user user 569568 May 13 07:56 u-boot.img
-rw-rw-r-- 1 user user 1719 May 13 07:56 u-boot.lds
-rw-rw-r-- 1 user user 1100407 May 13 07:56 u-boot.map
-rwxrwxr-x 1 user user 1538914 May 13 07:56 u-boot.srec*
-rw-rw-r-- 1 user user 195657 May 13 07:56 u-boot.sym
I also do the same thing for RPI 4 which the following command lines do:
wget https://dev.iopsys.eu/fork/uboot.git
tar -xf u-boot.tar.gz
ls ./configs
ls ./configs|grep rpi
make rpi_4_defconfig
export PATH=/home/<your user name>/x-tools/aarch64-rpi4-linux-gnu/bin/:$PATH
type aarch an hit tab if system recognize the compiler continue else
go back and export the compiler path.
export CROSS_COMPILE=aarch64-rpi4-linux-gnu-
make menuconfig
make
------------------------------------------------------------------------
cd ..
mkdir sdcard
sudo cp ../u-boot/u-boot.bin .
wget
------------------------------------------------------------------------
PREPARE MEMORY FOR BOOT
connect your memory to pc.
lsblk --> to know what is the name of the memory (assume it is sdb)
sudo umount /dev/sdb1
sudo cfdisk /dev/sdb --> erase older partitions and clear on 100M partition
-- note : type of the partition have to be fat32
once the partition is created.
sudo mkfs.vfat /dev/sdb1
sudo mount /dev/sdb1 /mnt
wget https://github.com/raspberrypi/firmware/raw/master/boot/start4.elf
wget https://github.com/raspberrypi/firmware/raw/master/boot/bcm2711-rpi-4-b.dtb
gedit config.txt
--#######################
IN THE CONFIG
enable_uart=1
kernel=u-boot.bin
arm_64bit=1
--#######################
cat config.txt
sudo cp * /mnt
sudo umount /mnt
unconnect the memory and connect it to the target machine.

How to insert the configuration.nix file inside my dot files?

I am creating my dot files following this tutorial. It successfully works for emacs.d.
Since I am using NixOS, I tried doing exactly the same steps with symlink creation for the configuration.nix file. Thus, I did:
1 - On terminal:
[pedro#system:/etc/nixos]$ sudo mv /etc/nixos/configuration.nix ~/.dotfiles/
2 - Then:
[pedro#system:/etc/nixos]$ ln -sf ~/.dotfiles/configuration.nix configuration.nix~
3 - It seems to work fine, as I do:
[pedro#system:/etc/nixos]$ ls -la
total 12
drwxr-xr-x 2 root root 4096 Dec 1 21:41 .
drwxr-xr-x 32 root root 4096 Dec 1 22:00 ..
lrwxrwxrwx 1 root root 39 Dec 1 21:41 configuration.nix~ -> /home/pedro/.dotfiles/configuration.nix
-rw-r--r-- 1 root root 842 Nov 12 17:40 hardware-configuration.nix
After doing some editions and saving the changes, I can't do nixos-rebuild switch, though. It throws an error:
[pedro#system:/etc/nixos]$ sudo nixos-rebuild switch
warning: Nix search path entry '/etc/nixos/configuration.nix' does not exist, ignoring
error: file 'nixos-config' was not found in the Nix search path (add it using $NIX_PATH or -I), at /nix/var/nix/profiles/per-user/root/channels/nixos/nixos/default.nix:1:60
(use '--show-trace' to show detailed location information)
building Nix...
warning: Nix search path entry '/etc/nixos/configuration.nix' does not exist, ignoring
error: file 'nixos-config' was not found in the Nix search path (add it using $NIX_PATH or -I), at /nix/var/nix/profiles/per-user/root/channels/nixos/nixos/default.nix:1:60
(use '--show-trace' to show detailed location information)
building the system configuration...
warning: Nix search path entry '/etc/nixos/configuration.nix' does not exist, ignoring
error: file 'nixos-config' was not found in the Nix search path (add it using $NIX_PATH or -I), at /nix/var/nix/profiles/per-user/root/channels/nixos/nixos/default.nix:1:60
(use '--show-trace' to show detailed location information)
The ~ after configuration.nix~ might be the problem here. How can I fix this?
Thanks!
Your Step 2 seems to have cause the issue here: The symlink should be called configuration.nix not configuration.nix~ as you have noticed.
You could fix this by running mv configuration.nix~ configuration.nix in the /etc/nixos folder which would rename configuration.nix~ to the correct configuration.nix.

File is both a regular file and a symlink

I have three files, one a real ("regular") file and two chained symlinks:
-rw-r--r-- 1 user staff 24 4 Nov 18:23 A
lrwxr-xr-x 1 user staff 1 25 Oct 17:43 B -> A
lrwxr-xr-x 1 user staff 1 4 Nov 16:54 C -> B
Now, using zsh conditional expressions ([[), I test whether B (or C) is a regular file or a symlink, and zsh says yes to both ...:
18:31 : [[ -f B ]] && echo "True"
True
18:31 : [[ -h B ]] && echo "True"
True
Isn't a symlink supposed not to be a regular file? zsh documentation of conditional expressions (here) doesn't give full details on how different cases work.
zsh --version
zsh 5.0.5 (x86_64-apple-darwin14.0)
edit
After more digging, I found this Q&A on Unix.SE : https://unix.stackexchange.com/questions/22009/distinguishing-a-regular-file-from-a-symlink. It's about bash but it looks like it also applies to zsh.
zsh is almost certainly using the S_ISREG() and S_ISLNK() macros from lstat(2). Since S_ISLNK() is younger than S_ISREG(), I imagine symlinks were historically treated like regular files here (since they aren't directories, block/character devices, etc.), and the behavior was kept for backwards compatibility. I wasn't able to find any direct evidence of this, however.

Use newsyslog to rotate log files, but only if they have a certain size

I'm on OS X 10.9.4 and trying to use newsyslog to rotate my app development log files.
More specifically, I want to rotate the files daily but only if they are not empty (newsyslog writes one or two lines to every logfile it rotates, so let's say I only want to rotate logs that are at least 1kb).
I created a file /etc/newsyslog.d/code.conf:
# logfilename [owner:group] mode count size when flags [/pid_file] [sig_num]
/Users/manuel/code/**/log/*.log manuel:staff 644 7 1 $D0 GN
The way I understand the man page for the configuration file is that size and when conditions should work in combination, so logfiles should be rotated every night at midnight only if they are 1kb or larger.
Unfortunately this is not what happens. The log files are rotated every night, no matter if they only the rotation message from newsyslog or anything else:
~/code/myapp/log (master) $ ls
total 32
drwxr-xr-x 6 manuel staff 204B Aug 8 00:17 .
drwxr-xr-x 22 manuel staff 748B Jul 25 14:56 ..
-rw-r--r-- 1 manuel staff 64B Aug 8 00:17 development.log
-rw-r--r-- 1 manuel staff 153B Aug 8 00:17 development.log.0
~/code/myapp/log (master) $ cat development.log
Aug 8 00:17:41 localhost newsyslog[81858]: logfile turned over
~/code/myapp/log (master) $ cat development.log.0
Aug 7 00:45:17 Manuels-MacBook-Pro newsyslog[34434]: logfile turned over due to size>1K
Aug 8 00:17:41 localhost newsyslog[81858]: logfile turned over
Any tips on how to get this working would be appreciated!
What you're looking for (rotate files daily unless they haven't logged anything) isn't possible using newsyslog. The man page you referenced doesn't say anything about size and when being combined other than to say that if when isn't specified, than it is as-if only size was specified. The reality is that the log is rotated when either condition is met. If the utility is like its FreeBSD counterpart, it won't rotate logs less than 512 bytes in size unless the binary flag is set.
MacOS' newer replacement for newsyslog, ASL, also doesn't have the behavior you desire. As far as I know, the only utility which has this is logrotate using its notifempty configuration option. You can install logrotate on your Mac using Homebrew

Problem with Ant's AnsiColorLogger in Snow Leopard

I have Ant configured to use the AnsiColorLogger. In Mac OS 10.5, everything was fine. Since upgrading to Snow Leopard, the AnsiColorLoggger no longer works. I see the Ant output (uncolorized) for a second then it just disappears. Has anyone else gotten this working in Snow Leopard? Other ANSI colors are working fine in Terminal.app (colored ls output, colors in my prompt).
Also, would this be a better question on SuperUser?
UPDATE: I have sorted out the issue. It has to do with ANT giving escape sequences that while appropriate for a linux xterm, are NOT correctly interpreted by Mac OS X. It is possible to filter the ANT output to convert these sequences and restore colorized output.
The moral of the story is that this wrapper script will achieve colorized output:
# cat /workspace/SDK/bin/ant-wrapper.sh
/usr/bin/ant -logger org.apache.tools.ant.listener.AnsiColorLogger "$#" | perl -pe 's/(?&lt=\e\[)2;//g'
# alias ant='/workspace/SDK/bin/ant-wrapper.sh'
# ant publish
(output has lots of pretty colors; well, maybe not so pretty, more like an easter egg)
Original Post (and debugging steps):
I'm having similar issues with regard to AnsiColorLogger not displaying colors at all. I'm not sure what the author means by "[output appears] for a second then it just disappears". That seems like a strange problem to occur on the Terminal.
My Box:
# uname -a
Darwin Dave-Dopsons-MacBook-Pro.local 10.7.0 Darwin Kernel Version 10.7.0: Sat Jan 29 15:17:16 PST 2011; root:xnu-1504.9.37~1/RELEASE_I386 i386
This is the ANT Logger we are using:
http://ant.apache.org/manual/listeners.html#AnsiColorLogger
Here's a related forum post (tried the advice given, to no avail): http://ant.1045680.n5.nabble.com/Macosx-and-AnsiColorLogger-td1355310.html
I did "ant | less", and I DO see escape sequences, but still no colors:
Buildfile: /workspace/Words/words_blackberry/build.xml
ESC[2;32m
publish:ESC[m
Still blocked on this, and would love advice if anyone has gotten it to work on OSX
GOT IT!
So here's the output of colorized ls:
# CLICOLOR_FORCE=exfxcxdxbxegedabagacad ls -lGF | less
total 112
-rw-r--r-- 1 ddopson admin 6511 May 29 12:41 build.xml
drwxr-xr-x 6 ddopson admin 204 May 28 23:59 ESC[34meclipse-binESC[mESC[m/
lrwxr-xr-x 1 ddopson admin 35 May 23 21:24 ESC[35mfilesESC[mESC[m# -> ../artwork/output/blackberry/files/
lrwxr-xr-x 1 ddopson admin 36 May 23 21:20 ESC[35mimagesESC[mESC[m# -> ../artwork/output/blackberry/images/
Notice how the escape sequences are subtly different; they don't have the '2;' like ANT did...
So to test this theory:
ant -logger org.apache.tools.ant.listener.AnsiColorLogger publish | sed 's/2;//g'
... and the output is COLORIZED! Victory!
I've take ddopson's knowledge and crammed it into a single line:
ant () { command ant -logger org.apache.tools.ant.listener.AnsiColorLogger "$#" | sed 's/2;//g' ; }
This works by using a Bash Function. Place this in your ~/.profile file and it will do the same thing as ddopson's ant-wrapper.sh, but without needing a second file to make it work. Slightly more elegant and less fragile.

Resources