Monday, September 18, 2017

MABM

Demo: Create MBAM 2.5 users and groups in Active Directory Domain Services





Configure MBAM 2.5 Roles for the instance of SQL Server


Deploy prerequisites for MBAM 2.5 administration and monitoring server


Create MBAM 2.5 users and groups in Active Directory Domain Services



Register SPNS for the application pool account and configure constrained delegation


Install MBAM 2.5 server software


Configure MBAM 2.5 database and reports role




Configure MBAM 2.5 Web application role

Monday, January 9, 2012

How to Convert VirtualBox to KVM image

This task is quite simple.
  • First *.vdi hard disk image should be converted to *.raw image
  • Then *.raw image need to converted to *.qcow2 image
[root@virtualhost ~]# VBoxManage clonehd --format RAW image.vdi image.raw
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Clone hard disk created in format 'RAW'. UUID: 5478eb4b-a593-4ef0-b85b-9b3a4a8cc831
[root@virtualhost ~]# qemu-img convert -f raw -O qcow2 image.raw image.qcow2
Now you can use image.qcow2 with KVM.

Sunday, August 21, 2011

Formatting and Labeling a Partition mkfs and e2label

Once you have done with partitioning, you need to format the partition for use,. Unless it is a raw partition. The partition still does not have a file system. Create the file system mkfs command can be utilized

[root@RHEL01i ~]# mkfs -t ext3 /dev/sdb1 mke2fs 1.41.12 (17-May-2010) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 262944 inodes, 1050241 blocks 52512 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=1077936128 33 block groups 32768 blocks per group, 32768 fragments per group 7968 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736 Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 20 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. [root@RHEL01i ~]#
If the file system on the new partition is /dev/sda6 and you want to label it /work, use:
e2label /dev/sda6 /work
By default, the installation program uses the mount point of the partition as the label to make sure the label is unique. You can use any label you want. Afterwards, create a mount point (e.g. /work) as root. Add to /etc/fstab
As root, edit the /etc/fstab file to include the new partition using the partition's UUID. Use the blkid -L label command to retrieve the partition's UUID. The new line should look similar to the following:
UUID=93a0429d-0318-45c0-8320-9676ebf1ca79 /work ext3 defaults 1 2
The first column should contain UUID= followed by the file system's UUID. The second column should contain the mount point for the new partition, and the next column should be the file system type (for example, ext3 or swap). If you need more information about the format, read the man page with the command man fstab.

If the fourth column is the word defaults, the partition is mounted at boot time. To mount the partition without rebooting, as root, type the command:
mount /work

Friday, August 19, 2011

How to partition a hard disk using parted

parted command is used for
  • View the existing partition table
  • Change the size of existing partitions
  • Add partitions from free space or additional hard drives
Listing Details of the Hard Disks
[root@RHEL01 ~]# parted -l Model: SMC Array 0 (scsi) Disk /dev/sda: 1000GB Sector size (logical/physical): 512B/512B Partition Table: msdos Number Start End Size Type File system Flags 1 32.3kB 526MB 526MB primary ext3 boot 2 526MB 105GB 105GB primary ext3 3 105GB 158GB 52.4GB primary linux-swap 4 158GB 1000GB 842GB extended 5 158GB 210GB 52.4GB logical ext3 6 210GB 1000GB 789GB logical ext3 Model: SMC Array1 (scsi) Disk /dev/sdb: 1000GB Sector size (logical/physical): 512B/512B Partition Table: msdos Number Start End Size Type File system Flags 1 32.3kB 1000GB 1000GB primary ext3

Once can be compared this with fdisk -l.
First we need to look all option parted carry.
[root@RHEL01i ~]# parted /dev/sdc GNU Parted 2.1 Using /dev/sdc Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) help align-check TYPE N check partition N for TYPE(min|opt) alignment check NUMBER do a simple check on the file system cp [FROM-DEVICE] FROM-NUMBER TO-NUMBER copy file system to another partition help [COMMAND] print general help, or help on COMMAND mklabel,mktable LABEL-TYPE create a new disklabel (partition table) mkfs NUMBER FS-TYPE make a FS-TYPE file system on partition NUMBER mkpart PART-TYPE [FS-TYPE] START END make a partition mkpartfs PART-TYPE FS-TYPE START END make a partition with a file system move NUMBER START END move partition NUMBER name NUMBER NAME name partition NUMBER as NAME print [devices|free|list,all|NUMBER] display the partition table, available devices, free space, all found partitions, or a particular partition quit exit program rescue START END rescue a lost partition near START and END resize NUMBER START END resize partition NUMBER and its file system rm NUMBER delete partition NUMBER select DEVICE choose the device to edit set NUMBER FLAG STATE change the FLAG on partition NUMBER toggle [NUMBER [FLAG]] toggle the state of FLAG on partition NUMBER unit UNIT set the default unit to UNIT version display the version number and copyright information of GNU Parted (parted)

