Friday, June 14, 2019

Thursday, June 6, 2019

mount sd card image on linux (dd)


Drivers in linux kernel when media is inserted create /dev entries for supported media organizations such as with sd creating /dev/sda1, etc. as well as the media dev entry /dev/sda.

With images, the loop mount has no support to break up the image into partitions, and require using the loop mount capability to find a supported file system by using offsets into the image.

These offsets are in byte counts, so knowledge of the blocksize of the original media is needed to calculate these offsets.

Also it was noted that some file systems don't support protections in the way linux does with access control in the file system, but just on the overall media.  Microsoft fat is the main culprit in that regard.  An option can be used to set the mounted media point properly for read access only or read/write.

https://askubuntu.com/questions/445979/how-to-mount-sd-card-image-created-with-dd

Mount with offset to partition

To avoid the need to create separate images for each partition or installing a utility like kpartx, you can mount each partition individually by specifying an offset in the mount command.
First examine the partitions in the image file and determine the offset by using fdisk:
$ fdisk -u -l rpi_image280914 

Disk rpi_image280914: 16.0 GB, 16012804096 bytes
255 heads, 63 sectors/track, 1946 cylinders, total 31275008 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 identifier: 0x000cdac7

           Device Boot      Start         End      Blocks   Id  System
rpi_image280914p1   *        2048      514047      256000    c  W95 FAT32 (LBA)
rpi_image280914p2          540672    31242239    15350784   83  Linux
Take the Start sector of the partition you want and multiply that value by the Units size. So if you want the second partition you'll get 540672 * 512 = 276824064.
Now create a folder and mount the partition:
mkdir rpi_partition2
sudo mount -o loop,offset=276824064 rpi_image280914 rpi_partition2/
Once you are done doing what you want with the partition data:
sudo umount rpi_partition2/
rm -r rpi_partition2/

https://www.daniweb.com/hardware-and-software/linux-and-unix/threads/22358/mounting-a-fat32-drive-in-linux

permissions for vfat.

2. Windows doesn't support UNIX-style permissions, and you can only apply permissions to the entire filesystem, not to individual Windows files/folders. This is done with the "umask" option of the mount command. In /etc/fstab, change the mount entry for your Windows partition to this:
/dev/hda6 /mnt/fat vfat users,defaults,umask=000 0 0
(the "users" option allows anyone to mount/unmount the drive and overrides the default , which is that only root is allowed to mount/unmount.)
- When issuing the mount command manually, the syntax is:
mount -t vfat -o umask=000 /dev/hda6 /mnt/fat

The value of the permission bits used with umask are the opposite of those used with the chmod command. For example, the following pairs are equivalent:
umask=000 and chmod 777
umask=022 and chmod 755

--30--

Wednesday, June 5, 2019

Raspberry Pi zero video notes




Mpeg video

MJPG Streamer

To run the camera stream from a USB webcam we'll make use of the package mjpg-streamer. Before we can install this we'll need to install a few dependencies first.
sudo apt-get update
sudo apt-get install libjpeg8-dev imagemagick libv4l-dev uvcdynctrl git cmake -y
After installing the dependencies, run the following commands to install mjpg-streamer.
git clone https://github.com/jacksonliam/mjpg-streamer.git
cd mjpg-streamer/mjpg-streamer-experimental
make USE_LIBV4L2=true clean all
sudo make install
sudo usermod -aG video pi
sudo modprobe bcm2835-v4l2
cd ../../
rm -rf mjpg-streamer
Start the camera livestream by running the following command.
mjpg_streamer -i 'input_uvc.so --device /dev/video0 --fps 30 --resolution VGA --quality 65' -o 'output_http.so'
If you followed all above instructions and everything went ok, you should now be able to see the stream when browsing to http://your-raspberry-pi.local:8080?action=stream. After you verified the stream is working, cancel by running ctrl+c and move on to the next section.

https://wouterdeschuyter.be/blog/how-to-create-a-15-dollar-web-controllable-camera-with-a-raspberry-pi-zero


