Category Archives: Software

Import and rename duplicated volume group

If you like to use a cloned volume with a volume group on it, then normally you will have a problem with the VG UUID and the VG Name. The good answer there is a nice solution for the problem and you can import and rename duplicated volume groups.

To rename and generate a new UUID for the volume group on the volume use the program vgimportclone.

sudo gimportclone -n old /dev/sdb1
WARNING: lvmetad is running but disabled. Restart lvmetad before enabling it!
WARNING: lvmetad is running but disabled. Restart lvmetad before enabling it!
WARNING: Activation disabled. No device-mapper interaction will be attempted.
WARNING: lvmetad is running but disabled. Restart lvmetad before enabling it!
Physical volume "/tmp/snap.cozRdFdC/vgimport0" changed
1 physical volume changed / 0 physical volumes not changed
WARNING: lvmetad is running but disabled. Restart lvmetad before enabling it!
WARNING: lvmetad is running but disabled. Restart lvmetad before enabling it!
WARNING: Activation disabled. No device-mapper interaction will be attempted.
WARNING: lvmetad is running but disabled. Restart lvmetad before enabling it!
Volume group "system" successfully changed
WARNING: lvmetad is running but disabled. Restart lvmetad before enabling it!
WARNING: lvmetad is running but disabled. Restart lvmetad before enabling it!
Volume group "system" successfully renamed to "old"
Reading all physical volumes. This may take a while...
Found volume group "system" using metadata type lvm2

After the successfully rename of the volume group activate it.

sudo vgchange -a y

Now you can use the renamed volume group old normally as other volume groups.

xfs filesystem duplicate UUID

If you clone a volume with xfs filesystem on it and you try to mount this on the same node, than normally you will receive error messages, like wrong fs type, bas superblock,… you have the problem with xfs filesystem duplicate UUID.

In the dmesg you should file a message like:

XFS: Filesystem sdb1 has duplicate UUID - can't mount.

If its a one time mount you can do it with:

sudo mount -o nouuid /dev/sdb1 /mnt

But the better solution is to generate a new uuid for the filesystem, because its clean and you can mount it easy without problems:

sudo xfs_admin -U generate /dev/sdb1
Clearing log and setting UUID
writing all SBs
new UUID = 01fbb4f2-1ers0-4dde-94fc-024efb3cd2a4
after that, you can mount this XFS partition regularly.

Then mount the volume normally with mount:

sudo mount /dev/sdb1 /mnt

Vagrant 1.8.5 – public key problem

If you like to create with kitchen a new Vagrant instance with the Vagrant version 1.8.5 you get the following problem:

           default: Vagrant insecure key detected. Vagrant will automatically replace
           default: this with a newly generated keypair for better security.
           default:
           default: Inserting generated public key within guest...
           default: Removing insecure key from the guest if it's present...
           default: Key inserted! Disconnecting and reconnecting using new SSH key...
           default: Warning: Authentication failure. Retrying...
           default: Warning: Authentication failure. Retrying...
           default: Warning: Authentication failure. Retrying...
           default: Warning: Authentication failure. Retrying...
           default: Warning: Authentication failure. Retrying...
           default: Warning: Authentication failure. Retrying...
           default: Warning: Authentication failure. Retrying...
           default: Warning: Authentication failure. Retrying...

To fix this, you should create this file:

vi .vagrant.d/Vagrantfile

With the content:

Vagrant.configure("2") do |config|
  config.ssh.insert_key = false
end

rsync status with lsof

To see the status from rsync, you can use lsof:

lsof -ad3-999 -c rsync

Output:

COMMAND  PID USER   FD   TYPE             DEVICE SIZE/OFF       NODE NAME
rsync   8097 root    3r   REG             252,17   404832 7559983121 /srv/data/safematix
rsync   8097 root    4u  unix 0xffff8806f4447080      0t0      85225 type=STREAM
rsync   8097 root    5u  unix 0xffff8806f4444ec0      0t0      85226 type=STREAM
rsync   8098 root    3u  unix 0xffff880738502580      0t0      77431 type=STREAM
rsync   8099 root    4u  unix 0xffff880738500b40      0t0      77432 type=STREAM

lxd shared directory

To share the data to a LXD container, you must set the UID and GID to 100000. In the container it will be the id from root (0).

chown -R 100000:100000 /srv/shared

Now you can connect the shared folder:

lxc config device add mycontainer shared disk path=/srv/shared source=/srv/shared

gem mirror – gemirro

Gemirro is a Ruby application that makes it easy way to create your own RubyGems mirror without having to push or write all gem you wanted in a configuration file. It does mirroring without any authentication and you can add your private gems in the gems directory. More, to mirroring a source, you only need to start the server, and gems will automaticly be downloaded when needed.

Gemirro will start on port 2000. I should proxy it via nginx.

Install the gem gemirro:

gem install gemirro

Create your mirror:

gemirro init /srv/mirror/gems/

Create a gemirro index:

gemirro index

Start the server:

gemirro server --start

Show the status:

gemirro server --status

Stop the server:

gemirro server --stop

Start the server with a http/s proxy:

https_proxy="https://proxy.safematix.com:8080" gemirro server --start

Github gemirro

OpenBSD chef client

OpenBSD chef client

If you like to install chef client on OpenBSD, you must install ruby on it:

pkg_add ruby
quirks-2.114 signed on 2015-08-09T11:57:52Z
Ambiguous: choose package for ruby
a       0: 
        1: ruby-1.8.7.374p4
        2: ruby-1.9.3.551p2
        3: ruby-2.0.0.645p0
        4: ruby-2.1.6p0
        5: ruby-2.2.2p0
Your choice: 5
ruby-2.2.2p0:libffi-3.1p0: ok
ruby-2.2.2p0:libyaml-0.1.6p1: ok
ruby-2.2.2p0:gmp-5.0.2p3: ok
ruby-2.2.2p0: ok
--- +ruby-2.2.2p0 -------------------
If you want to use this package as your default system ruby, as root
create symbolic links like so (overwriting any previous default):
 ln -sf /usr/local/bin/ruby22 /usr/local/bin/ruby
 ln -sf /usr/local/bin/erb22 /usr/local/bin/erb
 ln -sf /usr/local/bin/irb22 /usr/local/bin/irb
 ln -sf /usr/local/bin/rdoc22 /usr/local/bin/rdoc
 ln -sf /usr/local/bin/ri22 /usr/local/bin/ri
 ln -sf /usr/local/bin/rake22 /usr/local/bin/rake
 ln -sf /usr/local/bin/gem22 /usr/local/bin/gem

Now install chef client:

gem install chef

Raspberry Pi ntp server gps

raspberry pi ntp server gps

RASPBERRY PI NTP SERVER GPS
RASPBERRY PI NTP SERVER GPS

You need:

stty -F /dev/ttyAMA0 raw 9600 cs8 clocal -cstopb

test gps

cat /dev/ttyAMA0

gpsmon

gpsmon
gpsmon

(eg, remove console=ttyAMA0,115200 and if there, kgdboc=ttyAMA0,115200) /boot/cmdline.txt

dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait

Install ntp package

apt-get install ntp gpsd

/etc/default/gpsd

# Default settings for the gpsd init script and the hotplug wrapper.

# Start the gpsd daemon automatically at boot time
START_DAEMON="true"

# Use USB hotplugging to add new USB devices automatically to the daemon
USBAUTO="false"

# Devices gpsd should collect to at boot time.
# They need to be read/writeable, either by user gpsd or the group dialout.
DEVICES="/dev/ttyAMA0"

# Other options you want to pass to gpsd
GPSD_OPTIONS="-b -n"

/lib/systemd/system/gpsd.service

#ExecStart=/usr/sbin/gpsd -N $GPSD_OPTIONS $DEVICES
ExecStart=/usr/sbin/gpsd -N -b -n /dev/ttyAMA0

/usr/local/bin/leap-seconds.sh

#!/bin/sh
cd /etc/ntp
wget https://www.ietf.org/timezones/data/leap-seconds.list &> /dev/null
service ntp restart &> /dev/null

/etc/cron.d/ntp

0 0 31 6,12 * root /usr/local/bin/leap-seconds.sh
mkdir /etc/ntp

download the leap-seconds.list the first time

/usr/local/bin/leap-seconds.sh

/etc/ntp.conf

driftfile /var/lib/ntp/ntp.drift
leapfile /etc/ntp/leap-seconds.list

# Enable this if you want statistics to be logged.
statsdir /var/log/ntpstats/

statistics loopstats peerstats clockstats
filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable

# pool
server 0.ch.pool.ntp.org iburst
server 1.ch.pool.ntp.org iburst
server 2.ch.pool.ntp.org iburst
server 3.ch.pool.ntp.org iburst


# HW GPS
server 127.127.28.0 iburst
fudge 127.127.28.0 flag1 1 flag2 0 time2 0.600 refid GPS

# Access control configuration; see /usr/share/doc/ntp-doc/html/accopt.html for
# details.  The web page 
# might also be helpful.
#
# Note that "restrict" applies to both servers and clients, so a configuration
# that might be intended to block requests from certain clients could also end
# up blocking replies from your own upstream servers.

# By default, exchange time with everybody, but don't allow configuration.
restrict -4 default kod notrap nomodify nopeer noquery
restrict -6 default kod notrap nomodify nopeer noquery

# Local users may interrogate the ntp server more closely.
restrict 127.0.0.1
restrict ::1

# Clients from this (example!) subnet have unlimited access, but only if
# cryptographically authenticated.
restrict 172.23.0.0 mask 255.255.0.0 notrust

# If you want to provide time to your local subnet, change the next line.
# (Again, the address is an example only.)
#broadcast 192.168.123.255

# If you want to listen to time broadcasts on your local subnet, de-comment the
# next lines.  Please do this only if you trust everybody on the network!
#disable auth
#broadcastclient

Tricks:

query and synchronize against a pool

ntpdate -q 0.ch.pool.ntp.org 1.ch.pool.ntp.org

/etc/udev/rules.d/99-com.rules
KERNEL==”ttyAMA0″, SYMLINK+=”gps0″
KERNEL==”pps0″, SYMLINK+=”gpspps0″

The NTP status codes that ntpq is showing you are on this list, yours is showing an “*” which means you aren’t using the PPS, just the serial output of the GPS chip. You might want to look into that as the PPS is probably going to give you better time accuracy.

o = pps peer
* = sys peer
# = too distant
+ = selected
x = false ticker
– = discarded

[![MIT license](http://img.shields.io/badge/license-MIT-brightgreen.svg)](http://opensource.org/licenses/MIT)

curl HTTP-header only

curl HTTP-header only

-I, --head
              (HTTP/FTP/FILE) Fetch the HTTP-header only! HTTP-servers feature the command HEAD which this uses to get nothing but the header of a document. When used on an FTP or FILE file, curl displays the file size and last modification time only.
root@vh01 ~ # curl -I https://git.safematix.com 
HTTP/1.1 302 Found
Server: nginx
Date: Sun, 08 Nov 2015 15:51:31 GMT
Content-Type: text/html; charset=utf-8
Connection: keep-alive
Status: 302 Found
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
Location: https://git.safematix.com/users/sign_in
Cache-Control: no-cache
Set-Cookie: _gitlab_session=08f48dd9e9a254b8ef0531f16e58963c; path=/; expires=Sun, 15 Nov 2015 15:51:31 -0000; secure; HttpOnly
Set-Cookie: request_method=HEAD; path=/
X-Request-Id: 20f8f32e-79ca-4bdd-97c0-092e70e39abc
X-Runtime: 0.007302
X-Frame-Options: DENY
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
Public-Key-Pins: pin-sha256="tqbNSQH3NzwHzRVt1iYPI4cncKFhKQRCDrt8nt4mqhE="; pin-sha256="5C8kvU039KouVrl52D0eZSGf4Onjo4Khs8tmyTlV3nU="; max-age=5184000; includeSubDomains