SnakeNET

Utilisateur principal de ce site web.

Juin 302022
 

Trouver le chemin du disque

Identifier les partitions existantes et la place libre

partedUtil getptbl /vmfs/devices/disks/t10.ATA_____HGST_HTS721010A9E630__________________________JR10006PHDWJHE

gpt
121601 255 63 1953525168
1 64      204863   C12A7328F81F11D2BA4B00A0C93EC93B systemPartition 128
5 208896  1232895  EBD0A0A2B9E5443387C068B6B72699C7 linuxNative 0
6 1234944 2258943  EBD0A0A2B9E5443387C068B6B72699C7 linuxNative 0
7 2260992 15470591 4EB2EA3978554790A79EFAE495E21F8D vmfsl 0
  • Je peux créer à partir de la partition 8
  • Je peux prendre le dernier block utilisé (15470591) +1 (block suivant) +2048(taille de block) = 15472640
  • Mon disque a une taille de (1953525168) – les blocks précédents (15472640) = 1938052528

Trouver les identifiants de partitions

partedUtil showGuids
 Partition Type       GUID
 vmfs                 AA31E02A400F11DB9590000C2911D1B8
 vmkDiagnostic        9D27538040AD11DBBF97000C2911D1B8
 vsan                 381CFCCC728811E092EE000C2911D0B2
 virsto               77719A0CA4A011E3A47E000C29745A24
 VMware Reserved      9198EFFC31C011DB8F78000C2911D1B8
 Basic Data           EBD0A0A2B9E5443387C068B6B72699C7
 Linux Swap           0657FD6DA4AB43C484E50933C84B4F4F
 Linux Lvm            E6D6D379F50744C2A23C238F2A3DF928
 Linux Raid           A19D880F05FC4D3BA006743F0F84911E
 Efi System           C12A7328F81F11D2BA4B00A0C93EC93B
 Microsoft Reserved   E3C9E3160B5C4DB8817DF92DF00215AE
 Unused Entry         00000000000000000000000000000000

Ajouter une partition

partedUtil add /vmfs/devices/disks/t10.ATA_____HGST_HTS721010A9E630__________________________JR10006PHDWJHE gpt « 8 15472640 1938052528 AA31E02A400F11DB9590000C2911D1B8 0″

partedutil add <chemin du disque> <partition type> <partition numéro> <Secteur de début> <secteur de fin> <type de partition> 0 (je ne sais pas a quoi sert le zéro)

La formater

vmkfstools -C  vmfs6 -S « LOCAL Datastore » /vmfs/devices/disks/t10.ATA_____HGST_HTS721010A9E630__________________________JR10006PHDWJHE:8

-C ‘type de formatage’  -S ‘nom du datastore’  <chemin du disque : numéro de partition>

Sep 012020
 

Vous souhaitez avoir un Octoprint disponible pour votre imprimante 3D et avez un Onion Omega2+ qui traine ? c’est parti !

Ce document est TRES fortement basé sur le site  https://community.onion.io/topic/1569/octoprint-3d-print-server-on-omega2/15.

Allez les voir, leur boulot est super !

Pré-requis :

  • Un onion Omega2+ (testé en version 0.3.2 b237)
  • Une dock avec port USB
  • Une carte micro SD (4go est suffisant)
  • Un Onion à la dernière version et connecté à Internet.

 

Rappel :

  • Pour configurer le wifi en ligne de commande : wifisetup
  • Pour mettre à jour l’Omega2+ à la dernière version : oupgrade

Installer les pré-requis

  1. En ligne de commande :

opkg update

opkg install fdisk e2fsprogs block-mount swap-utils

Utiliser la carte SD pour augmenter l’espace disponible.

  1. Insérer une carte microSD dans l’Omega2+ et formatez-la.
    Normalement, elle se trouvera dans /dev/mmcblk0 et la première partition sera /dev/mmcblk0p1
    Vous pouvez le vérifier avec la commande fdisk -l
  2. Formatter la carte SD en EXT4

umount /dev/mmcblk0p1
mkfs.ext4 /dev/mmcblk0p1

  1. Monter la carte SD

