Outils pour utilisateurs

Outils du site


blog

8 billet(s) pour mars 2026

Notes conteneurs oras artifact OCI2026/03/23 21:13Jean-Baptiste
Notes podman secret2026/03/23 15:10Jean-Baptiste
Notes ansible podman2026/03/23 14:08Jean-Baptiste
Notes podman volume2026/03/23 14:00Jean-Baptiste
Find list - Trouver des fichiers à partir d'une liste2026/03/18 14:32Jean-Baptiste
AWX inventaire vault2026/03/17 18:04Jean-Baptiste
AWX - Configuration git en local (sans serveur web)2026/03/05 16:24Jean-Baptiste
OpenSMTP2026/03/03 16:58Jean-Baptiste

Notes Samba Winbind Kerberos

Voir

  • sssd
  • nslcd

Debug

Check NTP and :

service samba restart
service winbind restart
cat /etc/nsswitch.conf
 
net ads join --kerberos -U administrator -d 10

Pb

Kerberos

net ads info
net ads status
wbinfo -u
wbinfo -g
wbinfo -t
wbinfo -m
 
kinit administrator at UNILINEDOO.LOCAL
klist -ke
net ads testjoin
id <user>
getent passwd 
getent passwd DOMAIN/user
getent group
 
klist
kdestroy
wbinfo -t

Solution :

  • stop smbd, nmbd and winbindd (make sure they are really dead using ps. winbindd still lingered after I stopped the service)
  • delete the samba from the PDC (using the Management Console)
  • delete the secrets database (/var/lib/samba/secrets.tdb)
  • join the domain again
  • start the daemons again (smbd, nmbd and winbindd)

Source : https://ubuntuforums.org/showthread.php?t=1857135

2025/03/24 15:06

Notes rust lang

Voir aussi :

sh rustup.sh  --disable-sudo --prefix=opt/
export LD_LIBRARY_PATH=$PWD/opt/lib
opt/bin/rustc --version
export PATH=$PATH:$PWD/opt/bin
export RUST_BACKTRACE=1
2025/03/24 15:06

Notes ruby capistrano

capshell peut être remplacé par clush (paquet clustershell), pour avoir un shell sur plusieurs serveurs

  1. Création du paquage Capistrano (utilisable en userland) #

Voir https://rvm.io/integration/capistrano/#gem

[INSTALL DE RVM Ruby Version Manager] → Voir https://rvm.io/

-Prerequis yum install libxslt-devel curl git patch gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison iconv-devel yum install ruby-libs # (a verifier !)

-Install curl -L https://get.rvm.io | bash -s stable --ruby

[INSTALL DE CAPISTRANO] ~/.rvm/rubies/*/bin/gem install --user rvm-capistrano

[CREATION DU SCRIPT DE LANCEMENT] vi ~/bin/cap —

  1. ! /bin/bash

CAP=$(echo /home/eib/.gem/ruby/*/bin/cap |tail -1) RUBY=$(echo /home/eib/.rvm/rubies/ruby-*/bin/ruby|tail -1)

$RUBY $CAP $* — chmod +x ~/bin/cap

[TEST DE CAPISTRANO] ~/bin/cap shell

[CONSCRUCTION DU PAQUET] find /home/eib/.gem /home/eib/.rvm/rubies/ruby-* /home/eib/.rvm/gems/ruby-* /home/eib/.rvm/environments /home/eib/.rvm/bin /home/eib/bin/cap -depth |cpio -ov --format=ustar|gzip >captistrano.tar.gz

NB : les repertoires nécessaires au paquet peuvent être trouvé à l'aide de “strace”.

>Voir NOTES.

[DEINSTALL] rm -rf ~/.rvm ~/.gem ~/bin/cap

[NOTES] http://henriksjokvist.net/archive/2012/2/deploying-with-rbenv-and-capistrano/

Commande utile :

Pour relancer la compilation de ruby : rvm reinstall all --force

Pour trouver les repertoires nécessaires à la creation du paquet /bin/ls -ld $(strace -f -e trace=file cap 2>&1|grep -v 'No such file or directory' |grep open|cut -d'“' -f2|grep '/home/eib/.rvm/')|grep ^d|awk '{print $9}'

