Wednesday, 15 August 2018

mounting ntfs on mac

Mounting ntfs on Mac


$ df -ah
Filesystem      Size   Used  Avail Capacity  iused    ifree %iused  Mounted on
/dev/disk1     233Gi  228Gi  4.1Gi    99% 59886590  1061888   98%   /
devfs          186Ki  186Ki    0Bi   100%      642        0  100%   /dev
map -hosts       0Bi    0Bi    0Bi   100%        0        0  100%   /net
map auto_home    0Bi    0Bi    0Bi   100%        0        0  100%   /home

/dev/disk2s1   932Gi  908Gi   23Gi    98%   111606 25128162    0%   /Volumes/Expansion Drive


$ sudo umount /Volumes/Expansion\ Drive/

$ sudo mkdir /usbNTFS/

$ sudo mount -t ntfs -o rw,auto,nobrowse /dev/disk2s1 /usbNTFS/ 
# Note: With my current testing, we need to have no browse options also to have write access.

$ cd /usbNTFS/


$ open . 

Friday, 23 March 2018

knowing hosts type and understanding flags

knowing hosts type and understanding flags


For sure, learning from internet, but trying to make it over here, so my search will be less sometime :)

Links:

https://en.wikipedia.org/wiki/CPUID#EAX.3D1:_Processor_Info_and_Feature_Bits

To know if the OS is running on VM or Bare Metal:


# grep for "hypervisor" in /proc/cpuinfo

# grep hypervisor /proc/cpuinfo
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss ht syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts nopl xtopology tsc_reliable nonstop_tsc aperfmperf pni pclmulqdq ssse3 cx16 sse4_1 sse4_2 popcnt aes xsave avx hypervisor lahf_lm ida arat epb pln pts dtherm


https://unix.stackexchange.com/questions/43539/what-do-the-flags-in-proc-cpuinfo-mean

  • 64-bit (x86_64/AMD64/Intel64)? lm
  • Hardware virtualization (VMX/AMD-V)? vmx (Intel), svm (AMD)
  • Accelerated AES (AES-NI)? aes
  • TXT (TPM)? smx
  • a hypervisor (announced as such)? hypervisor
Most of the other features are only of interest to compiler or kernel authors.

The full listing is in the kernel source, in the file arch/x86/include/asm/cpufeatures.h.

Intel-defined CPU features, CPUID level 0x00000001 (edx)



Tuesday, 4 April 2017

internetworking with virtualbox - draft


External Link:








vboxmanage dhcpserver add --netname testlab --ip 10.10.10.1 --netmask 255.255.255.0 --lowerip 10.10.10.2 --upperip 10.10.10.12 --enable


[or]

You can also do internetworking with hosts only and select the host to the same network interface and that also works.

This you can check from vagrant:

example:


You can see in the above screen-shot the Adapter2: is (Host-only Adapter, vboxnet0)




mkdir ~/.ssh; cd ~/.ssh; echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCTI1Zljwk2ILNFgNU8GvfLejsOg3P/JCo1sq4Xc8C7cTvqSc1ihQXUJugH1RrH7mx1DoURPNsj4QcHeJy6QTUf8G1+4AICQ3yZ65mJNcWv8nTNSd7KGhDilcDIAbL+zXg5psOE7nS7cXlgoN+DAugk52yTF6G/cHKXLJ2FeUayUXPFu2bXHcS6kj6VIluFB3eiyuH+QdE+nard0thsxQrlUAvC55cZQ4y0BGtBg+06he9pfP/L/tnUly51hCCP31jUrxAA5JgdmMvHTe2RhBniEZ1HUlsIpapOMkA06oUaT38Pw7b0QNRovXaVksX3mYpDZwejtkX8dwhUV7/RpdlR /Users/amund/.ssh/vm" > authorized_keys




Host chef
        Hostname localhost
        User root
        port 1717
        IdentityFile ~/.ssh/vm

Host cluster1
        Hostname localhost
        User root
        port 43221
        IdentityFile ~/.ssh/vm

Host cluster2
        Hostname localhost
        User root
        port 43222
        IdentityFile ~/.ssh/vm

Host cluster3
        Hostname localhost
        User root
        port 43223
        IdentityFile ~/.ssh/vm





Configuring NTP server:

sudo apt-get install -y ntpdate
ntpdate -s ntp.ubuntu.com  [ to sync with ntp.ubuntu.com ]

sudo apt-get install ntp