Creating a Partition

Here we will make 4 partitions, 2 primary which have 4GB and 512MB, and 2 logical partitions inside an extended partition (3.5 GB). As a default unit in parted is megabytes (MB).
[root@RHEL01 ~]# parted /dev/sdc GNU Parted 2.1 Using /dev/sdc Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) mkpart Partition type? primary/extended? primary File system type? [ext2]? ext3 Start? 0 End? 4096 Warning: The resulting partition is not properly aligned for best performance. Ignore/Cancel? Ignore (parted) p Model: ATA VBOX HARDDISK (scsi) Disk /dev/sdc: 8590MB Sector size (logical/physical): 512B/512B Partition Table: msdos Number Start End Size Type File system Flags 1 512B 4096MB 4096MB primary (parted) mkpart Partition type? primary/extended? primary File system type? [ext2]? ext3 Start? 4096 End? 4608 (parted) p Model: ATA VBOX HARDDISK (scsi) Disk /dev/sdc: 8590MB Sector size (logical/physical): 512B/512B Partition Table: msdos Number Start End Size Type File system Flags 1 512B 4096MB 4096MB primary 2 4097MB 4608MB 512MB primary (parted) mkpart Partition type? primary/extended? extended Start? 4608 End? 8590 (parted) p Model: ATA VBOX HARDDISK (scsi) Disk /dev/sdc: 8590MB Sector size (logical/physical): 512B/512B Partition Table: msdos Number Start End Size Type File system Flags 1 512B 4096MB 4096MB primary 2 4097MB 4608MB 512MB primary 3 4608MB 8590MB 3981MB extended lba (parted) mkpart Partition type? primary/logical? logical File system type? [ext2]? ext3 Start? 4608 End? 6656 Warning: The resulting partition is not properly aligned for best performance. Ignore/Cancel? Ignore (parted) p Model: ATA VBOX HARDDISK (scsi) Disk /dev/sdc: 8590MB Sector size (logical/physical): 512B/512B Partition Table: msdos Number Start End Size Type File system Flags 1 512B 4096MB 4096MB primary 2 4097MB 4608MB 512MB primary 3 4608MB 8590MB 3981MB extended lba 5 4608MB 6656MB 2048MB logical (parted) mkpart Partition type? primary/logical? logical File system type? [ext2]? ext3 Start? 6656 End? 8590 (parted) p Model: ATA VBOX HARDDISK (scsi) Disk /dev/sdc: 8590MB Sector size (logical/physical): 512B/512B Partition Table: msdos Number Start End Size Type File system Flags 1 512B 4096MB 4096MB primary 2 4097MB 4608MB 512MB primary 3 4608MB 8590MB 3981MB extended lba 5 4608MB 6656MB 2048MB logical 6 6656MB 8590MB 1934MB logical (parted)

Thursday, August 18, 2011

How to partitions in a hard disk using fdisk

Listing Details of the Hard Disks

[root@RHEL01 ~]# fdisk -l Disk /dev/sda: 999.6 GB, 999653638144 bytes 255 heads, 63 sectors/track, 121534 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sda1 * 1 64 514048+ 83 Linux /dev/sda2 65 12812 102398310 83 Linux /dev/sda3 12813 19186 51199155 82 Linux swap / Solaris /dev/sda4 19187 121534 822110310 5 Extended /dev/sda5 19187 25560 51199123+ 83 Linux /dev/sda6 25561 121534 770911123+ 83 Linux Disk /dev/sdb: 999.6 GB, 999653638144 bytes 255 heads, 63 sectors/track, 121534 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sdb1 1 121534 976221823+ 83 Linux

Creating a Partition
For this purpose we need to find out which hard disk that we are going to partitioned. keep in mind that IDE hard disks can be seen as hda, hdb, hdc, etc., as well as SATA or SCSI can be seen as sda, sdb, sdc, etc,.