~/.rvm/bin/gem-ruby-2.0.0-p0 update

2025/03/24 15:06

Notes rsync

Voir aussi

Voir :

CD / ISO

Source https://www.debian.org/CD/mirroring/

Veuillez utiliser au moins les options --times --links --hard-links --partial --block-size=8192. 
Cela conservera la date de dernière modification, les liens symboliques et durs et un bloc de 8192 octets
(le plus adapté pour les images de CD) sera utilisé. 
Lorsque la date de dernière modification et la taille d'un fichier n'ont pas été modifiées, 
rsync ignore le fichier, aussi --times est réellement nécessaire
Machine distante vers machine distante
rsync -ax backup:/home/wiki wiki:/home/
The source and destination cannot both be remote.
ssh -A remotehostA rsync /remote/file/on/host/a remoteHostB:/destination/

Une autre solution consiste à utiliser SSHFS Mais les UID/GID ne sont pas préservés

Pb SSHFS Transport endpoint is not connected
fusermount -uz /data

/etc/fuse.conf

user_allow_other
sshfs -o allow_other,ro -o reconnect -o ServerAliveInterval=15 root@192.168.2.12:/var/www /data -p 12345 -C

Pour debug ajouter l'option -d

sshfs -d -o allow_other,ro -o reconnect -o ServerAliveInterval=15 root@192.168.2.12:/var/www /data -p 12345 -C
Gros fichiers avec plein de zéros, iso...

Voir l'option --sparse

-S, --sparse                traite les fichiers à trous efficacement
$ ls -lsh
total 22G
 16K drwx------ 2 root root  16K août   9 10:42 lost+found
7,7G -rw-r--r-- 1 jibe jibe 120G août   9 11:18 VM152-SUPPMSM-V-clone.img
 14G -rw-r--r-- 1 jibe jibe  14G févr. 24 09:15 VM152-SUPPMSM-V-clone.qcow2
Copie dossier

Ne pas oublier le barre oblique (slash) à la fin

rsync -ax /mnt/usb_disk/ /mnt/usb_disk2/
Utilisation de l'option --files-from
rsync -anv --files-from=push.lst / /tmp/plop/
rsync avec find
# rsync --files-from=<(find ~/DATA/ -type f -name '*.txt' -printf "%P\n") ~/DATA/ ~/DATA2/
# find ~/DATA/ -name '*.txt' -printf %P\\0 | rsync --files-from=- --from0 ~/DATA/ ~/DATA2/
 
cd ~/DATA/
find . -type f -name '*.txt' -exec rsync -av -R {} ~/DATA2/ \;
Diff - diffing
diff -r --exclude='.git' --exclude='.gitlab' projet_plop_fork/ projet_plop_orig/

Équivalent avec rsync

rsync -rcvn --delete --exclude='.git' --exclude='.gitlab' --itemize-changes projet_plop_fork/ projet_plop_orig/
Droits

chmod - exemple cd iso9660

chmod \ F pour File \ D pour Directory

rsync -a -H --delete --chmod=Fu+rw,Du=rwx /mnt/iso /tmp/iso

Cependant dans le cas d'un ISO CD/DVD nous préférerons :

fakeroot rsync -a -H --delete /mnt/iso /tmp/iso

chown - exemple synchro dokuwiki