Error: sudo: unable to resolve host [if you update the hostname, update at /etc/hostname and also at /etc/hosts:]

example:
127.0.0.1    localhost.localdomain localhost
127.0.1.1    cluster1



Not getting both the network card activated: in ubuntu 16.04 server

# Find the disabled network card logical name: 
sudo lshw -C network  [ or ] ifconfig -a

# Enable the disabled network card. [ example: enp0s8 or enp0s3 ]
sudo ifconfig enp0s8 up

# sudo vi /etc/network/interfaces [ make dhcp enable ]
auto enp0s3
iface enp0s3 inet dhcp

#you might try to give static ipaddress and check if its still able to connect to the network:
# based on the interface you have crated.
# after setting the default gw to 10.0.3.2 internet working.
# route add default gw 10.0.3.2

[or] try:
auto enp0s8
iface enp0s8 inet static
address 10.10.10.2
netmask 255.255.255.0
#network 10.10.10.0
#broadcast 10.10.10.255
gateway 10.10.10.0
#dns-nameservers 192.168.1.1

# if needed you might need to start networking service:
sudo /etc/init.d/networking restart



10.0.3.2 v-box default gateway
now update the default route:
route add default gw 10.0.3.2
[or]
route add default gw 10.0.2.2



Increase disk space size:

VBoxManage modifyhd "/Users/amund/VirtualBox VMs/U3/U3-disk1.vdi" --resize 10240
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%

In the above example I have resize the disk space from 8GB to 10GB.

NOTE: But later we need to upgrade the lvm size, with in the host.

You might need to do the following 2 times, because in the first time you might not get the total newly added free space from “VBoxManager” command:

# Note: You need to extend the original vdi disk file.

#fdisk -l [ do check your disk name and the newly allocated disk space: ]
Disk /dev/sda: 20 GiB, 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
Disklabel type: dos
Disk identifier: 0x23583428

#fdisk /dev/sda

Command (m for help): n
Partition type
   p   primary (1 primary, 1 extended, 2 free)
   l   logical (numbered from 5)
Select (default p): 

# Note: in the above output you see “2 free” , that’s why we have to 2 times :) [ for the following 3 and 4 ], but not which is the bigger one and add the same.

Created a new partition 4 of type 'Linux' and of size 1023 KiB.
 4 (partition number, since 1st and 2nd partition already exists, 3 is a small free space I am seeing)
 select default first available cylinder to the default last cylinder. [ which is enter and enter ]

 p (primary)
Partition number (3,4, default 3): 4
First sector (999424-41943039, default 999424): 
Last sector, +sectors or +size{K,M,G,T,P} (999424-1001469, default 1001469): 

Command (m for help): n
Partition type
   p   primary (2 primary, 1 extended, 1 free)
   l   logical (numbered from 5)
Select (default p): p

Selected partition 3
First sector (16775168-41943039, default 16775168): 
Last sector, +sectors or +size{K,M,G,T,P} (16775168-41943039, default 41943039): 

Created a new partition 3 of type 'Linux' and of size 12 GiB.

NOTE: see, now you got the bigger space. [ don’t get confuse with one for 10GB and another is 20 GB example. I am retrying the same. and making both the note at the same place for now] NOTE: Later do a good note.]



Command (m for help): t
Partition number (1-5, default 5): 4
Partition type (type L to list all types): 8e

Changed type of partition 'Linux' to 'Linux LVM'.

Command (m for help): t
Partition number (1-5, default 5): 3
Partition type (type L to list all types): 8e

Changed type of partition 'Linux' to 'Linux LVM'.

Command (m for help): p
Disk /dev/sda: 20 GiB, 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
Disklabel type: dos
Disk identifier: 0x23583428

Device     Boot    Start      End  Sectors  Size Id Type
/dev/sda1  *        2048   999423   997376  487M 83 Linux
/dev/sda2        1001470 16775167 15773698  7.5G  5 Extended
/dev/sda3       16775168 41943039 25167872   12G 8e Linux LVM
/dev/sda4         999424  1001469     2046 1023K 8e Linux LVM
/dev/sda5        1001472 16775167 15773696  7.5G 8e Linux LVM

Partition table entries are not in disk order.

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Re-reading the partition table failed.: 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).




# Now reboot:
reboot
NOTE: Once you have the new partition display:


pvcreate /dev/sda3 [I believe this will be your new big free disk space]
  Physical volume "/dev/sda3" successfully created


pvdisplay 
  --- Physical volume ---
  PV Name               /dev/sda5
  VG Name               ubuntu-vg
  PV Size               7.52 GiB / not usable 2.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              1925
  Free PE               0
  Allocated PE          1925
  PV UUID               Ij2DKd-oz25-e0so-8kks-A8FA-h9q7-KnfVuO

  "/dev/sda3" is a new physical volume of "12.00 GiB"
  --- NEW Physical volume ---
  PV Name               /dev/sda3
  VG Name               
  PV Size               12.00 GiB
  Allocatable           NO
  PE Size               0   
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               ygiiU9-kbTh-Xqw2-nWqC-SMZz-dZxL-G8q6Bb




# # vgdisplay  # [Before]
  --- Volume group ---
  VG Name               ubuntu-vg
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  3
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               7.52 GiB
  PE Size               4.00 MiB
  Total PE              1925
  Alloc PE / Size       1925 / 7.52 GiB
  Free  PE / Size       0 / 0   
  VG UUID               GpeiBN-Zvdo-1wtr-KhDm-IYUz-2ffo-TSs88f


# Now add new physical volume to the volume group.
vgextend ubuntu-vg /dev/sda3
  Volume group "ubuntu-vg" successfully extended

# vgdisplay #[display again]
  --- Volume group ---
  VG Name               ubuntu-vg
  System ID           
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               19.52 GiB  PE Size               4.00 MiB
  Total PE              4997
  Alloc PE / Size       1925 / 7.52 GiB
  Free  PE / Size       3072 / 12.00 GiB
  VG UUID               GpeiBN-Zvdo-1wtr-KhDm-IYUz-2ffo-TSs88f


#Have the Logical Volume (within the Volume Group) overtake the remaining free space of the Volume Group:
lvextend -l +100%FREE /dev/ubuntu-vg/root

output:  
Size of logical volume ubuntu-vg/root changed from 6.77 GiB (1733 extents) to 18.77 GiB (4805 extents).
  Logical volume root successfully resized.



# vgdisplay  [ again ]
  --- Volume group ---
  VG Name               ubuntu-vg
  System ID             
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  5
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               19.52 GiB
  PE Size               4.00 MiB
  Total PE              4997
  Alloc PE / Size       4997 / 19.52 GiB
  Free  PE / Size       0 / 0   
  VG UUID               GpeiBN-Zvdo-1wtr-KhDm-IYUz-2ffo-TSs88f


#
# resize2fs -p /dev/mapper/ubuntu--vg-root
resize2fs 1.42.13 (17-May-2015)
Filesystem at /dev/mapper/ubuntu--vg-root is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 2
The filesystem on /dev/mapper/ubuntu--vg-root is now 4920320 (4k) blocks long.



# Here you have the new allocated disk space:

# df -h /
Filesystem                   Size  Used Avail Use% Mounted on
/dev/mapper/ubuntu--vg-root   19G  1.3G   17G   8% /








umount /ghostcache 

fdisk /dev/sdd   # -> for each disk that is not the /

p   # -> for printing the current partition
d   # -> for deleting the partition 
w # -> for writing the changes.

pvcreate /dev/sda /dev/sdb /dev/sdc /dev/sdd /dev/sde /dev/sdf /dev/sdg /dev/sdh /dev/sdi /dev/sdj /dev/sdk /dev/sdl /dev/sdm /dev/sdn /dev/sdo /dev/sdp /dev/sdr

vgcreate SplunkVG /dev/sda /dev/sdb /dev/sdc /dev/sdd /dev/sde /dev/sdf /dev/sdg /dev/sdh /dev/sdi /dev/sdj /dev/sdk /dev/sdl /dev/sdm /dev/sdn /dev/sdo /dev/sdp /dev/sdr

lvcreate -L 29T -n ghostcache SplunkVG

mkfs.ext4 /dev/mapper/SplunkVG-ghostcache
Update /etc/fstab , comment out /ghostcache entry
# reboot
update the /etc/fstab again:
/dev/mapper/SplunkVG-ghostcache                   /ghostcache    ext4    noatime    1    4

# create a test file under /ghostcache and reboot the host and check if the host is back online.


# cat addkey 
ssh-agent -s > key
source key
ssh-add ~/.ssh/vm





# tail -3 .bashrc
route add default gw 10.0.2.2
source addkey
export PATH="/root:$PATH"



# cat /etc/hosts
127.0.0.1    localhost
127.0.1.1    u2

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

10.10.10.2 u2
10.10.10.3 u3
10.10.10.4 u4
10.10.10.5 u5
10.10.10.6 u6



