Reinstall live CentOS 7 server using ssh and change disk configuration of root filesystem to RAID1

Not all dedicated server providers have good web management panel or offer a remote management console (like IPMI/KVM, iDRAC, iLO and so on)! If you used multiple server providers you would experience the case when you received a server installed with the linux distro by your choice, but with no options to configure the hard drives setup. And in most cases when there is no choice of hard drives and partition configuration you end up with a dedicated server installed with root filesystem on the whole first device without any redundancy or performance. So it will be nice to reinstall the server without using remote management module (because it is missing, for example).
Here are the steps to reinstall a CentOS7 server with two hard drives, the initial installation uses the almost whole first device for root filesystem. At the end we will have the server with different hard drive configuration – root filesystem will be on a RAID1 device for redundancy (and read performance) and will have a dedicated space for it, there will be a bigger device for storage purposes.

Here are the steps to reinstall live CentOS 7 server using ssh and change disk configuration of root filesystem to RAID1:

STEP 1) Show the current configuration

[root@localhost ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda2       461G  1.5G  437G   1% /
devtmpfs         16G     0   16G   0% /dev
tmpfs            16G     0   16G   0% /dev/shm
tmpfs            16G  8.5M   16G   1% /run
tmpfs            16G     0   16G   0% /sys/fs/cgroup
/dev/sda1       485M  136M  324M  30% /boot
/dev/sda5       3.9G   17M  3.7G   1% /tmp
tmpfs           3.2G     0  3.2G   0% /run/user/0
[root@localhost ~]# ls -al /dev/sd?
brw-rw---- 1 root disk 8,  0 Apr  4 11:06 /dev/sda
brw-rw---- 1 root disk 8, 16 Apr  4 11:06 /dev/sdb
brw-rw---- 1 root disk 8, 32 Apr  4 11:06 /dev/sdc
brw-rw---- 1 root disk 8, 48 Apr  4 11:06 /dev/sdd
[root@localhost ~]# 

Root filesystem uses /dev/sda3, /tmp uses /dev/sda5 and the boot is on /dev/sda2. So the whole install uses only /dev/sda device and the other 3 are spare. We are going to use the second hard drive /dev/sdb to create a software RAID1 for our root filesystem.

STEP 2) Prepare the second drive for first reboot

Because /dev/sda is the first device the server will always boot from the grub installed in /dev/sda, so if we want to change the partition layout we must umount all partitions of /dev/sda, which is not a easy job. So because we have a second disk, we can change the partition layout of the second disk /dev/sdb, then copy the root filesystem from the first disk to the second and instruct the the grub to boot the root filesystem from the second disk. And more, at first we’ll use the partition for the swap of the second disk for root filesystem and then we’ll create the RAID1 device. Here we make initial setup of the second disk /dev/sdb:

[root@localhost ~]# parted /dev/sdb --script print
Model: ATA SanDisk SD6SB2M5 (scsi)
Disk /dev/sdb: 512GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start  End  Size  Type  File system  Flags

[root@localhost ~]# parted /dev/sdb --script mklabel gpt
[root@localhost ~]# parted /dev/sdb --script mkpart primary 0% 4M
[root@localhost ~]# parted /dev/sdb --script mkpart primary 4M 16G
[root@localhost ~]# parted /dev/sdb --script mkpart primary 16G 50G
[root@localhost ~]# parted /dev/sdb --script mkpart primary 50G 100%
[root@localhost ~]# parted /dev/sdb --script set 1 bios_grub on
[root@localhost ~]# parted /dev/sdb --script print
Model: ATA SanDisk SD6SB2M5 (scsi)
Disk /dev/sdb: 512GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name     Flags
 1      1049kB  4194kB  3146kB               primary  bios_grub
 2      4194kB  16.0GB  16.0GB               primary
 3      16.0GB  50.0GB  34.0GB               primary
 4      50.0GB  512GB   462GB                primary

[root@localhost ~]# mkfs.ext4 /dev/sdb2
mke2fs 1.42.9 (28-Dec-2013)
Discarding device blocks: done                            
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
977280 inodes, 3905280 blocks
195264 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2151677952
120 block groups
32768 blocks per group, 32768 fragments per group
8144 inodes per group
Superblock backups stored on blocks: 
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done   

[root@localhost ~]#

STEP 3) Copy all the files from the current filesystem to the newly created one using rsync

[root@localhost ~]# mkdir /mnt/centos
[root@localhost ~]# mount /dev/sdb2 /mnt/centos/
[root@localhost ~]# rsync --delete --partial --verbose --progress --stats --recursive --times --perms --links --owner --group --hard-links --devices --exclude=/mnt --exclude=/proc --exclude=/sys / /mnt/centos/
...
...
Number of files: 81519
Number of files transferred: 60909
Total file size: 1483871491 bytes
Total transferred file size: 1460598076 bytes
Literal data: 1460598076 bytes
Matched data: 0 bytes
File list size: 1691669
File list generation time: 0.001 seconds
File list transfer time: 0.000 seconds
Total bytes sent: 1465598884
Total bytes received: 1734750

sent 1465598884 bytes  received 1734750 bytes  79315331.57 bytes/sec
total size is 1483871491  speedup is 1.01
[root@localhost ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda2       461G  1.5G  437G   1% /
devtmpfs         16G     0   16G   0% /dev
tmpfs            16G     0   16G   0% /dev/shm
tmpfs            16G  8.5M   16G   1% /run
tmpfs            16G     0   16G   0% /sys/fs/cgroup
/dev/sda1       485M  136M  324M  30% /boot
/dev/sda5       3.9G   17M  3.7G   1% /tmp
tmpfs           3.2G     0  3.2G   0% /run/user/0
/dev/sdb2        15G  1.6G   13G  12% /mnt/centos
[root@localhost ~]# 

STEP 4) Prepare the new root

  1. umount /boot, because we want to use it for the first reboot but with changed grub configuration, generated for the new root filesystem
    [root@localhost ~]# umount /boot
    [root@localhost ~]# mount /dev/sda1 /mnt/centos/boot
    [root@localhost ~]# df -h
    Filesystem      Size  Used Avail Use% Mounted on
    /dev/sda2       461G  1.5G  437G   1% /
    devtmpfs         16G     0   16G   0% /dev
    tmpfs            16G     0   16G   0% /dev/shm
    tmpfs            16G  8.6M   16G   1% /run
    tmpfs            16G     0   16G   0% /sys/fs/cgroup
    /dev/sda5       3.9G   17M  3.7G   1% /tmp
    tmpfs           3.2G     0  3.2G   0% /run/user/0
    /dev/sdb2        15G  1.6G   13G  12% /mnt/centos
    /dev/sda1       485M  136M  324M  30% /mnt/centos/boot
    
  2. chroot in the new root and replace the old GIUD with the new one for the root filesystem in /etc/fstab
    [root@localhost ~]# mkdir /mnt/centos/proc
    [root@localhost ~]# mkdir /mnt/centos/sys
    [root@localhost ~]# mount -o bind /proc /mnt/centos/proc
    [root@localhost ~]# mount -o bind /dev /mnt/centos/dev
    [root@localhost ~]# mount -o bind /sys /mnt/centos/sys
    [root@localhost ~]# chroot /mnt/centos/
    [root@localhost /]# blkid |grep sdb2
    /dev/sdb2: UUID="b829d6f1-ca0e-4939-8764-c329aee0a5b2" TYPE="ext4" PARTLABEL="primary" PARTUUID="b150c7cc-0557-4de9-bbc9-05ae54b9cec5" 
    [root@localhost /]# blkid |grep sda2
    /dev/sda2: UUID="b43edab7-8b2f-4047-9ca2-0f3e3ea24e0e" TYPE="ext4" 
    [root@localhost /]# sed -i "s/b43edab7-8b2f-4047-9ca2-0f3e3ea24e0e/b829d6f1-ca0e-4939-8764-c329aee0a5b2/g" /etc/fstab
    
  3. comment out the /tmp in /etc/fstab (and any other directory, which uses /dev/sda, remember after the reboot we will change the partition layout of /dev/sda, so we need not to use any partition from it)
    [root@localhost /]# cat /etc/fstab 
    
    #
    # /etc/fstab
    # Created by anaconda on Wed Apr  4 11:00:01 2018
    #
    # Accessible filesystems, by reference, are maintained under '/dev/disk'
    # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
    #
    UUID=b829d6f1-ca0e-4939-8764-c329aee0a5b2 /                       ext4    defaults        1 1
    UUID=9b98bd49-34bd-43a3-89b9-32c36df722b2 /boot                   ext2    defaults        1 2
    UUID=7f44f0b8-cbbe-4e70-a763-112675cf9a2c /tmp                    ext4    noexec,nosuid,nodev        1 2
    UUID=20c3afea-87ae-4716-8a65-323bd9e6eae6 swap                    swap    defaults        0 0
    [root@localhost /]# sed -i "s/UUID=7f44f0b8-cbbe-4e70-a763-112675cf9a2c/#UUID=7f44f0b8-cbbe-4e70-a763-112675cf9a2c/g" /etc/fstab 
    [root@localhost /]# cat /etc/fstab 
    
    #
    # /etc/fstab
    # Created by anaconda on Wed Apr  4 11:00:01 2018
    #
    # Accessible filesystems, by reference, are maintained under '/dev/disk'
    # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
    #
    UUID=b829d6f1-ca0e-4939-8764-c329aee0a5b2 /                       ext4    defaults        1 1
    UUID=9b98bd49-34bd-43a3-89b9-32c36df722b2 /boot                   ext2    defaults        1 2
    #UUID=7f44f0b8-cbbe-4e70-a763-112675cf9a2c /tmp                    ext4    noexec,nosuid,nodev        1 2
    UUID=20c3afea-87ae-4716-8a65-323bd9e6eae6 swap                    swap    defaults        0 0
    [root@localhost /]#
    
  4. Generate the new grub2 configuration (because you are in the chrooted new root and there you change the /etc/fstab, grub will use the new GUID for the filesystem)
    [root@localhost /]# grub2-mkconfig -o /boot/grub2/grub.cfg
    Generating grub configuration file ...
    Found linux image: /boot/vmlinuz-3.10.0-693.21.1.el7.x86_64
    Found initrd image: /boot/initramfs-3.10.0-693.21.1.el7.x86_64.img
    Found linux image: /boot/vmlinuz-3.10.0-693.el7.x86_64
    Found initrd image: /boot/initramfs-3.10.0-693.el7.x86_64.img
    Found linux image: /boot/vmlinuz-0-rescue-3003b47aedb040f6baaf6fce8c6b8386
    Found initrd image: /boot/initramfs-0-rescue-3003b47aedb040f6baaf6fce8c6b8386.img
    done
    [root@localhost /]# exit
    exit
    [root@localhost ~]# umount /mnt/centos/boot
    [root@localhost ~]# umount /mnt/centos/proc
    [root@localhost ~]# umount /mnt/centos/sys
    [root@localhost ~]# umount /mnt/centos/dev
    [root@localhost ~]# umount /mnt/centos
    [root@localhost ~]# reboot
    Connection to srv closed by remote host.
    Connection to srv closed.
    

STEP 5) Prepare the two disks /dev/sda and /dev/sdb for RAID1 device

Unmount all devices of /dev/sda (such as swap, /boot). Then make a new partition layout for /dev/sda and tune the layout of /dev/sdb (we need the flag raid to be “on”)

[root@srv0 ~]# ssh srv
root@srv's password: 
Last login: Wed Apr  4 11:28:57 2018 from 192.168.0.110
[root@localhost ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sdb2        15G  1.6G   13G  12% /
devtmpfs         16G     0   16G   0% /dev
tmpfs            16G     0   16G   0% /dev/shm
tmpfs            16G  8.5M   16G   1% /run
tmpfs            16G     0   16G   0% /sys/fs/cgroup
/dev/sda1       485M  136M  324M  30% /boot
tmpfs           3.2G     0  3.2G   0% /run/user/0
[root@localhost ~]# umount /boot
[root@localhost ~]# swapoff -a
[root@localhost ~]# ls -al /boot/
total 128020
dr-xr-xr-x  6 root root     4096 Apr  4 11:07 .
dr-xr-xr-x 17 root root     4096 Apr  4 12:25 ..
-rw-r--r--  1 root root   140971 Mar  7 19:16 config-3.10.0-693.21.1.el7.x86_64
-rw-r--r--  1 root root   140894 Aug 22  2017 config-3.10.0-693.el7.x86_64
drwxr-xr-x  3 root root     4096 Apr  4 11:00 efi
drwxr-xr-x  2 root root     4096 Apr  4 11:00 grub
drwx------  5 root root     4096 Apr  4 11:04 grub2
-rw-------  1 root root 53705597 Apr  4 11:02 initramfs-0-rescue-3003b47aedb040f6baaf6fce8c6b8386.img
-rw-------  1 root root 17881515 Apr  4 11:04 initramfs-3.10.0-693.21.1.el7.x86_64.img
-rw-------  1 root root 15956344 Apr  4 11:07 initramfs-3.10.0-693.21.1.el7.x86_64kdump.img
-rw-------  1 root root 17871068 Apr  4 11:04 initramfs-3.10.0-693.el7.x86_64.img
-rw-r--r--  1 root root   610968 Apr  4 11:01 initrd-plymouth.img
drwx------  2 root root     4096 Apr  4 11:00 lost+found
-rw-r--r--  1 root root   293361 Mar  7 19:18 symvers-3.10.0-693.21.1.el7.x86_64.gz
-rw-r--r--  1 root root   293027 Aug 22  2017 symvers-3.10.0-693.el7.x86_64.gz
-rw-------  1 root root  3237433 Mar  7 19:16 System.map-3.10.0-693.21.1.el7.x86_64
-rw-------  1 root root  3228420 Aug 22  2017 System.map-3.10.0-693.el7.x86_64
-rwxr-xr-x  1 root root  5877760 Apr  4 11:02 vmlinuz-0-rescue-3003b47aedb040f6baaf6fce8c6b8386
-rwxr-xr-x  1 root root  5917504 Mar  7 19:16 vmlinuz-3.10.0-693.21.1.el7.x86_64
-rw-r--r--  1 root root      171 Mar  7 19:16 .vmlinuz-3.10.0-693.21.1.el7.x86_64.hmac
-rwxr-xr-x  1 root root  5877760 Aug 22  2017 vmlinuz-3.10.0-693.el7.x86_64
-rw-r--r--  1 root root      166 Aug 22  2017 .vmlinuz-3.10.0-693.el7.x86_64.hmac
[root@localhost ~]# parted /dev/sda --script mklabel gpt
[root@localhost ~]# parted /dev/sda --script mkpart primary 0% 4M
[root@localhost ~]# parted /dev/sda --script mkpart primary 4M 16G
[root@localhost ~]# parted /dev/sda --script mkpart primary 16G 50G
[root@localhost ~]# parted /dev/sda --script mkpart primary 50G 100%
[root@localhost ~]# parted /dev/sda --script set 1 bios_grub on
[root@localhost ~]# parted /dev/sda --script set 2 raid on
[root@localhost ~]# parted /dev/sda --script set 3 raid on
[root@localhost ~]# parted /dev/sda --script set 4 raid on
[root@localhost ~]# parted /dev/sda --script print
Model: ATA SanDisk SD6SB2M5 (scsi)
Disk /dev/sda: 512GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name     Flags
 1      1049kB  4194kB  3146kB  ext2         primary  bios_grub
 2      4194kB  16.0GB  16.0GB               primary  raid
 3      16.0GB  50.0GB  34.0GB               primary  raid
 4      50.0GB  512GB   462GB                primary  raid

[root@localhost ~]# parted /dev/sdb --script print
Model: ATA SanDisk SD6SB2M5 (scsi)
Disk /dev/sdb: 512GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name     Flags
 1      1049kB  4194kB  3146kB               primary  bios_grub
 2      4194kB  16.0GB  16.0GB  ext4         primary
 3      16.0GB  50.0GB  34.0GB               primary
 4      50.0GB  512GB   462GB                primary

[root@localhost ~]# parted /dev/sdb --script set 3 raid on
[root@localhost ~]# parted /dev/sdb --script print
Model: ATA SanDisk SD6SB2M5 (scsi)
Disk /dev/sdb: 512GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name     Flags
 1      1049kB  4194kB  3146kB               primary  bios_grub
 2      4194kB  16.0GB  16.0GB  ext4         primary
 3      16.0GB  50.0GB  34.0GB               primary  raid
 4      50.0GB  512GB   462GB                primary

STEP 6) Create the RAID1 device and format the filesystem, then copy all files from the root file system to the RAID1 device /dev/md1 (mounted again in /mnt/centos)