rsync -axP --chown=999:999 --exclude="cache" --exclude="tmp" --exclude="attic" --delete webapp:/home/wiki/data/* /home/wiki/data/
Options SSH
rsync -o StrictHostKeyChecking=no -o CheckHostIP=no
#rsync -e "ssh -o StrictHostKeyChecking=no -o CheckHostIP=no"
Exclusion

Le chemin des fichiers à exclure est relatif au répertoire que l'on sauvegarde.

# FAUX
rsync --archive --verbose --stats --info=progress2 --delete --delete-excluded --exclude="/home/jean/tmp/" /home/jean/ /media/backup/
 
# Exclus tous les /tmp
rsync --archive --verbose --stats --info=progress2 --delete --delete-excluded --exclude="/tmp" /home/jean/ /media/backup/
 
# OK
rsync --archive --verbose --stats --info=progress2 --delete --delete-excluded -filter="- /home/jean/tmp/" /home/jean/ /media/backup/

La racine “/” est relative au dossier racine qu'on sauvegarde

Source https://fortintam.com/blog/2010/03/18/le-parametre-exclude-de-rsync/

Exclure les fichiers cachés

rsync -ax --exclude=".*" --delete /source/ /dest/
Liste bande passante / ressources

Liste bande passante / ressources --bwlimit=KBps

/usr/bin/ionice -c2 -n7 rsync -axvn --bwlimit=20480 /home/jean/ backup1:/data/bck1/home/jean/
 
# systemd-run -p IOWeight=10 rsync -axvn --bwlimit=20480 /home/jean/ backup1:/data/bck1/home/jean/

Voir aussi

renice +19 -p $$ >/dev/null 2>&1
ionice -c3 -p $$ >/dev/null 2>&1
ntop -A
sudo /etc/init.d/ntop start

Rsync en mode daemon

Activation

/etc/default/rsync

RSYNC_ENABLE=true
systemctl enable --now rsync
systemctl status rsync
rsync rsync://pub@localhost/

Exemple de fichier de conf

/etc/rsyncd.conf

uid = swift
gid = swift
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
 
reverse lookup = false
 
 
[account]
max connections = 2
path = /srv/node
read only = false
lock file = /var/lock/account.lock
 
[container]
max connections = 4
path = /srv/node
read only = false
lock file = /var/lock/container.lock
 
[object]
max connections = 8
path = /srv/node
read only = false
lock file = /var/lock/object.lock

Autres

Installeur Debian Calamares

Running ("rsync", "-aHAXr", "--filter=-x trusted.overlay.*", "--exclude", "/proc/", "--exclude", "/sys/", "--exclude", "/dev/", "--exclude", "/run/", "--exclude", "/run/udev/", "--exclude", "/sys/firmware/efi/efivars/", "--progress", "/tmp/tmpqf5n2jx1/filesystem/", "/tmp/calamares-root-z6v29hnx")

Pb

Pb de taille

Source : https://sanitarium.net/rsyncfaq/#differentsizes

rsync -ax --delete ne fait pas forcément le sparce, et ne préserve pas les hardlinks

Pour vérifier que la copie fait bien la même taille

#echo `find . -type f -ls | awk '{print $7 "+"}'`0 | bc
echo `find /media/Disk1/ -type f -ls | awk '{print $7 "+"}'`0 | bc
echo `find /media/Disk2/ -type f -ls | awk '{print $7 "+"}'`0 | bc
rsync --delete -v -axHSc /media/Disk1/ /media/Disk2/
Option Description -c skip based on checksum, not mod-time & size -H preserve hard links -S\ --sparse handle sparse files efficiently
Pb : failed to set times on / No such file or directory
sshfs SRV_DEST:/var/www/ /home/jean/mnt/SRV_DEST
rsync -ax --bwlimit=20480 SRV_SRC01:/var/www/www.acme.fr/ /home/jean/mnt/SRV_DEST/www.acme.fr/
rsync: failed to set times on "/home/jean/mnt/SRV_DEST/www.acme.fr/htdocs/current": No such file or directory (2)

Solution : Tester avec l'option -J ou -O

rsync -ax -J --bwlimit=20480 SRV_SRC01:/var/www/www.acme.fr/ /home/jean/mnt/SRV_DEST/www.acme.fr/
Pb clef USB sync

Sur clef USB le système peut bufferiser beaucoup trop. La copie se met en pause un certain temps puis reprend. Si on interrompt le rsync le “sync” mais énormément de temps. Pendant tous ce temps il n'est pas possible de démonter la clef USB

Dans ce cas il est possible d'utiliser l'option --fsync

Note : sur du FAT il est possible d'utiliser --modify-window=1

2025/03/24 15:06

Notes resize disk FS

Exemple

Install de growpart

apt-get install cloud-guest-utils

Création du système de fichier

Voir gdisk et parted pour GPT

dd if=/dev/zero of=/home/disktest bs=1024k count=500
#fallocate -l 500M /home/disktest
 
losetup /dev/loop2 /home/disktest
fdisk /dev/loop2
# 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).
 
# blockdev --rereadpt /dev/loop2
# sfdisk -R /dev/loop2 # ioctl BLKRRPART
# kpartx -u /dev/loop2p1
# hdparm -z # ioctl BLKRRPART
partprobe /dev/loop2 # ioctl BLKPG²
# udevadm settle # (systemd-udev-settle.service)
# Voir aussi addpart / delpart (kernel)
 
mkfs.ext4 /dev/loop2p1
 
mkdir /mnt/test
mount /dev/loop2p1 /mnt/test
echo plop > /mnt/test/plop.txt

Augmentation de la taille du disque

dd if=/dev/zero bs=1024k count=500 >> /home/disktest

Rafraîchissement de la taille

# lsblk |grep loop2
loop2                                                                                      7:2    0  500M  0 loop
└─loop2p1                                                                                259:0    0  499M  0 loop /mnt/test
# losetup /dev/loop2
/dev/loop2: [65028]:12 (/home/disktest)
# lsblk |grep loop2
loop2                                                                                      7:2    0  500M  0 loop
└─loop2p1                                                                                259:0    0  499M  0 loop /mnt/test
# losetup -c /dev/loop2
# lsblk |grep loop2
loop2                                                                                      7:2    0 1000M  0 loop
└─loop2p1                                                                                259:0    0  499M  0 loop /mnt/test

Redimensionnement de la partition
extend a partition in a partition table to fill available space

growpart /dev/loop2 1

Redimensionnement du système de fichier

# df -hP /mnt/test/
Sys. de fichiers Taille Utilisé Dispo Uti% Monté sur
/dev/loop2p1       476M    2,3M  445M   1% /mnt/test

# resize2fs /dev/loop2p1
resize2fs 1.42.12 (29-Aug-2014)
Le système de fichiers de /dev/loop2p1 est monté sur /mnt/test ; le changement de taille doit être effectué en ligne
old_desc_blocks = 2, new_desc_blocks = 4
Le système de fichiers sur /dev/loop2p1 a maintenant une taille de 1022956 blocs (1k).

# df -hP /mnt/test/
Sys. de fichiers Taille Utilisé Dispo Uti% Monté sur
/dev/loop2p1       960M    2,5M  909M   1% /mnt/test

A l'inverse de growpart, il peut être utile de redimensionner un fichier img pour le réduire / tronquer (shrink) pour qu'il ne dépasse pas la taille de la sommes des partitions.

$ fdisk -l myimage.img

Disk myimage.img: 6144 MB, 6144000000 bytes, 12000000 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: 0x000ea37d

      Device Boot      Start         End      Blocks   Id  System
myimage.img1            2048     9181183     4589568    b  W95 FAT3
truncate --size=$[(9181183+1)*512] myimage.img

Source : https://softwarebakery.com/shrinking-images-on-linux

Anciennes notes

dd if=/dev/zero bs=1024k count=1000 >> /var/lib/libvirt/images/debianwheezy.qcow2
dd if=/dev/zero of=filename bs=1 count=1 seek=newsize conv=notrunc

Backup extended partition table

sfdisk -d /dev/hda > /tmp/hda

Restore extended partition table

sfdisk /dev/hda < /tmp/hda

A vérifier ! (manip dangereuse)

echo ", +" | sfdisk -N 1 /dev/vda
partprobe /dev/vda
resize2fs /dev/vda1

Autres

Taille disque en Go

echo $(( $(blockdev --getsize64 /dev/sda) / 1024 / 1024 / 1024 ))

GPT parted

Voir aussi gdisk

Redimensionnement agrandissement d'une partition GPT

Run parted on your device: parted /dev/sdX
  Change display unit to sectors: unit s
  Print current partition table and note the start sector for your partition: p
  Delete your partition (won’t delete the data or filesystem): rm <number>
  Recreate the partition with the starting sector from above: mkpart primary <start> <end>
  Exit parted: quit
  Check the filesystem : sudo e2fsck -f /dev/sdXX
  Resize filesystem : sudo resize2fs /dev/sdXX
sudo parted /dev/vda
#unit s
#unit GB
#unit %
(parted)print free
(parted)resizepart 2 100%
(parted)quit
sudo fdisk -l /dev/vda | grep ^/dev
sudo parted /dev/vda
(parted)print free
(parted)resizepart 5 100%
(parted)quit
2025/03/24 15:06
blog.txt · Dernière modification : de 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki