Thursday 23 July 2015

3. Redhat Linux : RHCE 6

3. Redhat Linux : RHCE 6

 
 
Giving sudo privilage to users:
------------------------------
1. edit /etc/sudoers using 'visudo -f /etc/sudoers' command
 Line 21 : User_Alias GROUP_NAME = User_name1, User_name2, ...
 Line 37 : Cmnd_Alias CMD = /usr/sbin/command, ...
 Line 38 : GROUP_NAME ALL = CMD
* By doing this, the users in the group will get the previlage to do the specified commands.

2. edit /etc/sudoers using 'visudo -f /etc/sudoers' command
 add '%groupname ALL=(ALL) ALL'
* This will give complete root permission for all the group members.

Filesystem:
----------
* ext4 is used rhel6
* IDE will be listed as /dev/hda
* Other devoces like sata, ata, scsi will be listed as /dev/sda
* FS types:
 Disk based : ext4, NTFS
 Pseuodo based : swap
 Network based : NFS

* IBM PC Rule:
 Only 4 primary partitions are possible in any harddsiks.
 So first 3 will be as primary and next will be made extended for more number of partitions.
 Extended partitons can be from sda5-sda15
 These are called as logical partitions

* Partition IDs:
 Swap  : 82
 Extended : 83
 LVM  : 8e

* fields in /etc/fstab:
 /dev/sdb5(device) mountpoint(/mnt)  filesystem_type(ext4)  user_permissions(defaults)  dump(0,1)  fsck(0,1)
* update these for permenant mounting

eg:- Delete swap area and resize it

1. fdisk /dev/sda
 p
 d
  'n'
 w
 n
  default starting cylinder
  +3G
 w
2. fdisk /dev/sdx
 t
  'n'
 82
 w
3. mkswap /dev/sdx
4. vim /etc/fstab
 add : /dev/sdax               swap                    swap    defaults        0 0

5. partprobe /dev/sdx
6. reboot

Encrypting the harddisk with LUKS:
---------------------------------
* Linux Unified Key Setup is to setup password security for harddisk drives.
* edit in /etc/crypttab
 name /dev/sdx
* edit in /etc/fstab(not sure, trainer not explained)
* cryptsetup luksOpen dev/sdx name
* cryptsetup luksClose name

# /* MAKE THE PARTITION IN LINUX LVM FORMAT */

      Logical Volume Manager
      ----------------------

* flexible storage
* hard disks form physical volumes which forms Volume groups which can create logical volumes
* max no of PVs possible is 256 to form a VG
* max no of LVs from a VG is 256

1. Creating a Physical Volume:
-----------------------------
* create some free partitons, say /dev/sdax, /dev/sday
* make the partition types as Linux LVM(8e)
 fdisk /dev/sdx
 select the partition
 type 't'
 type '8e'
 Do it for all PV partitions
* pvcreate /dev/sdax /dev/sday ....

2. Creating a Volume group:
--------------------------
* vgcreate vg_name /dev/sdax /dev/sday ....
* vgdisplay vg_name
* vgcreate -s 8 vg_name /dev/sdx /*Create a VG with PE=8M(Physical Extend or Physical Partition)*/

3. Extending a VG:
-----------------
* pvcreate /dev/sdax /*Create a new Linux LVM partition(PV) to add to vg*/
* vgextend vg_name /dev/sdax

4. Creating a Logical Volume:
----------------------------
* lvcreate -n lv_name -l 20 vg_name
* lvdisplay /dev/vg_name/lv_name
* mkfs.ext4 /dev/vg_name/lv_name
* mount /dev/vg_name/lv_name /mount_point

5. Extending an LV:
------------------
* lvextend -L +100M /dev/vg_name/lv_name
* lvextend -l +5 /dev/vg_name/lv_name
* resize2fs -p /dev/vg_name/lv_name

6. Reducing an LV:
------------------
* umount /mount_point
* e2fsck -f /dev/vg_name/lv_name
* resize2fs -p /dev/vg_name/lv_name 'n'M
* lvreduce -l -10 /dev/vg_name/lv_name

7. Reducing a VG:
----------------
* vgreduce vg_name /dev/sdax /*Remove a PV from VG*/

8. Removing LV:
--------------
* lvremove /dev/vg_name/lv_name

9. Removing VG:
--------------
* vgremove vg_name

10. Removing PV:
---------------
* pvremove /dev/sdx /dev/sdy /dev/sdz

11. To list PV, VG and LV:
-------------------------
* pvs
* vgs
* lvs


/*
Commands for the day:
--------------------

* free -m   : to see the free spaces in swap
* mkswap /dev/sdax : to create swap
* swapon /dev/sdax : mount swap temporarily
* swapoff /dev/sdax : unmount swap
* fdisk /dev/sda : to edit partitons
* partprobe /dev/sda : command for re-reading the partition table
* lvremove /dev/VG1/LV1 
* df -hT
* vgremove VG1
* pvremove /dev/sda7 /dev/sda8 /dev/sda9
* pvs
* vgs
* lvs
*/

No comments:

Post a Comment