Saturday, May 21, 2016

RHEL7 - LDAP client n auto fs set up.

LAB:
setup ldap client for  your server

server: ldap://sam.expanor.local
base dn: dc=expanor,dc=local
home dir: 192.168.10.120:/home/*


install following packages
pam_krb5
nss-pam-ldapd

1. Set up ldap client
# authconfig-tui

2. Install autofs
# yum install autofs

3. Setup autofs
# vi /etc/auto.master
/home   /etc/auto.ruser

wq!


2. define nfs server info

# vi /etc/auto.ruser
*       -rw     192.168.10.120:/home/&



Now change something

# vi /etc/auto.master
/export/home    /etc/auto.ruser

wq!


[root@sudhir ~]# umount -f /home/ldapuser1
umount.nfs4: /home/ldapuser1: device is busy
[root@sudhir ~]# pwd
/root
[root@sudhir ~]# fuser -cu /home/ldapuser1
/home/ldapuser1:     19600c(ldapuser1)
[root@sudhir ~]# ps -ef | grep 19600
ldapuse+ 19600 19599  0 12:17 pts/6    00:00:00 -bash
root     21647 20536  0 12:51 pts/4    00:00:00 grep --color=auto 19600
[root@sudhir ~]# kill -9 19600
[root@sudhir ~]# fuser -cu /home/ldapuser1
[root@sudhir ~]# umount /home/ldapuser1
[root@sudhir ~]#



RHEL7 - How to configure nfs server/autofs

 how to configure nfs server/autofs on RHEL7

1. add entry to /etc/exports
vi /etc/exports

/opt/myshare    *(rw,sync)

wq!

2. Start network service
# systemctl start nfs.server

3. Verify your export
# exportfs

# showmount -e localhost
Export list for localhost:
/opt/myshare *

# showmount -e 192.168.10.120
Export list for 192.168.10.120:
/opt/myshare *



Go to client
1. Verify you can access nfs server share

# showmount -e 192.168.10.120
Export list for 192.168.10.120:
/opt/myshare *


2. Mount the share
# mount -t nfs 192.168.10.120:/opt/myshare /mnt


3. Verify you mounted nfs share successfully

[root@localhost ~]# cd /mnt
[root@localhost mnt]# df -h .
Filesystem                   Size  Used Avail Use% Mounted on
192.168.10.120:/opt/myshare   20G   16G  4.7G  77% /mnt
[root@localhost mnt]#



autofs set up

nfs server

[root@sudhir ravi]# ls -ld /opt/sudhir/
drwxr-xr-x. 2 root root 6 May 14 11:00 /opt/sudhir/
[root@sudhir ravi]# pwd
/opt/ravi
[root@sudhir ravi]# exportfs
[root@sudhir ravi]# cat /etc/exports
/opt/sudhir     *(rw,sync)
[root@sudhir ravi]# systemctl start nfs-server
[root@sudhir ravi]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2016-05-21 08:40:27 EDT; 1h 16min ago
 Main PID: 663 (firewalld)
   CGroup: /system.slice/firewalld.service
           └─663 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid

May 21 08:40:19 sudhir.expanor.local systemd[1]: Starting firewalld - dynamic firewall dae.....
May 21 08:40:27 sudhir.expanor.local systemd[1]: Started firewalld - dynamic firewall daemon.
Hint: Some lines were ellipsized, use -l to show in full.
[root@sudhir ravi]# systemctl stop  firewalld
[root@sudhir ravi]# exportfs
/opt/sudhir     <world>
[root@sudhir ravi]#


autofs client


[root@localhost ravi]# cat /etc/auto.master
#
# Sample auto.master file
# This is a 'master' automounter map and it has the following format:
# mount-point [map-type[,format]:]map [options]
# For details of the format look at auto.master(5).
#
/misc   /etc/auto.misc
#
# NOTE: mounts done from a hosts map will be mounted with the
#       "nosuid" and "nodev" options unless the "suid" and "dev"
#       options are explicitly given.
#
/net    -hosts
#
# Include /etc/auto.master.d/*.autofs
# The included files must conform to the format of this file.
#
+dir:/etc/auto.master.d
#
# Include central master map if it can be found using
# nsswitch sources.
#
# Note that if there are entries for /net or /misc (as
# above) in the included master map any keys that are the
# same will not be seen as the first read key seen takes
# precedence.
#
+auto.master
/export/home    /etc/auto.sudhir

[root@localhost ravi]# cat /etc/auto.sudhir
sudhir  -rw     192.168.10.9:/opt/sudhir

[root@localhost ravi]# cd /export/home/sudhir
-bash: cd: /export/home/sudhir: No such file or directory

[root@localhost ravi]# systemctl status autofs
autofs.service - Automounts filesystems on demand
   Loaded: loaded (/usr/lib/systemd/system/autofs.service; disabled)
   Active: inactive (dead)

[root@localhost ravi]# systemctl start autofs
[root@localhost ravi]# systemctl status autofs
autofs.service - Automounts filesystems on demand
   Loaded: loaded (/usr/lib/systemd/system/autofs.service; disabled)
   Active: active (running) since Sat 2016-05-21 07:04:17 PDT; 2s ago
  Process: 6944 ExecStart=/usr/sbin/automount $OPTIONS --pid-file /run/autofs.pid (code=exited,                                                                         status=0/SUCCESS)
 Main PID: 6946 (automount)
   CGroup: /system.slice/autofs.service
           └─6946 /usr/sbin/automount --pid-file /run/autofs.pid

May 21 07:04:16 localhost.localdomain automount[6946]: setautomntent: lookup(sss): setautom...ry
May 21 07:04:17 localhost.localdomain systemd[1]: Started Automounts filesystems on demand.
Hint: Some lines were ellipsized, use -l to show in full.

[root@localhost ravi]# cd /export/home/sudhir
[root@localhost sudhir]# pwd
/export/home/sudhir
[root@localhost sudhir]# df -h .
Filesystem                Size  Used Avail Use% Mounted on
192.168.10.9:/opt/sudhir   13G  6.5G  5.7G  54% /export/home/sudhir
[root@localhost sudhir]#

RHEL7 - account creation


Requirement: create account with following specification.

  uid: 1220
  gid: 1500 - oradb
  shell: bourne
  comment: john 12-5nc
  home dir: /export/home/john


# groupadd -g 1500 oradb
# ls -ld /export/hom/
# useradd -u 1220 -g 1501 -d /export/hom/john -m -c "john 12-5nc" -s /bin/sh john


[root@sudhir html]# groupadd -g 1500 oradb1
groupadd: GID '1500' already exists
[root@sudhir html]# groupadd -g 1501 oradb1
[root@sudhir html]# ls -ld /export/hom/
ls: cannot access /export/hom/: No such file or directory
[root@sudhir html]# mkdir /export/hom/
mkdir: cannot create directory ‘/export/hom/’: No such file or directory
[root@sudhir html]# mkdir -p /export/hom/
[root@sudhir html]# useradd -u 1220 -g 1501 -d /export/hom/john -m -c "john 12-5nc" -s /bin/sh john
useradd: user 'john' already exists
[root@sudhir html]# useradd -u 1220 -g 1501 -d /export/hom/john -m -c "john 12-5nc" -s /bin/sh john1
useradd: user 'john1' already exists
[root@sudhir html]# useradd -u 1220 -g 1501 -d /export/hom/john -m -c "john 12-5nc" -s /bin/sh bill
[root@sudhir html]# id bill
uid=1220(bill) gid=1501(oradb1) groups=1501(oradb1)


Tuesday, May 17, 2016

RHEL:- Clear the disk cache

[root@sama ~]# free -m
             total       used       free     shared    buffers     cached
Mem:          2021       1458        562          0        206        412
-/+ buffers/cache:        839       1181
Swap:         4063          0       4063
You have new mail in /var/spool/mail/root

[root@sama ~]# echo 3 | tee /proc/sys/vm/drop_caches
3
[root@sama ~]# free -m
             total       used       free     shared    buffers     cached
Mem:          2021        908       1112          0          0        105
-/+ buffers/cache:        802       1219
Swap:         4063          0       4063
[root@sama ~]#

Sunday, May 15, 2016

RHEL7 - LVM intro

login as: ravi
ravi@192.168.10.13's password:
Last login: Sat May 14 05:57:38 2016 from 192.168.10.2
[ravi@ravi ~]$ su -
Password:
Last login: Sat May 14 07:15:05 PDT 2016 on pts/1
[root@ravi ~]# fdisk -l

Disk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000b272e

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      616447      307200   83  Linux
/dev/sda2          616448     4810751     2097152   82  Linux swap / Solaris
/dev/sda3         4810752    41943039    18566144   83  Linux

Disk /dev/sdb: 2147 MB, 2147483648 bytes, 4194304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x99a46fec

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048     1050623      524288   83  Linux
/dev/sdb2         1050624     2099199      524288   83  Linux
/dev/sdb3         2099200     3147775      524288   83  Linux
/dev/sdb4         3147776     4194303      523264    5  Extended

Disk /dev/sdc: 2147 MB, 2147483648 bytes, 4194304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/sdd: 2147 MB, 2147483648 bytes, 4194304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/sde: 2147 MB, 2147483648 bytes, 4194304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

[root@ravi ~]# echo "- - -" > /sys/class/
ata_device/    cpuid/         input/         pci_bus/       scsi_device/   usbmon/
ata_link/      dma/           iommu/         pcmcia_socket/ scsi_disk/     vc/
ata_port/      dmi/           leds/          powercap/      scsi_host/     vtconsole/
backlight/     drm/           mdio_bus/      power_supply/  sound/         watchdog/
bdi/           graphics/      mem/           ppdev/         spi_host/
block/         hidraw/        misc/          raw/           spi_transport/
bluetooth/     hwmon/         msr/           rfkill/        thermal/
bsg/           i2c-adapter/   net/           rtc/           tty/
[root@ravi ~]# echo "- - -" > /sys/class/s
scsi_device/   scsi_disk/     scsi_host/     sound/         spi_host/      spi_transport/
[root@ravi ~]# echo "- - -" > /sys/class/scsi_host/host
host0/ host1/ host2/
[root@ravi ~]# echo "- - -" > /sys/class/scsi_host/host0/scan
[root@ravi ~]# echo "- - -" > /sys/class/scsi_host/host1/scan
[root@ravi ~]# echo "- - -" > /sys/class/scsi_host/host2/scan
[root@ravi ~]# fdisk -l

Disk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000b272e

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      616447      307200   83  Linux
/dev/sda2          616448     4810751     2097152   82  Linux swap / Solaris
/dev/sda3         4810752    41943039    18566144   83  Linux

Disk /dev/sdb: 2147 MB, 2147483648 bytes, 4194304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x99a46fec

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048     1050623      524288   83  Linux
/dev/sdb2         1050624     2099199      524288   83  Linux
/dev/sdb3         2099200     3147775      524288   83  Linux
/dev/sdb4         3147776     4194303      523264    5  Extended

Disk /dev/sdc: 2147 MB, 2147483648 bytes, 4194304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/sdd: 2147 MB, 2147483648 bytes, 4194304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/sde: 2147 MB, 2147483648 bytes, 4194304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/sdf: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

[root@ravi ~]# fdisk /dev/sdf
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 0xcc95710b.

Command (m for help): p

Disk /dev/sdf: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xcc95710b

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p):
Using default response p
Partition number (1-4, default 1):
First sector (2048-20971519, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-20971519, default 20971519): +2G
Partition 1 of type Linux and of size 2 GiB is set

Command (m for help): p

Disk /dev/sdf: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xcc95710b

   Device Boot      Start         End      Blocks   Id  System
/dev/sdf1            2048     4196351     2097152   83  Linux

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

Calling ioctl() to re-read partition table.
Syncing disks.
[root@ravi ~]# fdisk -l /dev/sdf

Disk /dev/sdf: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xcc95710b

   Device Boot      Start         End      Blocks   Id  System
/dev/sdf1            2048     4196351     2097152   83  Linux
[root@ravi ~]# partprobe /dev/sdf
[root@ravi ~]# mkfs
mkfs         mkfs.cramfs  mkfs.ext3    mkfs.fat     mkfs.msdos   mkfs.xfs
mkfs.btrfs   mkfs.ext2    mkfs.ext4    mkfs.minix   mkfs.vfat
[root@ravi ~]# mkfs.ext4 /dev/sdf1
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
131072 inodes, 524288 blocks
26214 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=536870912
16 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912

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

[root@ravi ~]# blkid /dev/sdf1
/dev/sdf1: UUID="1e237efb-f3ed-4e73-b56b-a504543020b6" TYPE="ext4"
[root@ravi ~]# vi /etc/fstab
[root@ravi ~]# mkdir /opt/dir1
[root@ravi ~]# mount -a
[root@ravi ~]# df -h
Filesystem                 Size  Used Avail Use% Mounted on
/dev/sda3                   18G  4.5G   14G  26% /
devtmpfs                   482M     0  482M   0% /dev
tmpfs                      490M  184K  490M   1% /dev/shm
tmpfs                      490M  7.1M  483M   2% /run
tmpfs                      490M     0  490M   0% /sys/fs/cgroup
/dev/sda1                  297M  111M  187M  38% /boot
192.168.10.8:/opt/myshare   20G   16G  4.8G  77% /opt/share
/dev/sdf1                  2.0G  6.0M  1.8G   1% /opt/dir1
[root@ravi ~]# cd /opt/dir1
[root@ravi dir1]# df -h .
Filesystem      Size  Used Avail Use% Mounted on
/dev/sdf1       2.0G  6.0M  1.8G   1% /opt/dir1
[root@ravi dir1]# mkdir /opt/dir2
[root@ravi dir1]# df -h /opt/dir2
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda3        18G  4.5G   14G  26% /
[root@ravi dir1]# df -h /opt/dir1 /opt/dir2
Filesystem      Size  Used Avail Use% Mounted on
/dev/sdf1       2.0G  6.0M  1.8G   1% /opt/dir1
/dev/sda3        18G  4.5G   14G  26% /
[root@ravi dir1]# df -h .
Filesystem      Size  Used Avail Use% Mounted on
/dev/sdf1       2.0G  6.0M  1.8G   1% /opt/dir1
[root@ravi dir1]# mkdir /opt/oracle
[root@ravi dir1]# pwd
/opt/dir1
[root@ravi dir1]# fdisk /dev/sdf
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.


Command (m for help): p

Disk /dev/sdf: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xcc95710b

   Device Boot      Start         End      Blocks   Id  System
/dev/sdf1            2048     4196351     2097152   83  Linux

Command (m for help): n
Partition type:
   p   primary (1 primary, 0 extended, 3 free)
   e   extended
Select (default p): 1
Invalid partition type `1'

Command (m for help): n
Partition type:
   p   primary (1 primary, 0 extended, 3 free)
   e   extended
Select (default p): p
Partition number (2-4, default 2):
First sector (4196352-20971519, default 4196352):
Using default value 4196352
Last sector, +sectors or +size{K,M,G} (4196352-20971519, default 20971519): +2G
Partition 2 of type Linux and of size 2 GiB is set

Command (m for help): p

Disk /dev/sdf: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xcc95710b

   Device Boot      Start         End      Blocks   Id  System
/dev/sdf1            2048     4196351     2097152   83  Linux
/dev/sdf2         4196352     8390655     2097152   83  Linux

Command (m for help): t
Partition number (1,2, default 2):
Hex code (type L to list all codes): L

 0  Empty           24  NEC DOS         81  Minix / old Lin bf  Solaris
 1  FAT12           27  Hidden NTFS Win 82  Linux swap / So c1  DRDOS/sec (FAT-
 2  XENIX root      39  Plan 9          83  Linux           c4  DRDOS/sec (FAT-
 3  XENIX usr       3c  PartitionMagic  84  OS/2 hidden C:  c6  DRDOS/sec (FAT-
 4  FAT16 <32M      40  Venix 80286     85  Linux extended  c7  Syrinx
 5  Extended        41  PPC PReP Boot   86  NTFS volume set da  Non-FS data
 6  FAT16           42  SFS             87  NTFS volume set db  CP/M / CTOS / .
 7  HPFS/NTFS/exFAT 4d  QNX4.x          88  Linux plaintext de  Dell Utility
 8  AIX             4e  QNX4.x 2nd part 8e  Linux LVM       df  BootIt
 9  AIX bootable    4f  QNX4.x 3rd part 93  Amoeba          e1  DOS access
 a  OS/2 Boot Manag 50  OnTrack DM      94  Amoeba BBT      e3  DOS R/O
 b  W95 FAT32       51  OnTrack DM6 Aux 9f  BSD/OS          e4  SpeedStor
 c  W95 FAT32 (LBA) 52  CP/M            a0  IBM Thinkpad hi eb  BeOS fs
 e  W95 FAT16 (LBA) 53  OnTrack DM6 Aux a5  FreeBSD         ee  GPT
 f  W95 Ext'd (LBA) 54  OnTrackDM6      a6  OpenBSD         ef  EFI (FAT-12/16/
10  OPUS            55  EZ-Drive        a7  NeXTSTEP        f0  Linux/PA-RISC b
11  Hidden FAT12    56  Golden Bow      a8  Darwin UFS      f1  SpeedStor
12  Compaq diagnost 5c  Priam Edisk     a9  NetBSD          f4  SpeedStor
14  Hidden FAT16 <3 61  SpeedStor       ab  Darwin boot     f2  DOS secondary
16  Hidden FAT16    63  GNU HURD or Sys af  HFS / HFS+      fb  VMware VMFS
17  Hidden HPFS/NTF 64  Novell Netware  b7  BSDI fs         fc  VMware VMKCORE
18  AST SmartSleep  65  Novell Netware  b8  BSDI swap       fd  Linux raid auto
1b  Hidden W95 FAT3 70  DiskSecure Mult bb  Boot Wizard hid fe  LANstep
1c  Hidden W95 FAT3 75  PC/IX           be  Solaris boot    ff  BBT
1e  Hidden W95 FAT1 80  Old Minix
Hex code (type L to list all codes): 83
Changed type of partition 'Linux' to 'Linux'

Command (m for help): p

Disk /dev/sdf: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xcc95710b

   Device Boot      Start         End      Blocks   Id  System
/dev/sdf1            2048     4196351     2097152   83  Linux
/dev/sdf2         4196352     8390655     2097152   83  Linux

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

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
[root@ravi dir1]# mkfs.xfs /dev/sdf2
/dev/sdf2: No such file or directory
Usage: mkfs.xfs
/* blocksize */         [-b log=n|size=num]
/* metadata */          [-m crc=0|1,finobt=0|1]
/* data subvol */       [-d agcount=n,agsize=n,file,name=xxx,size=num,
                            (sunit=value,swidth=value|su=num,sw=num|noalign),
                            sectlog=n|sectsize=num
/* force overwrite */   [-f]
/* inode size */        [-i log=n|perblock=n|size=num,maxpct=n,attr=0|1|2,
                            projid32bit=0|1]
/* no discard */        [-K]
/* log subvol */        [-l agnum=n,internal,size=num,logdev=xxx,version=n
                            sunit=value|su=num,sectlog=n|sectsize=num,
                            lazy-count=0|1]
/* label */             [-L label (maximum 12 characters)]
/* naming */            [-n log=n|size=num,version=2|ci,ftype=0|1]
/* no-op info only */   [-N]
/* prototype file */    [-p fname]
/* quiet */             [-q]
/* realtime subvol */   [-r extsize=num,size=num,rtdev=xxx]
/* sectorsize */        [-s log=n|size=num]
/* version */           [-V]
                        devicename
<devicename> is required unless -d name=xxx is given.
<num> is xxx (bytes), xxxs (sectors), xxxb (fs blocks), xxxk (xxx KiB),
      xxxm (xxx MiB), xxxg (xxx GiB), xxxt (xxx TiB) or xxxp (xxx PiB).
<value> is xxx (512 byte blocks).
[root@ravi dir1]# partprobe /dev/sdf
[root@ravi dir1]# mkfs.xfs /dev/sdf2
meta-data=/dev/sdf2              isize=256    agcount=4, agsize=131072 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0        finobt=0
data     =                       bsize=4096   blocks=524288, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =internal log           bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
[root@ravi dir1]# blkid /dev/sdf2
/dev/sdf2: UUID="0147d214-11f9-4090-929e-38cada157a03" TYPE="xfs"
[root@ravi dir1]# vi /etc/fstab
[root@ravi dir1]# mount -a
[root@ravi dir1]# df -h

^C
[root@ravi dir1]# df -h




^C
[root@ravi dir1]# ^C
[root@ravi dir1]# ^C
[root@ravi dir1]# ^C
[root@ravi dir1]# df -h /opt/oracle
Filesystem      Size  Used Avail Use% Mounted on
/dev/sdf2       2.0G   33M  2.0G   2% /opt/oracle
[root@ravi dir1]#
[root@ravi dir1]#
[root@ravi dir1]#
[root@ravi dir1]#
[root@ravi dir1]#
[root@ravi dir1]#
[root@ravi dir1]#
[root@ravi dir1]# pwd
/opt/dir1
[root@ravi dir1]# pwd
/opt/dir1
[root@ravi dir1]# fdisk -l

Disk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000b272e

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      616447      307200   83  Linux
/dev/sda2          616448     4810751     2097152   82  Linux swap / Solaris
/dev/sda3         4810752    41943039    18566144   83  Linux

Disk /dev/sdb: 2147 MB, 2147483648 bytes, 4194304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x99a46fec

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048     1050623      524288   83  Linux
/dev/sdb2         1050624     2099199      524288   83  Linux
/dev/sdb3         2099200     3147775      524288   83  Linux
/dev/sdb4         3147776     4194303      523264    5  Extended

Disk /dev/sdc: 2147 MB, 2147483648 bytes, 4194304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/sdd: 2147 MB, 2147483648 bytes, 4194304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/sde: 2147 MB, 2147483648 bytes, 4194304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/sdf: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xcc95710b

   Device Boot      Start         End      Blocks   Id  System
/dev/sdf1            2048     4196351     2097152   83  Linux
/dev/sdf2         4196352     8390655     2097152   83  Linux

Disk /dev/sdg: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xc909817c

   Device Boot      Start         End      Blocks   Id  System
/dev/sdg1            2048     4196351     2097152   83  Linux
/dev/sdg2         4196352     8390655     2097152   83  Linux
/dev/sdg3         8390656     8390658           1+  83  Linux
/dev/sdg4         8392704    12587007     2097152    5  Extended
[root@ravi dir1]# pwd
/opt/dir1
[root@ravi dir1]# df -h
Filesystem                 Size  Used Avail Use% Mounted on
/dev/sda3                   18G  4.5G   14G  26% /
devtmpfs                   482M     0  482M   0% /dev
tmpfs                      490M  184K  490M   1% /dev/shm
tmpfs                      490M  7.2M  483M   2% /run
tmpfs                      490M     0  490M   0% /sys/fs/cgroup
/dev/sda1                  297M  111M  187M  38% /boot
192.168.10.8:/opt/myshare   20G   16G  4.8G  77% /opt/share
/dev/sdf1                  2.0G  6.0M  1.8G   1% /opt/dir1
/dev/sdf2                  2.0G   33M  2.0G   2% /opt/oracle
/dev/sdg1                  2.0G  6.0M  1.8G   1% /opt/agrima
/dev/sdg2                  2.0G  6.0M  1.8G   1% /opt/swostika
[root@ravi dir1]# fdisk -l

Disk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000b272e

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      616447      307200   83  Linux
/dev/sda2          616448     4810751     2097152   82  Linux swap / Solaris
/dev/sda3         4810752    41943039    18566144   83  Linux

Disk /dev/sdb: 2147 MB, 2147483648 bytes, 4194304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x99a46fec

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048     1050623      524288   83  Linux
/dev/sdb2         1050624     2099199      524288   83  Linux
/dev/sdb3         2099200     3147775      524288   83  Linux
/dev/sdb4         3147776     4194303      523264    5  Extended

Disk /dev/sdc: 2147 MB, 2147483648 bytes, 4194304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/sdd: 2147 MB, 2147483648 bytes, 4194304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/sde: 2147 MB, 2147483648 bytes, 4194304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/sdf: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xcc95710b

   Device Boot      Start         End      Blocks   Id  System
/dev/sdf1            2048     4196351     2097152   83  Linux
/dev/sdf2         4196352     8390655     2097152   83  Linux

Disk /dev/sdg: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xc909817c

   Device Boot      Start         End      Blocks   Id  System
/dev/sdg1            2048     4196351     2097152   83  Linux
/dev/sdg2         4196352     8390655     2097152   83  Linux
/dev/sdg3         8390656    12584959     2097152   83  Linux
/dev/sdg4        12584960    16779263     2097152    5  Extended
[root@ravi dir1]# fdisk -l /dev/sdg

Disk /dev/sdg: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xc909817c

   Device Boot      Start         End      Blocks   Id  System
/dev/sdg1            2048     4196351     2097152   83  Linux
/dev/sdg2         4196352     8390655     2097152   83  Linux
/dev/sdg3         8390656    12584959     2097152   83  Linux
/dev/sdg4        12584960    16779263     2097152    5  Extended
[root@ravi dir1]# fidsk /dev/sdg
bash: fidsk: command not found...
Similar command is: 'fdisk'
[root@ravi dir1]# fdisk /dev/sdg
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.


Command (m for help): p

Disk /dev/sdg: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xc909817c

   Device Boot      Start         End      Blocks   Id  System
/dev/sdg1            2048     4196351     2097152   83  Linux
/dev/sdg2         4196352     8390655     2097152   83  Linux
/dev/sdg3         8390656    12584959     2097152   83  Linux
/dev/sdg4        12584960    16779263     2097152    5  Extended

Command (m for help): d
Partition number (1-4, default 4):
Partition 4 is deleted

Command (m for help): p

Disk /dev/sdg: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xc909817c

   Device Boot      Start         End      Blocks   Id  System
/dev/sdg1            2048     4196351     2097152   83  Linux
/dev/sdg2         4196352     8390655     2097152   83  Linux
/dev/sdg3         8390656    12584959     2097152   83  Linux

Command (m for help): n
Partition type:
   p   primary (3 primary, 0 extended, 1 free)
   e   extended
Select (default e):
Using default response e
Selected partition 4
First sector (12584960-20971519, default 12584960):
Using default value 12584960
Last sector, +sectors or +size{K,M,G} (12584960-20971519, default 20971519):
Using default value 20971519
Partition 4 of type Extended and of size 4 GiB is set

Command (m for help): p

Disk /dev/sdg: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xc909817c

   Device Boot      Start         End      Blocks   Id  System
/dev/sdg1            2048     4196351     2097152   83  Linux
/dev/sdg2         4196352     8390655     2097152   83  Linux
/dev/sdg3         8390656    12584959     2097152   83  Linux
/dev/sdg4        12584960    20971519     4193280    5  Extended

Command (m for help): n
All primary partitions are in use
Adding logical partition 5
First sector (12587008-20971519, default 12587008):
Using default value 12587008
Last sector, +sectors or +size{K,M,G} (12587008-20971519, default 20971519): +2G
Partition 5 of type Linux and of size 2 GiB is set

Command (m for help): n
All primary partitions are in use
Adding logical partition 6
First sector (16783360-20971519, default 16783360):
Using default value 16783360
Last sector, +sectors or +size{K,M,G} (16783360-20971519, default 20971519):
Using default value 20971519
Partition 6 of type Linux and of size 2 GiB is set

Command (m for help): p

Disk /dev/sdg: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xc909817c

   Device Boot      Start         End      Blocks   Id  System
/dev/sdg1            2048     4196351     2097152   83  Linux
/dev/sdg2         4196352     8390655     2097152   83  Linux
/dev/sdg3         8390656    12584959     2097152   83  Linux
/dev/sdg4        12584960    20971519     4193280    5  Extended
/dev/sdg5        12587008    16781311     2097152   83  Linux
/dev/sdg6        16783360    20971519     2094080   83  Linux

Command (m for help): t
Partition number (1-6, default 6): 3
Hex code (type L to list all codes): L

 0  Empty           24  NEC DOS         81  Minix / old Lin bf  Solaris
 1  FAT12           27  Hidden NTFS Win 82  Linux swap / So c1  DRDOS/sec (FAT-
 2  XENIX root      39  Plan 9          83  Linux           c4  DRDOS/sec (FAT-
 3  XENIX usr       3c  PartitionMagic  84  OS/2 hidden C:  c6  DRDOS/sec (FAT-
 4  FAT16 <32M      40  Venix 80286     85  Linux extended  c7  Syrinx
 5  Extended        41  PPC PReP Boot   86  NTFS volume set da  Non-FS data
 6  FAT16           42  SFS             87  NTFS volume set db  CP/M / CTOS / .
 7  HPFS/NTFS/exFAT 4d  QNX4.x          88  Linux plaintext de  Dell Utility
 8  AIX             4e  QNX4.x 2nd part 8e  Linux LVM       df  BootIt
 9  AIX bootable    4f  QNX4.x 3rd part 93  Amoeba          e1  DOS access
 a  OS/2 Boot Manag 50  OnTrack DM      94  Amoeba BBT      e3  DOS R/O
 b  W95 FAT32       51  OnTrack DM6 Aux 9f  BSD/OS          e4  SpeedStor
 c  W95 FAT32 (LBA) 52  CP/M            a0  IBM Thinkpad hi eb  BeOS fs
 e  W95 FAT16 (LBA) 53  OnTrack DM6 Aux a5  FreeBSD         ee  GPT
 f  W95 Ext'd (LBA) 54  OnTrackDM6      a6  OpenBSD         ef  EFI (FAT-12/16/
10  OPUS            55  EZ-Drive        a7  NeXTSTEP        f0  Linux/PA-RISC b
11  Hidden FAT12    56  Golden Bow      a8  Darwin UFS      f1  SpeedStor
12  Compaq diagnost 5c  Priam Edisk     a9  NetBSD          f4  SpeedStor
14  Hidden FAT16 <3 61  SpeedStor       ab  Darwin boot     f2  DOS secondary
16  Hidden FAT16    63  GNU HURD or Sys af  HFS / HFS+      fb  VMware VMFS
17  Hidden HPFS/NTF 64  Novell Netware  b7  BSDI fs         fc  VMware VMKCORE
18  AST SmartSleep  65  Novell Netware  b8  BSDI swap       fd  Linux raid auto
1b  Hidden W95 FAT3 70  DiskSecure Mult bb  Boot Wizard hid fe  LANstep
1c  Hidden W95 FAT3 75  PC/IX           be  Solaris boot    ff  BBT
1e  Hidden W95 FAT1 80  Old Minix
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'

Command (m for help): p

Disk /dev/sdg: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xc909817c

   Device Boot      Start         End      Blocks   Id  System
/dev/sdg1            2048     4196351     2097152   83  Linux
/dev/sdg2         4196352     8390655     2097152   83  Linux
/dev/sdg3         8390656    12584959     2097152   8e  Linux LVM
/dev/sdg4        12584960    20971519     4193280    5  Extended
/dev/sdg5        12587008    16781311     2097152   83  Linux
/dev/sdg6        16783360    20971519     2094080   83  Linux

Command (m for help): t
Partition number (1-6, default 6): 5
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'

Command (m for help): t
Partition number (1-6, default 6):
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'

Command (m for help): p

Disk /dev/sdg: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xc909817c

   Device Boot      Start         End      Blocks   Id  System
/dev/sdg1            2048     4196351     2097152   83  Linux
/dev/sdg2         4196352     8390655     2097152   83  Linux
/dev/sdg3         8390656    12584959     2097152   8e  Linux LVM
/dev/sdg4        12584960    20971519     4193280    5  Extended
/dev/sdg5        12587008    16781311     2097152   8e  Linux LVM
/dev/sdg6        16783360    20971519     2094080   8e  Linux LVM

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

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
[root@ravi dir1]# partprobe /dev/sdg
[root@ravi dir1]# fdisk /dev/sdg
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.


Command (m for help): p

Disk /dev/sdg: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xc909817c

   Device Boot      Start         End      Blocks   Id  System
/dev/sdg1            2048     4196351     2097152   83  Linux
/dev/sdg2         4196352     8390655     2097152   83  Linux
/dev/sdg3         8390656    12584959     2097152   8e  Linux LVM
/dev/sdg4        12584960    20971519     4193280    5  Extended
/dev/sdg5        12587008    16781311     2097152   8e  Linux LVM
/dev/sdg6        16783360    20971519     2094080   8e  Linux LVM

Command (m for help): t
Partition number (1-6, default 6): 3
Hex code (type L to list all codes): L

 0  Empty           24  NEC DOS         81  Minix / old Lin bf  Solaris
 1  FAT12           27  Hidden NTFS Win 82  Linux swap / So c1  DRDOS/sec (FAT-
 2  XENIX root      39  Plan 9          83  Linux           c4  DRDOS/sec (FAT-
 3  XENIX usr       3c  PartitionMagic  84  OS/2 hidden C:  c6  DRDOS/sec (FAT-
 4  FAT16 <32M      40  Venix 80286     85  Linux extended  c7  Syrinx
 5  Extended        41  PPC PReP Boot   86  NTFS volume set da  Non-FS data
 6  FAT16           42  SFS             87  NTFS volume set db  CP/M / CTOS / .
 7  HPFS/NTFS/exFAT 4d  QNX4.x          88  Linux plaintext de  Dell Utility
 8  AIX             4e  QNX4.x 2nd part 8e  Linux LVM       df  BootIt
 9  AIX bootable    4f  QNX4.x 3rd part 93  Amoeba          e1  DOS access
 a  OS/2 Boot Manag 50  OnTrack DM      94  Amoeba BBT      e3  DOS R/O
 b  W95 FAT32       51  OnTrack DM6 Aux 9f  BSD/OS          e4  SpeedStor
 c  W95 FAT32 (LBA) 52  CP/M            a0  IBM Thinkpad hi eb  BeOS fs
 e  W95 FAT16 (LBA) 53  OnTrack DM6 Aux a5  FreeBSD         ee  GPT
 f  W95 Ext'd (LBA) 54  OnTrackDM6      a6  OpenBSD         ef  EFI (FAT-12/16/
10  OPUS            55  EZ-Drive        a7  NeXTSTEP        f0  Linux/PA-RISC b
11  Hidden FAT12    56  Golden Bow      a8  Darwin UFS      f1  SpeedStor
12  Compaq diagnost 5c  Priam Edisk     a9  NetBSD          f4  SpeedStor
14  Hidden FAT16 <3 61  SpeedStor       ab  Darwin boot     f2  DOS secondary
16  Hidden FAT16    63  GNU HURD or Sys af  HFS / HFS+      fb  VMware VMFS
17  Hidden HPFS/NTF 64  Novell Netware  b7  BSDI fs         fc  VMware VMKCORE
18  AST SmartSleep  65  Novell Netware  b8  BSDI swap       fd  Linux raid auto
1b  Hidden W95 FAT3 70  DiskSecure Mult bb  Boot Wizard hid fe  LANstep
1c  Hidden W95 FAT3 75  PC/IX           be  Solaris boot    ff  BBT
1e  Hidden W95 FAT1 80  Old Minix
Hex code (type L to list all codes): 82
Changed type of partition 'Linux LVM' to 'Linux swap / Solaris'

Command (m for help): p

Disk /dev/sdg: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xc909817c

   Device Boot      Start         End      Blocks   Id  System
/dev/sdg1            2048     4196351     2097152   83  Linux
/dev/sdg2         4196352     8390655     2097152   83  Linux
/dev/sdg3         8390656    12584959     2097152   82  Linux swap / Solaris
/dev/sdg4        12584960    20971519     4193280    5  Extended
/dev/sdg5        12587008    16781311     2097152   8e  Linux LVM
/dev/sdg6        16783360    20971519     2094080   8e  Linux LVM

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

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
[root@ravi dir1]# partprobe /dev/sdg
[root@ravi dir1]# fdisk -l /dev/sdg

Disk /dev/sdg: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xc909817c

   Device Boot      Start         End      Blocks   Id  System
/dev/sdg1            2048     4196351     2097152   83  Linux
/dev/sdg2         4196352     8390655     2097152   83  Linux
/dev/sdg3         8390656    12584959     2097152   82  Linux swap / Solaris
/dev/sdg4        12584960    20971519     4193280    5  Extended
/dev/sdg5        12587008    16781311     2097152   8e  Linux LVM
/dev/sdg6        16783360    20971519     2094080   8e  Linux LVM
[root@ravi dir1]# mk
mkafmmap          mkfifo            mkfs.ext2         mkfs.vfat         mklost+found
mkdict            mkfontdir         mkfs.ext3         mkfs.xfs          mkmanifest
mkdir             mkfontscale       mkfs.ext4         mkhomedir_helper  mknod
mkdosfs           mkfs              mkfs.fat          mkhybrid          mkrfc2734
mkdumprd          mkfs.btrfs        mkfs.minix        mkinitrd          mkswap
mke2fs            mkfs.cramfs       mkfs.msdos        mkisofs           mktemp
[root@ravi dir1]# mkswap /dev/sdg3
Setting up swapspace version 1, size = 2097148 KiB
no label, UUID=0359be0e-efa5-4483-8f53-05a57f2eb574
[root@ravi dir1]# vi blkid ^C
[root@ravi dir1]# blkid /dev/sdg3
/dev/sdg3: UUID="0359be0e-efa5-4483-8f53-05a57f2eb574" TYPE="swap"
[root@ravi dir1]# vi /etc/fstab
[root@ravi dir1]# vi /etc/fstab
[root@ravi dir1]# free
              total        used        free      shared  buff/cache   available
Mem:        1003160      761072       79028        3044      163060       75040
Swap:       2097148      157892     1939256
[root@ravi dir1]# cat /proc/swaps
Filename                                Type            Size    Used    Priority
/dev/sda2                               partition       2097148 157892  -1
[root@ravi dir1]# free -m
              total        used        free      shared  buff/cache   available
Mem:            979         743          77           2         159          73
Swap:          2047         154        1893
[root@ravi dir1]# free -g
              total        used        free      shared  buff/cache   available
Mem:              0           0           0           0           0           0
Swap:             1           0           1
[root@ravi dir1]# swapon -a /dev/sdg3
swapon: /dev/sdg3: swapon failed: Device or resource busy
[root@ravi dir1]# mount -a
[root@ravi dir1]# cat /proc/swaps
Filename                                Type            Size    Used    Priority
/dev/sda2                               partition       2097148 157832  -1
/dev/sdg3                               partition       2097148 0       -2
[root@ravi dir1]# free -m
              total        used        free      shared  buff/cache   available
Mem:            979         744          74           2         160          71
Swap:          4095         154        3941
[root@ravi dir1]# swapoff /dev/sdg3
[root@ravi dir1]# cat /proc/swaps
Filename                                Type            Size    Used    Priority
/dev/sda2                               partition       2097148 157824  -1
[root@ravi dir1]# swapon /dev/sdg3
[root@ravi dir1]# cat /proc/swaps
Filename                                Type            Size    Used    Priority
/dev/sda2                               partition       2097148 157800  -1
/dev/sdg3                               partition       2097148 0       -2
[root@ravi dir1]# fdisk -l /dev/sdg

Disk /dev/sdg: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xc909817c

   Device Boot      Start         End      Blocks   Id  System
/dev/sdg1            2048     4196351     2097152   83  Linux
/dev/sdg2         4196352     8390655     2097152   83  Linux
/dev/sdg3         8390656    12584959     2097152   82  Linux swap / Solaris
/dev/sdg4        12584960    20971519     4193280    5  Extended
/dev/sdg5        12587008    16781311     2097152   8e  Linux LVM
/dev/sdg6        16783360    20971519     2094080   8e  Linux LVM
[root@ravi dir1]# pvcreate /dev/sdg5 /dev/sdg6
  Physical volume "/dev/sdg5" successfully created
  Physical volume "/dev/sdg6" successfully created
[root@ravi dir1]# pvs
  PV         VG   Fmt  Attr PSize PFree
  /dev/sdg5       lvm2 ---  2.00g 2.00g
  /dev/sdg6       lvm2 ---  2.00g 2.00g
[root@ravi dir1]# vgcreate datavg /dev/sdg5 /dev/sdg6
  Volume group "datavg" successfully created
[root@ravi dir1]# vgs
  VG     #PV #LV #SN Attr   VSize VFree
  datavg   2   0   0 wz--n- 3.99g 3.99g
[root@ravi dir1]# lvcreate -L 3G -n datalv datavg
  Logical volume "datalv" created.
[root@ravi dir1]# vgs
  VG     #PV #LV #SN Attr   VSize VFree
  datavg   2   1   0 wz--n- 3.99g 1016.00m
[root@ravi dir1]# lvs
  LV     VG     Attr       LSize Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  datalv datavg -wi-a----- 3.00g
[root@ravi dir1]# lvscan
  ACTIVE            '/dev/datavg/datalv' [3.00 GiB] inherit
[root@ravi dir1]# vgdisplay
  --- Volume group ---
  VG Name               datavg
  System ID
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  2
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               0
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               3.99 GiB
  PE Size               4.00 MiB
  Total PE              1022
  Alloc PE / Size       768 / 3.00 GiB
  Free  PE / Size       254 / 1016.00 MiB
  VG UUID               NbgPTf-ro5p-O6zC-b97G-TSso-B22A-3fHY4p

[root@ravi dir1]# lvcreate -l 150 -n 150pe datavg
  Logical volume "150pe" created.
[root@ravi dir1]# lvs
  LV     VG     Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  150pe  datavg -wi-a----- 600.00m
  datalv datavg -wi-a-----   3.00g
[root@ravi dir1]# vgdisplay
  --- Volume group ---
  VG Name               datavg
  System ID
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  3
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               0
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               3.99 GiB
  PE Size               4.00 MiB
  Total PE              1022
  Alloc PE / Size       918 / 3.59 GiB
  Free  PE / Size       104 / 416.00 MiB
  VG UUID               NbgPTf-ro5p-O6zC-b97G-TSso-B22A-3fHY4p

[root@ravi dir1]# lvscan
  ACTIVE            '/dev/datavg/datalv' [3.00 GiB] inherit
  ACTIVE            '/dev/datavg/150pe' [600.00 MiB] inherit
[root@ravi dir1]# mkfs.xfs /dev/datavg/datalv
meta-data=/dev/datavg/datalv     isize=256    agcount=4, agsize=196608 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0        finobt=0
data     =                       bsize=4096   blocks=786432, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =internal log           bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
[root@ravi dir1]# mkfs.ext4 /dev/datavg/150pe
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
38400 inodes, 153600 blocks
7680 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=157286400
5 block groups
32768 blocks per group, 32768 fragments per group
7680 inodes per group
Superblock backups stored on blocks:
        32768, 98304

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

[root@ravi dir1]# lvscan
  ACTIVE            '/dev/datavg/datalv' [3.00 GiB] inherit
  ACTIVE            '/dev/datavg/150pe' [600.00 MiB] inherit
[root@ravi dir1]# vi /etc/fstab
[root@ravi dir1]# blkid /dev/datavg/150pe
/dev/datavg/150pe: UUID="74e93c18-1ff4-4428-99ab-d06769f70129" TYPE="ext4"
[root@ravi dir1]# vi /etc/fstab
[root@ravi dir1]# cat /etc/fstab

#
# /etc/fstab
#
# 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=fde35b35-5e2e-4a4a-b5ac-c482d939ae7e /                       xfs     defaults        0 0
UUID=938a60d0-04fc-4b31-b485-30cdc3c76483 /boot                   xfs     defaults        0 0
UUID=6ba14cc4-4351-46d1-9410-9d1708d1c359 swap                    swap    defaults        0 0
UUID="1e237efb-f3ed-4e73-b56b-a504543020b6" /opt/dir1   ext4    defaults        0 0
UUID="0147d214-11f9-4090-929e-38cada157a03"     /opt/oracle     xfs     defaults 0 0
UUID="fcb172ef-1e2e-454d-9335-e29327812875"     /opt/agrima     ext4    defaults 0 0
UUID="997c851c-190c-4c57-95b3-f5f9aba98e79"     /opt/swostika   ext4    defaults 0 0
UUID=0359be0e-efa5-4483-8f53-05a57f2eb574       swap    swap    defaults        0 0
#
/dev/datavg/datalv      /opt/myxfs      xfs     defaults        0 0
UUID="74e93c18-1ff4-4428-99ab-d06769f70129"     /opt/myext4     ext4    defaults        0 0
[root@ravi dir1]# mount -a
mount: mount point /opt/myxfs does not exist
mount: mount point /opt/myext4 does not exist
[root@ravi dir1]# mkdir /opt/myxfs /opt/myext4
[root@ravi dir1]# mount -a
[root@ravi dir1]# df -h
Filesystem                 Size  Used Avail Use% Mounted on
/dev/sda3                   18G  4.5G   14G  26% /
devtmpfs                   482M     0  482M   0% /dev
tmpfs                      490M  184K  490M   1% /dev/shm
tmpfs                      490M  7.2M  483M   2% /run
tmpfs                      490M     0  490M   0% /sys/fs/cgroup
/dev/sda1                  297M  111M  187M  38% /boot
192.168.10.8:/opt/myshare   20G   16G  4.8G  77% /opt/share
/dev/sdf1                  2.0G  6.0M  1.8G   1% /opt/dir1
/dev/sdf2                  2.0G   33M  2.0G   2% /opt/oracle
/dev/sdg1                  2.0G  6.0M  1.8G   1% /opt/agrima
/dev/sdg2                  2.0G  6.0M  1.8G   1% /opt/swostika
/dev/mapper/datavg-datalv  3.0G   33M  3.0G   2% /opt/myxfs
/dev/mapper/datavg-150pe   575M  912K  532M   1% /opt/myext4
[root@ravi dir1]# cat /proc/swaps
Filename                                Type            Size    Used    Priority
/dev/sda2                               partition       2097148 162656  -1
/dev/sdg3                               partition       2097148 0       -2
[root@ravi dir1]# umount /opt/myext4
[root@ravi dir1]# df -h /opt/myext4
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda3        18G  4.5G   14G  26% /
[root@ravi dir1]# vi /etc/fstab
[root@ravi dir1]# lvremove /dev/mapper/datavg-150pe^C
[root@ravi dir1]# lvscan
  ACTIVE            '/dev/datavg/datalv' [3.00 GiB] inherit
  ACTIVE            '/dev/datavg/150pe' [600.00 MiB] inherit
[root@ravi dir1]# lvremove /dev/datavg/150pe
Do you really want to remove active logical volume 150pe? [y/n]: y
  Logical volume "150pe" successfully removed
[root@ravi dir1]# lvs
  LV     VG     Attr       LSize Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  datalv datavg -wi-ao---- 3.00g
[root@ravi dir1]# vgremove datavg ^C
[root@ravi dir1]# pvs
  PV         VG     Fmt  Attr PSize PFree
  /dev/sdg5  datavg lvm2 a--  2.00g       0
  /dev/sdg6  datavg lvm2 a--  2.00g 1016.00m
[root@ravi dir1]# pvremove df -h
  pvremove: Remove LVM label(s) from physical volume(s)

pvremove
        [--commandprofile ProfileName]
        [-d|--debug]
        [-f[f]|--force [--force]]
        [-h|-?|--help]
        [-t|--test]
        [-v|--verbose]
        [--version]
        [-y|--yes]
        PhysicalVolume [PhysicalVolume...]

[root@ravi dir1]# df -h
Filesystem                 Size  Used Avail Use% Mounted on
/dev/sda3                   18G  4.7G   14G  27% /
devtmpfs                   482M     0  482M   0% /dev
tmpfs                      490M  184K  490M   1% /dev/shm
tmpfs                      490M  7.2M  483M   2% /run
tmpfs                      490M     0  490M   0% /sys/fs/cgroup
/dev/sda1                  297M  111M  187M  38% /boot
192.168.10.8:/opt/myshare   20G   16G  4.8G  77% /opt/share
/dev/sdf1                  2.0G  6.0M  1.8G   1% /opt/dir1
/dev/sdf2                  2.0G   33M  2.0G   2% /opt/oracle
/dev/sdg1                  2.0G  6.0M  1.8G   1% /opt/agrima
/dev/sdg2                  2.0G  6.0M  1.8G   1% /opt/swostika
/dev/mapper/datavg-datalv  3.0G   33M  3.0G   2% /opt/myxfs
[root@ravi dir1]# vgdisplay datavg
  --- Volume group ---
  VG Name               datavg
  System ID
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               3.99 GiB
  PE Size               4.00 MiB
  Total PE              1022
  Alloc PE / Size       768 / 3.00 GiB
  Free  PE / Size       254 / 1016.00 MiB
  VG UUID               NbgPTf-ro5p-O6zC-b97G-TSso-B22A-3fHY4p

[root@ravi dir1]# df -h
Filesystem                 Size  Used Avail Use% Mounted on
/dev/sda3                   18G  4.7G   14G  27% /
devtmpfs                   482M     0  482M   0% /dev
tmpfs                      490M  184K  490M   1% /dev/shm
tmpfs                      490M  7.2M  483M   2% /run
tmpfs                      490M     0  490M   0% /sys/fs/cgroup
/dev/sda1                  297M  111M  187M  38% /boot
192.168.10.8:/opt/myshare   20G   16G  4.8G  77% /opt/share
/dev/sdf1                  2.0G  6.0M  1.8G   1% /opt/dir1
/dev/sdf2                  2.0G   33M  2.0G   2% /opt/oracle
/dev/sdg1                  2.0G  6.0M  1.8G   1% /opt/agrima
/dev/sdg2                  2.0G  6.0M  1.8G   1% /opt/swostika
/dev/mapper/datavg-datalv  3.0G   33M  3.0G   2% /opt/myxfs
[root@ravi dir1]# lvextend -l +50%Free /dev/mapper/datavg-datalv
  Size of logical volume datavg/datalv changed from 3.00 GiB (768 extents) to 3.50 GiB (895 extents).
  Logical volume datalv successfully resized
[root@ravi dir1]# df -h /opt/myxfs
Filesystem                 Size  Used Avail Use% Mounted on
/dev/mapper/datavg-datalv  3.0G   33M  3.0G   2% /opt/myxfs
[root@ravi dir1]# lvscan
  ACTIVE            '/dev/datavg/datalv' [3.50 GiB] inherit
[root@ravi dir1]# grep datalv /etc/fstab
/dev/datavg/datalv      /opt/myxfs      xfs     defaults        0 0
[root@ravi dir1]# xfs_growfs /opt/myxfs^C
[root@ravi dir1]# df -h /opt/myxfs
Filesystem                 Size  Used Avail Use% Mounted on
/dev/mapper/datavg-datalv  3.0G   33M  3.0G   2% /opt/myxfs
[root@ravi dir1]# xfs_growfs /opt/myxfs
meta-data=/dev/mapper/datavg-datalv isize=256    agcount=4, agsize=196608 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0        finobt=0
data     =                       bsize=4096   blocks=786432, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =internal               bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 786432 to 916480
[root@ravi dir1]# df -h /opt/myxfs
Filesystem                 Size  Used Avail Use% Mounted on
/dev/mapper/datavg-datalv  3.5G   33M  3.5G   1% /opt/myxfs
[root@ravi dir1]# mkfs.
mkfs.btrfs   mkfs.ext2    mkfs.ext4    mkfs.minix   mkfs.vfat
mkfs.cramfs  mkfs.ext3    mkfs.fat     mkfs.msdos   mkfs.xfs
[root@ravi dir1]# mkfs.

Friday, May 13, 2016

RHEL7 - Autofs (nfs-client)


nfs server/autofs

Now, go to your LDAP server and configure nfs server as well

1. installl package


[root@sam migrationtools]# yum install nfs-utils

[root@sam migrationtools]# rpm -q nfs-utils
nfs-utils-1.3.0-0.21.el7.x86_64


[root@sam migrationtools]# vi /etc/exports
/opt/RHEL7.2    *(ro)
/home   *(rw,sync)
[root@sam migrationtools]#

[root@sam migrationtools]# systemctl reload nfs-server
[root@sam migrationtools]# exportfs
/opt/RHEL7.2    <world>
/home           <world>
[root@sam migrationtools]#

note: If you have problem starting nfs server, please check rpcbind service

Once you restarted, add it into firewall to enable. My case, firewall is disable

[root@sam migrationtools]# firewall-cmd --permanent --add-service nfs
FirewallD is not running
[root@sam migrationtools]# firewall-cmd --reload

verify your export

[root@sam migrationtools]# showmount -e localhost
Export list for localhost:
/home        *
/opt/RHEL7.2 *
[root@sam migrationtools]#


Now, your nfs server is configured


Configure nfs client

Go to client machine and check the packages

[root@localhost tmp]# rpm -qa | egrep "nfs-utils|autofs"
[root@localhost tmp]# yum install nfs-utils autofs



[root@localhost tmp]# vi /etc/auto.master
[root@localhost tmp]# vi /etc/auto.autofs


[root@localhost tmp]# cat /etc/auto.master
/home   /etc/auto.autofs --timeout=600

note: timeout value is optional


[root@localhost tmp]# cat /etc/auto.autofs
*       sam:/home/&
[root@localhost tmp]#



[root@localhost tmp]# systemctl enable autofs
Created symlink from /etc/systemd/system/multi-user.target.wants/autofs.service to /usr/lib/systemd/system/autofs.service.
[root@localhost tmp]# systemctl start autofs
[root@localhost tmp]#


edit /etc/ssh/ssh_config file and enable gss

[root@localhost tmp]# vi /etc/ssh/ssh_config

   GSSAPIAuthentication yes
   GSSAPIDelegateCredentials yes


Also verify if GSSAPIAuthentication is set to yes on server

[root@localhost tmp]# vi /etc/ssh/sshd_config
GSSAPIAuthentication yes

restart sshd
[root@localhost tmp]# systemctl reload sshd




[root@localhost home]# ssh ldapuser1@suvi
The authenticity of host 'suvi (192.168.10.20)' can't be established.
ECDSA key fingerprint is 24:5b:42:2e:96:0b:c9:1d:2a:e7:a3:5f:a9:fe:43:ca.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'suvi,192.168.10.20' (ECDSA) to the list of known hosts.
ldapuser1@suvi's password:
[ldapuser1@localhost ~]$ pwd
/home/ldapuser1
[ldapuser1@localhost ~]$ ls
[ldapuser1@localhost ~]$

[ldapuser1@localhost ~]$ df -h .
Filesystem           Size  Used Avail Use% Mounted on
sam:/home/ldapuser1   20G   16G  4.8G  77% /home/ldapuser1
[ldapuser1@localhost ~]$  mount | grep ldap
sam:/home/ldapuser1 on /home/ldapuser1 type nfs4 (rw,relatime,vers=4.0,rsize=524288,wsize=524288,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=192.168.10.20,local_lock=none,addr=192.168.10.8)
[ldapuser1@localhost ~]$



[ldapuser1@localhost ~]$ id ldapuser1
uid=1002(ldapuser1) gid=1002(ldapuser1) groups=1002(ldapuser1)
[ldapuser1@localhost ~]$ getent passwd | grep ldapuser2
ldapuser2:x:1003:1003:ldapuser2:/home/ldapuser2:/bin/bash
[ldapuser1@localhost ~]$


[ldapuser1@localhost ~]$ klist
Ticket cache: KEYRING:persistent:1002:krb_ccache_hbxE3HZ
Default principal: ldapuser1@EXPANOR.LOCAL

Valid starting       Expires              Service principal
05/13/2016 00:28:47  05/14/2016 00:28:47  krbtgt/EXPANOR.LOCAL@EXPANOR.LOCAL
[ldapuser1@localhost ~]$



Configured using following video below. Working perfect
https://www.youtube.com/watch?v=yS5mLBh-yGo









RHEL7 - LDAP client configuration

RHEL7 - LDAP client configuration

[root@localhost tmp]# id ldapuser1
id: ldapuser1: no such user
[root@localhost tmp]#


Install nss-pam-ldap

[root@localhost tmp]# yum install nss-pam-ldap


[root@localhost tmp]# authconfig-tui

Authentication configuration menu pops up.

On LDAP setting menu, enter the following info.
Do not select use TLS
Server: ldap://expanor.local
Base DN: dc=expanor, DC=local

Press next and enter the following info at the Kerberos setting menu

Realm: EXPANOR.LOCAL
KDC: sam.expanor.local
Admin Server: sam.expanor.local
and check [*] Use DNS to resolve hosts to realms


check nsswitch.conf file
[root@localhost tmp]# vi /etc/nsswitch.conf

passwd:     files sss ldap

wq!


Look for your ldap user that you imported to LDAP server
[root@localhost tmp]# grep ldapu /etc/passwd

no result

Now, server on LDAP database

[root@localhost tmp]# getent passwd ldapuser1
ldapuser1:x:1002:1002:ldapuser1:/home/ldapuser1:/bin/bash
[root@localhost tmp]# getent passwd ldapuser2
ldapuser2:x:1003:1003:ldapuser2:/home/ldapuser2:/bin/bash
[root@localhost tmp]#

if you don't get return result, you might have mistake somewhere.