Posts

Showing posts from August, 2017

17 updating the kernel

[svn@svn sysctl.d]$ sudo yum update kernel Install Package You can install a package with RPM like so rpm -Uvh foo.rpm You can install a package with YUM like so: yum install foo An explanation of rpm flags: -i # Install, (will throw an error if already installed) -U # Update (or install if not present), usually preferred over -i -v # verbose -h # hash, basically just shows a pretty progress bar

17 using sysctl

[svn@svn vm]$ sysctl -a  sysctl: permission denied on key 'fs.protected_hardlinks' sysctl: permission denied on key 'fs.protected_symlinks' sysctl: permission denied on key 'kernel.cad_pid' sysctl: permission denied on key 'kernel.usermodehelper.bset' sysctl: permission denied on key 'kernel.usermodehelper.inheritable' sysctl: permission denied on key 'net.ipv4.tcp_fastopen_key' abi.vsyscall32 = 1 crypto.fips_enabled = 0 debug.exception-trace = 1 debug.kprobes-optimization = 1 dev.cdrom.autoclose = 1 =================== [svn@svn vm]$ sysctl -a | grep forward sysctl: permission denied on key 'fs.protected_hardlinks' sysctl: permission denied on key 'fs.protected_symlinks' sysctl: permission denied on key 'kernel.cad_pid' sysctl: permission denied on key 'kernel.usermodehelper.bset' sysctl: permission denied on key 'kernel.usermodehelper.inheritable' net.ipv4.conf.all.f...

17 tuning kernel behavior through /proc

in / proc there is status information about kernel and / sys subdirectory which helps to optimize kernel parameters [svn@svn proc]$ cat cpuinfo processor : 0 vendor_id : GenuineIntel cpu family : 6 model : 60 model name : Intel(R) Core(TM) i5-4200M CPU @ 2.50GHz stepping : 3 microcode : 0x10 cpu MHz : 2493.758 cache size : 3072 KB [svn@svn proc]$ cat partitions  major minor  #blocks  name    8       16    5242880 sdb    8       17     102400 sdb1    8       18     102400 sdb2    8        0   31457280 sda    8        1    1048576 sda1    8        2   19921920 sda2   11        0    8086528 sr0  253        0   17821696 dm-0  253     ...

17 modifying kernel module behavior through modprobe

show which modules are loaded [svn@svn ~]$ lsmod Module                  Size  Used by nls_utf8               12557  1 isofs                  39844  1 fuse                   87741  3 binfmt_misc            17468  1 xt_CHECKSUM            12549  1 ipt_MASQUERADE         12678  3 nf_nat_masquerade_ipv4    13412  1 ipt_MASQUERADE tun                    27226  1 [svn@svn ~]$ lsmod | grep e100 e1000                 137544  0 show info of particular module [svn@svn ~]$ modinfo e1000 filename:       /lib/modules/3.10.0-514.el7.x86_64/kernel/drivers/net/ethernet/i...

17 working with kernel modules

lsmod - shows modules currently loaded and its dependency/size [root@localhost /]# lsmod Module                  Size  Used by ext4                  583541  1 mbcache                14958  1 ext4 jbd2                  102945  1 ext4 binfmt_misc            17468  1 vmw_vsock_vmci_transport    30577  0 vsock                  34855  3 vmw_vsock_vmci_transport snd_seq_midi           13565  0 snd_seq_midi_event     14899  1 snd_seq_midi intel_powerclamp       14419  0 coretemp               13444  0 on modern kernel versions the kernel works together with udev [root@localhost /]#...

17 managing the kernel

Image
it's the responsibility of kernel to address the hardware. udev gives information about new hardware to kernel udev  (userspace /dev) is a device manager for the  Linux kernel . As the successor of  devfsd  and hotplug, udev primarily manages  device nodes  in the  /dev  directory. At the same time, udev also handles all  user space  events raised when hardware devices are added into the system or removed from it, including  firmware  loading as required by certain devices

16 LVM shrinking lvreduce resize2fs umount/nount

[root@localhost /]# df -h Filesystem                 Size  Used Avail Use% Mounted on /dev/mapper/cl-root         17G  4.7G   13G  28% / devtmpfs                   480M     0  480M   0% /dev tmpfs                      493M   96K  493M   1% /dev/shm tmpfs                      493M   20M  473M   4% /run tmpfs                      493M     0  493M   0% /sys/fs/cgroup /dev/sda1                 1014M  188M  827M  19% /boot tmpfs                       99M   48K   99M   1% /run/user/1000 /dev/mapper/vgmyvg-l...

16 LVM growing lvs vgs fdisk /dev/sdb partprobe

FS->LV->VG->PVolume Extend operation In order to extend the file system First we need to create a new physical volume next assign PV to VG. grow LV from VG, then FS Reduce FS size vice-verse first resize FS, then LV, VG and PV ----------- [root@localhost /]# df -h Filesystem                 Size  Used Avail Use% Mounted on /dev/mapper/cl-root         17G  4.7G   13G  28% / devtmpfs                   480M     0  480M   0% /dev tmpfs                      493M   96K  493M   1% /dev/shm tmpfs                      493M   20M  473M   4% /run tmpfs                      493M     0  493M   0% /sys/fs/cgroup /dev/...

16 understanding device mapper and LVM device names lvdisplay, pvscan, pvdisplay -m

The Device-mapper is a component of the linux kernel (since version 2.6) that supports logical volume management. It is required by LVM2 and EVMS. The original LVM (included in stock 2.4 kernels) does not use it. Kernel over device mapper can communicate with LVM, LUKS, RAID kernel -> device-mapper -> LVM,LUKS, RAID kernel -> VFS(xfs, ext4) device-mapper names: /dev/dm-0 /dev/dm-1 above names could change, so we have mapper names /dev/mapper/vg-lv --->symbolic name --> /dev/dm-0...n lvdisplay - display attributes of a logical volume [root@localhost /]# lvdisplay /dev/vgmyvg/lvmylv  File descriptor 22 (socket:[27108]) leaked on lvdisplay invocation. Parent PID 3225: -bash   --- Logical volume ---   LV Path                /dev/vgmyvg/lvmylv   LV Name                lvmylv   VG Name                vgmyvg ...

16 creating LVM

to create a logic volume, you start by creating a partition [root@localhost /]# 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. Command (m for help): p Disk /dev/sdb: 4294 MB, 4294967296 bytes, 8388608 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: 0xc0ee42ab    Device Boot      Start         End      Blocks   Id  System /dev/sdb1            2048       206847       102400   83  Linux Command (m for help): # there is free space Command (m for help): n Partition type:    p   primary (1 primary, 0 extended, 3 free)    e   extended Se...

16 LVM | volume group | partition | physical volume

Image
When working with LVM, you always start with physical storage device, such as hard disk. in this example we are starting with hard disk which is sda When you work from a hard disk, typically you take a partition and mark a partition as physical volume. Physical volume next goes to volume group . Logical volumes are created from volume group . we don't care about physical volumes that are set behind. Once you created logical volume , you will get device with name /dev/vgroup/logvo l (mkfs) From volume group you can add additional volumes if there is space available. If there is no space available we can add physical volumes to the volume group