umount /dev/mmcblk0p1

mkdir /mnt/SD

mount /dev/mmcblk0p1 /mnt/SD

  1. Copier le système de fichier actuel.

tar -C /overlay -cvf – . | tar -C /mnt/SD/ -xf –

umount /mnt/SD

  1. Configurer le système pour monter la carte SD automatiquement au démarrage du système

block detect > /etc/config/fstab

  • Éditer /etc/config/fstab
    remplacer option target ‘/mnt/mmcblk0p1’ par option target ‘/overlay’
    et option enabled ‘0’ par option enabled ‘1’
  1. On redémarre l’Omega2+ pour vérifier que tout fonctionne.

reboot

  1. Après avoir redémarré, tapez la commande df -h afin de vérifier si la carte SD est bien montée.

Filesystem                Size      Used Available Use% Mounted on

/dev/root                 7.8M      7.8M         0 100% /rom

tmpfs                    60.9M     96.0K     60.8M   0% /tmp

/dev/mmcblk0p1            7.2G     33.5M      6.8G   0% /overlay

overlayfs:/overlay        7.2G     33.5M      6.8G   0% /

tmpfs                   512.0K         0    512.0K   0% /dev

/dev/mmcblk0p1            7.2G     33.5M      6.8G   0% /mnt/mmcblk0p1

/dev/mtdblock6           22.1M    764.0K     21.3M   3% /mnt/mtdblock6

/dev/mtdblock7          512.0K    196.0K    316.0K  38% /mnt/mtdblock7

Ajouter un fichier de SWAP (car on n’a pas assez de RAM).

On va avoir (entre-autre) besoin de compiler Python pour utiliser une version un peu plus moderne d’Octoprint que la 1.0.0, on va donc ajouter 512Mo de RAM.

  1. Configurer un fichier de SWAP et le monter

dd if=/dev/zero of=/swap.page bs=1M count=512

chmod 0600 /swap.page

mkswap /swap.page

swapon /swap.page

  1. On vérifie qu’on a bien les 512Mo de SWAP disponible avec la commande free.

root@Omega-AC5B:/# free

total       used       free     shared    buffers     cached

Mem:        124808     102472      22336         96       7068      72148

-/+ buffers/cache:      23256     101552

Swap:       524284          0     524284

Installer Octoprint.

  1. Ajoutez la source de package nécessaire à Python
    Editer le fichier /etc/opkg/distfeeds.conf et enlever le commentaire devant :

    • src/gz openwrt_base http://downloads.openwrt.org/releases/18.06-SNAPSHOT/packages/mipsel_24kc/base
    • src/gz openwrt_packages http://downloads.openwrt.org/releases/18.06-SNAPSHOT/packages/mipsel_24kc/packages
  2. Lancez l’installation

opkg update

opkg install gcc unzip python-dev python-pip –force-overwrite

pip install –upgrade setuptools

  1. Étendre le répertoire /tmp sur carte SD

mkdir overlay/tmp

rm -rf /overlay/tmp/*

cp -a /tmp/* /overlay/tmp/

umount /tmp

[ $? -ne 0 ] && {

umount -l /tmp

}

mount /overlay/tmp/ /tmp

  1. Télécharger Octoprint version 1.3.5

cd /root

wget https://github.com/foosel/OctoPrint/archive/1.3.5.zip

unzip 1.3.5.zip

  1. Bidouiller un peu pour que le compilateur soit reconnu

ln -s /usr/bin/gcc /usr/bin/ccache_cc

  1. Installer tous les pré-requis. Si la commande renvois une erreur, allez consulter le fichier /tmp/pip.log

cd OctoPrint-1.3.5

pip install -r requirements.txt –log /tmp/pip.log

  • Si vous avez l’erreur suivante lors de l’installation des pré-requis :

ERROR: Command errored out with exit status 1: /usr/bin/python2 -u -c ‘import sys, setuptools, tokenize; sys.argv[0] = ‘ »‘ »‘/tmp/pip-install-j0cjRE/psutil/setup.py' »‘ »‘; __file__=' »‘ »‘/tmp/pip-install-j0cjRE/psutil/setup.py' »‘ »‘;f=getattr(tokenize, ‘ »‘ »‘open' »‘ »‘, open)(__file__);code=f.read().replace(‘ »‘ »‘\r\n' »‘ »‘, ‘ »‘ »‘\n' »‘ »‘);f.close();exec(compile(code, __file__, ‘ »‘ »‘exec' »‘ »‘))’ install –record /tmp/pip-record-Qikfg8/install-record.txt –single-version-externally-managed –compile Check the logs for full command output

  • relancez la commande précédente et allez immédiatement modifier le fichier source de psutil (une fois que pip l’a retéléchargé) /tmp/pip-install-*****/psutil/psutil/_psutil_linux.c et commentez la ligne #include <sys/sysinfo.h>
  • Laissez tourner l’installation.
  1. Supprimer les caractères unicode non reconnus.

