Backup/Move LXC Container

  1. Stop lxc container
    $ sudo lxc-stop -n <container>
  2. Archive lxc container. DON’T forget the option ‘–numeric-owner’. The ‘–numeric-owner’ flag is very important! Without it, the container may not boot because the uid/gids get mangled in the extracted filesystem

    $ sudo - su
    $ cd /var/lib/lxc/<container>/
    $ tar --numeric-owner -czvf container_fs.tar.gz ./*
  3. Copy the archive file to another server (ftp, sftp, or scp)
  4. Extract files on the new server
    $ sudo su -
    $ mkdir /var/lib/lxc/<container>/
    $ cd /var/lib/lxc/<container>/
    $ tar --numeric-owner -xzvf container_fs.tar.gz 

    reference:

    http://stackoverflow.com/questions/23427129/how-do-i-backup-move-lxc-containers

Check Mysql user’s privileges

Show root user’s privileges:

mysql> SHOW GRANTS FOR 'root'@'localhost';
+---------------------------------------------------------------------+
| Grants for root@localhost                                           |
+---------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION |
+---------------------------------------------------------------------+

Show current user’s privileges:

mysql> show grants;
+---------------------------------------------------------------------+
| Grants for root@localhost                                           |
+---------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION |
| GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION        |
+---------------------------------------------------------------------+
2 rows in set (0.00 sec)

mysql> show grants for current_user;
+---------------------------------------------------------------------+
| Grants for root@localhost                                           |
+---------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION |
| GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION        |
+---------------------------------------------------------------------+
2 rows in set (0.00 sec)

mysql> show grants for current_user();
+---------------------------------------------------------------------+
| Grants for root@localhost                                           |
+---------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION |
| GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION        |
+---------------------------------------------------------------------+
2 rows in set (0.00 sec)

Add a new drive in CentOS

List all drives

ls /dev/sd*
/dev/sda  /dev/sda1  /dev/sda2  /dev/sdb

Create Linux partitions

$ sudo fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x59179040.

WARNING: The size of this disk is 36.0 TB (35997194649600 bytes).
DOS partition table format can not be used on drives for volumes
larger than (2199023255040 bytes) for 512-byte sectors. Use parted(1) and GUID
partition table format (GPT).


The device presents a logical sector size that is smaller than
the physical sector size. Aligning to a physical sector (or optimal
I/O) size boundary is recommended, or performance may be impacted.

Command (m for help): g
Building a new GPT disklabel (GUID: FEA1CC8D-685D-4B70-B533-3D758B387762)

Command (m for help): n
Partition number (1-128, default 1):
First sector (2048-70307020766, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-70307020766, default 70307020766):
Created partition 1

Command (m for help): p

Disk /dev/sdb: 35997.2 GB, 35997194649600 bytes, 70307020800 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk label type: gpt


#         Start          End    Size  Type            Name
 1         2048  70307020766   32.8T  Linux filesyste

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

Check result:

$ ls /dev/sd*
/dev/sda  /dev/sda1  /dev/sda2  /dev/sdb  /dev/sdb1

Create a file system

$ sudo mkfs.ext4 -L /data /dev/sdb1
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=/data
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
549273600 inodes, 8788377339 blocks
439418866 blocks (5.00%) reserved for the super user
First data block=0
268200 block groups
32768 blocks per group, 32768 fragments per group
2048 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, 512000000, 550731776, 644972544, 1934917632,
	2560000000, 3855122432, 5804752896

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

Create mount point

sudo mkdir /data

Modify fstab file to automatically mount the file system

$ sudo vi /etc/fstab
# add the following line at the end
LABEL=/data /data ext4 defaults 1 2

Mount filesystem

$ sudo mount -a
$ df -h
....
/dev/sdb1                    33T   20K   31T   1% /data

Configuring NTP on Windows Server 2012

Original: http://www.sysadminlab.net/windows/configuring-ntp-on-windows-server-2012

Run using PowerShell as Administrator:

w32tm /config /manualpeerlist:pool.ntp.org /syncfromflags:MANUAL
Stop-Service w32time
Start-Service w32time

Check status:

w32tm /query /status

Force a resnyc

w32tm /resync

Start from scratch:

Stop-Service w32time
w32tm /unregister
w32tm /register

Promote Windows 2012 R2 Domain Controller as a Primary DC

Run operations on the new Domain Controller server.

Server manager → Tools → Active directory Domains and Trusts

win2k12-change-domain1

Click right button on Root (Active Directory Domains and Trusts [win2012 server name]) → Operations Master → Change… → close

win2k12-change-domain2

Server manager → Tools → Active Directory Users and Computers

Click right button on the domain name → Operations master … → RIP tab → Chage … → PDC tab → Change… → Infrasturcture → Change… —> Close

win2k12-change-domain3

Start → Command Prompt (Admin) → regsvr32 schmmgmt.dll

win2k12-schema1
regsvr32 schmmgmt.dll

mmc → File → Add/Remove Snap-in … → Add “Active Directory Schema” → OK

win2k12-schema2

right click “Active Directory Schema” → Change Active Directory Domain Controller → Choose win2012 server (cc-dc2.cc01.adlan)

win2k12-schema3

win2k12-schema4

 right click “Active Directory Schema [cc-dc2.cc01.adlan]” → Operations Master … → Change… → Close

win2k12-schema5

Check status in command prompt window (example output. Win2012 server name is CC-DC2.cc01.adlan):

> netdom query fsmo
Schema master				CC-DC2.cc01.adlan
Domain naming master			CC-DC2.cc01.adlan
PDC					CC-DC2.cc01.adlan
RID pool manager			CC-DC2.cc01.adlan
Infrastructure master		        CC-DC2.cc01.adlan