List your devices.
ll /dev/sd* brw-rw----. 1 root disk 8, 0 Aug 18 18:40 /dev/sda brw-rw----. 1 root disk 8, 1 Aug 18 18:40 /dev/sda1 brw-rw----. 1 root disk 8, 2 Aug 18 18:40 /dev/sda2 brw-rw----. 1 root disk 8, 16 Aug 18 18:40 /dev/sdb brw-rw----. 1 root disk 8, 32 Aug 18 18:40 /dev/sdc brw-rw----. 1 root disk 8, 48 Aug 18 18:40 /dev/sdd

Syntax:
fdisk <device>

# fdisk /dev/sdb WARNING: DOS-compatible mode is deprecated. It's strongly recommended to switch off the mode (command 'c') and change display units to sectors (command 'u'). Command (m for help): m Command action a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition l list known partition types m print this menu n add a new partition o create a new empty DOS partition table p print the partition table q quit without saving changes s create a new empty Sun disklabel t change a partition's system id u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only) Command (m for help):

The basic fdisk commands you need are:
p print the partition table
n create a new partition
d delete a partition
q quit without saving changes
t change a partition's system id
w write the new partition table and exit

Here we are going to make 4GB partition as first partition. Then 512MB swap space. Then extended partition of  3.5G which has 2GB and 1.5GB. at last we change the partition type (id) to 82 which is Linux swap. The write all to disk and exit.

There are some limitations when it comes to working with partitions. You can have only four partitions to a physical disk—with one exception. If you want to make more than the four, you need to create three primary partitions and one extended partition, although the primary partitions aren’t required for extended partition creation. The extended partition can then hold 11 logical partitions (5–16) on it.

[root@RHEL01 ~]# fdisk /dev/sdb WARNING: DOS-compatible mode is deprecated. It's strongly recommended to switch off the mode (command 'c') and change display units to sectors (command 'u'). Command (m for help): p Disk /dev/sdb: 8589 MB, 8589934592 bytes 255 heads, 63 sectors/track, 1044 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x000896f3 Device Boot Start End Blocks Id System Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-1044, default 1): Using default value 1 Last cylinder, +cylinders or +size{K,M,G} (1-1044, default 1044): +4G Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 2 First cylinder (524-1044, default 524): Using default value 524 Last cylinder, +cylinders or +size{K,M,G} (524-1044, default 1044): +512M Command (m for help): n Command action e extended p primary partition (1-4) e Partition number (1-4): 3 First cylinder (590-1044, default 590): Using default value 590 Last cylinder, +cylinders or +size{K,M,G} (590-1044, default 1044): Using default value 1044 Command (m for help): n Command action l logical (5 or over) p primary partition (1-4) l First cylinder (590-1044, default 590): Using default value 590 Last cylinder, +cylinders or +size{K,M,G} (590-1044, default 1044): +2G Command (m for help): n Command action l logical (5 or over) p primary partition (1-4) l First cylinder (852-1044, default 852): Using default value 852 Last cylinder, +cylinders or +size{K,M,G} (852-1044, default 1044): Using default value 1044 Command (m for help): t Partition number (1-6): 2 Hex code (type L to list codes): 82 Changed system type of partition 2 to 82 (Linux swap / Solaris) Command (m for help): p Disk /dev/sdb: 8589 MB, 8589934592 bytes 255 heads, 63 sectors/track, 1044 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x000896f3 Device Boot Start End Blocks Id System /dev/sdb1 1 523 4200966 83 Linux /dev/sdb2 524 589 530145 82 Linux swap / Solaris /dev/sdb3 590 1044 3654787+ 5 Extended /dev/sdb5 590 851 2104483+ 83 Linux /dev/sdb6 852 1044 1550241 83 Linux Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. [root@RHEL01i sahan]#

Now task is completed and it need to be informed to the OS correctly. The Linux command for this is partprobe (inform the OS and kernel of partition table changes).  man partprobe will give you more details.
 SYNOPSIS:
       partprobe [-d] [-s] [devices...]
partprobe /dev/hdb
You can not found any out put here, it just informed the new partition table to OS.

Tuesday, August 16, 2011

Working with GRUB, Recover MBR

The GRUB bootloader is broken down into different stages. The code contained on the master boot record (MBR) is considered GRUB stage 1. It loads GRUB stage 1.5, which tries to identify the file system type (optional), or it can call GRUB stage 2 directly. Stage 2 is what calls the kernel and loads it into memory. In stage 1, GRUB needs to search the MBR looking for an active partition from which to boot the kernel. Grub boot options: e Edit the commands before booting a Modify or append the kernel arguments before booting c Open the GRUB command line Recover broken MBR in GRUB Boot the machine andd wait until the GRUB message appears and hit c.
GNU GRUB version 0.97 (639K lower . 392128K upper memory) [ Minimal BASH-like line editing is supported. For the first word, TAB lists possible command completions. Anywhere else TAB lists the possible completions of a device/filename. ESC at any time exits.] grub > find /grub/grub.conf (hd0,0) grub > root (hd0,0): Filesystem type is unknown, partition type 0x8e grub > setup (hd0) Checking if “/boot/grub/stage1” exists... no Checking if “/grub/stage1” exists... yes Checking if “/grub/stage2” exists... yes Checking if “/grub/e2fs_stage1_5” exists... yes Running “embed /grub/e2fs_stage1_5 (hd0)”... 26 sectors are embedded. succeeded. Running “install /grub/stage1 (hd0) (hd0)1+26 p(hd0,0)/grub/stage2 /grub/grub.conf”... succeeded Done. grub >

Friday, August 5, 2011

top, ps, nice and kill on CentOS/RHEL 6.0

Identify CPU/memory intensive processes, adjust process priority with renice, and kill processes What is a Process? A process is a set of instructions loaded in to memory. A process usually has a Process ID (PID) . For this purpose, we use top, ps, nice and kill command. 1) top - display Linux tasks 2)ps - report a snapshot of the current processes
********* simple selection ********* ********* selection by list ********* -A all processes -C by command name -N negate selection -G by real group ID (supports names) -a all w/ tty except session leaders -U by real user ID (supports names) -d all except session leaders -g by session OR by effective group name -e all processes -p by process ID T all processes on this terminal -s processes in the sessions given a all w/ tty, including other users -t by tty g OBSOLETE -- DO NOT USE -u by effective user ID (supports names) r only running processes U processes for specified users x processes w/o controlling ttys t by tty *********** output format ********** *********** long options *********** -o,o user-defined -f full --Group --User --pid --cols --ppid -j,j job control s signal --group --user --sid --rows --info -O,O preloaded -o v virtual memory --cumulative --format --deselect -l,l long u user-oriented --sort --tty --forest --version -F extra full X registers --heading --no-heading --context ********* misc options ********* -V,V show version L list format codes f ASCII art forest -m,m,-L,-T,H threads S children in sum -y change -l format -M,Z security data c true command name -c scheduling class -w,w wide output n numeric WCHAN,UID -H process hierarchy
3)nice - run a program with modified scheduling priority 4)kill - terminate a process

Use single-user mode to gain access to a system

Log in to single-user mode

  1. Boot the machine and wait until the GRUB message appears and hit any key.
  2. Select current kernel version that you wish to boot and type a to append the line.
  3. Then type single or 1 at the end of the line (there should be a space between single and the last parameter). Then Enter to proceed.


Monday, August 1, 2011

Manage System Services

For steady and reliable system you need to know how to manage services efficiently. In Linux we call them daemons. You need to know how to turn on/off, and restrict for certain run-levels. If a name of a system process that ends d, it is a daemon. e.g. SSH service is sshd and Apache web service is httpd.

1) chkconfig
Here we exploit chkconfig command. it basically updates and queries runlevel information for system services. Syntax and synopsis for the service management command as follows.
chkconfig [options] service_name
usual Options are:
chkconfig [--list] [--type type][name] chkconfig --add name chkconfig --del name chkconfig --override name chkconfig [--level <levels>] [--type type] name
Check the sshd service status/on/off for particular runlevel:
# chkconfig --list sshd sshd 0:off 1:off 2:on 3:on 4:on 5:on 6:off # chkconfig sshd off # chkconfig --list sshd sshd 0:off 1:off 2:off 3:off 4:off 5:off 6:off # chkconfig sshd on # chkconfig --list sshd sshd 0:off 1:off 2:on 3:on 4:on 5:on 6:off # chkconfig --level 5 sshd off # chkconfig --list sshd sshd 0:off 1:off 2:on 3:on 4:on 5:off 6:off

2) ntsysv
netsysv is a simple interface for configuring runlevel services which are also configurable through chkconfig. By default, it configures the current runlevel. if the user would like to configure other runlevels, those levels can be specified on the command line by listing the kevels after --level, without any spaces. For example, the option --level 235 edits runlevels 2, 3, and 6.
A service is considers to be started in the runlevel set if it is started in any of the runlevels which are being edited.The ntsysv window normally contains a Cancel button. If --back is specified, a Back button appears instead.
SYNOPSIS
# ntsysv [--back] [--level <levels>]
# ntsysv --levels 235

