ISOUSB request

Technical issues/questions of an intermediate or advanced nature.
User avatar
Blaze
Moderator
Moderator
Posts: 1384
Joined: 28 Dec 2010, 11:31
Distribution: ⟰ Porteus 3.2 Cinnamon x86_64
Location: ☭ Russian Federation, Lipetsk region, Dankov
Contact:

Re: Porteus-v3.2.2 bug reports here

Post#16 by Blaze » 04 Apr 2017, 18:47

port wrote:

Code: Select all

# mloop myimage.iso
# cp -a /mnt/loop/* /mnt/usb/
# uloop
This that I need :good: Thanks.

I think need to replace "# Loop of copy with progress bar" section on the port suggestion + of course, some tweaks :)

Code: Select all

#!/bin/bash

# Written by Patrice Bourrel (Esclapion) for Manjaro Linux
# Description : used to write an installation ISO on a USB stick
# Version 1.4 of 04/20/2014


LG=`echo "$LANG" | cut -c1-2`
case $LG in


  ca)
M=(
[0]="Selecciona la ISO a copiar"
[1]="Sortir d'isousb"
[2]="N°"
[3]="Nom"
[4]="Mida en GB"
[5]="Selecciona la unitat de disc USB"
[6]="Ves en compte si la mida és massa gran"
[7]="ATENCIÓ ! ! !"
[8]="Podria ser un disc dur extern.\nContinuar ?"
[9]="Problema amb l'eina, contacta amb l'autor"
[10]="Porcentatge fet"
[11]="Còpia de"
[12]="Pots extreure la clau USB si vols"
[13]="Fi de la còpia"
);;


  de)
M=(
[0]="Wahl der ISO-Datei"
[1]="Isousb beenden"
[2]="Nr."
[3]="Pfad"
[4]="Grösse in GB"
[5]="Wahl des USB-Sticks"
[6]="Achtung!\nAlle Daten auf dem gewählten Laufwerk\nwerden gelöscht.\nBeenden Sie das Programm, falls Sie anhand\nder 'Grösse in GB' Ihren USB-Stick nicht\neindeutig erkennen können."
[7]="ACHTUNG ! ! !"
[8]="Dies könnte eine externe Festplatte sein.\nFortfahren?"
[9]="Fehler im Programm. Bitte den Autor benachrichtigen."
[10]="Fortschritt"
[11]="Kopie von"
[12]="Der USB-Stick kann jetzt entfernt werden."
[13]="Kopiervorgang abgeschlossen"
);;


  el)
M=(
[0]="Επιλέτε το ISO προς αντιγραφή"
[1]="Τερματισμός isousb"
[2]="Νο"
[3]="Όνομα"
[4]="Μέγεθος σε GB"
[5]="Επιλέξτε το δίσκο USB"
[6]="Προσέξτε μήπως το μέγεθος είναι πολύ μεγάλο"
[7]="ΠΡΟΣΟΧΗ! ! !"
[8]="Θα μπορούσε να είναι εξωτερικός σκληρός δίσκος.\nΣυνέχεια ?"
[9]="Πρόβλημα στο εργαλείο. Επικοινωνήστε με τον συγγραφέα του."
[10]="Ποσοστό έτοιμο"
[11]="Αντιγραφή του"
[12]="Μπορείτε να αφαιρέσετε τον δίσκο εάν επιθυμείτε"
[13]="Η αντιγραφή τελείωσε"
);;


  es)
M=(
[0]="Seleccionar la ISO a copiar"
[1]="Cerrar isousb"
[2]="N°"
[3]="Nombre"
[4]="Tamaño en GB"
[5]="Seleccionar la unidad USB"
[6]="Controlar que el tamaño del ISO no sea demasiado grande"
[7]="ATENCIÓN ! ! !"
[8]="Podría ser un disco rigido esterno.\nContinuar ?"
[9]="Problema con la herramienta, contactar con el autor"
[10]="Porcentaje completado"
[11]="Copia de"
[12]="Puede extraer la llave si quiere"
[13]="Copia completada"
);;


  fr)
M=(
[0]="Sélectionnez l'ISO à copier"
[1]="Quitter isousb"
[2]="N°"
[3]="Nom"
[4]="Taille en Go"
[5]="Sélectionnez votre clé USB"
[6]="Attention si taille trop grande"
[7]="ATTENTION ! ! !"
[8]="Ça pourrait être un disque dur externe.\nContinuer ?"
[9]="Problème dans l'outil. Contactez l'auteur"
[10]="Pourcentage fait"
[11]="Copie de"
[12]="Vous pouvez retirer la clé si vous le souhaitez"
[13]="Fin de la copie"
);;

  it)
M=(
[0]="Selezionare la ISO da copiare"
[1]="Chiudere isousb"
[2]="N°"
[3]="Nome"
[4]="Dimensione in GB"
[5]="Selezionare l'unità USB"
[6]="Controllare che la dimensione della ISO non sia troppo grande"
[7]="ATTENZIONE ! ! !"
[8]="Potrebbe essere un disco rigido esterno.\nContinuare ?"
[9]="Problemi con lo strumento, contattare l'autore"
[10]="Percentuale completato"
[11]="Copia di"
[12]="Puoi estrarre la chiave se vuoi"
[13]="Copia completata"
);;


  pl)
M=(
[0]="Wybierz obraz ISO do skopiowania"
[1]="Zakończ isousb"
[2]="Nr"
[3]="Nazwa"
[4]="Rozmiar w GB"
[5]="Wybierz swój dysk USB"
[6]="Uważaj jeśli rozmiar jest zbyt duży"
[7]="UWAGA ! ! !"
[8]="To może być zewnętrzny dysk twardy.\nKontynuować ?"
[9]="Problem z narzędziem, skontaktuj się z autorem"
[10]="Procent ukończenia"
[11]="Kopia"
[12]="Możesz odpiąć swój dysk jeśli chcesz"
[13]="Koniec kopiowania"
);;


  pt)
M=(
[0]="Selecione a ISO para copiar"
[1]="Sair isousb"
[2]="N°"
[3]="Nome"
[4]="Tamanho em GB"
[5]="Selecione o seu USB drive"
[6]="Atenção tamanho muito grande"
[7]="ATENÇÃO ! ! !"
[8]="Poderia ser um disco rígido externo. \nContinuar ?"
[9]="Problema na ferramenta. Contactar o autor."
[10]="Porcentagem"
[11]="Copiar de"
[12]="Você já pode remover o seu USB drive."
[13]="Fim de copiar"
);;


  ro)
M=(
[0]="Selectați ISO-ul de copiat"
[1]="Ieșire"
[2]="Nr."
[3]="Nume"
[4]="Dimensiune în GB"
[5]="Selectați drive-ul USB"
[6]="Verificați dacă mărimea este prea mare"
[7]="ATENȚIE ! ! !"
[8]="Ar putea fi un hard disc extern.\nContinuați ?"
[9]="Problemă cu unealta, contactați autorul"
[10]="Procent terminat"
[11]="Copie al"
[12]="Puteți scoate cheia dacă doriți"
[13]="Copiere terminată"
);;


  ru)
M=(
[0]="Выберите ISO образ для копирования его содержимого на USB накопитель"
[1]="Выход"
[2]="Номер"
[3]="Наименование"
[4]="Размер в Гб"
[5]="Выберите USB-накопитель"
[6]="Внимание! Все данные на выбранном накопителе будут удалены!!!\nОстерегайтесь, если размер содержимого ISO образа превышает размер USB накопителя!"
[7]="ПРЕДУПРЕЖДЕНИЕ ! ! !"
[8]="Это может быть внешний жесткий диск.\nПродолжить ?"
[9]="Проблема в сценарии isousb, обратитесь к автору."
[10]="Выполняется копирование"
[11]="Копирование содержимого"
[12]="Копирование содержимого ISO образа на USB накопитель успешно завершено.\nДля корректного перемонтирования USB накопителя извлеките и снова подключите его."
[13]="Копирование успешно завершено"
);;


  tr)
M=(
[0]="Kopyalanacak kalıbı seçiniz"
[1]="Isousb den çık"
[2]="No"
[3]="İsim"
[4]="Yüklenecek boyut"
[5]="USB sürücünüzü seçin"
[6]="Boyut çok büyükse dikkat edin"
[7]="DİKKAT! ! !"
[8]="Harici bir sürücü olabilir.\nDevam ?"
[9]="Araçta problem var, yayınlayıcı ile irtibat kurun"
[10]="Tamamlanan yüzde"
[11]="Kopyalanan kalıp"
[12]="USB anahtarını isterseniz çıkarabilirsiniz"
[13]="Kopyalama bitti"
);;

  *)
M=(
[0]="Select the ISO to be copied"
[1]="Exit isousb"
[2]="Nr"
[3]="Name"
[4]="Size in GB"
[5]="Select your USB drive"
[6]="Beware if size is too large"
[7]="WARNING ! ! !"
[8]="It could be an external hard drive.\nContinue ?"
[9]="Problem in the tool, contact the author."
[10]="Percentage done"
[11]="Copy of"
[12]="You can remove the key if you want."
[13]="End of copy"
);;
esac


NomIso=`zenity --file-selection --title="${M[0]}" --filename=/home/$USER/ --file-filter=*.iso`
[ $? -eq 0 ] || exit 0

Boucle=1
while [ $Boucle = 1 ]
do
  # List of devices that are in /dev/disk/by-path
  # ---------------------------------------------
  Liste1=()
  nbval1=0
  for i in $(ls -l /dev/disk/by-path/*-usb-* | sed -n -e 's/.*\///' -e /[a-z]$/p | sort -d)
  do
    Liste1[$nbval1]="/dev/"$i
    ((nbval1++))
  done

  # List of devices seen by blkid
  # -----------------------------
  Liste2=()
  nbval2=0
  for j in $(blkid -o device | sed -e 's/[0-9]*$//' -e 's/\/dev\///' | uniq | sort -d)
  do
    Liste2[$nbval2]="/dev/"$j
    ((nbval2++))
  done

  # List of files seen by the two
  # -----------------------------
  Choix=()
  nbchoix=0
  for ((i=0; i < nbval1; i++))
  do
    for ((j=0; j < nbval2; j++))
    do
      if [ ${Liste1[$i]} = ${Liste2[$j]} ]; then
        Choix[nbchoix]=${Liste1[$i]}
        ((nbchoix++))
      fi
    done
  done

  # User's choice
  # -------------

  Taille=()
  choix=$nbchoix
  fictemp=$(mktemp)

  while [ "$choix" -lt 0 -o "$choix" -ge $nbchoix ]
  do
    for ((i= 0; i < $nbchoix; i++))
    do
      taille=`fdisk -s ${Choix[$i]}`
      Taille[$i]=$(((taille + 500000) / 1000000))
      printf "%d %s %5d\n" $i ${Choix[$i]} ${Taille[$i]} >> $fictemp
    done
    echo "$i ${M[1]}" >> $fictemp
    rep=`zenity --list --height=250 --width=400 --column="${M[2]}" --column="${M[3]}" --column="${M[4]}" $(cat $fictemp) --title="${M[5]}" --text="${M[6]}"`
    rm $fictemp
    case "$rep" in
      [0-$((nbchoix -1))])
        choix=$rep
        Boucle=0
        if [ ${Taille[$rep]} -gt 128 ]; then
           zenity --question --title="${M[7]}" --text "${M[8]}"
           [ $? -ne 0 ] && { choix=-1; Boucle=1; }
        fi
        ;;
      $nbchoix)
        exit 0
        ;;
      "")
        break
        ;;
      *)
        zenity --error --text="${M[9]}"
        exit 1
        ;;
    esac
  done
done


# Loop of copy with progress bar
# ------------------------------
i=0
l=0
fictemp=$(mktemp)
taille=`fdisk -s "$NomIso"`
(while [ $l -lt $taille ]; do
  echo "dd if=$NomIso of=${Choix[$choix]} bs=8192000 count=1 skip=$i seek=$i oflag=direct" > $fictemp
  dd if="$NomIso" of=${Choix[$choix]} bs=8192000 count=1 skip=$i seek=$i oflag=direct >>$fictemp 2>&1
  [ $? -ne 0 ] && break
  rm $fictemp
  i=$(($i+1))
  l=$(($l+8000))
  q=$(($l*100/$taille))
  echo -e "$q \n#""${M[10]}"" : $q %"
done) | zenity --progress --width 650 --auto-close --title "${M[11]}"" $NomIso"

if [ -f $fictemp ]; then
  zenity --error --text="$(cat $fictemp)"
  rm $fictemp
  exit 1
else
  sync; sync
  zenity --info --text="${M[12]}" --title="${M[13]}"
  exit 0
fi
Linux porteus 4.12.7-porteus #1 SMP PREEMPT Sun Aug 13 17:38:30 x86_64 Intel(R) Core(TM) i5-6600K CPU @ 3.50GHz GenuineIntel GNU/Linux
MS-7A12 » [AMD/ATI] Tobago PRO [Radeon R7 360 / R9 360 OEM] (rev 81) » Vengeance LPX 16GB DDR4 K2 3200MHz C16

User avatar
Ed_P
Contributor
Contributor
Posts: 3159
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 3.2.2 64-bit ISO
Location: Western NY, USA

Re: Porteus-v3.2.2 bug reports here

Post#17 by Ed_P » 04 Apr 2017, 20:12

Blaze wrote:Sorry about my English.
There is absolutely nothing wrong with your English. :good: Execute implies executing an .exe or .cmd file and can also imply booting. :)
port wrote:the better and simple way to achieve this is simply mount iso image file and the copy content to usb drive, something like this (supposing usb drive is mounted in /mnt/usb):

Code: Select all

# mloop myimage.iso
# cp -a /mnt/loop/* /mnt/usb/
# uloop
But this approach doesn't stop someone, including the owner of the USB drive, from accidently deleting a file or two off the drive. A thing not possible with a CD/DVD disc or the USB drives created with the isousb app.

Would the USB drive be bootable with your approach port?
Ed

port
Samurai
Samurai
Posts: 135
Joined: 18 Feb 2016, 09:25
Distribution: Linux porteus 3.2.2 KDE
Location: Spain

Re: Porteus-v3.2.2 bug reports here

Post#18 by port » 04 Apr 2017, 23:34

Ed_P wrote:
But this approach doesn't stop someone, including the owner of the USB drive, from accidently deleting a file or two off the drive. A thing not possible with a CD/DVD disc or the USB drives created with the isousb app.

Would the USB drive be bootable with your approach port?
I'm missing something here, I've supposed you want a r/w filesystem in the usb with the contents of dvd filesystem, at least that is what Blaze seems to want, if you want that you get that with the mloop and copying method.

But now you're saying you want a writable filesystem but preventing accidental deletion, so what you really say is you want a writable filesystem that doesn't allow writing in the filesystem (deleting is writing at the end)

I think first we need setting goals clearly, there're four goals:
  1. We want a read only file system which is an exact copy of iso file image (a clone)

    So use the isousb app or simply dd to copy iso file to usb drive (or cd/dvd), you will end with a usb drive (or cd/dvd) that is and act as a DVD: read only filesystem and bootable if iso file is a bootable iso.
  2. We want a read only bootable usb drive being an exact copy of iso file image

    This is a special case of previous goal, if the iso file is already a bootable iso then it's the same of previous goal, if it is not then you have to patch the iso before copying to usb drive, i.e. if you have a normal ISO 9660 image you have to convert it to El Torito extension before copying, you can make this with several tools like cdrtools
  3. We want a writable usb drive with all content present in iso file (all data)

    The use the mloop and cp method, you end up with a "normal" usb drive (maybe fat or ext3 or whatever) r/w filesystem with all data present in iso file, you can add new data and modify or remove data already in usb (and iso file)
  4. We want a read/write bootable usb drive being an exact copy of iso file image

    Then you need a Hybrid ISO, you will need to patch te iso file before copying to add it mbr and partion table, there're tools for doing that but it is easy if iso file is already a Hybrid ISO. You will end up with a usb drive that is an exact copy of dvd/cd iso file (thus read only) plus some partitions added to make it writable. If you copy this Hybrid ISO to a cd/dvd it will act like a bootable dvd/cd but if you copy it to usb drive it will act as a bootable disk (like a hd or sdd) where you can write
Obviously if you make a filesystem writable you cannot prevent it for being deleted but it's important to highlight that iso filesystem is always read only and thus preserved, you only write on writable partitions on usb drive. Even if you want to avoid writing in usb drive partitions there's something you can do, simply mount the usb drive as read only ;-)

User avatar
Blaze
Moderator
Moderator
Posts: 1384
Joined: 28 Dec 2010, 11:31
Distribution: ⟰ Porteus 3.2 Cinnamon x86_64
Location: ☭ Russian Federation, Lipetsk region, Dankov
Contact:

Re: Porteus-v3.2.2 bug reports here

Post#19 by Blaze » 05 Apr 2017, 20:30

port wrote:3. We want a writable usb drive with all content present in iso file (all data)

The use the mloop and cp method, you end up with a "normal" usb drive (maybe fat or ext3 or whatever) r/w filesystem with all data present in iso file, you can add new data and modify or remove data already in usb (and iso file)
Yes, I want this with a good permissions and chown root:root (truncate rights guest for this content)

I found some time and tweak script for it

Code: Select all

#!/bin/bash

# Written by Patrice Bourrel (Esclapion) for Manjaro Linux
# Description : used to write an installation ISO on a USB stick
# Version 1.4 of 04/20/2014


LG=`echo "$LANG" | cut -c1-2`
case $LG in


  ca)
M=(
[0]="Selecciona la ISO a copiar"
[1]="Sortir d'isousb"
[2]="N°"
[3]="Nom"
[4]="Mida en GB"
[5]="Selecciona la unitat de disc USB"
[6]="Ves en compte si la mida és massa gran"
[7]="ATENCIÓ ! ! !"
[8]="Podria ser un disc dur extern.\nContinuar ?"
[9]="Problema amb l'eina, contacta amb l'autor"
[10]="Porcentatge fet"
[11]="Còpia de"
[12]="Pots extreure la clau USB si vols"
[13]="Fi de la còpia"
);;


  de)
M=(
[0]="Wahl der ISO-Datei"
[1]="Isousb beenden"
[2]="Nr."
[3]="Pfad"
[4]="Grösse in GB"
[5]="Wahl des USB-Sticks"
[6]="Achtung!\nAlle Daten auf dem gewählten Laufwerk\nwerden gelöscht.\nBeenden Sie das Programm, falls Sie anhand\nder 'Grösse in GB' Ihren USB-Stick nicht\neindeutig erkennen können."
[7]="ACHTUNG ! ! !"
[8]="Dies könnte eine externe Festplatte sein.\nFortfahren?"
[9]="Fehler im Programm. Bitte den Autor benachrichtigen."
[10]="Fortschritt"
[11]="Kopie von"
[12]="Der USB-Stick kann jetzt entfernt werden."
[13]="Kopiervorgang abgeschlossen"
);;


  el)
M=(
[0]="Επιλέτε το ISO προς αντιγραφή"
[1]="Τερματισμός isousb"
[2]="Νο"
[3]="Όνομα"
[4]="Μέγεθος σε GB"
[5]="Επιλέξτε το δίσκο USB"
[6]="Προσέξτε μήπως το μέγεθος είναι πολύ μεγάλο"
[7]="ΠΡΟΣΟΧΗ! ! !"
[8]="Θα μπορούσε να είναι εξωτερικός σκληρός δίσκος.\nΣυνέχεια ?"
[9]="Πρόβλημα στο εργαλείο. Επικοινωνήστε με τον συγγραφέα του."
[10]="Ποσοστό έτοιμο"
[11]="Αντιγραφή του"
[12]="Μπορείτε να αφαιρέσετε τον δίσκο εάν επιθυμείτε"
[13]="Η αντιγραφή τελείωσε"
);;


  es)
M=(
[0]="Seleccionar la ISO a copiar"
[1]="Cerrar isousb"
[2]="N°"
[3]="Nombre"
[4]="Tamaño en GB"
[5]="Seleccionar la unidad USB"
[6]="Controlar que el tamaño del ISO no sea demasiado grande"
[7]="ATENCIÓN ! ! !"
[8]="Podría ser un disco rigido esterno.\nContinuar ?"
[9]="Problema con la herramienta, contactar con el autor"
[10]="Porcentaje completado"
[11]="Copia de"
[12]="Puede extraer la llave si quiere"
[13]="Copia completada"
);;


  fr)
M=(
[0]="Sélectionnez l'ISO à copier"
[1]="Quitter isousb"
[2]="N°"
[3]="Nom"
[4]="Taille en Go"
[5]="Sélectionnez votre clé USB"
[6]="Attention si taille trop grande"
[7]="ATTENTION ! ! !"
[8]="Ça pourrait être un disque dur externe.\nContinuer ?"
[9]="Problème dans l'outil. Contactez l'auteur"
[10]="Pourcentage fait"
[11]="Copie de"
[12]="Vous pouvez retirer la clé si vous le souhaitez"
[13]="Fin de la copie"
);;

  it)
M=(
[0]="Selezionare la ISO da copiare"
[1]="Chiudere isousb"
[2]="N°"
[3]="Nome"
[4]="Dimensione in GB"
[5]="Selezionare l'unità USB"
[6]="Controllare che la dimensione della ISO non sia troppo grande"
[7]="ATTENZIONE ! ! !"
[8]="Potrebbe essere un disco rigido esterno.\nContinuare ?"
[9]="Problemi con lo strumento, contattare l'autore"
[10]="Percentuale completato"
[11]="Copia di"
[12]="Puoi estrarre la chiave se vuoi"
[13]="Copia completata"
);;


  pl)
M=(
[0]="Wybierz obraz ISO do skopiowania"
[1]="Zakończ isousb"
[2]="Nr"
[3]="Nazwa"
[4]="Rozmiar w GB"
[5]="Wybierz swój dysk USB"
[6]="Uważaj jeśli rozmiar jest zbyt duży"
[7]="UWAGA ! ! !"
[8]="To może być zewnętrzny dysk twardy.\nKontynuować ?"
[9]="Problem z narzędziem, skontaktuj się z autorem"
[10]="Procent ukończenia"
[11]="Kopia"
[12]="Możesz odpiąć swój dysk jeśli chcesz"
[13]="Koniec kopiowania"
);;


  pt)
M=(
[0]="Selecione a ISO para copiar"
[1]="Sair isousb"
[2]="N°"
[3]="Nome"
[4]="Tamanho em GB"
[5]="Selecione o seu USB drive"
[6]="Atenção tamanho muito grande"
[7]="ATENÇÃO ! ! !"
[8]="Poderia ser um disco rígido externo. \nContinuar ?"
[9]="Problema na ferramenta. Contactar o autor."
[10]="Porcentagem"
[11]="Copiar de"
[12]="Você já pode remover o seu USB drive."
[13]="Fim de copiar"
);;


  ro)
M=(
[0]="Selectați ISO-ul de copiat"
[1]="Ieșire"
[2]="Nr."
[3]="Nume"
[4]="Dimensiune în GB"
[5]="Selectați drive-ul USB"
[6]="Verificați dacă mărimea este prea mare"
[7]="ATENȚIE ! ! !"
[8]="Ar putea fi un hard disc extern.\nContinuați ?"
[9]="Problemă cu unealta, contactați autorul"
[10]="Procent terminat"
[11]="Copie al"
[12]="Puteți scoate cheia dacă doriți"
[13]="Copiere terminată"
);;


  ru)
M=(
[0]="Выберите ISO образ для копирования его содержимого на USB накопитель"
[1]="Выход"
[2]="Номер"
[3]="Наименование"
[4]="Размер в Гб"
[5]="Выберите USB-накопитель"
[6]="Остерегайтесь, если размер содержимого ISO образа превышает размер USB накопителя!"
[7]="ПРЕДУПРЕЖДЕНИЕ ! ! !"
[8]="Это может быть внешний жесткий диск.\nПродолжить ?"
[9]="Проблема в сценарии isousb, обратитесь к автору."
[10]="Выполняется копирование"
[11]="Копирование содержимого"
[12]="Копирование содержимого ISO образа на USB накопитель успешно завершено."
[13]="Копирование успешно завершено"
);;


  tr)
M=(
[0]="Kopyalanacak kalıbı seçiniz"
[1]="Isousb den çık"
[2]="No"
[3]="İsim"
[4]="Yüklenecek boyut"
[5]="USB sürücünüzü seçin"
[6]="Boyut çok büyükse dikkat edin"
[7]="DİKKAT! ! !"
[8]="Harici bir sürücü olabilir.\nDevam ?"
[9]="Araçta problem var, yayınlayıcı ile irtibat kurun"
[10]="Tamamlanan yüzde"
[11]="Kopyalanan kalıp"
[12]="USB anahtarını isterseniz çıkarabilirsiniz"
[13]="Kopyalama bitti"
);;

  *)
M=(
[0]="Select the ISO to be copied"
[1]="Exit isousb"
[2]="Nr"
[3]="Name"
[4]="Size in GB"
[5]="Select your USB drive"
[6]="Beware if size is too large"
[7]="WARNING ! ! !"
[8]="It could be an external hard drive.\nContinue ?"
[9]="Problem in the tool, contact the author."
[10]="Percentage done"
[11]="Copy of"
[12]="You can remove the key if you want."
[13]="End of copy"
);;
esac


NomIso=`zenity --file-selection --title="${M[0]}" --filename=/home/$USER/ --file-filter=*.iso`
[ $? -eq 0 ] || exit 0

Boucle=1
while [ $Boucle = 1 ]
do
  # List of devices that are in /dev/disk/by-path
  # ---------------------------------------------
  Liste1=()
  nbval1=0
  for i in $(ls -l /dev/disk/by-path/*-usb-* | sed -n -e 's/.*\///' -e /[a-z][0-9]$/p | sort -d)
  do
    Liste1[$nbval1]="/mnt/"$i
    ((nbval1++))
  done

  # List of devices seen by blkid
  # -----------------------------
  Liste2=()
  nbval2=0
  for j in $(blkid -o device | sed -e 's/*$//' -e 's/\/dev\///' | uniq | sort -d)
  do
    Liste2[$nbval2]="/mnt/"$j
    ((nbval2++))
  done

  # List of files seen by the two
  # -----------------------------
  Choix=()
  nbchoix=0
  for ((i=0; i < nbval1; i++))
  do
    for ((j=0; j < nbval2; j++))
    do
      if [ ${Liste1[$i]} = ${Liste2[$j]} ]; then
        Choix[nbchoix]=${Liste1[$i]}
        ((nbchoix++))
      fi
    done
  done

  # User's choice
  # -------------

  Taille=()
  choix=$nbchoix
  fictemp=$(mktemp)

  while [ "$choix" -lt 0 -o "$choix" -ge $nbchoix ]
  do
    for ((i= 0; i < $nbchoix; i++))
    do
      taille=`fdisk -s ${Choix[$i]}`
      Taille[$i]=$(((taille + 500000) / 1000000))
      printf "%d %s %5d\n" $i ${Choix[$i]} ${Taille[$i]} >> $fictemp
    done
    echo "$i ${M[1]}" >> $fictemp
    rep=`zenity --list --height=250 --width=400 --column="${M[2]}" --column="${M[3]}" --column="${M[4]}" $(cat $fictemp) --title="${M[5]}" --text="${M[6]}"`
    rm $fictemp
    case "$rep" in
      [0-$((nbchoix -1))])
        choix=$rep
        Boucle=0
        if [ ${Taille[$rep]} -gt 128 ]; then
           zenity --question --title="${M[7]}" --text "${M[8]}"
           [ $? -ne 0 ] && { choix=-1; Boucle=1; }
        fi
        ;;
      $nbchoix)
        exit 0
        ;;
      "")
        break
        ;;
      *)
        zenity --error --text="${M[9]}"
        exit 1
        ;;
    esac
  done
done


# Loop of copy with progress bar
# ------------------------------
i=0
l=0
fictemp=$(mktemp)
taille=`fdisk -s "$NomIso"`
(while [ $l -lt $taille ]; do
  echo "mloop $NomIso && rsync -a /mnt/loop/* ${Choix[$choix]} && uloop;" > $fictemp
  mloop "$NomIso" && rsync -a /mnt/loop/* ${Choix[$choix]} && uloop; >> $fictemp 2>&1
  [ $? -ne 0 ] && break
  rm $fictemp
  i=$(($i+1))
  l=$(($l+8000))
  q=$(($l*100/$taille))
  echo -e "$q \n#""${M[10]}"" : $q %"
done) | zenity --progress --width 650 --auto-close --title "${M[11]}"" $NomIso"

if [ -f $fictemp ]; then
  zenity --error --text="$(cat $fictemp)"
  rm $fictemp
  exit 1
else
  sync; sync
  zenity --info --text="${M[12]}" --title="${M[13]}"
  exit 0
fi
for test, you can run

Code: Select all

sh +x /opt/porteus-scripts/isousb
I have a small trouble with not correct usb flash drive size and freezes with messages

Code: Select all

mount: /dev/loop13 is write-protected, mounting read-only
blah blah blah
mount: /dev/loop13 is write-protected, mounting read-only
+ I can add function for format USB stick to ext2 (advantage it's a good permissions and owner with group is root:root). What do you think about this?
Linux porteus 4.12.7-porteus #1 SMP PREEMPT Sun Aug 13 17:38:30 x86_64 Intel(R) Core(TM) i5-6600K CPU @ 3.50GHz GenuineIntel GNU/Linux
MS-7A12 » [AMD/ATI] Tobago PRO [Radeon R7 360 / R9 360 OEM] (rev 81) » Vengeance LPX 16GB DDR4 K2 3200MHz C16

port
Samurai
Samurai
Posts: 135
Joined: 18 Feb 2016, 09:25
Distribution: Linux porteus 3.2.2 KDE
Location: Spain

Re: Porteus-v3.2.2 bug reports here

Post#20 by port » 07 Apr 2017, 21:23

Blaze wrote:I found some time and tweak script for it
In my opinion there's a problem with this fragment of code:

Code: Select all

# Loop of copy with progress bar
# ------------------------------
i=0
l=0
fictemp=$(mktemp)
taille=`fdisk -s "$NomIso"`
(while [ $l -lt $taille ]; do
  echo "mloop $NomIso && rsync -a /mnt/loop/* ${Choix[$choix]} && uloop;" > $fictemp
  mloop "$NomIso" && rsync -a /mnt/loop/* ${Choix[$choix]} && uloop; >> $fictemp 2>&1
  [ $? -ne 0 ] && break
  rm $fictemp
  i=$(($i+1))
  l=$(($l+8000))
  q=$(($l*100/$taille))
  echo -e "$q \n#""${M[10]}"" : $q %"
done) | zenity --progress --width 650 --auto-close --title "${M[11]}"" $NomIso"
this code was originally written for a raw copy (dd) in data chunks of 8 Mb size (paremeter bs) so there's a loop for copying each chunk of data and a counter to increment data chunk (variable i), since you are copying file by file a block loop and counter are no longer needed.

Even worse, you're mounting the same iso file every loop step using a new loop device every time, this leads to inefficiency, bad performance and loop device starvation (I guess this is realated with the errors you got), this is not needed, mounting iso file once is enough.

Also computing copied percentage is a nonsense when copying files one by one, you don't know how much they will be and computing percentage per file does not provide useful information. It only has sense when copying full data by data blocks. So it's not needed to accumulate data copied (variable l) neither compute percentage (variable q)

Another optimization is using cp rather that rsync, you're copying files to a local filesystem not across a network so using rsync is overkilled, cp is much faster.

Thus the code can be rewritten as:

Code: Select all

# Loop of copy with progress bar
# ------------------------------
fictemp=$(mktemp)
  echo "mloop $NomIso && cp -a /mnt/loop/* ${Choix[$choix]} && uloop;" > $fictemp
  mloop "$NomIso" && cp -a /mnt/loop/* ${Choix[$choix]} && uloop; >> $fictemp 2>&1
  [ $? -ne 0 ] && break
  rm $fictemp
But there's an error in this code, you're chaining several commads using operator && and redirecting output to a file at the end, but using redirection after the last command of the chain will redirect only the output of that last command, not output of every command in the chain what I suppose is what you want, even worse you are using a semicolon after last command in chain so you will redirect nothing at all. If you want to redirect output of every command in the chain you need command grouping, so:

Code: Select all

# Loop of copy with progress bar
# ------------------------------
fictemp=$(mktemp)
  echo "mloop $NomIso && cp -a /mnt/loop/* ${Choix[$choix]} && uloop;" > $fictemp
  { mloop "$NomIso" && cp -a /mnt/loop/* ${Choix[$choix]} && uloop; } >> $fictemp 2>&1
  [ $? -ne 0 ] && break
  rm $fictemp
Really deleting temporal output file doesn't have sense to me and break without being inside a loop is a nonsense. What would be interesting is copying iso file contents only if there's enough space in target drive, so:

Code: Select all

fictemp=$(mktemp)
taille=`fdisk -s "$NomIso"`
if [ ${Taille[$choix]} -lt $taille ]; then
  echo "mloop $NomIso && cp -a /mnt/loop/* ${Choix[$choix]} && uloop;" > $fictemp
  { mloop "$NomIso" && cp -a /mnt/loop/* ${Choix[$choix]} && uloop; } >> $fictemp 2>&1
fi
But you really want that cute progress bar so a pretty inefficient but simple way of achieve it may be:

Code: Select all

# Loop of copy with progress bar
# ------------------------------
fictemp=$(mktemp)
taille=`fdisk -s "$NomIso"`
if [ ${Taille[$choix]} -lt $taille ]; then
  mloop "$NomIso" >> $fictemp 2>&1
  T=$(du -s /mnt/loop/ | cut -f 1)
  (for f in /mnt/loop/* ; do 
     cp $f ${Choix[$choix]} >> $fictemp 2>&1  
     echo "# $f" 
     echo "$(echo "scale=2; $(du -s ${Choix[$choix]} | cut -f 1) / $T * 100" |bc)" 
  done) | zenity --progress --width 650 --auto-close --title "${M[11]}"" $NomIso"
  uloop >> $fictemp 2>&1
fi 
it's not tested just typed while thinking about, it will require profiling
Blaze wrote:+ I can add function for format USB stick to ext2 (advantage it's a good permissions and owner with group is root:root). What do you think about this?
I wouldn't format a drive without user authorization, maybe including the feature as an option would be fine, if doing so it would be great to offer several formatting options like ext2, ext4 and vfat.
Last edited by port on 08 Apr 2017, 19:40, edited 1 time in total.

User avatar
Blaze
Moderator
Moderator
Posts: 1384
Joined: 28 Dec 2010, 11:31
Distribution: ⟰ Porteus 3.2 Cinnamon x86_64
Location: ☭ Russian Federation, Lipetsk region, Dankov
Contact:

Re: Porteus-v3.2.2 bug reports here

Post#21 by Blaze » 08 Apr 2017, 19:09

port wrote:But you really want that cute progress bar so a pretty inefficient but simple way of achieve it may be:
In this line

Code: Select all

     echo "$(echo "scale=2; $(du -s ${Choix[$choix] | cut -f 1) / $T * 100" |bc)"
is missing }

Code: Select all

     echo "$(echo "scale=2; $(du -s ${Choix[$choix]} | cut -f 1) / $T * 100" | bc)"
port wrote:it's not tested just typed while thinking about, it will require profiling
I tested and it does not work (look at my current variant below). In terminal nothing about errors.

I fixed trouble with not correct usb flash drive size in column.

What I have now

Code: Select all

#!/bin/bash

# Written by Patrice Bourrel (Esclapion) for Manjaro Linux
# Description : used to write an installation ISO on a USB stick
# Version 1.4 of 04/20/2014


LG=`echo "$LANG" | cut -c1-2`
case $LG in


  ca)
M=(
[0]="Selecciona la ISO a copiar"
[1]="Sortir d'isousb"
[2]="N°"
[3]="Nom"
[4]="Mida en GB"
[5]="Selecciona la unitat de disc USB"
[6]="Ves en compte si la mida és massa gran"
[7]="ATENCIÓ ! ! !"
[8]="Podria ser un disc dur extern.\nContinuar ?"
[9]="Problema amb l'eina, contacta amb l'autor"
[10]="Porcentatge fet"
[11]="Còpia de"
[12]="Pots extreure la clau USB si vols"
[13]="Fi de la còpia"
);;


  de)
M=(
[0]="Wahl der ISO-Datei"
[1]="Isousb beenden"
[2]="Nr."
[3]="Pfad"
[4]="Grösse in GB"
[5]="Wahl des USB-Sticks"
[6]="Achtung!\nAlle Daten auf dem gewählten Laufwerk\nwerden gelöscht.\nBeenden Sie das Programm, falls Sie anhand\nder 'Grösse in GB' Ihren USB-Stick nicht\neindeutig erkennen können."
[7]="ACHTUNG ! ! !"
[8]="Dies könnte eine externe Festplatte sein.\nFortfahren?"
[9]="Fehler im Programm. Bitte den Autor benachrichtigen."
[10]="Fortschritt"
[11]="Kopie von"
[12]="Der USB-Stick kann jetzt entfernt werden."
[13]="Kopiervorgang abgeschlossen"
);;


  el)
M=(
[0]="Επιλέτε το ISO προς αντιγραφή"
[1]="Τερματισμός isousb"
[2]="Νο"
[3]="Όνομα"
[4]="Μέγεθος σε GB"
[5]="Επιλέξτε το δίσκο USB"
[6]="Προσέξτε μήπως το μέγεθος είναι πολύ μεγάλο"
[7]="ΠΡΟΣΟΧΗ! ! !"
[8]="Θα μπορούσε να είναι εξωτερικός σκληρός δίσκος.\nΣυνέχεια ?"
[9]="Πρόβλημα στο εργαλείο. Επικοινωνήστε με τον συγγραφέα του."
[10]="Ποσοστό έτοιμο"
[11]="Αντιγραφή του"
[12]="Μπορείτε να αφαιρέσετε τον δίσκο εάν επιθυμείτε"
[13]="Η αντιγραφή τελείωσε"
);;


  es)
M=(
[0]="Seleccionar la ISO a copiar"
[1]="Cerrar isousb"
[2]="N°"
[3]="Nombre"
[4]="Tamaño en GB"
[5]="Seleccionar la unidad USB"
[6]="Controlar que el tamaño del ISO no sea demasiado grande"
[7]="ATENCIÓN ! ! !"
[8]="Podría ser un disco rigido esterno.\nContinuar ?"
[9]="Problema con la herramienta, contactar con el autor"
[10]="Porcentaje completado"
[11]="Copia de"
[12]="Puede extraer la llave si quiere"
[13]="Copia completada"
);;


  fr)
M=(
[0]="Sélectionnez l'ISO à copier"
[1]="Quitter isousb"
[2]="N°"
[3]="Nom"
[4]="Taille en Go"
[5]="Sélectionnez votre clé USB"
[6]="Attention si taille trop grande"
[7]="ATTENTION ! ! !"
[8]="Ça pourrait être un disque dur externe.\nContinuer ?"
[9]="Problème dans l'outil. Contactez l'auteur"
[10]="Pourcentage fait"
[11]="Copie de"
[12]="Vous pouvez retirer la clé si vous le souhaitez"
[13]="Fin de la copie"
);;

  it)
M=(
[0]="Selezionare la ISO da copiare"
[1]="Chiudere isousb"
[2]="N°"
[3]="Nome"
[4]="Dimensione in GB"
[5]="Selezionare l'unità USB"
[6]="Controllare che la dimensione della ISO non sia troppo grande"
[7]="ATTENZIONE ! ! !"
[8]="Potrebbe essere un disco rigido esterno.\nContinuare ?"
[9]="Problemi con lo strumento, contattare l'autore"
[10]="Percentuale completato"
[11]="Copia di"
[12]="Puoi estrarre la chiave se vuoi"
[13]="Copia completata"
);;


  pl)
M=(
[0]="Wybierz obraz ISO do skopiowania"
[1]="Zakończ isousb"
[2]="Nr"
[3]="Nazwa"
[4]="Rozmiar w GB"
[5]="Wybierz swój dysk USB"
[6]="Uważaj jeśli rozmiar jest zbyt duży"
[7]="UWAGA ! ! !"
[8]="To może być zewnętrzny dysk twardy.\nKontynuować ?"
[9]="Problem z narzędziem, skontaktuj się z autorem"
[10]="Procent ukończenia"
[11]="Kopia"
[12]="Możesz odpiąć swój dysk jeśli chcesz"
[13]="Koniec kopiowania"
);;


  pt)
M=(
[0]="Selecione a ISO para copiar"
[1]="Sair isousb"
[2]="N°"
[3]="Nome"
[4]="Tamanho em GB"
[5]="Selecione o seu USB drive"
[6]="Atenção tamanho muito grande"
[7]="ATENÇÃO ! ! !"
[8]="Poderia ser um disco rígido externo. \nContinuar ?"
[9]="Problema na ferramenta. Contactar o autor."
[10]="Porcentagem"
[11]="Copiar de"
[12]="Você já pode remover o seu USB drive."
[13]="Fim de copiar"
);;


  ro)
M=(
[0]="Selectați ISO-ul de copiat"
[1]="Ieșire"
[2]="Nr."
[3]="Nume"
[4]="Dimensiune în GB"
[5]="Selectați drive-ul USB"
[6]="Verificați dacă mărimea este prea mare"
[7]="ATENȚIE ! ! !"
[8]="Ar putea fi un hard disc extern.\nContinuați ?"
[9]="Problemă cu unealta, contactați autorul"
[10]="Procent terminat"
[11]="Copie al"
[12]="Puteți scoate cheia dacă doriți"
[13]="Copiere terminată"
);;


  ru)
M=(
[0]="Выберите ISO образ для копирования его содержимого на USB накопитель"
[1]="Выход"
[2]="Номер"
[3]="Наименование"
[4]="Размер в Гб"
[5]="Выберите USB-накопитель"
[6]="Остерегайтесь, если размер содержимого ISO образа превышает размер USB накопителя!"
[7]="ПРЕДУПРЕЖДЕНИЕ ! ! !"
[8]="Это может быть внешний жесткий диск.\nПродолжить ?"
[9]="Проблема в сценарии isousb, обратитесь к автору."
[10]="Выполняется копирование"
[11]="Копирование содержимого"
[12]="Копирование содержимого ISO образа на USB накопитель успешно завершено."
[13]="Копирование успешно завершено"
);;


  tr)
M=(
[0]="Kopyalanacak kalıbı seçiniz"
[1]="Isousb den çık"
[2]="No"
[3]="İsim"
[4]="Yüklenecek boyut"
[5]="USB sürücünüzü seçin"
[6]="Boyut çok büyükse dikkat edin"
[7]="DİKKAT! ! !"
[8]="Harici bir sürücü olabilir.\nDevam ?"
[9]="Araçta problem var, yayınlayıcı ile irtibat kurun"
[10]="Tamamlanan yüzde"
[11]="Kopyalanan kalıp"
[12]="USB anahtarını isterseniz çıkarabilirsiniz"
[13]="Kopyalama bitti"
);;

  *)
M=(
[0]="Select the ISO to be copied"
[1]="Exit isousb"
[2]="Nr"
[3]="Name"
[4]="Size in GB"
[5]="Select your USB drive"
[6]="Beware if size is too large"
[7]="WARNING ! ! !"
[8]="It could be an external hard drive.\nContinue ?"
[9]="Problem in the tool, contact the author."
[10]="Percentage done"
[11]="Copy of"
[12]="You can remove the key if you want."
[13]="End of copy"
);;
esac


NomIso=`zenity --file-selection --title="${M[0]}" --filename=/home/$USER/ --file-filter=*.iso`
[ $? -eq 0 ] || exit 0

Boucle=1
while [ $Boucle = 1 ]
do
  # List of devices that are in /dev/disk/by-path
  # ---------------------------------------------
  Liste1=()
  nbval1=0
  for i in $(ls -l /dev/disk/by-path/*-usb-* | sed -n -e 's/.*\///' -e /[a-z][0-9]$/p | sort -d)
  do
    Liste1[$nbval1]="/mnt/"$i
    ((nbval1++))
  done

  # List of devices seen by blkid
  # -----------------------------
  Liste2=()
  nbval2=0
  for j in $(blkid -o device | sed -e 's/*$//' -e 's/\/dev\///' | uniq | sort -d)
  do
    Liste2[$nbval2]="/mnt/"$j
    ((nbval2++))
  done

  # Show size of device in GB
  # -------------------------
  Liste3=()
  nbval3=0
  for i in $(ls -l /dev/disk/by-path/*-usb-* | sed -n -e 's/.*\///' -e /[a-z]$/p | sort -d)
  do
    Liste3[$nbval3]="/dev/"$i
    ((nbval3++))
  done

  # List of files seen by the two
  # -----------------------------
  Choix=()
  nbchoix=0
  for ((i=0; i < nbval1; i++))
  do
    for ((j=0; j < nbval2; j++))
    do
      if [ ${Liste1[$i]} = ${Liste2[$j]} ]; then
        Choix[nbchoix]=${Liste1[$i]}
        ((nbchoix++))
      fi
    done
  done

  # User's choice
  # -------------

  Taille=()
  choix=$nbchoix
  fictemp=$(mktemp)

  while [ "$choix" -lt 0 -o "$choix" -ge $nbchoix ]
  do
    for ((i= 0; i < $nbchoix; i++))
    do
      taille=`fdisk -s ${Liste3[$i]}`
      Taille[$i]=$(((taille + 500000) / 1000000))
      printf "%d %s %5d\n" $i ${Liste3[$i]} ${Taille[$i]} >> $fictemp
    done
    echo "$i ${M[1]}" >> $fictemp
    rep=`zenity --list --height=250 --width=400 --column="${M[2]}" --column="${M[3]}" --column="${M[4]}" $(cat $fictemp) --title="${M[5]}" --text="${M[6]}"`
    rm $fictemp
    case "$rep" in
      [0-$((nbchoix -1))])
        choix=$rep
        Boucle=0
        if [ ${Taille[$rep]} -gt 128 ]; then
           zenity --question --title="${M[7]}" --text "${M[8]}"
           [ $? -ne 0 ] && { choix=-1; Boucle=1; }
        fi
        ;;
      $nbchoix)
        exit 0
        ;;
      "")
        break
        ;;
      *)
        zenity --error --text="${M[9]}"
        exit 1
        ;;
    esac
  done
done


# Loop of copy with progress bar
# ------------------------------
fictemp=$(mktemp)
taille=`fdisk -s "$NomIso"`
if [ ${Taille[$choix]} -lt $taille ]; then
  mloop "$NomIso" >> $fictemp 2>&1
  T=$(du -s /mnt/loop/ | cut -f 1)
  (for f in /mnt/loop/* ; do
     cp $f ${Choix[$choix]} >> $fictemp 2>&1 
     echo "# $f"
     echo "$(echo "scale=2; $(du -s ${Choix[$choix]} | cut -f 1) / $T * 100" | bc)"
  done) | zenity --progress --width 650 --auto-close --title "${M[11]}"" $NomIso"
  uloop >> $fictemp 2>&1
fi

if [ -f $fictemp ]; then
  zenity --error --text="$(cat $fictemp)"
  rm $fictemp
  exit 1
else
  sync; sync
  zenity --info --text="${M[12]}" --title="${M[13]}"
  exit 0
fi
But it need in fix of # Loop of copy with progress bar section.

If I use

Code: Select all

# Loop of copy with progress bar
# ------------------------------
fictemp=$(mktemp)
taille=`fdisk -s "$NomIso"`
if [ ${Taille[$choix]} -lt $taille ]; then
  echo "mloop $NomIso && cp -a /mnt/loop/* ${Choix[$choix]} && uloop;" > $fictemp
  { mloop "$NomIso" && cp -a /mnt/loop/* ${Choix[$choix]} && uloop; } >> $fictemp 2>&1
fi
all ok. Thanks, but I don't want a progress bar, I want this message

Code: Select all

[12]="You can remove the key if you want."
[13]="End of copy"
with the window

Code: Select all

if [ -f $fictemp ]; then
  zenity --error --text="$(cat $fictemp)"
  rm $fictemp
  exit 1
else
  sync; sync
  zenity --info --text="${M[12]}" --title="${M[13]}"
  exit 0
fi
port wrote:I wouldn't format a drive without user authorization, maybe including the feature as an option would be fine, if doing so it would be great to offer several formatting options like ext2, ext4 and vfat.
something like this
Image

Code: Select all

mintstick -m format
mintstick_1.3.1_all.deb
A GUI to write .img or .iso files to a USB Key. It can also format them.
But I'm not able to run correctly mintstick in Porteus.

port, thanks for your help.
Linux porteus 4.12.7-porteus #1 SMP PREEMPT Sun Aug 13 17:38:30 x86_64 Intel(R) Core(TM) i5-6600K CPU @ 3.50GHz GenuineIntel GNU/Linux
MS-7A12 » [AMD/ATI] Tobago PRO [Radeon R7 360 / R9 360 OEM] (rev 81) » Vengeance LPX 16GB DDR4 K2 3200MHz C16

port
Samurai
Samurai
Posts: 135
Joined: 18 Feb 2016, 09:25
Distribution: Linux porteus 3.2.2 KDE
Location: Spain

Re: Porteus-v3.2.2 bug reports here

Post#22 by port » 09 Apr 2017, 14:41

Blaze wrote:In this line

Code: Select all

     echo "$(echo "scale=2; $(du -s ${Choix[$choix] | cut -f 1) / $T * 100" |bc)" 
is missing }
right, thanks, already fixed in my post
Blaze wrote:I fixed trouble with not correct usb flash drive size in column.

What I have now
What's your fix? as far as I see it's the same code fragment I post (with } error fixed).

Anyway you're right I doesn't work and now I had a little bit time to profile it, there were several errors, missing -a option in cp command, a few syntax errors and we must take into account empty dir size (4096 but this number may be different in your system), also you sure want a pause while showing progress bar...

what I have now that seems to work quite fine (unless a few zenity warnings) is:

Code: Select all

# Loop of copy with progress bar
# ------------------------------
fictemp=$(mktemp)
taille=`fdisk -s "$NomIso"`
if [ ${Taille[$choix]} -lt $taille ]; then
  mloop "$NomIso" >> $fictemp 2>&1
  T=$(du -sb /mnt/loop/ | cut -f 1)
  (for f in /mnt/loop/* ; do
     cp -a $f ${Choix[$choix]} >> $fictemp 2>&1 
     echo "# $f"
     echo "$(echo "scale=2; ($(du -sb ${Choix[$choix]} | cut -f 1) - 4096) / $T * 100" | bc)"
     sleep 1
  done) | zenity --progress --width 650 --auto-close --title "${M[11]}"" $NomIso"
  uloop >> $fictemp 2>&1
fi
Blaze wrote:something like this
Image

Code: Select all

mintstick -m format
Yes that would be fine, I think you can achieve something similar with zenity, since you already have selected usb device you can ask for formatting parameters with something like:

Code: Select all

R=$(zenity --forms --title="USB Stick Formatter" --text="Want to format ${Choix[$choix]} ?"  --add-list="Format"  --add-entry="volume label" --list-values "ext2|ext4|vfat")
if [! -z "$R" ] ; then
  CMD="mkfs.$(echo $R | cut -d, -f 1) -L '$(echo $R | cut -d'|' -f 2)' ${Choix[$choix]}"
  $CMD 
fi
Blaze wrote:mintstick A GUI to write .img or .iso files to a USB Key. It can also format them.
But I'm not able to run correctly mintstick in Porteus.
that tool is written in python, you need to have python installed but you also need to install all python modules minststick use:

Code: Select all

$ grep import /usr/lib/mintstick/mintstick.py 
import commands
from subprocess import Popen,PIPE,call,STDOUT
import os
import signal
import re
import gettext
import locale
import sys
import getopt
import time
import gi
from gi.repository import GObject, Gio, Polkit, Gtk, GLib, UDisks
    from gi.repository import Unity
So you need to install commads, subprocess, os, signal, re, gettext, locale, getopt, time and gi (I don't know if you already have some installed) before mintstick can work properly.

Installing modules in python could be a nightmare, if you are lucky maybe pip works for you, if not prepare to use setup.py or something worse.

It's incredible how many modules need such a silly tool! ;-)

another approach is to pack python and all needed modules (better if installed in a local way rather than system wide) with minstick in a porteus module, but this way it may conflict with your installed python or another modules.

User avatar
Blaze
Moderator
Moderator
Posts: 1384
Joined: 28 Dec 2010, 11:31
Distribution: ⟰ Porteus 3.2 Cinnamon x86_64
Location: ☭ Russian Federation, Lipetsk region, Dankov
Contact:

Re: Porteus-v3.2.2 bug reports here

Post#23 by Blaze » 09 Apr 2017, 16:29

port wrote:What's your fix? as far as I see it's the same code fragment I post (with } error fixed).
Added

Code: Select all

  # Show size of device in GB
  # -------------------------
  Liste3=()
  nbval3=0
  for i in $(ls -l /dev/disk/by-path/*-usb-* | sed -n -e 's/.*\///' -e /[a-z]$/p | sort -d)
  do
    Liste3[$nbval3]="/dev/"$i
    ((nbval3++))
  done
${Choix[$i]} replaced with ${Liste3[$i]} in the

Code: Select all

  # User's choice
  # -------------

  Taille=()
  choix=$nbchoix
  fictemp=$(mktemp)

  while [ "$choix" -lt 0 -o "$choix" -ge $nbchoix ]
  do
    for ((i= 0; i < $nbchoix; i++))
    do
      taille=`fdisk -s ${Liste3[$i]}`
      Taille[$i]=$(((taille + 500000) / 1000000))
      printf "%d %s %5d\n" $i ${Liste3[$i]} ${Taille[$i]} >> $fictemp
    done
python way not for us :)

I tested your code. About USB Stick Formatter.
You are forgot a space between the [ and !

Code: Select all

R=$(zenity --forms --title="USB Stick Formatter" --text="Want to format ${Choix[$choix]} ?"  --add-list="Format"  --add-entry="volume label" --list-values "ext2|ext4|vfat")
if [ ! -z "$R" ] ; then
  CMD="mkfs.$(echo $R | cut -d, -f 1) -L '$(echo $R | cut -d'|' -f 2)' ${Choix[$choix]}"
  $CMD
fi
In GUI I can't to confirm this dialog
Proceed anyway? (y,n) y
and for mkfs.vfat: invalid option -- 'L'
plus
partition table wasn't reread after running fdisk, due to a modified partition being busy and in use

Code: Select all

mke2fs 1.43.3 (04-Sep-2016)
/mnt/sdc1 contains `directory' data
Proceed anyway? (y,n) y
mkfs.ext4: Device size reported to be zero.  Invalid partition specified, or
	partition table wasn't reread after running fdisk, due to
	a modified partition being busy and in use.  You may need to reboot
	to re-read your partition table.

mkfs.fat 3.0.28 (2015-05-16)
mkfs.vfat: invalid option -- 'L'
Unknown option: ?
Usage: mkfs.fat [-a][-A][-c][-C][-v][-I][-l bad-block-file][-b backup-boot-sector]
       [-m boot-msg-file][-n volume-name][-i volume-id]
       [-s sectors-per-cluster][-S logical-sector-size][-f number-of-FATs]
       [-h hidden-sectors][-F fat-size][-r root-dir-entries][-R reserved-sectors]
       [-M FAT-media-byte][-D drive_number]
       [--invariant]
       [--help]
       /dev/name [blocks]

mke2fs 1.43.3 (04-Sep-2016)
/mnt/sdc1 contains `directory' data
Proceed anyway? (y,n) y
mkfs.ext2: Device size reported to be zero.  Invalid partition specified, or
	partition table wasn't reread after running fdisk, due to
	a modified partition being busy and in use.  You may need to reboot
	to re-read your partition table.
For me

Code: Select all

# Loop of copy with progress bar
# ------------------------------
fictemp=$(mktemp)
taille=`fdisk -s "$NomIso"`
if [ ${Taille[$choix]} -lt $taille ]; then
  mloop "$NomIso" >> $fictemp 2>&1
  T=$(du -sb /mnt/loop/ | cut -f 1)
  (for f in /mnt/loop/* ; do
     cp -a $f ${Choix[$choix]} >> $fictemp 2>&1
     echo "# $f"
     echo "$(echo "scale=2; ($(du -sb ${Choix[$choix]} | cut -f 1) - 4096) / $T * 100" | bc)"
     sleep 1
  done) | zenity --progress --width 650 --auto-close --title "${M[11]}"" $NomIso"
  uloop >> $fictemp 2>&1
fi
it does not work too.

At this moment I stay with this working variant without a progress bar (I like this variant)

Code: Select all

  # Loop of copy
  # ------------
  fictemp=$(mktemp)
  taille=`fdisk -s "$NomIso"`
    if [ ${Taille[$choix]} -lt $taille ]; then
       echo "mloop $NomIso && cp -a /mnt/loop/* ${Choix[$choix]} && uloop;" > $fictemp
       { mloop "$NomIso" && cp -a /mnt/loop/* ${Choix[$choix]} && uloop; } >> $fictemp 2>&1
       zenity --info --text="${M[12]}" --title="${M[13]}"
       exit 0
    fi
A new variant

Code: Select all

#!/bin/bash

# Written by Patrice Bourrel (Esclapion) for Manjaro Linux
# Tweaks by port and Blaze for Porteus
# Description : used to copy ISO content on a USB stick
# Version 1.0 of 09.04.2017


LG=`echo "$LANG" | cut -c1-2`
case $LG in


  ca)
M=(
[0]="Selecciona la ISO a copiar"
[1]="Sortir d'isousb"
[2]="N°"
[3]="Nom"
[4]="Mida en GB"
[5]="Selecciona la unitat de disc USB"
[6]="Ves en compte si la mida és massa gran"
[7]="ATENCIÓ ! ! !"
[8]="Podria ser un disc dur extern.\nContinuar ?"
[9]="Problema amb l'eina, contacta amb l'autor"
[10]="Porcentatge fet"
[11]="Còpia de"
[12]="Pots extreure la clau USB si vols"
[13]="Fi de la còpia"
);;


  de)
M=(
[0]="Wahl der ISO-Datei"
[1]="Isousb beenden"
[2]="Nr."
[3]="Pfad"
[4]="Grösse in GB"
[5]="Wahl des USB-Sticks"
[6]="Achtung!\nAlle Daten auf dem gewählten Laufwerk\nwerden gelöscht.\nBeenden Sie das Programm, falls Sie anhand\nder 'Grösse in GB' Ihren USB-Stick nicht\neindeutig erkennen können."
[7]="ACHTUNG ! ! !"
[8]="Dies könnte eine externe Festplatte sein.\nFortfahren?"
[9]="Fehler im Programm. Bitte den Autor benachrichtigen."
[10]="Fortschritt"
[11]="Kopie von"
[12]="Der USB-Stick kann jetzt entfernt werden."
[13]="Kopiervorgang abgeschlossen"
);;


  el)
M=(
[0]="Επιλέτε το ISO προς αντιγραφή"
[1]="Τερματισμός isousb"
[2]="Νο"
[3]="Όνομα"
[4]="Μέγεθος σε GB"
[5]="Επιλέξτε το δίσκο USB"
[6]="Προσέξτε μήπως το μέγεθος είναι πολύ μεγάλο"
[7]="ΠΡΟΣΟΧΗ! ! !"
[8]="Θα μπορούσε να είναι εξωτερικός σκληρός δίσκος.\nΣυνέχεια ?"
[9]="Πρόβλημα στο εργαλείο. Επικοινωνήστε με τον συγγραφέα του."
[10]="Ποσοστό έτοιμο"
[11]="Αντιγραφή του"
[12]="Μπορείτε να αφαιρέσετε τον δίσκο εάν επιθυμείτε"
[13]="Η αντιγραφή τελείωσε"
);;


  es)
M=(
[0]="Seleccionar la ISO a copiar"
[1]="Cerrar isousb"
[2]="N°"
[3]="Nombre"
[4]="Tamaño en GB"
[5]="Seleccionar la unidad USB"
[6]="Controlar que el tamaño del ISO no sea demasiado grande"
[7]="ATENCIÓN ! ! !"
[8]="Podría ser un disco rigido esterno.\nContinuar ?"
[9]="Problema con la herramienta, contactar con el autor"
[10]="Porcentaje completado"
[11]="Copia de"
[12]="Puede extraer la llave si quiere"
[13]="Copia completada"
);;


  fr)
M=(
[0]="Sélectionnez l'ISO à copier"
[1]="Quitter isousb"
[2]="N°"
[3]="Nom"
[4]="Taille en Go"
[5]="Sélectionnez votre clé USB"
[6]="Attention si taille trop grande"
[7]="ATTENTION ! ! !"
[8]="Ça pourrait être un disque dur externe.\nContinuer ?"
[9]="Problème dans l'outil. Contactez l'auteur"
[10]="Pourcentage fait"
[11]="Copie de"
[12]="Vous pouvez retirer la clé si vous le souhaitez"
[13]="Fin de la copie"
);;

  it)
M=(
[0]="Selezionare la ISO da copiare"
[1]="Chiudere isousb"
[2]="N°"
[3]="Nome"
[4]="Dimensione in GB"
[5]="Selezionare l'unità USB"
[6]="Controllare che la dimensione della ISO non sia troppo grande"
[7]="ATTENZIONE ! ! !"
[8]="Potrebbe essere un disco rigido esterno.\nContinuare ?"
[9]="Problemi con lo strumento, contattare l'autore"
[10]="Percentuale completato"
[11]="Copia di"
[12]="Puoi estrarre la chiave se vuoi"
[13]="Copia completata"
);;


  pl)
M=(
[0]="Wybierz obraz ISO do skopiowania"
[1]="Zakończ isousb"
[2]="Nr"
[3]="Nazwa"
[4]="Rozmiar w GB"
[5]="Wybierz swój dysk USB"
[6]="Uważaj jeśli rozmiar jest zbyt duży"
[7]="UWAGA ! ! !"
[8]="To może być zewnętrzny dysk twardy.\nKontynuować ?"
[9]="Problem z narzędziem, skontaktuj się z autorem"
[10]="Procent ukończenia"
[11]="Kopia"
[12]="Możesz odpiąć swój dysk jeśli chcesz"
[13]="Koniec kopiowania"
);;


  pt)
M=(
[0]="Selecione a ISO para copiar"
[1]="Sair isousb"
[2]="N°"
[3]="Nome"
[4]="Tamanho em GB"
[5]="Selecione o seu USB drive"
[6]="Atenção tamanho muito grande"
[7]="ATENÇÃO ! ! !"
[8]="Poderia ser um disco rígido externo. \nContinuar ?"
[9]="Problema na ferramenta. Contactar o autor."
[10]="Porcentagem"
[11]="Copiar de"
[12]="Você já pode remover o seu USB drive."
[13]="Fim de copiar"
);;


  ro)
M=(
[0]="Selectați ISO-ul de copiat"
[1]="Ieșire"
[2]="Nr."
[3]="Nume"
[4]="Dimensiune în GB"
[5]="Selectați drive-ul USB"
[6]="Verificați dacă mărimea este prea mare"
[7]="ATENȚIE ! ! !"
[8]="Ar putea fi un hard disc extern.\nContinuați ?"
[9]="Problemă cu unealta, contactați autorul"
[10]="Procent terminat"
[11]="Copie al"
[12]="Puteți scoate cheia dacă doriți"
[13]="Copiere terminată"
);;


  ru)
M=(
[0]="Выберите ISO образ для копирования его содержимого на USB накопитель"
[1]="Выход"
[2]="Номер"
[3]="Наименование"
[4]="Размер в Гб"
[5]="Выберите USB-накопитель"
[6]="Остерегайтесь, если размер содержимого ISO образа превышает размер USB накопителя!"
[7]="ПРЕДУПРЕЖДЕНИЕ ! ! !"
[8]="Это может быть внешний жесткий диск.\nПродолжить ?"
[9]="Проблема в сценарии isousb, обратитесь к автору."
[10]="Выполняется копирование"
[11]="Копирование содержимого"
[12]="Копирование содержимого ISO образа на USB накопитель успешно завершено."
[13]="Копирование успешно завершено"
);;


  tr)
M=(
[0]="Kopyalanacak kalıbı seçiniz"
[1]="Isousb den çık"
[2]="No"
[3]="İsim"
[4]="Yüklenecek boyut"
[5]="USB sürücünüzü seçin"
[6]="Boyut çok büyükse dikkat edin"
[7]="DİKKAT! ! !"
[8]="Harici bir sürücü olabilir.\nDevam ?"
[9]="Araçta problem var, yayınlayıcı ile irtibat kurun"
[10]="Tamamlanan yüzde"
[11]="Kopyalanan kalıp"
[12]="USB anahtarını isterseniz çıkarabilirsiniz"
[13]="Kopyalama bitti"
);;

  *)
M=(
[0]="Select the ISO to be copied"
[1]="Exit isousb"
[2]="Nr"
[3]="Name"
[4]="Size in GB"
[5]="Select your USB drive"
[6]="Beware if size is too large"
[7]="WARNING ! ! !"
[8]="It could be an external hard drive.\nContinue ?"
[9]="Problem in the tool, contact the author."
[10]="Percentage done"
[11]="Copy of"
[12]="You can remove the key if you want."
[13]="End of copy"
);;
esac


NomIso=`zenity --file-selection --title="${M[0]}" --filename=/home/guest/ --file-filter=*.iso`
[ $? -eq 0 ] || exit 0

Boucle=1
while [ $Boucle = 1 ]
do
  # List of devices that are in /dev/disk/by-path
  # ---------------------------------------------
  Liste1=()
  nbval1=0
  for i in $(ls -l /dev/disk/by-path/*-usb-* | sed -n -e 's/.*\///' -e /[a-z][0-9]$/p | sort -d)
  do
    Liste1[$nbval1]="/mnt/"$i
    ((nbval1++))
  done

  # List of devices seen by blkid
  # -----------------------------
  Liste2=()
  nbval2=0
  for j in $(blkid -o device | sed -e 's/*$//' -e 's/\/dev\///' | uniq | sort -d)
  do
    Liste2[$nbval2]="/mnt/"$j
    ((nbval2++))
  done

  # Variable for showing size in GB
  # -------------------------------
  Liste3=()
  nbval3=0
  for i in $(ls -l /dev/disk/by-path/*-usb-* | sed -n -e 's/.*\///' -e /[a-z]$/p | sort -d)
  do
    Liste3[$nbval3]="/dev/"$i
    ((nbval3++))
  done

  # List of files seen by the two
  # -----------------------------
  Choix=()
  nbchoix=0
  for ((i=0; i < nbval1; i++))
  do
    for ((j=0; j < nbval2; j++))
    do
      if [ ${Liste1[$i]} = ${Liste2[$j]} ]; then
        Choix[nbchoix]=${Liste1[$i]}
        ((nbchoix++))
      fi
    done
  done

  # User's choice
  # -------------
  Taille=()
  choix=$nbchoix
  fictemp=$(mktemp)

  while [ "$choix" -lt 0 -o "$choix" -ge $nbchoix ]
  do
    for ((i= 0; i < $nbchoix; i++))
    do
      taille=`fdisk -s ${Liste3[$i]}`
      Taille[$i]=$(((taille + 500000) / 1000000))
      printf "%d %s %5d\n" $i ${Liste3[$i]} ${Taille[$i]} >> $fictemp
    done
    echo "$i ${M[1]}" >> $fictemp
    rep=`zenity --list --height=250 --width=400 --column="${M[2]}" --column="${M[3]}" --column="${M[4]}" $(cat $fictemp) --title="${M[5]}" --text="${M[6]}"`
    rm $fictemp
    case "$rep" in
      [0-$((nbchoix -1))])
        choix=$rep
        Boucle=0
        if [ ${Taille[$rep]} -gt 128 ]; then
           zenity --question --title="${M[7]}" --text "${M[8]}"
           [ $? -ne 0 ] && { choix=-1; Boucle=1; }
        fi
        ;;
      $nbchoix)
        exit 0
        ;;
      "")
        break
        ;;
      *)
        zenity --error --text="${M[9]}"
        exit 1
        ;;
    esac
  done
done

  # Loop of copy
  # ------------
  fictemp=$(mktemp)
  taille=`fdisk -s "$NomIso"`
    if [ ${Taille[$choix]} -lt $taille ]; then
       echo "mloop $NomIso && cp -a /mnt/loop/* ${Choix[$choix]} && uloop;" > $fictemp
       { mloop "$NomIso" && cp -a /mnt/loop/* ${Choix[$choix]} && uloop; } >> $fictemp 2>&1
       zenity --info --text="${M[12]}" --title="${M[13]}"
       exit 0
    fi
Linux porteus 4.12.7-porteus #1 SMP PREEMPT Sun Aug 13 17:38:30 x86_64 Intel(R) Core(TM) i5-6600K CPU @ 3.50GHz GenuineIntel GNU/Linux
MS-7A12 » [AMD/ATI] Tobago PRO [Radeon R7 360 / R9 360 OEM] (rev 81) » Vengeance LPX 16GB DDR4 K2 3200MHz C16

User avatar
Blaze
Moderator
Moderator
Posts: 1384
Joined: 28 Dec 2010, 11:31
Distribution: ⟰ Porteus 3.2 Cinnamon x86_64
Location: ☭ Russian Federation, Lipetsk region, Dankov
Contact:

Re: ISOUSB request

Post#24 by Blaze » 26 Apr 2017, 18:10

isousb-1.6.xzm

Code: Select all

#!/bin/bash

# Written by Patrice Bourrel (Esclapion) for Manjaro Linux
# Tweaks by port and Blaze for Porteus
# Description : used to copy ISO content on a USB stick
# Version 1.6 of 26.04.2017


LG=`echo "$LANG" | cut -c1-2`
case $LG in


  ca)
M=(
[0]="Selecciona la ISO a copiar"
[1]="Sortir d'isousb"
[2]="N°"
[3]="Nom"
[4]="Mida en GB"
[5]="Selecciona la unitat de disc USB"
[6]="Ves en compte si la mida és massa gran"
[7]="ATENCIÓ ! ! !"
[8]="Podria ser un disc dur extern.\nContinuar ?"
[9]="Problema amb l'eina, contacta amb l'autor"
[10]="Pots extreure la clau USB si vols"
[11]="Fi de la còpia"
);;


  de)
M=(
[0]="Wahl der ISO-Datei"
[1]="Isousb beenden"
[2]="Nr."
[3]="Pfad"
[4]="Grösse in GB"
[5]="Wahl des USB-Sticks"
[6]="Achtung!\nBeenden Sie das Programm, falls Sie anhand\nder 'Grösse in GB' Ihren USB-Stick nicht\neindeutig erkennen können."
[7]="ACHTUNG ! ! !"
[8]="Dies könnte eine externe Festplatte sein.\nFortfahren?"
[9]="Fehler im Programm. Bitte den Autor benachrichtigen."
[10]="Der USB-Stick kann jetzt entfernt werden."
[11]="Kopiervorgang abgeschlossen"
);;


  el)
M=(
[0]="Επιλέτε το ISO προς αντιγραφή"
[1]="Τερματισμός isousb"
[2]="Νο"
[3]="Όνομα"
[4]="Μέγεθος σε GB"
[5]="Επιλέξτε το δίσκο USB"
[6]="Προσέξτε μήπως το μέγεθος είναι πολύ μεγάλο"
[7]="ΠΡΟΣΟΧΗ! ! !"
[8]="Θα μπορούσε να είναι εξωτερικός σκληρός δίσκος.\nΣυνέχεια ?"
[9]="Πρόβλημα στο εργαλείο. Επικοινωνήστε με τον συγγραφέα του."
[10]="Μπορείτε να αφαιρέσετε τον δίσκο εάν επιθυμείτε"
[11]="Η αντιγραφή τελείωσε"
);;


  es)
M=(
[0]="Seleccionar la ISO a copiar"
[1]="Cerrar isousb"
[2]="N°"
[3]="Nombre"
[4]="Tamaño en GB"
[5]="Seleccionar la unidad USB"
[6]="Controlar que el tamaño del ISO no sea demasiado grande"
[7]="ATENCIÓN ! ! !"
[8]="Podría ser un disco rigido esterno.\nContinuar ?"
[9]="Problema con la herramienta, contactar con el autor"
[10]="Puede extraer la llave si quiere"
[11]="Copia completada"
);;


  fr)
M=(
[0]="Sélectionnez l'ISO à copier"
[1]="Quitter isousb"
[2]="N°"
[3]="Nom"
[4]="Taille en Go"
[5]="Sélectionnez votre clé USB"
[6]="Attention si taille trop grande"
[7]="ATTENTION ! ! !"
[8]="Ça pourrait être un disque dur externe.\nContinuer ?"
[9]="Problème dans l'outil. Contactez l'auteur"
[10]="Vous pouvez retirer la clé si vous le souhaitez"
[11]="Fin de la copie"
);;

  it)
M=(
[0]="Selezionare la ISO da copiare"
[1]="Chiudere isousb"
[2]="N°"
[3]="Nome"
[4]="Dimensione in GB"
[5]="Selezionare l'unità USB"
[6]="Controllare che la dimensione della ISO non sia troppo grande"
[7]="ATTENZIONE ! ! !"
[8]="Potrebbe essere un disco rigido esterno.\nContinuare ?"
[9]="Problemi con lo strumento, contattare l'autore"
[10]="Puoi estrarre la chiave se vuoi"
[11]="Copia completata"
);;


  pl)
M=(
[0]="Wybierz obraz ISO do skopiowania"
[1]="Zakończ isousb"
[2]="Nr"
[3]="Nazwa"
[4]="Rozmiar w GB"
[5]="Wybierz swój dysk USB"
[6]="Uważaj jeśli rozmiar jest zbyt duży"
[7]="UWAGA ! ! !"
[8]="To może być zewnętrzny dysk twardy.\nKontynuować ?"
[9]="Problem z narzędziem, skontaktuj się z autorem"
[10]="Możesz odpiąć swój dysk jeśli chcesz"
[11]="Koniec kopiowania"
);;


  pt)
M=(
[0]="Selecione a ISO para copiar"
[1]="Sair isousb"
[2]="N°"
[3]="Nome"
[4]="Tamanho em GB"
[5]="Selecione o seu USB drive"
[6]="Atenção tamanho muito grande"
[7]="ATENÇÃO ! ! !"
[8]="Poderia ser um disco rígido externo. \nContinuar ?"
[9]="Problema na ferramenta. Contactar o autor."
[10]="Você já pode remover o seu USB drive."
[11]="Fim de copiar"
);;


  ro)
M=(
[0]="Selectați ISO-ul de copiat"
[1]="Ieșire"
[2]="Nr."
[3]="Nume"
[4]="Dimensiune în GB"
[5]="Selectați drive-ul USB"
[6]="Verificați dacă mărimea este prea mare"
[7]="ATENȚIE ! ! !"
[8]="Ar putea fi un hard disc extern.\nContinuați ?"
[9]="Problemă cu unealta, contactați autorul"
[10]="Puteți scoate cheia dacă doriți"
[11]="Copiere terminată"
);;


  ru)
M=(
[0]="Выберите ISO образ для копирования его содержимого на USB накопитель"
[1]="Выход"
[2]="Номер"
[3]="Наименование"
[4]="Размер в Гб"
[5]="Выберите USB-накопитель"
[6]="Остерегайтесь, если размер содержимого ISO образа превышает размер USB накопителя!"
[7]="ПРЕДУПРЕЖДЕНИЕ ! ! !"
[8]="Это может быть внешний жесткий диск.\nПродолжить ?"
[9]="Проблема в сценарии isousb, обратитесь к авторам данного скрипта."
[10]="Копирование содержимого ISO образа на USB накопитель успешно завершено."
[11]="Копирование успешно завершено"
);;


  tr)
M=(
[0]="Kopyalanacak kalıbı seçiniz"
[1]="Isousb den çık"
[2]="No"
[3]="İsim"
[4]="Yüklenecek boyut"
[5]="USB sürücünüzü seçin"
[6]="Boyut çok büyükse dikkat edin"
[7]="DİKKAT! ! !"
[8]="Harici bir sürücü olabilir.\nDevam ?"
[9]="Araçta problem var, yayınlayıcı ile irtibat kurun"
[10]="USB anahtarını isterseniz çıkarabilirsiniz"
[11]="Kopyalama bitti"
);;

  *)
M=(
[0]="Select the ISO to be copied"
[1]="Exit isousb"
[2]="Nr"
[3]="Name"
[4]="Size in GB"
[5]="Select your USB drive"
[6]="Beware if size is too large"
[7]="WARNING ! ! !"
[8]="It could be an external hard drive.\nContinue ?"
[9]="Problem in the tool, contact the author."
[10]="You can remove the key if you want."
[11]="End of copy"
);;
esac


NomIso=`zenity --file-selection --title="${M[0]}" --filename=/home/guest/ --file-filter=*.iso`
[ $? -eq 0 ] || exit 0

Boucle=1
while [ $Boucle = 1 ]
do
  # List of devices that are in /dev/disk/by-path
  # ---------------------------------------------
  Liste1=()
  nbval1=0
  for i in $(ls -l /dev/disk/by-path/*-usb-* | sed -n -e 's/.*\///' -e /[a-z][0-9]$/p | sort -d)
  do
    Liste1[$nbval1]="/mnt/"$i
    ((nbval1++))
  done

  # List of devices seen by blkid
  # -----------------------------
  Liste2=()
  nbval2=0
  for j in $(blkid -o device | sed -e 's/*$//' -e 's/\/dev\///' | uniq | sort -d)
  do
    Liste2[$nbval2]="/mnt/"$j
    ((nbval2++))
  done

  # Variable for showing size in GB
  # -------------------------------
  Liste3=()
  nbval3=0
  for i in $(ls -l /dev/disk/by-path/*-usb-* | sed -n -e 's/.*\///' -e /[a-z]$/p | sort -d)
  do
    Liste3[$nbval3]="/dev/"$i
    ((nbval3++))
  done

  # List of files seen by the two
  # -----------------------------
  Choix=()
  nbchoix=0
  for ((i=0; i < nbval1; i++))
  do
    for ((j=0; j < nbval2; j++))
    do
      if [ ${Liste1[$i]} = ${Liste2[$j]} ]; then
        Choix[nbchoix]=${Liste1[$i]}
        ((nbchoix++))
      fi
    done
  done

  # User's choice
  # -------------
  Taille=()
  choix=$nbchoix
  fictemp=$(mktemp)

  while [ "$choix" -lt 0 -o "$choix" -ge $nbchoix ]
  do
    for ((i= 0; i < $nbchoix; i++))
    do
      taille=`fdisk -s ${Liste3[$i]}`
      Taille[$i]=$(((taille + 500000) / 1000000))
      printf "%d %s %5d\n" $i ${Liste3[$i]} ${Taille[$i]} >> $fictemp
    done
    echo "$i ${M[1]}" >> $fictemp
    rep=`zenity --list --height=250 --width=400 --column="${M[2]}" --column="${M[3]}" --column="${M[4]}" $(cat $fictemp) --title="${M[5]}" --text="${M[6]}"`
    rm $fictemp
    case "$rep" in
      [0-$((nbchoix -1))])
        choix=$rep
        Boucle=0
        if [ ${Taille[$rep]} -gt 128 ]; then
           zenity --question --title="${M[7]}" --text "${M[8]}"
           [ $? -ne 0 ] && { choix=-1; Boucle=1; }
        fi
        ;;
      $nbchoix)
        exit 0
        ;;
      "")
        break
        ;;
      *)
        zenity --error --text="${M[9]}"
        exit 1
        ;;
    esac
  done
done

  # Loop of copy
  # ------------
  fictemp=$(mktemp)
  taille=`fdisk -s "$NomIso"`
    if [ ${Taille[$choix]} -lt $taille ]; then
       echo "mloop $NomIso && cp -a /mnt/loop/* ${Choix[$choix]} && uloop;" > $fictemp
       { mloop "$NomIso" && cp -a /mnt/loop/* ${Choix[$choix]} && uloop; } >> $fictemp 2>&1
       zenity --info --text="${M[10]}" --title="${M[11]}"
       exit 0
    fi
We are done the wheel :ROFL:, because Create Porteus live USB by neko is present in Start > System

Code: Select all

/usr/share/live-usb/bin/live-usb
+ in XFCE DE does not present zenity package.

port, sorry for your time spent and thanks for your help. I got a new knowledge :)
Linux porteus 4.12.7-porteus #1 SMP PREEMPT Sun Aug 13 17:38:30 x86_64 Intel(R) Core(TM) i5-6600K CPU @ 3.50GHz GenuineIntel GNU/Linux
MS-7A12 » [AMD/ATI] Tobago PRO [Radeon R7 360 / R9 360 OEM] (rev 81) » Vengeance LPX 16GB DDR4 K2 3200MHz C16

Post Reply