Rechercher dans ce blog

jeudi 11 février 2021

Use usb Apple superdrive with linux

 

from techtalk – Christian Moser

Thanks to him. 


Unlock with SCSI Generic (sg) driver

For communicating with the SCSI device directly we need the Linux SCSI Generic (sg) driver packages.

# Debian
sudo apt-get install sg3-utils

Lookup the device, it should be sr0 or sr1 by default depending on how many USB disc drives are currently attached. Check the output of following command to get a list off all device paths:

ls /dev

After you’ve the SuperDrive identified, we’ll send the magic sequence to the device.

# Do magic...
sg_raw /dev/sr0 EA 00 00 00 00 00 01

Try to insert a disc, the drive should be awake now and start initialising the disc. For now the last step is necessary each time the drive is unplugged, so let’s automate it!

Custom udev rule

We’ll make us of the udev device manager. It runs as a deamon and receives events each time a device is initialised or removed. Furthermore, it features an extensible rule set for easy customising. Please check out this very good guide for further instructions.

Let’s write such a custom rule.

# Debian
sudo nano /etc/udev/rules.d/99-local.rules

Add following rule definition.

# Initialise Apple SuperDrive
ACTION=="add", ATTRS{idProduct}=="1500", ATTRS{idVendor}=="05ac", DRIVERS=="usb", RUN+="/usr/bin/sg_raw /dev/$kernel EA 00 00 00 00 00 01"

This will do the “magic” each time a SuperDrive device is connected. To test the rule, disconnect the drive and connect it again, the drive should be unlocked, already.

AT commands

1.2. Exécuter une commande à une date donnée

Par exemple, pour exécuter les commandes date puis df -h le 28 septembre 2008 à midi 42, tapez :

% at 12:42 28.09.2008

Vous voyez alors apparaître le prompt du programme at pour taper les commandes :

at> date
at> df -h

Une fois que vous avez fini de taper les commandes, utilisez la combinaison de touches Ctrl+d. Le résultat de la série de commandes, appelée job, vous sera envoyé par mail juste après leur exécution.

Pour voir la liste des jobs en attente, utilisez la commande atq. Pour annuler un job, tapez atrm numéro_du_job.


Editer sudoers

visudo

cdrecord wodim commands

wodim -v -eject speed=24 -pad -audio *.wav
wodim dev=/dev/sr0 -v blank=fast
wodim dev=/dev/sr0 -v -eject
Gravure non finalisée

Pour empêcher la finalisation par défaut de wodim, ajouter l'option -nofix.
Gravure de 2 pistes sans finalisation :

wodim -v -nofix speed=24 -pad -audio track01.wav track02.wav

Ajout de 2 pistes puis finalisation :

Ces 2 commandes l'une après l'autre le fait :

wodim -v -nofix speed=24 -pad -audio track03.wav

wodim -v -eject dev=1,0,0 speed=24 -pad -audio track04.wav

Finalisation sans ajout de piste :

wodim -v -eject -fix


Chapitre 52. Graver en console

1. Installation des paquets
2. Les CD de données
3. Les CD audio

1. Installation des paquets

Installez les paquets requis :

# aptitude install genisoimage wodim

2. Les CD de données
2.1. Créer l'image ISO du CD
À partir de fichiers

Avant de commencer à graver, il faut créer l'image ISO du CD, c'est à dire le système de fichiers qui sera gravé tel quel sur le disque. Pour cela, on utilise la commande genisoimage.

Prenons l'exemple d'une sauvegarde du home de l'utilisateur toto :

    vérifiez qu'il fait moins que la capacité du CD-R ou RW :

    % du -sh /home/toto/

    créez l'ISO :

    % genisoimage -R -r -J --hide-rr-moved -V "SauvHome" -o backup.iso /home/toto/

Explication des options utilisées dans genisoimage:

    -R : rajoute l'extension Rock Ridge qui permet de conserver les noms longs et les permissions sous Linux,

    -r : permet de générer une image qui soit lisible par tout le monde malgré les permissions activées par l'extension Rock Ridge,

    -J : active l'extension Joliet pour avoir les noms longs sous Windows,

    --hide-rr-moved : renomme le répertoire rr_moved (dû aux extensions Rock Ridge) en un répertoire caché .rr_moved,

    -V : spécifie un Nom de Volume (ici "SauvHome"),

    -o : spécifie le nom et l'emplacement du fichier ISO (ici backup.iso dans le répertoire courant).

