Saturday, 4 March 2017

Links I want to maintain

Nice Motivational Video

link to article on how to print string using assembly :
https://baptiste-wicht.com/posts/2011/11/print-strings-integers-intel-assembly.html 

Friday, 17 February 2017

Creating loop device on fedora


We can create a loop device in Linux which we can use as a virtual device for experiment. Following steps will show how to create loop device and use it for creation of file system. 

  • Add new device
 # losetup -f
/dev/loop0


  • Create a file which will serve as virtual device.


# dd if=/dev/urandom of=/bhushan bs=1M count=128
128+0 records in
128+0 records out
134217728 bytes (134 MB, 128 MiB) copied, 12.9207 s, 10.4 MB/s


  • Setup up the mapping between loop device and new file 

# losetup /dev/loop0 /bhushan



  • Use new virtual device for file system creation

# mkfs -t ext4 /dev/loop0
mke2fs 1.43.3 (04-Sep-2016)
Discarding device blocks: done                          
Creating filesystem with 131072 1k blocks and 32768 inodes
Filesystem UUID: 7be2cbaf-a2a5-4319-a7e9-51b749c69184
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729

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

# mount -t ext4 /dev/loop0 /mnt

# df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/loop0               120M  1.6M  110M   2% /mnt1

# umount /mnt1


  • Detach a file from loop device

# losetup -d /dev/loop0



Tuesday, 31 January 2017

.config changes for KGDB

Change following parameter for custom kernel development during KGDB setup :

CONFIG_STRICT_DEVMEM = n
CONFIG_KGDB_KDB = y
CONFIG_KGDB_KDB = y
CONFIG_KDB_DEFAULT_ENABLE=0x1
CONFIG_DEBUG_RODATA=n => kernel hacking => write protect kernel read only data strucuture

Reference :

https://www.kernel.org/pub/linux/kernel/people/jwessel/kdb/quickKDBkeyboard.html

http://landley.net/kdocs/Documentation/DocBook/xhtml-nochunks/kgdb.html#CompilingAKernel

https://www.kernel.org/pub/linux/kernel/people/jwessel/kdb/

Convert Fedora 25 login from command line to GUI

#dnf install @gnome-desktop
#dnf distro-sync
#dnf groupinstall gnome
#dnf groupinstall x-base
#systemctl start gdm
#systemctl set-default graphical.target

Saturday, 31 December 2016

Assignment on 32 bit and 64 bit components in Processor to Application stack





Due to back word compatibility with 32 bit component like OS , application is allowed to run on 64 bit component, but vice versa is not allowed.

Inner component can be 32 or 64 bit if outer is 32
But inner component must be 64 if outer is 64 bit
Any level of miss match will result in problem.

Not applicable for device driver. Cannot run 32 bit driver on 64 bit machine (as per backward compatibility rule).


How to check whether binary is 32bit or 64 bit?

# file <filename>
[root@localhost driver]# file a.out
a.out: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=740131a4dacce9424b1db8fc53406040406d41bd, not stripped

How to check Whether OS  is 32 or 64 bit?

#uname –a or uname -m
[root@localhost ~]$ uname -a
Linux localhost.localdomain 3.15.10-201.fc20.i686 #1 SMP Wed Aug 27 21:33:30 UTC 2014 i686 i686 i386 GNU/Linux

[root@localhost ~]$ uname -m
i686
Its 32 bit. If you have a 64-bit OS, instead of i686, you have x86_64 or ia64 in the output of uname –a.

Check machine is 32 or 64 bit:

Use grep flags /proc/cpuinfo or lscpu

[root@localhost ~]$ grep flags /proc/cpuinfo
flags                       : fpu vme de pse tsc msr mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 rdtscp constant_tsc pni monitor ssse3

If this content lm flag then it is 64 bit.

 [root@localhost ~]$ lscpu
Architecture:          i686

CPU op-mode(s):        32-bit

Friday, 30 December 2016


Machine Learning - Basics and classification

  • Machine Learning is giving ability to machines to learn/program on it own.
  • Machine learning is not restricted to Artificial Intelligence. It is having many applications in various filed, Recommendations System raging from data mining, rating system to automation of house hold activities.
  • Machine is said to be 'learning', if its performance improves with experience. 


Classification of Machine Learning (ML):
  1. Supervised ML.
  2. Unsupervised ML.
1. Supervised ML
  • Known Sample data sets are given. (Test Passed / Failed )
  • Regression : Continuous value .
  • Classification : Discrete value
2. Unsupervised ML
  • Data set don't have any label (like Passed /Failed)  
  • Just data set is given and algorithm will divide it in cluster.
  • As we are not specifying what data belong to what segment/ cluster its unsupervised learning.
  • We have to derive structure from unknown data.

Monday, 31 August 2015

File System Basics


What is File System?

File system is set of rules which help us to organise our data in efficient ways, so what we can retrieve, store and do other operations on data in efficient way.

How we store information?

Information or data on disk or any other media is stored in the form of binary i.e. 0s and 1s.we try to keep relevant Information at same place so that it can be organised nicely. We call this block of data as a file.

How file is stored on Disk?

As we discuss file is stored in disk in the form of binary. i.e. sequence of 0s and 1s.
Let’s consider a scenario we are having 3 files:
File 1 with data 101011101010
File 2 with data 111100001110
File 3 with data 000111100001

Let’s keep this data on disk:





Only keeping this binary data on disk we can’t understand where my file starts and  file ends.

Introduction to Inode:

As we have seen only keeping binary data sequentially on disk won’t allow us to understand data.so we need some way to understand which binary data belongs to which file.one way of solving this problem is, we will maintain a data structure called inode. There will be one inode per file and which will maintain information related to file. Inode can contain information like position where file staring, position where file is ending, what is size of file and so on …


Introduction to Super Block:

Like same as files, we will be having multiple Inode present in our file system scattered over our disk.so we need other centralised data structure which will maintain this file system wide information.

So to solve this problem new data structure was introduced I.e. Super block.So super block will maintain information like, how many inode file system have, what is location of those. Apart from inode ‘s information super block also maintain overall file system wide information like how much space file system have, how much space is free etc.