[root@localhost ~]# mdadm --create --verbose --metadata=1.2 /dev/md1 --level=1 --raid-devices=2 /dev/sda3 /dev/sdb3
mdadm: size set to 33186816K
mdadm: array /dev/md1 started.
[root@localhost ~]# cat /proc/mdstat
Personalities : [raid1] 
md1 : active raid1 sdb3[1] sda3[0]
      33186816 blocks super 1.2 [2/2] [UU]
      [==>..................]  resync = 10.8% (3602048/33186816) finish=2.4min speed=200113K/sec
      
unused devices: <none>
[root@localhost ~]# mkfs.ext4 /dev/md1
mke2fs 1.42.9 (28-Dec-2013)
Discarding device blocks: done                            
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
977280 inodes, 3905280 blocks
195264 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2151677952
120 block groups
32768 blocks per group, 32768 fragments per group
8144 inodes per group
Superblock backups stored on blocks: 
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done   
[root@localhost ~]# mount /dev/md1 /mnt/centos/
[root@localhost ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sdb2        15G  1.6G   13G  12% /
devtmpfs         16G     0   16G   0% /dev
tmpfs            16G     0   16G   0% /dev/shm
tmpfs            16G  8.5M   16G   1% /run
tmpfs            16G     0   16G   0% /sys/fs/cgroup
tmpfs           3.2G     0  3.2G   0% /run/user/0
/dev/md1         32G   49M   30G   1% /mnt/centos
[root@localhost ~]# rsync --delete --partial --verbose --progress --stats --recursive --times --perms --links --owner --group --hard-links --devices --exclude=/mnt --exclude=/proc --exclude=/sys / /mnt/centos/
sending incremental file list
./
.autorelabel
           0 100%    0.00kB/s    0:00:00 (xfer#1, to-check=1022/1024)
.readahead
      237849 100%   39.12MB/s    0:00:00 (xfer#2, to-check=1021/1024)
bin -> usr/bin
lib -> usr/lib
lib64 -> usr/lib64
sbin -> usr/sbin
....
....
Number of files: 81532
Number of files transferred: 60917
Total file size: 1484146321 bytes
Total transferred file size: 1460872926 bytes
Literal data: 1460872926 bytes
Matched data: 0 bytes
File list size: 1693018
File list generation time: 0.001 seconds
File list transfer time: 0.000 seconds
Total bytes sent: 1465875457
Total bytes received: 1734920

sent 1465875457 bytes  received 1734920 bytes  83863450.11 bytes/sec
total size is 1484146321  speedup is 1.01
[root@localhost ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sdb2        15G  1.6G   13G  12% /
devtmpfs         16G     0   16G   0% /dev
tmpfs            16G     0   16G   0% /dev/shm
tmpfs            16G  8.5M   16G   1% /run
tmpfs            16G     0   16G   0% /sys/fs/cgroup
tmpfs           3.2G     0  3.2G   0% /run/user/0
/dev/md1         32G  1.6G   28G   6% /mnt/centos

STEP 7) Prepare the new root in the RAID1 device

chroot in the new place (/mnt/centos) and change the GUID of the root filesystem in /etc/fstab, comment the “/boot”, we will use /boot on our root filesystem (we can do it, because we have a separate boot grub partition, the first one, so our /boot could reside on a RAID device). Also add the configuration of the UUID array in /etc/default/grub to generate a proper grub2 configuration for the next boot.

[root@localhost ~]# mkdir -p /mnt/centos/proc
[root@localhost ~]# mkdir -p /mnt/centos/sys
[root@localhost ~]# mount -o bind /proc /mnt/centos/proc
[root@localhost ~]# mount -o bind /dev /mnt/centos/dev
[root@localhost ~]# mount -o bind /sys /mnt/centos/sys
[root@localhost ~]# chroot /mnt/centos/
[root@localhost /]# blkid |grep sdb2
/dev/sdb2: UUID="b829d6f1-ca0e-4939-8764-c329aee0a5b2" TYPE="ext4" PARTLABEL="primary" PARTUUID="b150c7cc-0557-4de9-bbc9-05ae54b9cec5" 
[root@localhost /]# blkid |grep md1
/dev/md1: UUID="38407879-7399-492c-bad6-d8a3ef0297d4" TYPE="ext4" 
[root@localhost /]# sed -i "s/b829d6f1-ca0e-4939-8764-c329aee0a5b2/38407879-7399-492c-bad6-d8a3ef0297d4/g" /etc/fstab 
[root@localhost /]# cat /etc/fstab 

#
# /etc/fstab
# Created by anaconda on Wed Apr  4 11:00:01 2018
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=38407879-7399-492c-bad6-d8a3ef0297d4 /                       ext4    defaults        1 1
UUID=9b98bd49-34bd-43a3-89b9-32c36df722b2 /boot                   ext2    defaults        1 2
#UUID=7f44f0b8-cbbe-4e70-a763-112675cf9a2c /tmp                    ext4    noexec,nosuid,nodev        1 2
UUID=20c3afea-87ae-4716-8a65-323bd9e6eae6 swap                    swap    defaults        0 0
[root@localhost /]# sed -i "s/UUID=9b98bd49-34bd-43a3-89b9-32c36df722b2/#UUID=9b98bd49-34bd-43a3-89b9-32c36df722b2/g" /etc/fstab 
[root@localhost /]# cat /etc/fstab 

#
# /etc/fstab
# Created by anaconda on Wed Apr  4 11:00:01 2018
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=38407879-7399-492c-bad6-d8a3ef0297d4 /                       ext4    defaults        1 1
#UUID=9b98bd49-34bd-43a3-89b9-32c36df722b2 /boot                   ext2    defaults        1 2
#UUID=7f44f0b8-cbbe-4e70-a763-112675cf9a2c /tmp                    ext4    noexec,nosuid,nodev        1 2
UUID=20c3afea-87ae-4716-8a65-323bd9e6eae6 swap                    swap    defaults        0 0
[root@localhost /]# mdadm -E /dev/sda3
/dev/sda3:
          Magic : a92b4efc
        Version : 1.2
    Feature Map : 0x0
     Array UUID : e59b6269:7af24168:193c51d0:65b33fd9
           Name : localhost.localdomain:1  (local to host localhost.localdomain)
  Creation Time : Wed Apr  4 12:38:58 2018
     Raid Level : raid1
   Raid Devices : 2

 Avail Dev Size : 66373632 (31.65 GiB 33.98 GB)
     Array Size : 33186816 (31.65 GiB 33.98 GB)
    Data Offset : 32768 sectors
   Super Offset : 8 sectors
   Unused Space : before=32616 sectors, after=0 sectors
          State : active
    Device UUID : 8ebd8e2d:aa01d194:55a51280:e4192e08

    Update Time : Wed Apr  4 12:44:00 2018
  Bad Block Log : 512 entries available at offset 136 sectors
       Checksum : 3e7cfbb6 - correct
         Events : 18


   Device Role : Active device 0
   Array State : AA ('A' == active, '.' == missing, 'R' == replacing)
[root@localhost /]# nano /etc/default/grub
[root@localhost /]# cat /etc/default/grub
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL="serial console"
GRUB_SERIAL_COMMAND="serial --speed=115200"
GRUB_CMDLINE_LINUX="rd.md.uuid=e59b6269:7af24168:193c51d0:65b33fd9 crashkernel=auto console=ttyS0,115200"
GRUB_DISABLE_RECOVERY="true"
[root@localhost /]# mdadm --detail --scan >> /etc/mdadm.conf
[root@localhost /]# cat /etc/mdadm.conf
ARRAY /dev/md1 metadata=1.2 name=localhost.localdomain:1 UUID=e59b6269:7af24168:193c51d0:65b33fd9
[root@localhost /]# dracut --regenerate-all --force
[root@localhost /]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.0-693.21.1.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-693.21.1.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-693.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-693.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-3003b47aedb040f6baaf6fce8c6b8386
Found initrd image: /boot/initramfs-0-rescue-3003b47aedb040f6baaf6fce8c6b8386.img
done
[root@localhost /]# grub2-install /dev/sda
Installing for i386-pc platform.
Installation finished. No error reported.
[root@localhost /]# grub2-install /dev/sdb
Installing for i386-pc platform.
Installation finished. No error reported.
[root@localhost /]# exit
exit
[root@localhost ~]# umount /mnt/centos/proc
[root@localhost ~]# umount /mnt/centos/sys
[root@localhost ~]# umount /mnt/centos/dev
[root@localhost ~]# umount /mnt/centos
[root@localhost ~]# reboot
PolicyKit daemon disconnected from the bus.
We are no longer a registered authentication agent.
Connection to srv closed by remote host.
Connection to srv closed.

STEP 8) Create one more RAID1 device for the swap

Create a new RAID1 for the swap partition and configure the /dev/sdb with parted. Add the new RAID1 device in /dev/default/grub and generate the grub2 configuration file.

[root@srv0 ~]# ssh srv
root@srv's password: 
Last login: Wed Apr  4 11:38:19 2018 from 192.168.0.110

[root@localhost ~]# parted /dev/sda --script print
Model: ATA SanDisk SD6SB2M5 (scsi)
Disk /dev/sda: 512GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name     Flags
 1      1049kB  4194kB  3146kB               primary  bios_grub
 2      4194kB  16.0GB  16.0GB               primary  raid
 3      16.0GB  50.0GB  34.0GB               primary  raid
 4      50.0GB  512GB   462GB                primary  raid

[root@localhost ~]# parted /dev/sdb --script print
Model: ATA SanDisk SD6SB2M5 (scsi)
Disk /dev/sdb: 512GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name     Flags
 1      1049kB  4194kB  3146kB               primary  bios_grub
 2      4194kB  16.0GB  16.0GB  ext4         primary
 3      16.0GB  50.0GB  34.0GB               primary  raid
 4      50.0GB  512GB   462GB                primary

[root@localhost ~]# parted /dev/sdb --script set 2 raid on
[root@localhost ~]# parted /dev/sdb --script set 4 raid on
[root@localhost ~]# mdadm --create --verbose --metadata=1.2 /dev/md0 --level=1 --raid-devices=2 /dev/sda2 /dev/sdb2
mdadm: /dev/sdb2 appears to contain an ext2fs file system
       size=15621120K  mtime=Wed Apr  4 12:24:37 2018
mdadm: size set to 15612928K
Continue creating array? yes
mdadm: array /dev/md0 started.
[root@localhost ~]# cat /proc/mdstat 
Personalities : [raid1] 
md0 : active raid1 sdb2[1] sda2[0]
      15612928 blocks super 1.2 [2/2] [UU]
      [====>................]  resync = 21.5% (3371072/15612928) finish=0.9min speed=210692K/sec
      
md1 : active raid1 sdb3[1] sda3[0]
      33186816 blocks super 1.2 [2/2] [UU]
      
unused devices: <none>
[root@localhost ~]# cat /proc/mdstat 
Personalities : [raid1] 
md0 : active raid1 sdb2[1] sda2[0]
      15612928 blocks super 1.2 [2/2] [UU]
      
md1 : active raid1 sdb3[1] sda3[0]
      33186816 blocks super 1.2 [2/2] [UU]
      
unused devices: <none>
[root@localhost ~]# mkswap /dev/md0
Setting up swapspace version 1, size = 15612924 KiB
no label, UUID=0916f8c5-079d-4780-af38-89411fa7ec24
[root@localhost ~]# cat /etc/fstab |grep swap
UUID=20c3afea-87ae-4716-8a65-323bd9e6eae6 swap                    swap    defaults        0 0
[root@localhost ~]# sed -i "s/20c3afea-87ae-4716-8a65-323bd9e6eae6/0916f8c5-079d-4780-af38-89411fa7ec24/g" /etc/fstab
[root@localhost ~]# cat /proc/mdstat 
Personalities : [raid1] 
md0 : active raid1 sdb2[1] sda2[0]
      15612928 blocks super 1.2 [2/2] [UU]
      
md1 : active raid1 sdb3[1] sda3[0]
      33186816 blocks super 1.2 [2/2] [UU]
      
unused devices: <none>
[root@localhost ~]# cat /etc/fstab 

#
# /etc/fstab
# Created by anaconda on Wed Apr  4 11:00:01 2018
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=38407879-7399-492c-bad6-d8a3ef0297d4 /                       ext4    defaults        1 1
#UUID=9b98bd49-34bd-43a3-89b9-32c36df722b2 /boot                   ext2    defaults        1 2
#UUID=7f44f0b8-cbbe-4e70-a763-112675cf9a2c /tmp                    ext4    noexec,nosuid,nodev        1 2
UUID=0916f8c5-079d-4780-af38-89411fa7ec24 swap                    swap    defaults        0 0
[root@localhost ~]# mdadm -E /dev/sda2
/dev/sda2:
          Magic : a92b4efc
        Version : 1.2
    Feature Map : 0x0
     Array UUID : 2e122130:2eefd9ec:5ad5b846:6bd10d6b
           Name : localhost.localdomain:0  (local to host localhost.localdomain)
  Creation Time : Wed Apr  4 13:11:03 2018
     Raid Level : raid1
   Raid Devices : 2

 Avail Dev Size : 31225856 (14.89 GiB 15.99 GB)
     Array Size : 15612928 (14.89 GiB 15.99 GB)
    Data Offset : 16384 sectors
   Super Offset : 8 sectors
   Unused Space : before=16232 sectors, after=0 sectors
          State : clean
    Device UUID : 7ef8d502:96208fd4:bbed302a:37063c83

    Update Time : Wed Apr  4 13:12:42 2018
  Bad Block Log : 512 entries available at offset 136 sectors
       Checksum : c808e2cc - correct
         Events : 17


   Device Role : Active device 0
   Array State : AA ('A' == active, '.' == missing, 'R' == replacing)
[root@localhost ~]# nano /etc/default/grub 
[root@localhost ~]# cat /etc/default/grub 
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL="serial console"
GRUB_SERIAL_COMMAND="serial --speed=115200"
GRUB_CMDLINE_LINUX="rd.md.uuid=e59b6269:7af24168:193c51d0:65b33fd9 rd.md.uuid=2e122130:2eefd9ec:5ad5b846:6bd10d6b crashkernel=auto console=ttyS0,115200"
GRUB_DISABLE_RECOVERY="true"

[root@localhost ~]# mdadm --detail --scan > /etc/mdadm.conf
[root@localhost ~]# cat /etc/mdadm.conf 
ARRAY /dev/md1 metadata=1.2 name=localhost.localdomain:1 UUID=e59b6269:7af24168:193c51d0:65b33fd9
ARRAY /dev/md0 metadata=1.2 name=localhost.localdomain:0 UUID=2e122130:2eefd9ec:5ad5b846:6bd10d6b
[root@localhost ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.0-693.21.1.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-693.21.1.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-693.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-693.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-3003b47aedb040f6baaf6fce8c6b8386
Found initrd image: /boot/initramfs-0-rescue-3003b47aedb040f6baaf6fce8c6b8386.img
done
[root@localhost ~]# reboot
Connection to srv closed by remote host.
Connection to srv closed.
[root@srv0 ~]# 

So we changed our root filesystem device configuration from a single partition to a RAID1 device for redundancy and better performance!

[root@srv0 ~]# ssh srv
root@srv's password: 
Last login: Wed Apr  4 13:35:55 2018 from 192.168.0.110
[root@localhost ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/md1         32G  1.6G   28G   6% /
devtmpfs         16G     0   16G   0% /dev
tmpfs            16G     0   16G   0% /dev/shm
tmpfs            16G  8.5M   16G   1% /run
tmpfs            16G     0   16G   0% /sys/fs/cgroup
tmpfs           3.2G     0  3.2G   0% /run/user/0
[root@localhost ~]# free -h
              total        used        free      shared  buff/cache   available
Mem:            31G        273M         30G        8.5M        199M         30G
Swap:           14G          0B         14G
[root@localhost ~]# cat /proc/mdstat 
Personalities : [raid1] 
md0 : active raid1 sda2[0] sdb2[1]
      15612928 blocks super 1.2 [2/2] [UU]
      
md1 : active raid1 sda3[0] sdb3[1]
      33186816 blocks super 1.2 [2/2] [UU]
      
unused devices: <none>
[root@localhost ~]#

STEP 9) Create the storage device

The storage device is a RAID5 setup with 4 hard disks available in the current machine (but it is the same with two devices except the RAID is RAID1). The idea is to separate the storage from the root filesystem that’s why we have separate two RAID devices.

[root@localhost ~]# parted /dev/sdc --script mklabel gpt
[root@localhost ~]# parted /dev/sdc --script mkpart primary 0% 4M
[root@localhost ~]# parted /dev/sdc --script mkpart primary 4M 16G
[root@localhost ~]# parted /dev/sdc --script mkpart primary 16G 50G
[root@localhost ~]# parted /dev/sdc --script mkpart primary 50G 100%
[root@localhost ~]# parted /dev/sdc --script set 1 bios_grub on
[root@localhost ~]# parted /dev/sdc --script set 2 raid on
[root@localhost ~]# parted /dev/sdc --script set 3 raid on
[root@localhost ~]# parted /dev/sdc --script set 4 raid on
[root@localhost ~]# parted /dev/sdd --script mklabel gpt
[root@localhost ~]# parted /dev/sdd --script mkpart primary 0% 4M
[root@localhost ~]# parted /dev/sdd --script mkpart primary 4M 16G
[root@localhost ~]# parted /dev/sdd --script mkpart primary 16G 50G
[root@localhost ~]# parted /dev/sdd --script mkpart primary 50G 100%
[root@localhost ~]# parted /dev/sdd --script set 1 bios_grub on
[root@localhost ~]# parted /dev/sdd --script set 2 raid on
[root@localhost ~]# parted /dev/sdd --script set 3 raid on
[root@localhost ~]# parted /dev/sdd --script set 4 raid on
[root@localhost ~]# mdadm --create --verbose /dev/md2 --level=5 --raid-devices=4 --chunk=1024 /dev/sda4 /dev/sdb4 /dev/sdc4 /dev/sdd4
mdadm: layout defaults to left-symmetric
mdadm: layout defaults to left-symmetric
mdadm: size set to 451147776K
mdadm: automatically enabling write-intent bitmap on large array
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md2 started.
[root@localhost ~]# cat /proc/mdstat 
Personalities : [raid1] [raid6] [raid5] [raid4] 
md2 : active raid5 sdd4[4] sdc4[2] sdb4[1] sda4[0]
      1353443328 blocks super 1.2 level 5, 1024k chunk, algorithm 2 [4/3] [UUU_]
      [>....................]  recovery =  0.9% (4316984/451147776) finish=36.2min speed=205570K/sec
      bitmap: 0/4 pages [0KB], 65536KB chunk

md0 : active raid1 sda2[0] sdb2[1]
      15612928 blocks super 1.2 [2/2] [UU]
      
md1 : active raid1 sda3[0] sdb3[1]
      33186816 blocks super 1.2 [2/2] [UU]
      
unused devices: <none>
[root@localhost ~]# mkfs.ext4 /dev/md2
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=256 blocks, Stripe width=768 blocks
84590592 inodes, 338360832 blocks
16918041 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2487222272
10326 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
        4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, 
        102400000, 214990848

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done       

[root@localhost ~]# blkid | grep md2
/dev/md2: UUID="0ba39ec9-a1fc-4593-a704-6171cb2a3403" TYPE="ext4" 
[root@localhost ~]# nano /etc/fstab 
[root@localhost ~]# mkdir -p /mnt/storage
[root@localhost ~]# mount /mnt/storage
[root@localhost ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/md1         32G  1.6G   28G   6% /
devtmpfs         16G     0   16G   0% /dev
tmpfs            16G     0   16G   0% /dev/shm
tmpfs            16G  8.6M   16G   1% /run
tmpfs            16G     0   16G   0% /sys/fs/cgroup
tmpfs           3.2G     0  3.2G   0% /run/user/0
/dev/md2        1.3T   77M  1.2T   1% /mnt/storage

QEMU full virtualization – CPU emulations (enable/disable CPU flags/instruction sets) of QEMU 2.0.0

After the two QEMU full virtualization howtos

You can use QEMU with a nearly native full virtualization. Here are some important tips for the guest CPU to consider when using QEMU directly (without any virtualization manager like virt-manager, libvirt and so on).

TIP 1)Choose your host CPU emulation

You can see what options are available for host emulation with:

srv@local ~$ qemu-system-x86_64 -cpu help

x86           qemu64  QEMU Virtual CPU version 2.0.0                  
x86           phenom  AMD Phenom(tm) 9550 Quad-Core Processor         
x86         core2duo  Intel(R) Core(TM)2 Duo CPU     T7700  @ 2.40GHz 
x86            kvm64  Common KVM processor                            
x86           qemu32  QEMU Virtual CPU version 2.0.0                  
x86            kvm32  Common 32-bit KVM processor                     
x86          coreduo  Genuine Intel(R) CPU           T2600  @ 2.16GHz 
x86              486                                                  
x86          pentium                                                  
x86         pentium2                                                  
x86         pentium3                                                  
x86           athlon  QEMU Virtual CPU version 2.0.0                  
x86             n270  Intel(R) Atom(TM) CPU N270   @ 1.60GHz          
x86           Conroe  Intel Celeron_4x0 (Conroe/Merom Class Core 2)   
x86           Penryn  Intel Core 2 Duo P9xxx (Penryn Class Core 2)    
x86          Nehalem  Intel Core i7 9xx (Nehalem Class Core i7)       
x86         Westmere  Westmere E56xx/L56xx/X56xx (Nehalem-C)          
x86      SandyBridge  Intel Xeon E312xx (Sandy Bridge)                
x86          Haswell  Intel Core Processor (Haswell)                  
x86       Opteron_G1  AMD Opteron 240 (Gen 1 Class Opteron)           
x86       Opteron_G2  AMD Opteron 22xx (Gen 2 Class Opteron)          
x86       Opteron_G3  AMD Opteron 23xx (Gen 3 Class Opteron)          
x86       Opteron_G4  AMD Opteron 62xx class CPU                      
x86       Opteron_G5  AMD Opteron 63xx class CPU                      
x86             host  KVM processor with all supported host features (only available in KVM mode)

Recognized CPUID flags:
  pbe ia64 tm ht ss sse2 sse fxsr mmx acpi ds clflush pn pse36 pat cmov mca pge mtrr sep apic cx8 mce pae msr tsc pse de vme fpu
  hypervisor rdrand f16c avx osxsave xsave aes tsc-deadline popcnt movbe x2apic sse4.2|sse4_2 sse4.1|sse4_1 dca pcid pdcm xtpr cx16 fma cid ssse3 tm2 est smx vmx ds_cpl monitor dtes64 pclmulqdq|pclmuldq pni|sse3
  smap adx rdseed rtm invpcid erms bmi2 smep avx2 hle bmi1 fsgsbase
  3dnow 3dnowext lm|i64 rdtscp pdpe1gb fxsr_opt|ffxsr mmxext nx|xd syscall
  perfctr_nb perfctr_core topoext tbm nodeid_msr tce fma4 lwp wdt skinit xop ibs osvw 3dnowprefetch misalignsse sse4a abm cr8legacy extapic svm cmp_legacy lahf_lm
  pmm-en pmm phe-en phe ace2-en ace2 xcrypt-en xcrypt xstore-en xstore
  kvm_pv_unhalt kvm_pv_eoi kvm_steal_time kvm_asyncpf kvmclock kvm_mmu kvm_nopiodelay kvmclock
  pfthreshold pause_filter decodeassists flushbyasid vmcb_clean tsc_scale nrip_save svm_lock lbrv npt

The host server will expose different instruction set to the guest server (the emulated CPU), so when you choose your host to emulate for example “qemu64” with:

qemu-system-x86_64 -enable-kvm  \
-cpu qemu64,+ssse3,+sse4.1,+sse4.2,+x2apic -smp 2,maxcpus=8 \
-daemonize -vnc 192.168.0.10:1 \
-drive file=/mnt/storage/qemu/roofs/srv_virt.qcow2,index=0,cache=none,aio=threads,if=virtio \
-cdrom /mnt/storage/images/install-amd64-minimal-20140327.iso -boot d \
-net nic,model=virtio,macaddr=$(< /sys/class/net/macvtap0/address) \
-net tap,fd=3 3<>/dev/tap$(< /sys/class/net/macvtap0/ifindex) \
-balloon virtio -m 8192 \
-monitor telnet:127.0.0.1:5801,server,nowait -writeconfig /opt/qemu/config/srv_virt.qcow2.conf

The guest server (the virtual machine) will have the following CPU and instruction set:

vendor_id       : GenuineIntel
cpu family      : 6
model           : 6
model name      : QEMU Virtual CPU version 2.0.0
stepping        : 3
microcode       : 0x1
cpu MHz         : 2133.408
cache size      : 4096 KB
fpu             : yes
fpu_exception   : yes
cpuid level     : 4
wp              : yes
flags           : fpu de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pse36 clflush mmx fxsr sse sse2 syscall nx lm rep_good nopl pni ssse3 cx16 sse4_1 x2apic popcnt hypervisor lahf_lm
bogomips        : 4266.81
clflush size    : 64
cache_alignment : 64
address sizes   : 40 bits physical, 48 bits virtual
power management:

processor       : 1
vendor_id       : GenuineIntel
cpu family      : 6
model           : 6
model name      : QEMU Virtual CPU version 2.0.0
stepping        : 3
microcode       : 0x1
cpu MHz         : 2133.408
cache size      : 4096 KB
fpu             : yes
fpu_exception   : yes
cpuid level     : 4
wp              : yes
flags           : fpu de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pse36 clflush mmx fxsr sse sse2 syscall nx lm rep_good nopl pni ssse3 cx16 sse4_1 x2apic popcnt hypervisor lahf_lm
bogomips        : 4266.81
clflush size    : 64
cache_alignment : 64
address sizes   : 40 bits physical, 48 bits virtual
power management:

A base set of instructions (flags) with the explicitly included by our command with

+ssse3,+sse4.1,+sse4.2,+x2apic

. The format:

-cpu qemu64,+ssse3,+sse4.1,+sse4.2,+x2apic

IF you choose the last option:

-cpu host

the host server will try to emulate and expose to the virtual machine its processor and all flags:

qemu-system-x86_64 -enable-kvm  \
-cpu host -smp 2,maxcpus=8 \
-daemonize -vnc 192.168.0.10:1 \
-drive file=/mnt/storage/qemu/roofs/srv_virt.qcow2,index=0,cache=none,aio=threads,if=virtio \
-cdrom /mnt/storage/images/install-amd64-minimal-20140327.iso -boot d \
-net nic,model=virtio,macaddr=$(< /sys/class/net/macvtap0/address) \
-net tap,fd=3 3<>/dev/tap$(< /sys/class/net/macvtap0/ifindex) \
-balloon virtio -m 8192 \
-monitor telnet:127.0.0.1:5801,server,nowait -writeconfig /opt/qemu/config/srv_virt.qcow2.conf

The virtual machine:

[root@vm0 ~]# cat /proc/cpuinfo 
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 44
model name      : Intel(R) Xeon(R) CPU           E5606  @ 2.13GHz
stepping        : 2
microcode       : 0x1
cpu MHz         : 2133.408
cache size      : 8192 KB
fpu             : yes
fpu_exception   : yes
cpuid level     : 11
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon rep_good nopl pni pclmulqdq ssse3 cx16 pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes hypervisor lahf_lm tsc_adjust
bogomips        : 4266.81
clflush size    : 64
cache_alignment : 64
address sizes   : 40 bits physical, 48 bits virtual
power management:

The host server:

[root@srv0 ~]# cat /proc/cpuinfo 
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 44
model name      : Intel(R) Xeon(R) CPU           E5606  @ 2.13GHz
stepping        : 2
microcode       : 0x14
cpu MHz         : 1200.000
cache size      : 8192 KB
physical id     : 0
siblings        : 4
core id         : 0
cpu cores       : 4
apicid          : 0
initial apicid  : 0
fpu             : yes
fpu_exception   : yes
cpuid level     : 11
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm pcid dca sse4_1 sse4_2 popcnt aes lahf_lm tpr_shadow vnmi flexpriority ept vpid dtherm arat
bogomips        : 4266.41
clflush size    : 64
cache_alignment : 64
address sizes   : 40 bits physical, 48 bits virtual
power management:

TIP 2) Disable certain CPU flags (instruction sets)

As you can see with the above CPU options you can hide your exact type of processor and you could disable specific CPU flags (instruction sets) to the user’s virtual machine. The purpose is up to the user and one reason for example could be not offer “avx” (or “avx2”) to discourage crypto mining with the virtual machine. Or limit the SSE2/3/4/4.2/SSSE3 and other “multimedia” instruction sets to discourage video encoding and so on. Probably you would like to be used It’s up to you what to offer to the virtual machine user.
Here is the command to emulate the host CPU with all supported flags but disable “sse4.1” and “sse4.2”:
The syntax:

-cpu host,-sse4.1,-sse4.2

And the qemu command is:

qemu-system-x86_64 -enable-kvm \
-cpu host,-sse4.1,-sse4.2 \
-smp 2,maxcpus=8 \
-daemonize -vnc 192.168.0.10:1 \
-drive file=/mnt/storage/qemu/roofs/srv_virt.qcow2,index=0,cache=none,aio=threads,if=virtio \
-cdrom /mnt/storage/images/install-amd64-minimal-20140327.iso -boot d \
-net nic,model=virtio,macaddr=$(< /sys/class/net/macvtap0/address) \
-net tap,fd=3 3<>/dev/tap$(< /sys/class/net/macvtap0/ifindex) \
-balloon virtio -m 8192 \
-monitor telnet:127.0.0.1:5801,server,nowait -writeconfig /opt/qemu/config/srv_virt.qcow2.conf

So the virtual machine lacks the disabled flags:

flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon rep_good nopl pni pclmulqdq ssse3 cx16 pcid x2apic popcnt tsc_deadline_timer aes hypervisor lahf_lm tsc_adjust

TIP 3) Number of virtual processors in the virtual machine

The syntax

-smp 2,maxcpus=8

of the qemu command:

qemu-system-x86_64 -enable-kvm  -cpu host \
-smp 2,maxcpus=8 \
-daemonize -vnc 192.168.0.10:1 \
-drive file=/mnt/storage/qemu/roofs/srv_virt.qcow2,index=0,cache=none,aio=threads,if=virtio \
-cdrom /mnt/storage/images/install-amd64-minimal-20140327.iso -boot d \
-net nic,model=virtio,macaddr=$(< /sys/class/net/macvtap0/address) \
-net tap,fd=3 3<>/dev/tap$(< /sys/class/net/macvtap0/ifindex) \
-balloon virtio -m 8192 \
-monitor telnet:127.0.0.1:5801,server,nowait -writeconfig /opt/qemu/config/srv_virt.qcow2.conf

will start up the virtual machine with 2 processors and you can hot add a cpu up to 8 total in any time you want with the management console listening on 127.0.0.1:5801.

Howto do QEMU full virtualization with bridged networking

This howto rather continues the previous one “Howto do QEMU full virtualization with MacVTap networking” with the exception it will be showed how to use a classic setup of the networking – the use of bridge device. Because this setup requires a specific configuration for every Linux distro if we do not just add the bridge manually it is separated in this howto. For the clear and full howto, we would repeat the two first steps just to enable this howto to be independent of the original one mentioned above.
So use full virtualization under Linux you can use QEMU and no other library or manager like virt-manager. QEMU is simple enough and with a couple of parameters to it, you can start KVM virtual machines with near-native performance. To use KVM you must enable it in the BIOS of your server (or desktop machine).

Here are the main steps:

STEP 1) Enable KVM in the BIOS

  • For Intel machine you must find option Intel Virtualization Technology (or Intel VT-x) probably in BIOS menu of Chipset, Advanced CPU Configuration or other.
  • For AMD machine the virtualization cannot be disabled so it is enabled by default, but you can check for additional virtualization features to enable like Virtualization Extensions, Vanderpool and other.
  • Enable also additional features – Intel VT-d or AMD IOMMU, if they are available.