Autre exemple : vous voulez créer une ISO qui contienne le répertoire /home/toto/, le fichier /etc/X11/XF86Config-4, et en plus le contenu du répertoire /mnt/win/toto/ qui devra apparaître sur le CD dans un répertoire win-toto :

% genisoimage -R -r -J --hide-rr-moved -V "SauvHome" -o backup.iso
-graft-points /home/toto/ /etc/X11/XF86Config-4 win-toto/=/mnt/win/toto/

À partir d'un CD

Pour créer l'image ISO d'un CD de données, il suffit de copier directement les données du disque original vers un fichier :

% dd if=/dev/cdrom of=backup.iso

2.2. Tester l'ISO

Pour vérifier que l'ISO du CD marche bien, on va monter le fichier contenant l'ISO en loopback dans le répertoire /mnt/tmp/ (à créer avant s'il n'existe pas) :

# mount -t iso9660 -o loop backup.iso /mnt/tmp

Si tout va bien, vous pouvez aller vous balader dans le répertoire /mnt/tmp/ pour voir le contenu de l'ISO. Une fois que vous avez vérifié que tout est bon, démontez l'ISO du CD :

# umount /mnt/tmp

2.3. Graver le CD
Les options de wodim

Maintenant que l'ISO est créée, vous allez utiliser la commande wodim (write optical disc medium) pour graver le CD. Les options à connaître et à utiliser sont :

    dev=/dev/cdrw où /dev/cdrw est un lien symbolique pointant vers le périphérique correspondant à votre graveur IDE ;

    -data image_ISO.iso pour préciser que l'on grave à partir de l'image ISO d'un CD ;

    blank=all pour effacer complètement le contenu d'un disque réinscriptible ;

    blank=fast pour effacer la table des matières d'un disque réinscriptible ;

Lancer la gravure

Pour lancer la gravure, tapez la commande suivante :

# wodim -v dev=/dev/cdrw -data backup.iso

2.4. Copie directe de lecteur à graveur

Pour réaliser une copie directe de lecteur CD à graveur, il faut lancer wodim avec l'option -isosize :

# wodim -v dev=/dev/cdrw -isosize /dev/cdrom

3. Les CD audio
3.1. Quel programme utiliser ?
[Note]     Note

L'utilisation de wodim pour graver des CD audio induit une pause de deux secondes entre chaque piste lors de la lecture, car il utilise le mode TAO (Track At Once). Pour éliminer cette pause, il faut graver le CD en mode DAO (Disk At Once).
3.2. Graver avec wodim

Pour graver un CD audio avec wodim, il faut disposer d'un fichier son au format CDR, WAV ou AU pour chaque piste. Si les fichiers sont au format WAV ou AU, chaque fichier doit être en stéréo, 16-bits à 44100 échantillons / seconde.
Convertir au bon format

Pour convertir un MP3 au format CDR, il suffit d'utiliser mpg321 :

% mpg123 --cdr ma_chanson.cdr ma_chanson.mp3

Pour extraire une piste d'un CD audio au format CDR, il faut utiliser cdparanoia (disponible dans le paquet du même nom) :

% cdparanoia -B -p

Graver le CD audio

Il suffit alors de taper :

# wodim -v -dev=/dev/cdrw -dao -audio track1.cdr track2.cdr track3.cdr [etc.]

ou

# wodim -v -dev=/dev/cdrw -dao -audio track1.wav track2.wav track3.wav [etc.]

ou

# wodim -v -dev=/dev/cdrw -dao -audio track1.au track2.au track3.au [etc.]


Turn on VIM in hexa mode

:%!xxd
:%!xxd -r

Rescale pictures with ffmpeg

for file in *.jpg; do ffmpeg -i "$file" -vf scale=iw*.5:ih*.5 "$file".half.jpg;done


FFmpeg has got a very powerful scale filter, which can be used to accomplish various tasks. Some of them are listed here. More can be found in the official documentation. In all the examples, the starting image (input.jpg) will be this one (535x346 pixels):