sed -i ‘s/Häußge/H\./g’ /root/OctoPrint-1.3.5/src/octoprint/util/comm.py

sed -i ‘s/Häußge/H\./g’ /root/OctoPrint-1.3.5/src/octoprint/plugins/virtual_printer/virtual.py

  1. Récupérez l’adresse IP de votre Omega2+ avec la commande ifconfig
  2. Démarrer Octoprint manuellement.

octoprint serve –iknowwhatimdoing &

  1. Connectez-vous sur la page web d’octoprint et vérifiez si ça démarre. http://IP_OMEGA:5000

Configurer le démarrage automatique d’Octoprint.

Parce qu’on n’a pas que ça à faire 😊

  1. Editer le fichier /etc/rc.local et ajouter (avant la ligne exit 0) la commande suivante :

octoprint serve –iknowwhatimdoing &

  1. Configurer Octoprint (via l’interface web) pour qu’il ait les commandes suivantes :
    • Shutdown system : reboot
    • Restart system : reboot
    • Restart Octoprint : reboot

 

 

Jan 292020
 

Sur le PC sur lequel je veux donner accès , je lance ceci :  (j’ai mis le script dans un fichier bat pour qu’il essaie de se recréer constamment)

:debut
  plink.exe -ssh -pw VPNPASS -batch -R 3390:127.0.0.1:3389 VPNUSER@VPN.SERVERNAME.COM
goto debut

Ca veut dire qu’il va créer un port 3390 sur le serveur VPN.SERVERNAME.COM qui pointera directement sur mon PC sur le port 3389.
Je me connecte avec l’utilisateur VPNUSER et le mot de passe VPNPASS

Attention, je n’ai JAMAIS dit que cétait recommandé/sécurisé !

Jan 282020
 

Pour info, la gestion du POE sur un OS6465 est super bizarre…
Voici les étapes que j’ai utilisées pour le faire fonctionner.

R35-ParkingLancierGauche> show lanpower slot 1/1
Port Maximum(mW) Actual Used(mW)   Status    Priority   On/Off   Class   Type
----+-----------+---------------+-----------+---------+--------+-------+----------
  1     30000            0       Powered Off    Low      OFF       .
  2     30000            0       Powered Off    Low      OFF       .
  3     60000            0       Powered Off    Low      OFF       .
  4     30000            0       Powered Off    Low      OFF       .
  5     60000            0       Powered Off    Low      OFF       .
  6     30000            0       Powered Off    Low      OFF       .
  7     60000            0       Powered Off    Low      OFF       .
  8     30000            0       Powered Off    Low      OFF       .

ChassisId 1 Slot 1 Max Watts 0
0 Watts Actual Power Consumed
0 Watts Total Power Budget Used
0 Watts Total Power Budget Available
0 Power Supply Available
'*' appending port maxpower indicates 4pair port operating in 2pair mode

Par défaut, il n’y a pas de source de courant disponible.

R35-ParkingLancierGauche> show powersupply total 
Total Power (watts):   0

Donc, il faut créer une source de courant (je l’ai appelée « integrated »):

no powersupply 1 name "integrated" chassis-id 1
powersupply 1 name "integrated" type ale 24vdc
powersupply enable 1

Activer la source de courant

powersupply enable chassis-id 1 1

Démarrer la function POE

lanpower slot 1/1 service start
Avr 082019
 

Si vous avez détruit les associations des fichiers .JAR en installant un logiciel de type winzip, pas de panique.

La méthode la plus rapide et simple est de lancer les deux commandes suivantes en tant qu’administrateur :

ftype jarfile="C:\Program Files (x86)\Java\jre1.8.0_201\bin\javaw.exe" -jar "%1" %*
assoc .jar=jarfile

Pensez à adapter le chemin de java 🙂

 

Mar 202019
 

Vous l’avez certainement remarqué, si vous fermez votre fenêtre WSL, toutes les tâches (y compris nohup et crontab) s’arrêtent.
L’idée est de démarrer cron au démarrage de votre session Windows (ou pc via tache plannifiée)

D’abord autoriser de lancer cron en root sans mot de passe :

sudo visudo
et ajouter :
%sudo ALL=NOPASSWD: /etc/init.d/cron start

Ensuite, dans le dossier « démarrage » de Windows, rajouter le démarrage de cron via un nouveau shortcut:

C:\Windows\System32\wsl.exe sudo /etc/init.d/cron start

voila..

Mar 062019
 

Si vous lancer une commande graphique avec sudo, vous pourriez avoir cette erreur et ça ne fonctionne pas:

Gtk-WARNING **: cannot open display: :10.0

La solution, ajouter cette ligne à la fin du fichier de configuration de sudo (avec la commande « visudo », je rappelle)

Defaults env_keep="XAUTHORIZATION XAUTHORITY TZ PS2 PS1 PATH LS_COLORS KRB5CCNAME HOSTNAME HOME DISPLAY COLORS"

 

Jan 082019
 

J’ai créé un service similaire à dweet.io
Je m’en sers pour logguer des infos (capteur de temperature, uptime,…)

J’ai des Raspberry, CHIP, Omega, Arduino (esp8266) qui ont besoin de remonter facilement ce genre d’infos. Comment?

Comme ceci dans un « crontab -e « :

* * * * * wget --user-agent=arduino "http://www.snakenet.be/dweet/?key=ONION&freemem=`grep "MemFree" /proc/meminfo | awk '{print $2}'`&uptime=`cat /proc/uptime |awk '{print $2}'`" -O /dev/null &

Faut aussi penser à activer crontab (sous Omega)

/etc/init.d/cron start
/etc/init.d/cron enable

et on visionne le résultat avec cette page :

Exemple d’analyse de la vitesse d’upload de ma connexion internet :

#!/bin/bash
upload=`./speedtest-cli --no-pre-allocate --no-download --simple | grep "Upload" | cut -f 2 -d ':' | cut -d ' ' -f 2`
wget --user-agent=arduino "http://www.snakenet.be/dweet/?key=VOO&upload=$upload" -O /dev/null

 

Mai 142018
 

Source : https://github.com/foosel/OctoPrint/wiki/Setup-on-a-Raspberry-Pi-running-Raspbian

apt-get install python2.7 git gcc python-pip python-dev python-setuptools python-virtualenv git libyaml-dev build-essential

# a ne PAS faire en root !!!
cd ~
git clone https://github.com/foosel/OctoPrint.git
cd OctoPrint
virtualenv venv
./venv/bin/pip install pip --upgrade
./venv/bin/python setup.py install
mkdir ~/.octoprint

Tester si ca démarre :

~/OctoPrint/venv/bin/octoprint

Si ça démarre sans problème, alors corriger la suite :

edit ~/OctoPrint/scripts/octoprint.init and ~/OctoPrint/scripts/octoprint.default and change DAEMON to this : 
DAEMON=/root/OctoPrint/venv/bin/octoprint

sudo cp ~/OctoPrint/scripts/octoprint.init /etc/init.d/octoprint
sudo chmod +x /etc/init.d/octoprint
sudo cp ~/OctoPrint/scripts/octoprint.default /etc/default/octoprint

sudo update-rc.d octoprint defaults

sudo service octoprint start

Et voilà, c’est finit…

Déc 222017
 
#!/bin/sh
# This program gets the battery info from PMU
# Voltage and current charging/discharging
#
# Nota : temperature can be more than real because of self heating
#######################################################################
# Copyright (c) 2014 by RzBo, Bellesserre, France
#
# Permission is granted to use the source code within this
# file in whole or in part for any use, personal or commercial,
# without restriction or limitation.
#
# No warranties, either explicit or implied, are made as to the
# suitability of this code for any purpose. Use at your own risk.
#######################################################################

# force ADC enable for battery voltage and current
#i2cset -y -f 0 0x34 0x82 0xC3
i2cset -y -f 0 0x34 0x82 0xff

################################
#read Power status register @00h
POWER_STATUS=$(i2cget -y -f 0 0x34 0x00)
#echo $POWER_STATUS

BAT_STATUS=$(($(($POWER_STATUS&0x02))/2)) # divide by 2 is like shifting rigth 1 times
#echo $(($POWER_STATUS&0x02))
echo "BAT_STATUS="$BAT_STATUS
# echo $BAT_STATUS

################################
#read Power OPERATING MODE register @01h
POWER_OP_MODE=$(i2cget -y -f 0 0x34 0x01)
#echo $POWER_OP_MODE

CHARG_IND=$(($(($POWER_OP_MODE&0x40))/64)) # divide by 64 is like shifting rigth 6 times
#echo $(($POWER_OP_MODE&0x40))
echo "CHARG_IND="$CHARG_IND
# echo $CHARG_IND

[ $(($POWER_STATUS & 0x80)) -ne 0 ] && {
 echo "ACIN Present"
 ACIN_VOLT_MSB=$(i2cget -y -f 0 0x34 0x56)
 ACIN_VOLT_LSB=$(i2cget -y -f 0 0x34 0x57)
 ACIN_BIN=$(( $(($ACIN_VOLT_MSB << 4)) | $(($(($ACIN_VOLT_LSB & 0x0F)) )) ))
 ACIN_VOLT=$(echo "($ACIN_BIN*1.7)"|bc)
 echo " ACIN voltage = "$ACIN_VOLT"mV"

ACIN_I_MSB=$(i2cget -y -f 0 0x34 0x58)
 ACIN_I_LSB=$(i2cget -y -f 0 0x34 0x59)
 ACIN_I_BIN=$(( $(($ACIN_I_MSB << 4)) | $(($(($ACIN_I_LSB & 0x0F)) )) ))
 ACIN_I=$(echo "($ACIN_I_BIN*0.625)"|bc)
 echo " ACIN current = "$ACIN_I"mA"
}
[ $(($POWER_STATUS & 0x20)) -ne 0 ] && {
 echo "VBUS Present"
 VBIN_VOLT_MSB=$(i2cget -y -f 0 0x34 0x5a)
 VBIN_VOLT_LSB=$(i2cget -y -f 0 0x34 0x5b)
 VBIN_BIN=$(( $(($VBIN_VOLT_MSB << 4)) | $(($(($VBIN_VOLT_LSB & 0x0F)) )) ))
 VBIN_VOLT=$(echo "($VBIN_BIN*1.7)"|bc)
 echo " VBUS voltage = "$VBIN_VOLT"mV"

VBIN_I_MSB=$(i2cget -y -f 0 0x34 0x5c)
 VBIN_I_LSB=$(i2cget -y -f 0 0x34 0x5d)
 VBIN_I_BIN=$(( $(($VBIN_I_MSB << 4)) | $(($(($VBIN_I_LSB & 0x0F)) )) ))
 VBIN_I=$(echo "($VBIN_I_BIN*0.375)"|bc)
 echo " VBUS current = "$VBIN_I"mA"
}

################################
#read Charge control register @33h
CHARGE_CTL=$(i2cget -y -f 0 0x34 0x33)
echo "CHARGE_CTL="$CHARGE_CTL
# echo $CHARGE_CTL