Reboot your machine and check if the KVM is supported:

srv@local ~$ cat /proc/cpuinfo |grep -E "vmx|svm"
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single pti intel_pt tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap xsaveopt dtherm ida arat pln pts
...

STEP 2) Install QEMU

Under CentOS 7 you can just install couple of packets – that’s all you need:

yum install -y qemu qemu-common qemu-img qemu-kvm-common qemu-system-x86 qemu-user bridge-utils

Or under Ubuntu

apt-get install qemu-kvm bridge-utils

STEP 3) Prepare the network 1 – the bridge device

Under CentOS 7 add the following configuration file

/etc/sysconfig/network-scripts/ifcfg-br0

with the content of

DEVICE=br0
TYPE=Bridge
BOOTPROTO=none
ONBOOT=yes
IPADDR0=192.168.0.1
PREFIX0=24
#GATEWAY0=192.168.0.1
NETMASK=255.255.255.0
IPV6_FAILURE_FATAL=no
NM_CONTROLLED=no
ZONE=public

If you want to use a real IP set to your virtual machine, you should set a real IP here and uncomment the GATEWAY0 with the real gateway IP. If real IP is used then you should include the main Internet network interface to the bridge by adding at the end of the configuration file /etc/sysconfig/network-scripts/ifcfg-eth0 (if eth0 is your network interface):