If you need to simply resize your video to a specific size (e.g 320x240), you can use the scale filter in its most basic form:

ffmpeg -i input.avi -vf scale=320:240 output.avi

Same works for images too:

ffmpeg -i input.jpg -vf scale=320:240 output_320x240.png

The resulting image will look like this:

As you can see, the aspect ratio is not the same as in the original image, so the image appears stretched. If we'd like to keep the aspect ratio, we need to specify only one component, either width or height, and set the other component to -1. For example, this command line:

ffmpeg -i input.jpg -vf scale=320:-1 output_320.png

will set the width of the output image to 320 pixels and will calculate the height of the output image according to the aspect ratio of the input image. The resulting image will have a dimension of 320x207 pixels.

There are also some useful constants which can be used instead of numbers, to specify width and height of the output image. For example, if you want to stretch the image in such a way to only double the width of the input image, you can use something like this (iw = input width constant, ih = input height constant):

ffmpeg -i input.jpg -vf scale=iw*2:ih input_double_width.png

The output image will look like this:

If you want to half the size of the picture, just multiply by .5

ffmpeg -i input.jpg -vf scale=iw*.5:ih*.5 input_half_size.png

Sometimes there is a need to scale the input image in such way it fits into a specified rectangle, i.e. if you have a placeholder (empty rectangle) in which you want to scale any given image. This is a little bit tricky, since you need to check the original aspect ratio, in order to decide which component to specify and to set the other component to -1 (to keep the aspect ratio). For example, if we would like to scale our input image into a rectangle with dimensions of 320x240, we could use something like this:

ffmpeg -i input.jpg -vf scale="'if(gt(a,4/3),320,-1)':'if(gt(a,4/3),-1,240)'" output_320x240_boxed.png

The output image will look like this:

The area below the image is shaded with boxes to show there was some additional space left in the box, due to the original image not having the same aspect ratio as the box, in which the image was supposed to fit.

Of course, this approach is only used when your input image is not known in advance, because if it was known, you would easily figure out if you need to use either:

-vf scale=320:-1

or

-vf scale=-1:240

Raccourcis BASH

Control Key combinations (CTRL+KEY)

   Ctrl + a : jump to the start of the line
   Ctrl + b : move back a char
   Ctrl + c : terminate the command
   Ctrl + d : delete from under the cursor
   Ctrl + e : jump to the end of the line
   Ctrl + f : move forward a char
   Ctrl + k : delete to EOL
   Ctrl + l : clear the screen
   Ctrl + r : search the history backwards
   Ctrl + R : search the history backwards with multi-occurrence
   Ctrl + u : delete backward from cursor
   Ctrl + w : delete backward a word
   Ctrl + xx : move between EOL and current cursor position
   Ctrl + z : suspend/stop the command

Alt Key combinations (ALT+KEY)

   Alt + < : move to the first line in the history
   Alt + > : move to the last line in the history
   Alt + ? : show current completion list
   Alt + * : insert all possible completions
   Alt + / : attempt to complete filename
   Alt + . : yank last argument to previous command
   Alt + b : move backward
   Alt + c : capitalize the word
   Alt + d : delete word
   Alt + f : move forward
   Alt + l : make word lowercase
   Alt + n : search the history forwards non-incremental
   Alt + p : search the history backwards non-incremental
   Alt + r : recall command
   Alt + t : move words around
   Alt + u : make word uppercase
   Alt + Backspace : delete backward from cursor

Escape Key combinations (ESC+KEY)

   Esc + d : delete from cursor position to end of the word
   Esc + f : move forward a word
   Esc + b : move backward a word
   Esc + t : transpose two adjacent words

------------------------------------------------
Thanks to:

http://cheat.errtheblog.com/s/bash
http://www.shell-tips.com

Monter un volume veracrypt en ligne de commande avec cryptsetup ou veracrypt

sudo cryptsetup --veracrypt open --type tcrypt '/media/moi/DT16G/container' veracrypt1
sudo mount /dev/mapper/veracrypt1 /media/veracrypt1/
sudo umount /media/veracrypt1
sudo cryptsetup --veracrypt close --type tcrypt veracrypt1



veracrypt '/media/moi/DT16G/container' /media/veracrypt1/
veracrypt -d veracrypt1