# cat /etc/hostname 
u2



# cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto enp0s3
iface enp0s3 inet dhcp

auto enp0s8
#iface enp0s8 inet dhcp
iface enp0s8 inet static
address 10.10.10.2
netmask 255.255.255.0
#network 10.10.10.0
#broadcast 10.10.10.255
gateway 10.10.10.1
#dns-nameservers 192.168.1.1



# ifconfig 
enp0s3    Link encap:Ethernet  HWaddr 08:00:27:13:65:41  
          inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe13:6541/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1252 errors:0 dropped:0 overruns:0 frame:0
          TX packets:947 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:89627 (89.6 KB)  TX bytes:120176 (120.1 KB)

enp0s8    Link encap:Ethernet  HWaddr 08:00:27:35:8f:f6  
          inet addr:10.10.10.2  Bcast:10.10.10.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe35:8ff6/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:6 errors:0 dropped:0 overruns:0 frame:0
          TX packets:20 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:360 (360.0 B)  TX bytes:1548 (1.5 KB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:168 errors:0 dropped:0 overruns:0 frame:0
          TX packets:168 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1 
          RX bytes:12240 (12.2 KB)  TX bytes:12240 (12.2 KB)







Thursday, 29 December 2016

For Kid and on mac


cat  tellWordsWithArgs.py


#!/usr/bin/env python

import subprocess
import sys

# Example on how to use this code:
# ./tellWordsWithArgs.py I like to eat apple

command = "say"

text = sys.argv[1:]

tc = list(text)
topCharacters = list(tc)

for characters in topCharacters:
  c1 = list(characters)
  for c1 in characters:
    if c1 == " ":
      subprocess.call([command, ",,"])
    else:
      subprocess.call([command, c1])

#Changing list to string again.
text=''.join(text)
subprocess.call([command, text])

github

Github

README:

*) How to pull files from this repository?
Ans: a) Install git
b) create a directory where you want to pull these files.
c) cd into that directory
d) type: git init
e) git pull https://github.com/Amitmund/quick_tools

# Example: 
mkdir -p ~/github/amitmund/quick_tools
cd ~/github/amitmund/quick_tools [ unix quick key: cd + [esc + _ ]
# make sure you are in the above directory
# Note: You can create your won directory name, its just an example.
git init
git pull https://github.com/Amitmund/quick_tools


### For owner ###
Steps: if you want to add or edit things at this repo. [ example: adding Updating README file ]
a. vi README [ update your content.]
b. git add README
c. git commit -m “Updating README file"
d. git remote add origin https://github.com/Amitmund/quick_tools
e. git push -u origin master

# It will ask your username and password please provide the same.


# Few more Note:

$HOME/.gitconfig is your global config for git.
There are three levels of config files.

 cat $(git rev-parse --show-toplevel)/.git/config
(mentioned by bereal) is your local config, local to the repo you have cloned.

you can also type from within your repo:

git remote -v
And see if there is any remote named 'origin' listed in it.

If not, if that remote (which is created by default when cloning a repo) is missing, you can add it again:

git remote add origin url/to/your/fork

Original Link: http://stackoverflow.com/questions/15637507/fatal-origin-does-not-appear-to-be-a-git-repository


Friday, 18 November 2016

ABCD_Samvrita


This is a quick note for my following project.

https://github.com/Amitmund/ABCD_samvrita

Learn A to Z with image and audio... just for fun and for my daughter [ samvrita ]

For sound recording in mac:

say -o apple.m4a "a,p,p,l,e,apple"



Following is an example of sample code.

Tuesday, 12 April 2016

virtualbox internetworking




vboxmanage dhcpserver add --netname testlab --ip 10.10.10.1 --netmask 255.255.255.0 --lowerip 10.10.10.2 --upperip 10.10.10.12 --enable




If you see the vm image, in the network section: you will be having something like:

Intel PRO/1000 MT Desktop (Internal Network, ‘testlab’)

And in the host you will see ip as: 10.10.10.3 and something else like: 10.10.10.2 and you can ping to each other.


# What to do, to have internet even?

In the above setting, we are not able to connect to external network. But internal networking working fine. 

With NAT its working fine :) and in NAT, we can do port forwarding and to access the port what we want to access.




### And in NAT, we can do port forwarding and to access the port what we want to access.

Example:



Select Port Forwarding and can configure.





External link:

https://www.youtube.com/watch?v=lhOY-KilEeE