...
BRIDGE=br0

And restart the network

srv@local ~$ systemctl restart network

Under Ubuntu add to the file

/etc/network/interfaces

the following:

# Bridge
auto br0
iface br0 inet static
  address 192.168.0.10
  netmask 255.255.255.0
#  gateway 192.168.0.1
  bridge_ports none
  bridge_stp off
  bridge_fd 0
  bridge_maxwait 0

If you want to use real IP set to your virtual machine, you should set a real IP here and uncomment the GATEWAY0 with the real gateway IP and replace the “none” in the option “bridge_ports” with the name of your main Internet network interface. For example:

  ...
  bridge_ports eth0
  ...

And restart the network

srv@local ~$ /etc/init.d/networking restart

Or we can add the bridge device manually:

srv@local ~$ brctl addbr br0
srv@local ~$ ip link set dev br0 up
srv@local ~$ ip addr add 192.168.0.1/24 dev br0

If we use real IP we have to add the main Internet network interface to the bridge, so when you set up the network in our virtual machine with a real IP it will work with no more additional configurations, but if we use a local IPs like our setup here and we want to have Internet in our virtual machine we must enable masquerade and linux routing. You can do it with:

srv@local ~$ echo 1 > /proc/sys/net/ipv4/ip_forward
#NAT with firewalld
srv@local ~$ firewall-cmd --add-masquerade --permanent
#NAT with iptables
srv@local ~$ iptables -t nat -A POSTROUTING -o br0 -j MASQUERADE

Use either firewalld or iptables setup, depends on your system configuration, just check if firewalld is running with:

srv@local ~$ firewall-cmd --list-all

If you receive an error, saying command not found or firewalld is not running, you should use the “NAT with iptables”
So the network is ready!

STEP 4) Prepare the network 2 – the tun/tap for the virtual machine

After we have added a bridge device tun/tap device, which will be used for the QEMU virtual machine must be added:

srv@local ~$ ip tuntap add tap0 mode tap
srv@local ~$ brctl addif br0 tap0

STEP 5) Create a QEMU hard drive

Create a 100G file

srv@local ~$ cd /mnt/storage1/disks/
srv@local ~$ qemu-img create -f qcow2 vm_harddisk.qcow2 100G
Formatting 'vm_harddisk.qcow2', fmt=qcow2 size=107374182400 encryption=off cluster_size=65536 lazy_refcounts=off 

or you can enable encryption (but on every start of your virtual machine you must set the key through the qemu console to start the virtual machine):

srv@local ~$ qemu-img create -f qcow2 vm_harddisk_e.bin -o encryption 100G
Formatting 'vm_harddisk_e.bin', fmt=qcow2 size=107374182400 encryption=on cluster_size=65536 lazy_refcounts=off

STEP 6) Boot up the QEMU KVM virtual server

srv@local ~$ qemu-system-x86_64 -enable-kvm -cpu host -smp 4 -runas qemu -daemonize -vnc 127.0.0.1:1 \
-drive file=/mnt/storage1/disks/vm_harddisk.qcow2,index=0,cache=none,aio=threads,if=virtio \
-boot d -net nic,model=virtio,macaddr=00:00:00:00:00:01 -net tap,ifname=tap0 \
-balloon virtio -m 2048 -monitor telnet:127.0.0.1:5801,server,nowait

The command above will :

  • “-enable-kvm” – enable the KVM – full virtualization with near native performance
  • “-cpu host” – will expose all supported host CPU features (only supported in KVM mode)
  • “-smp 4” – sets 4 processors to the virtual machine
  • “-daemonize” – start the command in daemon mode
  • “-runas qemu” – run under user, you can run thwo whole virtual machine from a user created especially for it, no need to run it with root, even it is recommended to run it under unprivileged user
  • “-vnc 192.168.1.10:1” – start a VNC server on this IP:PORT = 192.168.1.10:5901, the IP must present on the server or you can use 0.0.0.0:1 for 0.0.0.0:5901, but in every situation limit the access by a firewall
  • “-drive file=/mnt/storage1/disks/vm_harddisk.qcow2,index=0,cache=none,aio=threads,if=virtio” – set the main hard drive of the system
  • “-boot d” – boot from the first hard drive
  • “-net nic,model=virtio,macaddr=00:00:00:00:00:01 -net tap,ifname=tap0” – set the network interface using the tap device created by STEP 3) and STEP 4)
  • “-balloon virtio” – use balloon driver to be able to hot add or hot remove RAM (newer version this option is depricated and it can be skipped)
  • “-m 2048” – set virtual RAM size to megs
  • “-monitor telnet:127.0.0.1:5801,server,nowait” – set the management console for the this virtual server, you can connect with:
    srv@local ~$ telnet 127.0.0.1 5801
    Trying 127.0.0.1...
    Connected to 127.0.0.1.
    Escape character is '^]'.
    QEMU 2.0.0 monitor - type 'help' for more information
    (qemu) 
    <Press "CTRL+]">
    telnet> Connection closed.
    

    When quitting the management console you must NOT exit the console with quite/exit or CTRL+d, becuause it will terminate the virtual server, you must disconnect from the console with “CTRL+]” and then quit the telnet shell. With the console you can hot add/remove CPU, RAM, network cards, pci devices, harddrives, start/stop/shutdown/reset the virtual machine and a lot more.

Boot the virtual machine from the hard drive given by “-drive” with network “-net” (couple of options), the RAM uses baloon memory and could be adjusted on-the-fly and sets the vncserver to listen for connection on port IP:port = 192.168.1.1:5901 (probably you’ll want to change this with a the real IP of your server, but be careful to set up a firewall rule for 5901 – the vnc port) and a management console listening on IP:port 127.0.0.1:5801.

* Boot the virtual server from a virtual CD/DVD

Probably the first time booting you might need to boot from an installation disk, this could be done by the following command:

srv@local ~$ qemu-system-x86_64 -enable-kvm -cpu host -smp 4 -runas qemu -daemonize -vnc 127.0.0.1:1 -cdrom /mnt/storage1/disks/isos/CentOS-7-x86_64-NetInstall-1708.iso -boot c -drive file=/mnt/storage1/disks/vm_harddisk.qcow2,index=0,cache=none,aio=threads,if=virtio -net nic,model=virtio,macaddr=00:00:00:00:00:01 -net tap,ifname=tap0 -balloon virtio -m 2048 -monitor telnet:127.0.0.1:5805,server,nowait

The changes:

  1. “-boot c” – First boot device is now CD/DVD. “c” is for CD, “d” is for disk
  2. “-cdrom /mnt/storage1/disks/isos/CentOS-7-x86_64-NetInstall-1708.iso” – added the installation disk to the virtual machine

A newer QEMU version may need adding “script=no,downscript=no” to the tap0 interface!

srv@local ~$ qemu-system-x86_64 -enable-kvm -cpu host -smp 4 -runas qemu -daemonize -vnc 127.0.0.1:1 -cdrom /mnt/storage1/disks/isos/CentOS-7-x86_64-NetInstall-1708.iso -boot c -drive file=/mnt/storage1/disks/vm_harddisk.qcow2,index=0,cache=none,aio=threads,if=virtio -net nic,model=virtio,macaddr=00:00:00:00:00:01 -net tap,ifname=tap0,script=no,downscript=no -m 2048 -monitor telnet:127.0.0.1:5805,server,nowait

Howto do QEMU full virtualization with MacVTap networking

To use full virtualization under linux you can use QEMU and no other library or manager like virt-manager. QEMU is simple enough and with couple of parameters to it you can start KVM virtual machines with near native performance. To use KVM you must enable it in the BIOS of your server (or desktop machine).

Here a several simple step to start a KVM virtual server:

STEP 1) Enable KVM in the BIOS

  • For Intel machine you must find option Intel Virtualization Technology (or Intel VT-x) probably in BIOS menu of Chipset, Advanced CPU Configuration or other.
  • For AMD machine the virtualization cannot be disabled so it is enabled by default, but you can check for additional virtualization features to enable like Virtualization Extensions, Vanderpool and other.
  • Enable also additional features – Intel VT-d or AMD IOMMU, if they are available.

Reboot your machine and check if the KVM is supported:

srv@local ~$ cat /proc/cpuinfo |grep -E "vmx|svm"
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single pti intel_pt tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap xsaveopt dtherm ida arat pln pts
...

STEP 2) Install QEMU

Under CentOS 7 you can just install couple of packets – that’s all you need:

yum install -y qemu qemu-common qemu-img qemu-kvm-common qemu-system-x86 qemu-user bridge-utils

Or under Ubuntu

apt-get install qemu-kvm bridge-utils

STEP 3) Prepare the network

srv@local ~$ ip link add link enp8s0f1 name macvtap0 type macvtap mode bridge
srv@local ~$ ip link set macvtap0 up

Here we create a macvtap0 device in bridge mode, these commands will create a tap device bridged to the network interface “enp8s0f1” (in our case, you must replace this device name with the device name you want to bridge your virtual machine network, probably the main interface of your server/desktop machine?). Only these two commands are needed, no other devices or network reload is needed.
The device will show in “ip addr”

7: macvtap0@enp8s0f1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 500
    link/ether 2e:51:7e:bb:44:ee brd ff:ff:ff:ff:ff:ff
    inet6 fe80::2c51:7eff:febb:44ee/64 scope link 
       valid_lft forever preferred_lft forever

This setup could expose the MAC address of the macvtap device to the router port connected

STEP 4) Create a QEMU hard drive

Create a 100G file

srv@local ~$ cd /mnt/storage1/disks/
srv@local ~$ qemu-img create -f qcow2 vm_harddisk.qcow2 100G
Formatting 'vm_harddisk.qcow2', fmt=qcow2 size=107374182400 encryption=off cluster_size=65536 lazy_refcounts=off 

or you can enable encryption (but on every start of your virtual machine you must set the key through the qemu console to start the virtual machine):

srv@local ~$ qemu-img create -f qcow2 vm_harddisk_e.bin -o encryption 100G
Formatting 'vm_harddisk_e.bin', fmt=qcow2 size=107374182400 encryption=on cluster_size=65536 lazy_refcounts=off

STEP 5) Boot up the QEMU KVM virtual server

srv@local ~$ qemu-system-x86_64 -enable-kvm -cpu host -smp 4 -runas qemu -daemonize -vnc 127.0.0.1:1 \
-drive file=/mnt/storage1/disks/vm_harddisk.qcow2,index=0,cache=none,aio=threads,if=virtio \
-boot d -net nic,model=virtio,macaddr=$(cat /sys/class/net/macvtap0/address) \
-net tap,fd=3 3<>/dev/tap$(cat /sys/class/net/macvtap0/ifindex) \
-balloon virtio -m 2048 -monitor telnet:127.0.0.1:5801,server,nowait

The command above will :

  • “-enable-kvm” – enable the KVM – full virtualization with near native performance
  • “-cpu host” – will expose all supported host CPU features (only supported in KVM mode)
  • “-smp 4” – sets 4 processors to the virtual machine
  • “-daemonize” – start the command in daemon mode
  • “-runas qemu” – run under user, you can run thwo whole virtual machine from a user created especially for it, no need to run it with root, even it is recommended to run it under unprivileged user
  • “-vnc 192.168.1.10:1” – start a VNC server on this IP:PORT = 192.168.1.10:5901, the IP must present on the server or you can use 0.0.0.0:1 for 0.0.0.0:5901, but in every situation limit the access by a firewall
  • “-drive file=/mnt/storage1/disks/vm_harddisk.qcow2,index=0,cache=none,aio=threads,if=virtio” – set the main hard drive of the system
  • “-boot d” – boot from the first hard drive
  • “-net nic,model=virtio,macaddr=$(cat /sys/class/net/macvtap0/address) -net tap,fd=3 3<>/dev/tap$(cat /sys/class/net/macvtap0/ifindex)” – set the network interface using the tap device created by macvtap0 device (STEP 3)
  • “-balloon virtio” – use balloon driver to be able to hot add or hot remove RAM
  • “-m 2048” – set virtual RAM size to megs
  • “-monitor telnet:127.0.0.1:5801,server,nowait” – set the management console for the this virtual server, you can connect with:
    srv@local ~$ telnet 127.0.0.1 5801
    Trying 127.0.0.1...
    Connected to 127.0.0.1.
    Escape character is '^]'.
    QEMU 2.0.0 monitor - type 'help' for more information
    (qemu) 
    <Press "CTRL+]">
    telnet> Connection closed.
    

    When quitting the management console you must NOT exit the console with quite/exit or CTRL+d, becuause it will terminate the virtual server, you must disconnect from the console with “CTRL+]” and then quit the telnet shell. With the console you can hot add/remove CPU, RAM, network cards, pci devices, harddrives, start/stop/shutdown/reset the virtual machine and a lot more.

Boot the virtual machine from the hard drive given by “-drive” with network “-net” (couple of options), the RAM uses baloon memory and could be adjusted on-the-fly and sets the vncserver to listen for connection on port IP:port = 192.168.1.1:5901 (probably you’ll want to change this with a the real IP of your server, but be careful to set up a firewall rule for 5901 – the vnc port) and a management console listening on IP:port 127.0.0.1:5801.

* Boot the virtual server from a virtual CD/DVD

Probably the first time booting you might need to boot from an installation disk, this could be done by the following command:

srv@local ~$ qemu-system-x86_64 -enable-kvm -cpu host -smp 4 -runas qemu -daemonize -vnc 127.0.0.1:1 -cdrom /mnt/storage1/disks/isos/CentOS-7-x86_64-NetInstall-1708.iso -boot c -drive file=/mnt/storage1/disks/vm_harddisk.qcow2,index=0,cache=none,aio=threads,if=virtio -net nic,model=virtio,macaddr=$(cat /sys/class/net/macvtap0/address) -net tap,fd=3 3<>/dev/tap$(cat /sys/class/net/macvtap0/ifindex) -balloon virtio -m 2048 -monitor telnet:127.0.0.1:5801,server,nowait

The changes:

  1. “-boot c” – First boot device is now CD/DVD. “c” is for CD, “d” is for disk
  2. “-cdrom /mnt/storage1/disks/isos/CentOS-7-x86_64-NetInstall-1708.iso” – added the installation disk to the virtual machine

Generate a new Groestlcoin address (wallet) and list accounts and addresses

The generation of a new Groestlcoin address is super simple, just use

groestlcoin-cli

and personally create your new address. DO NOT TRUST any online or website or any other Internet source to generate your Groestlcoin wallet address for you. DO IT YOURSELF with the official software from the official site!
And for those of you, which do not have “groestlcoin-cli” command or even do not know what is this, check out our howtos here:

  1. Install Ubuntu 16 LTS (comming soon)
  2. Running a Groestlcoin node (wallet cli) from source under Ubuntu 16 LTS

Go to your directory where is the groestlcoin-cli binary and execute the following command (the path and directories in the following examples are based on the above howto):

srv@local:~$ cd ~/groestlcoin-core/bin/
srv@local:~/groestlcoin-core/bin$ ./groestlcoin-cli getnewaddress mygroestlcoin
FeNFjh81VDJvZrdvi8EotKuJ8es8cCz7bZ
srv@local:~/groestlcoin-core/bin$ ./groestlcoin-cli encryptwallet "my secret pass"
wallet encrypted; Groestlcoin server stopping, restart to run with encrypted wallet. The keypool has been flushed and a new HD seed was generated (if you are using HD). You need to make a new backup.

The groestlcoind daemon was stopped and you need to start it again if you want to make transactions or to get your balance.
With Groestlcoin Core Wallet you can create an account, which could be a group of groestlcoin addresses (this is a groestlcoin address: “FeNFjh81VDJvZrdvi8EotKuJ8es8cCz7bZ”) or just use the default with no name of the account.
It is important to encrypt your wallet with a password, because if the wallet is unprotected with a password anyone could steal it! Then enter a password for your wallet protection is the second command above!

This sequence of numbers and alphabets

FeNFjh81VDJvZrdvi8EotKuJ8es8cCz7bZ

is your public Groestlcoin address, which could be used to receive Groestlcoins – the coins of the Groestlcoin network.

After generating the address two things must be done:

  1. Backup your Groestlcoin wallet address file (wallet.dat), which is placed in your home directory under “.groestlcoin”:
    srv@local:~/groestlcoin-core/bin$ ls -altr ~/.groestlcoin/
    srv@local:~$ ls -altr ~/.groestlcoin/
    total 476
    -rw------- 1 ubuntu ubuntu      0 Mar 27 21:41 .lock
    -rw------- 1 ubuntu ubuntu      0 Mar 27 21:41 db.log
    -rw------- 1 ubuntu ubuntu     37 Mar 27 21:41 banlist.dat
    drwx------ 3 ubuntu ubuntu   4096 Mar 27 22:18 blocks
    drwxr-xr-x 7 ubuntu ubuntu   4096 Mar 28 01:25 ..
    -rw------- 1 ubuntu ubuntu 145650 Mar 28 14:16 peers.dat
    -rw------- 1 ubuntu ubuntu     17 Mar 28 14:16 mempool.dat
    -rw------- 1 ubuntu ubuntu  16625 Mar 28 14:16 fee_estimates.dat
    -rw------- 1 ubuntu ubuntu  73728 Mar 28 14:16 wallet.dat
    -rw------- 1 ubuntu ubuntu      5 Mar 28 14:17 groestlcoin.pid
    -rw------- 1 ubuntu ubuntu     75 Mar 28 14:17 .cookie
    drwxrwxr-x 5 ubuntu ubuntu   4096 Mar 28 14:17 .
    drwx------ 2 ubuntu ubuntu   4096 Mar 28 14:18 chainstate
    drwx------ 2 ubuntu ubuntu   4096 Mar 28 14:18 database
    -rw------- 1 ubuntu ubuntu 206800 Mar 28 14:27 debug.log
    srv@local:~$ 
    

    The best practice is to backup all the files under “~/.groestlcoin/”, too!

  2. Backup your password for the private key!

Accounts

List all accounts in the wallet

srv@local:~/groestlcoin-core/bin$ ./groestlcoin-cli listaccounts
{
  "": 0.00000000,
  "mygroestlcoin": 0.00000000
}

List all Groestlcoin addresses in a given account:

srv@local:~/groestlcoin-core/bin$ ./groestlcoin-cli getaddressesbyaccount ""
[
  "FYM6aAQdmg6tziT4trPb777xNfPaaUnfqp", 
  "FamX8GYBuLFkLSAbyZ7M55vFW6AECoYKEV", 
  "Fp9PwAgfTqaF3aJ4zGGLjGKP7iEMdsrR3Z"
]
srv@local:~/groestlcoin-core/bin$ ./groestlcoin-cli getaddressesbyaccount "mygroestlcoin"
[
  "FeNFjh81VDJvZrdvi8EotKuJ8es8cCz7bZ", 
  "FrrnHESU8Utqk1ZjhQZjpWwc5cjKgHwCaS"
]

* It is absolutely necessary your crypto wallet addresses to have a password for security reasons and DO NOT FORGET IT you cannot recover the password therefore your access to the wallet! If you lose your password you lose ALL your funds in the address! It’s better to write it down somewhere on a safe physical place. You can print it on a sheet of paper and place it somewhere safe!

* All available commands with “groestlcoin-cli

groestlcoin-cli help
== Blockchain ==
getbestblockhash
getblock "hash" ( verbose )
getblockchaininfo
getblockcount
getblockhash index
getblockheader "hash" ( verbose )
getchaintips
getdifficulty
getmempoolancestors txid (verbose)
getmempooldescendants txid (verbose)
getmempoolentry txid
getmempoolinfo
getrawmempool ( verbose )
gettxout "txid" n ( includemempool )
gettxoutproof ["txid",...] ( blockhash )
gettxoutsetinfo
preciousblock "hash"
verifychain ( checklevel numblocks )
verifytxoutproof "proof"

== Control ==
getinfo
getmemoryinfo
help ( "command" )
stop

== Generating ==
generate numblocks ( maxtries )
generatetoaddress numblocks address (maxtries)

== Mining ==
getblocktemplate ( TemplateRequest )
getmininginfo
getnetworkhashps ( blocks height )
prioritisetransaction <txid> <priority delta> <fee delta>
submitblock "hexdata" ( "jsonparametersobject" )

== Network ==
addnode "node" "add|remove|onetry"
clearbanned
disconnectnode "node" 
getaddednodeinfo ( "node" )
getconnectioncount
getnettotals
getnetworkinfo
getpeerinfo
listbanned
ping
setban "ip(/netmask)" "add|remove" (bantime) (absolute)
setnetworkactive true|false

== Rawtransactions ==
createrawtransaction [{"txid":"id","vout":n},...] {"address":amount,"data":"hex",...} ( locktime )
decoderawtransaction "hexstring"
decodescript "hex"
fundrawtransaction "hexstring" ( options )
getrawtransaction "txid" ( verbose )
sendrawtransaction "hexstring" ( allowhighfees )
signrawtransaction "hexstring" ( [{"txid":"id","vout":n,"scriptPubKey":"hex","redeemScript":"hex"},...] ["privatekey1",...] sighashtype )

== Util ==
createmultisig nrequired ["key",...]
estimatefee nblocks
estimatepriority nblocks
estimatesmartfee nblocks
estimatesmartpriority nblocks
signmessagewithprivkey "privkey" "message"
validateaddress "groestlcoinaddress"
verifymessage "groestlcoinaddress" "signature" "message"

== Wallet ==
abandontransaction "txid"
addmultisigaddress nrequired ["key",...] ( "account" )
addwitnessaddress "address"
backupwallet "destination"
dumpprivkey "groestlcoinaddress"
dumpwallet "filename"
getaccount "groestlcoinaddress"
getaccountaddress "account"
getaddressesbyaccount "account"
getbalance ( "account" minconf includeWatchonly )
getnewaddress ( "account" )
getrawchangeaddress
getreceivedbyaccount "account" ( minconf )
getreceivedbyaddress "groestlcoinaddress" ( minconf )
gettransaction "txid" ( includeWatchonly )
getunconfirmedbalance
getwalletinfo
importaddress "address" ( "label" rescan p2sh )
importmulti '[<json import requests>]' '<json options>' 
importprivkey "groestlcoinprivkey" ( "label" rescan )
importprunedfunds
importpubkey "pubkey" ( "label" rescan )
importwallet "filename"
keypoolrefill ( newsize )
listaccounts ( minconf includeWatchonly)
listaddressgroupings
listlockunspent
listreceivedbyaccount ( minconf includeempty includeWatchonly)
listreceivedbyaddress ( minconf includeempty includeWatchonly)
listsinceblock ( "blockhash" target-confirmations includeWatchonly)
listtransactions ( "account" count from includeWatchonly)
listunspent ( minconf maxconf  ["address",...] )
lockunspent unlock ([{"txid":"txid","vout":n},...])
move "fromaccount" "toaccount" amount ( minconf "comment" )
removeprunedfunds "txid"
sendfrom "fromaccount" "togroestlcoinaddress" amount ( minconf "comment" "comment-to" )
sendmany "fromaccount" {"address":amount,...} ( minconf "comment" ["address",...] )
sendtoaddress "groestlcoinaddress" amount ( "comment" "comment-to" subtractfeefromamount )
setaccount "groestlcoinaddress" "account"
settxfee amount
signmessage "groestlcoinaddress" "message"
walletlock
walletpassphrase "passphrase" timeout
walletpassphrasechange "oldpassphrase" "newpassphrase"

Bacula – show configuration, status and information with bconsole tool

The following list of commands could be used to get a brief or detailed view of a Bacula backup server from the management utility

bconsole

. These commands are extremely useful for getting information on the backup process and policy and Bacula troubleshooting – could be used for fast debugging of an error, problems or misconfiguration.

the following commands give information for

  • Jobs

    list jobtotals Lists stats for all jobs, it also shows all jobs’ names
    show jobs Lists all jobs with their full configurations – show all jobs and for each job show detail explanation of what represent. The detail output includes full configuration of a job including client, catalog, fileset,schedule,pool,message. This will show all relationships between the different components of bacula system, how and which clients,storages,pools,schedules,filesets relate to. You’ll a thoroughly view of how let’s say a server is made the backup.
    show job=[job_name] shows full configuration for a job, the name could be taken by the two above commands
    list jobs Lists all jobs’ status – ID, StartTime, Type (backup?), Level (Full, increment, differential?), Files and bytes processed and the status of the job (Terminated normally, Running,Fatal error and so on)
    list files jobid=[ID] which files were included in the backup? Lists all paths and files included in the backup, not a configuration set but real physical path and filenames.
    status dir if you want to find all scheduled jobs for the next day (or more if you add a parameter). This will show the status of the director process.
  • Storages

    status storage list storage devices and their status – you can see the physical path on the filesystem where the Devices will put backup files
  • Clients

    show client show all clients’ names and backup policy
    status client=[client_name] show client status and what is doing, check the network connection between the director and the client, last terminated jobs and their status.
  • Filesets

    show fileset show all filesets, a fileset is a set with files and directories to include or exclude from a backup.
  • Schedule

    show schedule shows all registered schedulers and details for each one (Run Level=Full,Differential,Incremental), months, days, minutes.
    show schedule=[scheduler_name] shows details for a schedule with name scheduler_name (Run Level=Full,Differential,Incremental), months, days, minutes. It’s like the schedule backup plan of a server
  • Director

    message shows the last message of the backup process. If empty all logs of the backup process could be found in “/var/log/bacula/bacula.log”
    reload the director will re-read its all configuration files. Should be used when adding configuration files.

And here is the example output of the above commands with a little bit of explanation:

  • Jobs

    1) Get the stats and the jobs’ names, the names could be used in many other commands!

    srvbkp@local # bconsole 
    Connecting to Director localhost:9101
    1000 OK: 1 srvbkp-dir Version: 7.0.5 (28 July 2014)
    Enter a period to cancel a command.
    *list jobtotals
    Automatically selected Catalog: allbackup
    Using Catalog "allbackup"
    +------+-----------+-------------------+--------------------------------+
    | Jobs | Files     | Bytes             | Job                            |
    +------+-----------+-------------------+--------------------------------+
    |   90 |        90 |   123,665,584,337 | BackupCatalog                  |
    |    5 |         5 |   281,593,737,603 | RestoreFiles                   |
    |   13 | 1,232,316 |   118,480,634,434 | srv1-media                     |
    |   32 |        12 |             3,674 | srv1-dns                       |
    |   32 |        10 |             3,064 | srv2-dns                       |
    |   32 |        10 |             3,064 | srv3-dns                       |
    |   32 |        10 |             3,086 | srv4-dns                       |
    |   32 |        10 |             3,084 | srv5-dns                       |
    |   26 | 3,837,536 |   587,812,183,466 | srv1-images                    |
    +------+-----------+-------------------+--------------------------------+
    +-------+------------+-------------------+
    | Jobs  | Files      | Bytes             |
    +-------+------------+-------------------+
    | 1,474 | 14,925,321 | 5,475,024,028,957 |
    +-------+------------+-------------------+
    *
    

    2) Get all configurations for all jobs, here are included only two for clarity. All needed information for taking a backup of a server. You can see the files, which will be included (or excluded), where the backup will be stored when will happen in time, and how many different types of backup will be done – full, incremental, and differential. And this whole information is for all clients (servers).

    *show jobs
    Job: name=srv1-dns JobType=66 level= Priority=10 Enabled=1
         MaxJobs=1 Resched=0 Times=0 Interval=1,800 Spool=0 WritePartAfterJob=1
         Accurate=0
      --> Client: name=srv1-dns address=192.168.0.100 FDport=9102 MaxJobs=1
          JobRetention=1 month  FileRetention=1 month  AutoPrune=1
      --> Catalog: name=allbackup address=localhost DBport=0 db_name=bacula
          db_driver=*None* db_user=bacula MutliDBConn=0
      --> FileSet: name=bind
          O MZ6
          N
          I /var/lib/named
          N
      --> Schedule: name=bind
      --> Run Level=Full
          hour=20 
          mday=0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 
          month=0 1 2 3 4 5 6 7 8 9 10 11 
          wday=0 
          wom=0 
          woy=0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 
          mins=0
      --> Run Level=Differential
          hour=20 
          mday=0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 
          month=0 1 2 3 4 5 6 7 8 9 10 11 
          wday=0 
          wom=1 2 3 4 
          woy=0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 
          mins=0
      --> Run Level=Incremental
          hour=20 
          mday=0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 
          month=0 1 2 3 4 5 6 7 8 9 10 11 
          wday=1 2 3 4 5 6 
          wom=0 1 2 3 4 5 
          woy=0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 
          mins=0
      --> Storage: name=bind address=192.168.0.10 SDport=9103 MaxJobs=10
          DeviceName=bind MediaType=File StorageId=17
      --> Pool: name=Default PoolType=Backup
          use_cat=1 use_once=0 cat_files=1
          max_vols=100 auto_prune=1 VolRetention=1 year 
          VolUse=0 secs recycle=1 LabelFormat=*None*
          CleaningPrefix=*None* LabelType=0
          RecyleOldest=0 PurgeOldest=0 ActionOnPurge=0
          MaxVolJobs=0 MaxVolFiles=0 MaxVolBytes=53687091200
          MigTime=0 secs MigHiBytes=0 MigLoBytes=0
          JobRetention=0 secs FileRetention=0 secs
      --> Pool: name=bind-full PoolType=Backup
          use_cat=1 use_once=1 cat_files=1
          max_vols=0 auto_prune=1 VolRetention=2 months 
          VolUse=0 secs recycle=1 LabelFormat=bind-full
          CleaningPrefix=*None* LabelType=0
          RecyleOldest=0 PurgeOldest=0 ActionOnPurge=0
          MaxVolJobs=0 MaxVolFiles=0 MaxVolBytes=0
          MigTime=0 secs MigHiBytes=0 MigLoBytes=0
          JobRetention=0 secs FileRetention=0 secs
      --> Pool: name=bind-incr PoolType=Backup
          use_cat=1 use_once=0 cat_files=1
          max_vols=0 auto_prune=1 VolRetention=7 days 
          VolUse=23 hours  recycle=1 LabelFormat=bind-incr
          CleaningPrefix=*None* LabelType=0
          RecyleOldest=0 PurgeOldest=0 ActionOnPurge=0
          MaxVolJobs=0 MaxVolFiles=0 MaxVolBytes=0
          MigTime=0 secs MigHiBytes=0 MigLoBytes=0
          JobRetention=0 secs FileRetention=0 secs
      --> Pool: name=bind-diff PoolType=Backup
          use_cat=1 use_once=0 cat_files=1
          max_vols=0 auto_prune=1 VolRetention=1 month 1 day 
          VolUse=0 secs recycle=1 LabelFormat=bind-diff
          CleaningPrefix=*None* LabelType=0
          RecyleOldest=0 PurgeOldest=0 ActionOnPurge=0
          MaxVolJobs=0 MaxVolFiles=0 MaxVolBytes=0
          MigTime=0 secs MigHiBytes=0 MigLoBytes=0
          JobRetention=0 secs FileRetention=0 secs
      --> Messages: name=Standard
          mailcmd=/usr/sbin/bsmtp -h localhost -f "(Bacula) <%r>" -s "Bacula: %t %e of %c %l" %r
          opcmd=/usr/sbin/bsmtp -h localhost -f "(Bacula) <%r>" -s "Bacula: Intervention needed for %j" %r
    Job: name=srv2-dns JobType=66 level= Priority=10 Enabled=1
         MaxJobs=1 Resched=0 Times=0 Interval=1,800 Spool=0 WritePartAfterJob=1
         Accurate=0
      --> Client: name=srv2-dns address=192.168.0.101 FDport=9102 MaxJobs=1
          JobRetention=1 month  FileRetention=1 month  AutoPrune=1
      --> Catalog: name=allbackup address=localhost DBport=0 db_name=bacula
          db_driver=*None* db_user=bacula MutliDBConn=0
      --> FileSet: name=bind
          O MZ6
          N
          I /var/lib/named
          N
      --> Schedule: name=bind
      --> Run Level=Full
          hour=20 
          mday=0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 
          month=0 1 2 3 4 5 6 7 8 9 10 11 
          wday=0 
          wom=0 
          woy=0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 
          mins=0
      --> Run Level=Differential
          hour=20 
          mday=0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 
          month=0 1 2 3 4 5 6 7 8 9 10 11 
          wday=0 
          wom=1 2 3 4 
          woy=0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 
          mins=0
      --> Run Level=Incremental
          hour=20 
          mday=0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 
          month=0 1 2 3 4 5 6 7 8 9 10 11 
          wday=1 2 3 4 5 6 
          wom=0 1 2 3 4 5 
          woy=0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 
          mins=0
      --> Storage: name=bind address=192.168.0.10 SDport=9103 MaxJobs=10
          DeviceName=bind MediaType=File StorageId=17
      --> Pool: name=Default PoolType=Backup
          use_cat=1 use_once=0 cat_files=1
          max_vols=100 auto_prune=1 VolRetention=1 year 
          VolUse=0 secs recycle=1 LabelFormat=*None*
          CleaningPrefix=*None* LabelType=0
          RecyleOldest=0 PurgeOldest=0 ActionOnPurge=0
          MaxVolJobs=0 MaxVolFiles=0 MaxVolBytes=53687091200
          MigTime=0 secs MigHiBytes=0 MigLoBytes=0
          JobRetention=0 secs FileRetention=0 secs
      --> Pool: name=bind-full PoolType=Backup
          use_cat=1 use_once=1 cat_files=1
          max_vols=0 auto_prune=1 VolRetention=2 months 
          VolUse=0 secs recycle=1 LabelFormat=bind-full
          CleaningPrefix=*None* LabelType=0
          RecyleOldest=0 PurgeOldest=0 ActionOnPurge=0
          MaxVolJobs=0 MaxVolFiles=0 MaxVolBytes=0
          MigTime=0 secs MigHiBytes=0 MigLoBytes=0
          JobRetention=0 secs FileRetention=0 secs
      --> Pool: name=bind-incr PoolType=Backup
          use_cat=1 use_once=0 cat_files=1
          max_vols=0 auto_prune=1 VolRetention=7 days 
          VolUse=23 hours  recycle=1 LabelFormat=bind-incr
          CleaningPrefix=*None* LabelType=0
          RecyleOldest=0 PurgeOldest=0 ActionOnPurge=0
          MaxVolJobs=0 MaxVolFiles=0 MaxVolBytes=0
          MigTime=0 secs MigHiBytes=0 MigLoBytes=0
          JobRetention=0 secs FileRetention=0 secs
      --> Pool: name=bind-diff PoolType=Backup
          use_cat=1 use_once=0 cat_files=1
          max_vols=0 auto_prune=1 VolRetention=1 month 1 day 
          VolUse=0 secs recycle=1 LabelFormat=bind-diff
          CleaningPrefix=*None* LabelType=0
          RecyleOldest=0 PurgeOldest=0 ActionOnPurge=0
          MaxVolJobs=0 MaxVolFiles=0 MaxVolBytes=0
          MigTime=0 secs MigHiBytes=0 MigLoBytes=0
          JobRetention=0 secs FileRetention=0 secs
      --> Messages: name=Standard
          mailcmd=/usr/sbin/bsmtp -h localhost -f "(Bacula) <%r>" -s "Bacula: %t %e of %c %l" %r
          opcmd=/usr/sbin/bsmtp -h localhost -f "(Bacula) <%r>" -s "Bacula: Intervention needed for %j" %r
    

    3) You can get the full configuration information of a job (the information is the same as above, but for a given job name, which could be taken from the first command above, it is not necessary to output all the configurations every time):

    srvbkp@local # bconsole 
    Connecting to Director localhost:9101
    1000 OK: 1 srvbkp-dir Version: 7.0.5 (28 July 2014)
    Enter a period to cancel a command.
    *show jobs=srv2-dns
    Job: name=srv2-dns JobType=66 level= Priority=10 Enabled=1
         MaxJobs=1 Resched=0 Times=0 Interval=1,800 Spool=0 WritePartAfterJob=1
         Accurate=0
      --> Client: name=srv2-dns address=192.168.0.101 FDport=9102 MaxJobs=1
          JobRetention=1 month  FileRetention=1 month  AutoPrune=1
      --> Catalog: name=allbackup address=localhost DBport=0 db_name=bacula
          db_driver=*None* db_user=bacula MutliDBConn=0
      --> FileSet: name=bind
          O MZ6
          N
          I /var/lib/named
          N
      --> Schedule: name=bind
      --> Run Level=Full
          hour=20 
          mday=0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 
          month=0 1 2 3 4 5 6 7 8 9 10 11 
          wday=0 
          wom=0 
          woy=0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 
          mins=0
      --> Run Level=Differential
          hour=20 
          mday=0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 
          month=0 1 2 3 4 5 6 7 8 9 10 11 
          wday=0 
          wom=1 2 3 4 
          woy=0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 
          mins=0
      --> Run Level=Incremental
          hour=20 
          mday=0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 
          month=0 1 2 3 4 5 6 7 8 9 10 11 
          wday=1 2 3 4 5 6 
          wom=0 1 2 3 4 5 
          woy=0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 
          mins=0
      --> Storage: name=bind address=192.168.0.10 SDport=9103 MaxJobs=10
          DeviceName=bind MediaType=File StorageId=17
      --> Pool: name=Default PoolType=Backup
          use_cat=1 use_once=0 cat_files=1
          max_vols=100 auto_prune=1 VolRetention=1 year 
          VolUse=0 secs recycle=1 LabelFormat=*None*
          CleaningPrefix=*None* LabelType=0
          RecyleOldest=0 PurgeOldest=0 ActionOnPurge=0
          MaxVolJobs=0 MaxVolFiles=0 MaxVolBytes=53687091200
          MigTime=0 secs MigHiBytes=0 MigLoBytes=0
          JobRetention=0 secs FileRetention=0 secs
      --> Pool: name=bind-full PoolType=Backup
          use_cat=1 use_once=1 cat_files=1
          max_vols=0 auto_prune=1 VolRetention=2 months 
          VolUse=0 secs recycle=1 LabelFormat=bind-full
          CleaningPrefix=*None* LabelType=0
          RecyleOldest=0 PurgeOldest=0 ActionOnPurge=0
          MaxVolJobs=0 MaxVolFiles=0 MaxVolBytes=0
          MigTime=0 secs MigHiBytes=0 MigLoBytes=0
          JobRetention=0 secs FileRetention=0 secs
      --> Pool: name=bind-incr PoolType=Backup
          use_cat=1 use_once=0 cat_files=1
          max_vols=0 auto_prune=1 VolRetention=7 days 
          VolUse=23 hours  recycle=1 LabelFormat=bind-incr
          CleaningPrefix=*None* LabelType=0
          RecyleOldest=0 PurgeOldest=0 ActionOnPurge=0
          MaxVolJobs=0 MaxVolFiles=0 MaxVolBytes=0
          MigTime=0 secs MigHiBytes=0 MigLoBytes=0
          JobRetention=0 secs FileRetention=0 secs
      --> Pool: name=bind-diff PoolType=Backup
          use_cat=1 use_once=0 cat_files=1
          max_vols=0 auto_prune=1 VolRetention=1 month 1 day 
          VolUse=0 secs recycle=1 LabelFormat=bind-diff
          CleaningPrefix=*None* LabelType=0
          RecyleOldest=0 PurgeOldest=0 ActionOnPurge=0
          MaxVolJobs=0 MaxVolFiles=0 MaxVolBytes=0
          MigTime=0 secs MigHiBytes=0 MigLoBytes=0
          JobRetention=0 secs FileRetention=0 secs
      --> Messages: name=Standard
          mailcmd=/usr/sbin/bsmtp -h localhost -f "(Bacula) <%r>" -s "Bacula: %t %e of %c %l" %r
          opcmd=/usr/sbin/bsmtp -h localhost -f "(Bacula) <%r>" -s "Bacula: Intervention needed for %j" %r
    

    4) Lists all jobs’ status – ID, StartTime, Type (backup?), Level (Full, increment, differential?), Files and bytes processed and the status of the job (Terminated normally, Running,Fatal error and so on). Found out if you have backups of a server or the backup process failed!

    srvbkp@local # bconsole 
    Connecting to Director localhost:9101
    1000 OK: 1 srvbkp-dir Version: 7.0.5 (28 July 2014)
    Enter a period to cancel a command.
    *list jobs
    +-------+--------------------------------+---------------------+------+-------+-----------+-----------------+-----------+
    | JobId | Name                           | StartTime           | Type | Level | JobFiles  | JobBytes        | JobStatus |
    +-------+--------------------------------+---------------------+------+-------+-----------+-----------------+-----------+
    |   128 | srv1-test                      | 2016-12-04 23:05:00 | B    | F     |    17,506 |      52,116,400 | T         |
    |   178 | srv1-test                      | 2016-12-09 23:05:01 | B    | I     |        13 |           1,509 | T         |
    |   188 | srv1-test                      | 2016-12-10 23:05:01 | B    | I     |        13 |           1,509 | T         |
    .........................................................................................................................
    | 8,927 | srv2-images                    | 2018-03-04 20:00:00 | B    | F     |         0 |               0 | f         |
    | 8,928 | srv1-media                     | 2018-03-04 20:00:00 | B    | F     |         3 |             978 | T         |
    | 8,930 | srv1-dns                       | 2018-03-04 20:00:01 | B    | F     |         6 |           1,843 | T         |
    | 8,932 | srv2-dns                       | 2018-03-04 20:00:01 | B    | F     |         6 |           1,837 | T         |
    | 8,931 | srv3-dns                       | 2018-03-04 20:00:03 | B    | F     |         5 |           1,542 | T         |
    | 8,933 | srv4-dns                       | 2018-03-04 20:00:04 | B    | F     |         4 |           1,258 | T         |
    | 8,934 | srv5-dns                       | 2018-03-04 20:00:04 | B    | F     |         4 |           1,258 | T         |
    +-------+--------------------------------+---------------------+------+-------+-----------+-----------------+-----------+
    

    5) Which files were included in a backup job? Lists all paths and files included in the backup job (the ID is from the above command):

    *list files jobid=8934
    +----------+
    | Filename |
    +----------+
    | /var/lib/named/ |
    | /var/lib/named/root.cache |
    | /var/lib/named/sec |
    | /var/lib/named/sec/example.com.db |
    | /var/lib/named/sec/example2.net.db |
    | /var/lib/named/pri |
    +----------+
    +-------+----------+---------------------+------+-------+----------+----------+-----------+
    | JobId | Name     | StartTime           | Type | Level | JobFiles | JobBytes | JobStatus |
    +-------+----------+---------------------+------+-------+----------+----------+-----------+
    | 8,934 | srv5-dns | 2018-03-04 20:00:20 | B    | F     |        6 |    1,851 | T         |
    +-------+----------+---------------------+------+-------+----------+----------+-----------+
    

    6) Get the scheduled jobs. Which jobs will be executed and when:

    *status dir
    Scheduled Jobs:
    Level          Type     Pri  Scheduled          Job Name           Volume
    ===================================================================================
    Incremental    Backup    10  06-Mar-18 20:00    srv1-dns           *unknown*
    Incremental    Backup    10  06-Mar-18 20:00    srv2-dns           *unknown*
    Incremental    Backup    10  06-Mar-18 20:00    srv3-dns           *unknown*
    Incremental    Backup    10  06-Mar-18 20:00    srv4-dns           *unknown*
    Incremental    Backup    10  06-Mar-18 20:00    srv5-dns           *unknown*
    ...................................................................................
    Incremental    Backup    10  06-Mar-18 23:05    srv1-media         *unknown*
    Full           Backup    10  06-Mar-18 23:05    srv1-images        *unknown*
    ====
    Running Jobs:
    Console connected at 06-Mar-18 13:36
    No Jobs running.
    ====
    Terminated Jobs:
     JobId  Level    Files      Bytes   Status   Finished        Name
    ====================================================================
      9006  Incr        472    296.8 M  OK       05-Mar-18 23:05 srv1-dns
      9007  Incr     10,547    194.8 M  Error    05-Mar-18 23:05 srv2-dns
      9002  Incr         37    133.0 M  OK       05-Mar-18 23:05 srv3-dns
      8995  Incr         57    372.2 M  OK       05-Mar-18 23:06 srv4-dns
      9000  Incr        391    1.195 G  OK       05-Mar-18 23:07 srv5-dns
      9008  Full        832    7.139 G  OK       05-Mar-18 23:49 srv1-images
      9009  Full          1    1.493 G  OK       05-Mar-18 23:50 srv1-media
      9011  Full    315,027    121.6 G  OK       06-Mar-18 03:44 srv2-images
      9012  Full    314,804    93.85 G  OK       06-Mar-18 04:18 srv2-media
    ====
    *
    
  • Storages

  • Where are the backup files on your system? Trace the bacula media devices to the real path of your backup files.

    *status storage
    Automatically selected Storage: bind
    Connecting to Storage daemon bind at 192.168.0.10:9103
    srvbkp-sd Version: 7.0.5 (28 July 2014) x86_64-pc-linux-gnu ubuntu 16.04
    Daemon started 06-Nov-17 17:25. Jobs: run=5025, running=0.
     Heap: heap=135,168 smbytes=2,231,640 max_bytes=5,264,027 bufs=439 max_bufs=2,152
     Sizes: boffset_t=8 size_t=8 int32_t=4 int64_t=8 mode=0,0
    Running Jobs:
    No Jobs running.
    ====
    Jobs waiting to reserve a drive:
    ====
    Terminated Jobs:
     JobId  Level    Files      Bytes   Status   Finished        Name
    ===================================================================
      9071  Incr          0         0   OK       06-Mar-18 20:00 srv1-dns
      9074  Incr          0         0   OK       06-Mar-18 20:00 srv2-dns
      9073  Incr          0         0   OK       06-Mar-18 20:00 srv3-dns
      9075  Incr          5    2.043 K  OK       06-Mar-18 20:00 srv4-dns
      9078  Incr          5    2.042 K  OK       06-Mar-18 20:00 srv5-dns
      9077  Incr          0         0   OK       06-Mar-18 20:00 srv1-media
      9079  Incr          0         0   OK       06-Mar-18 20:00 srv1-images
      9076  Incr          0         0   OK       06-Mar-18 20:00 srv2-images
      9057  Full          0         0   Other    06-Mar-18 20:31 srv2-media
    ====
    Device status:
    Device "localstorage" (/mnt/storage1/bacula-storage/local) is not open.
    ==
    Device "media" (/mnt/storage1/bacula-storage/media) is not open.
    ==
    Device "bind" (/mnt/storage1/bacula-storage/bind) is not open.
    ==
    Device "image" (/mnt/storage1/bacula-storage/image) is not open.
    ==
    ====
    Used Volume status:
    ====
    Attr spooling: 0 active jobs, 34,753 bytes; 120 total jobs, 34,753 max bytes.
    ====
    *
    
  • Clients

    1) Show all client names in the bacula system, this could be useful to link a client name with a server and then to use the name in the next command (below in 2):

    *show client
    Client: name=srvbkp-fd address=192.168.0.5 FDport=9102 MaxJobs=1
          JobRetention=3 months  FileRetention=2 months  AutoPrune=1
      --> Catalog: name=allbackup address=localhost DBport=0 db_name=bacula
          db_driver=*None* db_user=bacula MutliDBConn=0
    Client: name=srv1-dns address=192.168.0.100 FDport=9102 MaxJobs=1
          JobRetention=1 month  FileRetention=1 month  AutoPrune=1
      --> Catalog: name=allbackup address=localhost DBport=0 db_name=bacula
          db_driver=*None* db_user=bacula MutliDBConn=0
    Client: name=srv2-dns address=192.168.0.101 FDport=9102 MaxJobs=1
          JobRetention=1 month  FileRetention=1 month  AutoPrune=1
      --> Catalog: name=allbackup address=localhost DBport=0 db_name=bacula
          db_driver=*None* db_user=bacula MutliDBConn=0
    Client: name=srv3-dns address=192.168.0.103 FDport=9102 MaxJobs=1
          JobRetention=1 month  FileRetention=1 month  AutoPrune=1
      --> Catalog: name=allbackup address=localhost DBport=0 db_name=bacula
          db_driver=*None* db_user=bacula MutliDBConn=0
    Client: name=srv4-dns address=192.168.0.104 FDport=9102 MaxJobs=1
          JobRetention=1 month  FileRetention=1 month  AutoPrune=1
      --> Catalog: name=allbackup address=localhost DBport=0 db_name=bacula
          db_driver=*None* db_user=bacula MutliDBConn=0
    Client: name=srv5-dns address=192.168.0.105 FDport=9102 MaxJobs=1
          JobRetention=1 month  FileRetention=1 month  AutoPrune=1
      --> Catalog: name=allbackup address=localhost DBport=0 db_name=bacula
          db_driver=*None* db_user=bacula MutliDBConn=0
    Client: name=srv1-media address=192.168.0.106 FDport=9102 MaxJobs=1
          JobRetention=1 month  FileRetention=1 month  AutoPrune=1
      --> Catalog: name=allbackup address=localhost DBport=0 db_name=bacula
          db_driver=*None* db_user=bacula MutliDBConn=0
    Client: name=srv1-images address=192.168.0.107 FDport=9102 MaxJobs=1
          JobRetention=1 month  FileRetention=1 month  AutoPrune=1
      --> Catalog: name=allbackup address=localhost DBport=0 db_name=bacula
          db_driver=*None* db_user=bacula MutliDBConn=0
    *
    

    2) Show status of a client. We can use this command to check what is going on with the client at the moment of issuing the command, the last terminated backup jobs and their status. In addition we can check the connection between the Director daemon and the client daemon, because the Director connects at the moment we issue the command, so it is useful for debugging purposes:

    *status client=srv1-dns
    Connecting to Client srv1-dns at 192.168.0.100:9102
    
    srv1-dns-fd Version: 7.0.5 (28 July 2014)  x86_64-pc-linux-gnu ubuntu 16.04
    Daemon started 23-Feb-18 00:43. Jobs: run=8 running=0.
     Heap: heap=98,304 smbytes=188,701 max_bytes=571,361 bufs=64 max_bufs=97
     Sizes: boffset_t=8 size_t=8 debug=0 trace=0 mode=0,0 bwlimit=0kB/s
     Plugin: bpipe-fd.so 
    
    Running Jobs:
    Director connected at: 06-Mar-18 22:51
    No Jobs running.
    ====
    
    Terminated Jobs:
     JobId  Level    Files      Bytes   Status   Finished        Name 
    ===================================================================
      1832  Full          4    1.333 K  OK       01-Mar-18 23:48 srv1-dns
      1836  Incr          0         0   OK       02-Mar-18 00:01 srv1-dns
      1864  Incr          0         0   OK       02-Mar-18 20:30 srv1-dns
      1907  Incr          0         0   OK       03-Mar-18 20:00 srv1-dns
      1950  Full          4    1.333 K  OK       04-Mar-18 20:01 srv1-dns
      1994  Incr          0         0   OK       05-Mar-18 20:00 srv1-dns
      1037  Incr          0         0   OK       06-Mar-18 20:00 srv1-dns
    ====
    *
    
  • Filesets

    Which files will be included or excluded from the backup process. The lines starting with “I” mean “include”, the lines starting with “E” mean exclude.

     *show fileset
    FileSet: name=Full Set
     O M
     N
     I /usr/sbin
     N
     E /var/lib/bacula
     E /proc
     E /tmp
     E /sys
     E /.journal
     E /.fsck
     N
    FileSet: name=Catalog
     O M
     N
     I /var/lib/bacula/bacula.sql
     N
    FileSet: name=images
     O MfZ6
     N
     I /
     N
     E /proc
     E /tmp
     E /run
     E /dev
     E /sys
     N
    FileSet: name=bind
     O MZ6
     N
     I /var/lib/named
     N
    FileSet: name=media
     O MfZ6
     N
     I /
     N
     E /proc
     E /tmp
     E /run
     E /dev
     E /sys
     N
    
  • Schedule

    1) The all timeline plans for taking backups

    *show schedule
    Schedule: name=WeeklyCycle
      --> Run Level=Full
          hour=23 
          mday=0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 
          month=0 1 2 3 4 5 6 7 8 9 10 11 
          wday=0 
          wom=0 
          woy=0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 
          mins=5
      --> Run Level=Differential
          hour=23 
          mday=0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 
          month=0 1 2 3 4 5 6 7 8 9 10 11 
          wday=0 
          wom=1 2 3 4 
          woy=0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 
          mins=5
      --> Run Level=Incremental
          hour=23 
          mday=0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 
          month=0 1 2 3 4 5 6 7 8 9 10 11 
          wday=1 2 3 4 5 6 
          wom=0 1 2 3 4 5 
          woy=0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 
          mins=5
    Schedule: name=WeeklyCycleAfterBackup
      --> Run Level=Full
          hour=23 
          mday=0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 
          month=0 1 2 3 4 5 6 7 8 9 10 11 
          wday=0 1 2 3 4 5 6 
          wom=0 1 2 3 4 5 
          woy=0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 
          mins=10
    Schedule: name=images
      --> Run Level=Full
          hour=10 
          mday=0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 
          month=0 1 2 3 4 5 6 7 8 9 10 11 
          wday=0 
          wom=0 
          woy=0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 
          mins=0
      --> Run Level=Differential
          hour=10 
          mday=0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 
          month=0 1 2 3 4 5 6 7 8 9 10 11 
          wday=0 
          wom=1 2 3 4 
          woy=0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 
          mins=0
      --> Run Level=Incremental
          hour=20 
          mday=0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 
          month=0 1 2 3 4 5 6 7 8 9 10 11 
          wday=1 2 3 4 5 6 
          wom=0 1 2 3 4 5 
          woy=0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 
          mins=0
    

    2) The schedule plan for one client or groups of clients (server/s):

    *show schedule=bind
    Schedule: name=bind
      --> Run Level=Full
          hour=20 
          mday=0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 
          month=0 1 2 3 4 5 6 7 8 9 10 11 
          wday=0 
          wom=0 
          woy=0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 
          mins=0
      --> Run Level=Differential
          hour=20 
          mday=0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 
          month=0 1 2 3 4 5 6 7 8 9 10 11 
          wday=0 
          wom=1 2 3 4 
          woy=0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 
          mins=0
      --> Run Level=Incremental
          hour=20 
          mday=0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 
          month=0 1 2 3 4 5 6 7 8 9 10 11 
          wday=1 2 3 4 5 6 
          wom=0 1 2 3 4 5 
          woy=0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 
          mins=0
    
  • Director

    1) Show the last messages of the backup processes. As you can see there is an error in one of the jobs, this error means that the client did not connect to the backup daemon (probably the same server with the Director), the problem was the firewall did not allow connections from this client (IP):

    *message
    06-Mar 20:00 srvbkp-dir JobId 1075: Start Backup JobId 1075, Job=srv1-bind.2018-03-06_20.00.01_05
    06-Mar 20:00 srvbkp-dir JobId 1075: Using Device "bind" to write.
    06-Mar 20:00 srvbkp-sd JobId 1066: Elapsed time=00:00:10, Transfer rate=0  Bytes/second
    06-Mar 20:00 srvbkp-dir JobId 1066: Bacula srvbkp-dir 7.0.5 (28Jul14):
      Build OS:               x86_64-pc-linux-gnu ubuntu 16.04
      JobId:                  1066
      Job:                    srv1-media.2018-03-06_20.00.00_56
      Backup Level:           Incremental, since=2018-03-06 20:00:14
      Client:                 "srv1-media" 7.0.5 (28Jul14) x86_64-pc-linux-gnu,ubuntu,16.04
      FileSet:                "bind" 2017-11-07 17:19:45
      Pool:                   "bind-incr" (From Job IncPool override)
      Catalog:                "allbackup" (From Client resource)
      Storage:                "bind" (From Job resource)
      Scheduled time:         06-Mar-2018 20:00:00
      Start time:             06-Mar-2018 20:00:15
      End time:               06-Mar-2018 20:00:26
      Elapsed time:           11 secs
      Priority:               10
      FD Files Written:       0
      SD Files Written:       0
      FD Bytes Written:       0 (0 B)
      SD Bytes Written:       0 (0 B)
      Rate:                   0.0 KB/s
      Software Compression:   None
      VSS:                    no
      Encryption:             no
      Accurate:               no
      Volume name(s):        
      Volume Session Id:      1025
      Volume Session Time:    1509989534
      Last Volume Bytes:      4,618 (4.618 KB)
      Non-fatal FD errors:    0
      SD Errors:              0
      FD termination status:  OK
      SD termination status:  OK
      Termination:            Backup OK
    06-Mar 20:01 srvbkp-dir JobId 1057: Using Device "bind" to write.
    06-Mar 20:05 srv2-dns-fd JobId 1057: Warning: bsock.c:112 Could not connect to Storage daemon on 192.168.0.5:9103. ERR=Connection timed out
    Retrying ...
    06-Mar 20:31 srv2-dns-fd JobId 1057: Fatal error: bsock.c:118 Unable to connect to Storage daemon on 192.168.0.5:9103. ERR=Interrupted system call
    06-Mar 20:31 srv2-dns-fd JobId 1057: Fatal error: job.c:1893 Failed to connect to Storage daemon: 192.168.0.5:9103
    06-Mar 20:31 srvbkp-dir JobId 1057: Fatal error: Bad response to Storage command: wanted 2000 OK storage
    , got 2902 Bad storage
    06-Mar 20:31 srvbkp-dir JobId 1057: Error: Bacula srvbkp-dir 7.0.5 (28Jul14):
      Build OS:               x86_64-pc-linux-gnu ubuntu 16.04
      JobId:                  1057
      Job:                    srv2-dns.2018-03-06_20.00.00_47
      Backup Level:           Full (upgraded from Incremental)
      Client:                 "srv2-dns" 7.0.5 (28Jul14) x86_64-pc-linux-gnu,ubuntu,16.04
      FileSet:                "bind" 2017-11-07 17:19:45
      Pool:                   "bind-full" (From Job FullPool override)
      Catalog:                "allbackup" (From Client resource)
      Storage:                "bind" (From Job resource)
      Scheduled time:         06-Mar-2018 20:00:00
      Start time:             06-Mar-2018 20:00:00
      End time:               06-Mar-2018 20:31:22
      Elapsed time:           31 mins 22 secs
      Priority:               10
      FD Files Written:       0
      SD Files Written:       0
      FD Bytes Written:       0 (0 B)
      SD Bytes Written:       0 (0 B)
      Rate:                   0.0 KB/s
      Software Compression:   None
      VSS:                    no
      Encryption:             no
      Accurate:               no
      Volume name(s):        
      Volume Session Id:      1201
      Volume Session Time:    1509989534
      Last Volume Bytes:      1 (1 B)
      Non-fatal FD errors:    2
      SD Errors:              0
      FD termination status:  Error
      SD termination status:  Waiting on FD
      Termination:            *** Backup Error ***
    

    2) reload – reload the configuration files of bacula system. The daemons will re-read all configuration files in “/etc/bacula”. Unfortunately there is no output:

    *reload
    *
    