3) Service
Service also can be utilize for start, stop, and check the status of services on the system after it has already up. service runs a System V init script in as predictable environment as possible, removing most environment variables and with current working directory set to /.
SYNOPSIS
service [--status-all] service service_name <{start|stop|status|restart|force-reload}>]
Here, normally service_name located in directory /etc/init.d/ .
# service sshd status openssh-daemon (pid 1880) is running... # service sshd stop Stopping sshd: [ OK ] # service sshd status openssh-daemon is stopped # service sshd start Starting sshd: [ OK ]

4) initctl
initctl allows a system administrator to communicate and interact with the Upstart init daemon.
Syntex: initctl {start|stop|restart|reload|status|list|emit}
Options:
start Starts a job
stop Stops a job
restart Restarts a job
reload Sends a HUP signal to a job
status Queries the status of a job
list Lists known jobs
emit Emits an event
# initctl list rc stop/waiting tty (/dev/tty3) start/running, process 2673 tty (/dev/tty2) start/running, process 2671 tty (/dev/tty6) start/running, process 2679 tty (/dev/tty5) start/running, process 2677 tty (/dev/tty4) start/running, process 2675 plymouth-shutdown stop/waiting control-alt-delete stop/waiting system-setup-keyboard start/running, process 1259 readahead-collector stop/waiting vpnc-cleanup stop/waiting quit-plymouth stop/waiting rcS stop/waiting prefdm start/running, process 2666 init-system-dbus stop/waiting ck-log-system-restart stop/waiting readahead stop/waiting ck-log-system-start stop/waiting splash-manager stop/waiting start-ttys stop/waiting readahead-disable-services stop/waiting ck-log-system-stop stop/waiting rcS-sulogin stop/waiting serial stop/waiting
Please find more about UPSTART in CentOS/RHEL 5.6/6

Recover Root Password in CentOS/RHEL 5.6/6

You can log in using single-user mode or rescue-mode to reset the root password.


1) Log in to single-user mode
  1. Boot the machine andd wait until the GRUB message appears and hit any key.
  2. Select current kernel version that you wish to boot and type a to append the line.
  3. Then type single or 1 at the end of the line (there should be a space between single and the last parameter). Then Enter to proceed. 
    [root@hostname /]# passwd
    Changing password for user root.
    New password:
    Retype new password:
    passwd: all authentication tokens updated successfully.
    [root@hostname /]#

    RHEL 6.0 has a bug that will prevent you from changing your root password in single user mode.You may temporarily disable SELinux.  ()

    # setenforce 0

    2) Boot in to rescue mode
    1. Boot the machine using a CentOS/RHEL installation DVD or CD#1 and wait until the Welcome Screen appears.
    2. You can find three options,
      1. Install or upgrade an existing system
      2. Install system with basic video driver
      3. Rescue installed system
      4. Boot from local drive
      5. Select the Rescue installed system and Enter to proceed.
      6. Then it will ask you to Choose a Language and Keyboard Type. Choose appropriately.   
      7. Then you will find a dialog whether you need network setup. you can choos yes or no it want mater.
      8. Then you will find Rescue dialog box. Choose Continue option and hit OK twice and Start shell. Then you will be in the shell.
      Starting shell...
      bash-4.1# chroot /mnt/sysimage
      sh-4.1# passwd
      Changing password for user root.
      New password:
      Retype new password:
      passwd: all authentication tokens updated successfully.
      sh-4.1# exit
      exit
      bash-4.1# reboot

      3) Using recovery mode

      1. Chose root Drop to root shell prompt.
      2. mount -o remount,rw / this will mount your root diectory with read/write permission.
      3. Type passwd


      Boot, reboot, and shut down a system normally

      Some examples:
      1) Shutdown the system immediately.
      # shutdown -h now

      2) Reboot the system now
      # shutdown -r now

      3) or you can use reboot command
      # reboot

      4) Delayed shutdown by 2 minutes
      # shutdown -h 120

      5) Shutdown at 10:00PM
      # shutdown -h 22:00

      6) Requests that the system be powered off explicitly.
      # shutdown -P now

      7) Force the filesystem check during reboot
      # shutdown -Fr now


      In CentOS/RHEL 6, with new Upstart utility both poweroff and halt commands pointed to reboot command. These programs allow a system administrator to reboot, halt or poweroff the system.

      # shutdown -P now
      is quite equal to
      # poweroff

      and

      # shutdown -r now
      is quite equal to
      # reboot

      MABM

      Demo: Create MBAM 2.5 users and groups in Active Directory Domain Services Configure MBAM 2.5 Roles for the instance of SQL Server ...