--30--


Article

https://medium.com/@kevalpatel2106/monitor-the-core-temperature-of-your-raspberry-pi-3ddfdf82989f


#!/usr/bin/python2.7
import os
import time

def measure_temp():
        temp = os.popen("vcgencmd measure_temp").readline()
        return (temp.replace("temp=",""))

while True:
        print(measure_temp())
        time.sleep(1)


Thru a web page using python direct listening

https://raspberrypi.stackexchange.com/questions/8689/how-do-i-display-the-temperature-from-the-internal-sensor-on-a-html-page

install python-tornado

#!/usr/bin/env python

import tornado.ioloop
import tornado.web
import os

class MainHandler(tornado.web.RequestHandler):
    def getCPUtemperature( self ):
        res = os.popen('vcgencmd measure_temp').readline()
        return(res.replace("temp=","").replace("'C\n",""))

    def get(self):
        self.write( "Temperature: %s" % ( self.getCPUtemperature() ) )

application = tornado.web.Application([
    (r"/", MainHandler),
])

if __name__ == "__main__":
    application.listen(8888)
    tornado.ioloop.IOLoop.instance().start()
 

using RRD tool

http://lazydroid.com/2013/05/raspberry-pi-monitoring-cpu-temperature-with-rrdtool/

raw measurement of cpu temp
 
vcgencmd measure_temp
Monitor loop
watch -n 1 vcgencmd measure_temp


 

--30--

Saturday, June 1, 2019

notes on accessing vmware esxi remotely

Notes on monitoring ESXI 6

SSH remote access

  1. Generate public/private keys. For more information, see the OpenBSD Reference Manual section in the OpenBSD.

    Note: The preceding link was valid as of June 22, 2016. If you find the link to be broken, provide feedback on the article and a VMware employee will update the article as necessary.

    Notes:
    • These instructions generate two files in ~/.ssh: id_rsa and id_rsa.pub.
    • In ESXi 5.x, the ssh-keygen command is located at /usr/lib/vmware/openssh/bin.
       
  2. On the remote host, store the public key content, id_rsa.pubin ~/.ssh/authorized_keys.

    Notes:
     
    • For ESXi 5.x, 6.0 and 6.5, the authorized_keys is located at: /etc/ssh/keys-<username>/authorized_keys
    • More than one key can be stored in this file.
       
  3. To allow root access, change PermitRootLogin no to PermitRootLogin yes in the /etc/ssh/sshd_config file.
  4. To disable password login, ensure that the ChallengeResponseAuthentication and PasswordAuthentication are set to no.
  5. Reload the service:
     
    • For ESXi, run the command:

      /etc/init.d/SSH restart
       
    • For ESX, run the command:

      service sshd reload

https://kb.vmware.com/s/article/1002866

Accessing process information (ps command)

https://kb.vmware.com/s/article/1010993

  1. Run the minimalized ps command:
    ps -Tcjstv
    The output shows information such PID, command-line used, and state.
  2. To generate output for certain processes and maintain a title row, run this command:

    ps -Tcjstv | egrep "WID|{proc-name}"
  3. The esxcfg-info command can offer some detail on process memory and CPU and is contained in the vm-support dumps. Process information in esxcfg-info is contained in sections called Groups, but the groups can be cumbersome to sift through.
    Grep these groups for information on process memory and CPU with the command:
    esxcfg-info | egrep -A85 "Group Id" | egrep "Group Name|Group Id|Total CPU|Total Memory|Used Time|Parent Id|----Active\.\.\.\." | less
  4. To check for file-system issues, run this command:

    stat –f {filesystem}

    Note:
    This checks inode use, from which a runaway process can sometimes be determined (even if you do not know exactly what files are involved).
    To check across all filesystems, run this command:

    stat -f `df | grep -v "Filesystem" | awk '{print $6}'` | egrep "File|Inodes"
  5. To view network connection (socket) details, run this command:

    esxcli network connection list
    Note: For ESXi 5.x and later, run this command:

    esxcli network ip connection list


--30--