Send coins in Ethereum network with geth console

Here are the steps needed to make a secure transfer of your funds under linux distro of Ubuntu. To be able to transfer money safely without any 3rd party involved (no online wallet) just funds from your personal Ethereum wallet address on your computer to another Ethereum wallet address we need the official command line interface for running a full ethereum node:

geth

STEP 1) Install and run an Ethereum node with geth

Here you can follow this tutorial – “Running an Ethereum node from source under Ubuntu 16 LTS”.
The Ethereum node must be running and synced with the Ethereum network.

STEP 2) Attach to the console of geth tool

ubuntu@srv.local:~/go-ethereum/build/bin$ ./geth attach
Welcome to the Geth JavaScript console!

instance: Geth/v1.8.2-unstable-b574b577/linux-amd64/go1.9.4
coinbase: 0x30d8810bb1a74e808b46788b2316bd93cf056517
at block: 5172179 (Wed, 28 Feb 2018 15:59:17 UTC)
 datadir: /home/ubuntu/.ethereum
 modules: admin:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0

>

STEP 3) Check how many funds you have in your Ethereum wallet address

While you are in the geth console paste the following:

> web3.fromWei(eth.getBalance('30d8810bb1a74e808b46788b2316bd93cf056517'), "ether")
0.105
> 

You can see there are 0.105 Ethers in the Ethereum wallet address 30d8810bb1a74e808b46788b2316bd93cf056517, replace the address with your public address.

STEP 3) Unlock your account

As you remember your wallet private key is encrypted with a password, so before you can use the private key to send funds you must decrypt the key with:

> personal.unlockAccount('30d8810bb1a74e808b46788b2316bd93cf056517', '<your_password>',300)
true

So your key will stay dectrypted for 300 seconds, this is the purpose of the third parameter. It can be omitted.

STEP 4) Send the amount you like to the Ethereum wallet address you like

, BE CAREFUL the operation is irreversible, if you put wrong address or unknown or unexciting one, you’ll lose your Ether coins!!
Every transaction has a cost, which is computed by the miners. That’s why the gas price is dynamic. The price is determined by the miner of a block and it can change from block to block. You can check the gas price here on http://ethgasstation.info. Determining and computing the price in Ether is very difficult there could be at least 3 new howtos about that. The best and the easiest way is just to check a site (like http://ethgasstation.info) for the average gas price in dollars and when executing a transaction of sending Ethereum funds make sure the same amount of Ether in dollars will stay in your wallet address to be used for the gas.

> eth.sendTransaction({from: '30d8810bb1a74e808b46788b2316bd93cf056517', to: '9009a960fb38c379813a4a2e26c5b94909dc8599', value: web3.toWei(0.104, "ether")})
"0x31b4f213f88f2831756bd9cc37b12e80c6dfe413a3b3423659ca91be352961fc"

If you see the transaction ID, it means the you have executed the command successfully and you can check the status of the transaction.

STEP 5) Check the transaction status.

The status of your transaction could be checked in sites offering Ethereum block explorer sites like

https://etherscan.io/

Here is the check URL for our transaction:

https://etherscan.io/tx/0x31b4f213f88f2831756bd9cc37b12e80c6dfe413a3b3423659ca91be352961fc

Here is the screenshot of the status page:

main menu
Transaction details in https://etherscan.io

And verify the other address has the coins:

ubuntu@ip-172-31-30-78:~/go-ethereum/build/bin$ ./geth attach
Welcome to the Geth JavaScript console!

instance: Geth/v1.8.2-unstable-b574b577/linux-amd64/go1.9.4
coinbase: 0x30d8810bb1a74e808b46788b2316bd93cf056517
at block: 5195693 (Sun, 04 Mar 2018 15:40:58 UTC)
 datadir: /home/ubuntu/.ethereum
 modules: admin:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0

> web3.fromWei(eth.getBalance('9009a960fb38c379813a4a2e26c5b94909dc8599'), "ether")
0.104
>

And how many coins remained at “30d8810bb1a74e808b46788b2316bd93cf056517”:

> web3.fromWei(eth.getBalance('30d8810bb1a74e808b46788b2316bd93cf056517'), "ether")
0.000811

So as you see the Gas was 0.000189 Ethers as you can see in the block explorer page.

Here is the whole output of the “geth” tool:

> ubuntu@ip-172-31-30-78:~/go-ethereum/build/bin$ ./geth attach
Welcome to the Geth JavaScript console!

instance: Geth/v1.8.2-unstable-b574b577/linux-amd64/go1.9.4
coinbase: 0x30d8810bb1a74e808b46788b2316bd93cf056517
at block: 5193986 (Sun, 04 Mar 2018 08:48:41 UTC)
 datadir: /home/ubuntu/.ethereum
 modules: admin:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0

> web3.fromWei(eth.getBalance('30d8810bb1a74e808b46788b2316bd93cf056517'), "ether")
0.105
> personal.unlockAccount('30d8810bb1a74e808b46788b2316bd93cf056517', '<the_password_of_the_address>',300)
true
> eth.sendTransaction({from: '30d8810bb1a74e808b46788b2316bd93cf056517', to: '9009a960fb38c379813a4a2e26c5b94909dc8599', value: web3.toWei(0.104, "ether")})
"0x31b4f213f88f2831756bd9cc37b12e80c6dfe413a3b3423659ca91be352961fc"
> web3.fromWei(eth.getBalance('30d8810bb1a74e808b46788b2316bd93cf056517'), "ether")
0.000811
> 

network time synchronization status with ntpq

There is a handy program called

ntpstats

, which shows the network time synchronization status of your server under Ubuntu 16, but the older version or other linux distros do not have this program. The output of the program is:

srv@local # ntpstat
synchronised to NTP server (129.250.35.250) at stratum 3 
   time correct to within 133 ms
   polling server every 1024 s

As you can see the time is correct within some interval of milliseconds. In other words your time in the server could be trusted only within these milliseconds! If your server is synchronized with the program ntp your time of the server will be correct within a tiny fractions of a second, closer to a time server much smaller interval of correctness. The interval is computed according to how away the server is and how much the latency of the network of the server is.
ntpstats compute the output with the formula:

rootdisp + rootdelay / 2.0

  • rootdisp – indicating the maximum error relative to the primary reference source. If your server gets the time from an external source (GPS, radio, high precise clock external device), this value is the estimated maximum error of that clock and if your server gets the time from another NTP server (in most cases), this value is the current NTP server’s root dispersion (to which your server is synced) plus the dispersion added by the network link between your server and the NTP server
  • rootdelay – indicating the total roundtrip delay to the primary reference source. Because it is a roundtrip we divide it to 2 to get the single trip delay of the network

You can get these two values with the ntpq program:

srv@local # ntpq -c "rv 0 rootdisp,rootdelay"
rootdelay=202.882, rootdisp=31.816

So the time correct to within 31.816+(202.882/2) = 133.257 ms, which is the output of ntpstat.

Delete millions of files slowly without loading the server

There a situations when we need to delete a great deal of files from our filesystem and if we just execute

rm -Rf

the server will surely get loaded and the service it provides will degrade! What if you cannot reformat the filesystem, because the server use it extensively, but you need to delete let’s say a couple of millions file from it? We can use find and usleep (in most linux distro this program is installed by an additional package). The idea is to delete files one by one tuning the pause between every delete. Here you can execute this command in the background or a screen:

find /mnt/storage/old/ -type f -exec echo {} \; -exec rm {} \; -exec usleep 200000 \;

usleep accepts microseconds, so 200000 microseconds are 0.2 seconds. You can tune it precisely with a step of just a microsecond. In the real world under the bash console we probably will use values of max 1/10 of a second around above 100000 microseconds. Execute the command and then watch your server load and tune.

  • usleep in CentOS 7 is installed with package “initscripts”, which is installed by default
  • usleep in Ubuntu is missing and probably won’t find any safe place to download a package to install, but it can be sort of replace with “sleep <floating_point_number>s”, GNU sleep could accept floating point number for the delay and when added “s” at the end it could sleep for a fractions of a seconds. So the command for the Ubuntu is slightly changed:
    find /mnt/storage/old/ -type f -exec echo {} \; -exec rm {} \; -exec sleep 0.2s \;
    
  • not GNU version of sleep require NUMBER, so the smallest sleep is only 1 second, which is too big for the purpose. Check your man manual to see if your system has GNU sleep command.

Reset any linux system from the console as if the reset button was pushed

What if you do not have the physical access to your server and you know there is a great possibility your server won’t shutdown properly, when you issue a reboot command (halt, shutdown and so on).
Ok, here is a situation, you have a dedicated server with no panel for resets, no IPMI access and a kernel bug just left a process with Disk sleep or any uninterruptible state that even a kill -9 won’t help! So just rebooting with the normal process of shutdown (going through the init levels or systemd states) won’t help, the shutdown process will be waiting infinite time for proper process termination, which won’t happen! All you need is just a simple old reset button pushed, but you have only a console, here what you can do and it is essentially the same as if someone pushed the server reset button:

echo 1 > /proc/sys/kernel/sysrq
echo b > /proc/sysrq-trigger

This technique is known as magic SysRq key and have more options, but this is probably most used. It will immediately reboot the server, without unmounting or syncing filesystems. So be extremely careful and an additional advice: issue a sync command before the reset, even if you know it it won’t finish.

sync &

BE WARNED, you can break your filesystem (with the modern filesystem and their late state this is unlikely to happen) or database (this is really likely to happen, but you could always repair or at least shutdown the database software and/or make a backup before), but you can save your server!