################################
#read Charge control register @34h
CHARGE_CTL2=$(i2cget -y -f 0 0x34 0x34)
echo "CHARGE_CTL2="$CHARGE_CTL2
# echo $CHARGE_CTL2

###################
#read internal temperature 5eh, 5fh -144.7c -> 000h, 0.1c/bitFFFh -> 264.8c
TEMP_MSB=$(i2cget -y -f 0 0x34 0x5e)
TEMP_LSB=$(i2cget -y -f 0 0x34 0x5f)

# bash math -- converts hex to decimal so `bc` won't complain later...
# MSB is 8 bits, LSB is lower 4 bits
TEMP_BIN=$(( $(($TEMP_MSB << 4)) | $(($(($TEMP_LSB & 0x0F)) )) ))

TEMP_C=$(echo "($TEMP_BIN*0.1-144.7)"|bc)
echo "Internal temperature = "$TEMP_C"c"

BAT_EXIST=$(($(($POWER_OP_MODE&0x20))/32)) # divide by 32 is like shifting rigth 5 times
#echo $(($POWER_OP_MODE&0x20))
echo "BAT_EXIST="$BAT_EXIST
# echo $BAT_EXIST

[ $BAT_EXIST -ne 0 ] && {
################################
#read battery voltage 79h, 78h 0 mV -> 000h, 1.1 mV/bit FFFh -> 4.5045 V
BAT_VOLT_MSB=$(i2cget -y -f 0 0x34 0x78)
BAT_VOLT_LSB=$(i2cget -y -f 0 0x34 0x79)

#echo $BAT_VOLT_MSB $BAT_VOLT_LSB
# bash math -- converts hex to decimal so `bc` won't complain later...
# MSB is 8 bits, LSB is lower 4 bits
BAT_BIN=$(( $(($BAT_VOLT_MSB << 4)) | $(($(($BAT_VOLT_LSB & 0x0F)) )) ))

BAT_VOLT=$(echo "($BAT_BIN*1.1)"|bc)
echo " Battery voltage = "$BAT_VOLT"mV"


###################
#read Battery Discharge Current 7Ch, 7Dh 0 mV -> 000h, 0.5 mA/bit 1FFFh -> 1800 mA
#AXP209 datasheet is wrong, discharge current is in registers 7Ch 7Dh
#13 bits
BAT_IDISCHG_MSB=$(i2cget -y -f 0 0x34 0x7C)
BAT_IDISCHG_LSB=$(i2cget -y -f 0 0x34 0x7D)

#echo $BAT_IDISCHG_MSB $BAT_IDISCHG_LSB

BAT_IDISCHG_BIN=$(( $(($BAT_IDISCHG_MSB << 5)) | $(($(($BAT_IDISCHG_LSB & 0x1F)) )) ))

BAT_IDISCHG=$(echo "($BAT_IDISCHG_BIN*0.5)"|bc)
echo " Battery discharge current = "$BAT_IDISCHG"mA"

###################
#read Battery Charge Current 7Ah, 7Bh 0 mV -> 000h, 0.5 mA/bit FFFh -> 1800 mA
#AXP209 datasheet is wrong, charge current is in registers 7Ah 7Bh
#(12 bits)
BAT_ICHG_MSB=$(i2cget -y -f 0 0x34 0x7A)
BAT_ICHG_LSB=$(i2cget -y -f 0 0x34 0x7B)

#echo $BAT_ICHG_MSB $BAT_ICHG_LSB

BAT_ICHG_BIN=$(( $(($BAT_ICHG_MSB << 4)) | $(($(($BAT_ICHG_LSB & 0x0F)) )) ))

BAT_ICHG=$(echo "($BAT_ICHG_BIN*0.5)"|bc)
echo " Battery charge current = "$BAT_ICHG"mA"

FUEL_GAUGE=$(i2cget -y -f 0 0x34 0x0b9)
 FUEL_GAUGE=$(($FUEL_GAUGE&0x7f))
 echo " Fuel Gauge=$FUEL_GAUGE%"
}