Como criar uma unidade USB Ubuntu ao vivo com persistência para BIOS usando apenas o terminal?

3

Eu quero ser capaz de inicializar a partir de um pendrive do Ubuntu, e então usar um script rsync permanentemente no pendrive, fazer snapshots incrementais (backups) do meu sistema Debian principal para um segundo disco rígido.

Alguém poderia pensar que fazer um pendrive USB persistente no Ubuntu seria tão fácil, mas a maioria dos fabricantes de USB não permite a persistência, e aqueles que o fazem, não funcionaram. Isso inclui o UNetBootin, mesmo depois de eu ter compilado e depurado localmente as dependências ausentes. Então, eu quero uma solução simples, apenas terminal, que eu possa entender e depurar quando necessário.

O dd simples de iso, e depois adicionar o método de arquivo casper-rw teve problemas com ferramentas de particionamento ficando confusas com a imagem de partição efi não-padrão. ( ref )

Algumas soluções, como o UNetBootin, chegaram perto de funcionar, mas, quando tentei fazer um sudo -s para obter um shell de root, elas davam um crash e despejavam e destruíam minha imagem USB ao vivo.

    
por Elliptical view 28.08.2016 / 21:46

2 respostas

5

A maior parte da solução (abaixo) vem de este ótimo artigo que chega perto de funcionar, mas não completamente, já que precisa de algumas atualizações em alguns lugares. Mas sugiro que você olhe para ele, pois é mais completo na explicação dos passos.

Isto é para o meu laptop baseado em BIOS. Eu estou supondo que isso pode não funcionar para uma máquina de inicialização EUFI.

DICAS:

  • Não faça o arquivo de configuração do grub como o artigo acima sugere, mas sim como mostro abaixo.

  • Quando você finalmente trabalhar abaixo, verá que, com o tempo, o sistema de arquivos ficará cheio inesperadamente. Eu finalmente descobri que isso ocorre porque o Ubuntu está silenciosamente fazendo apt-get update e isso irá preencher todo o seu espaço no arquivo e, em seguida, você receberá uma mensagem de aviso. (Demorei alguns anos para descobrir o que estava acontecendo.)

A correção inicial era fazer apt-get clean para despejar o cache do apt, mas isso realmente não resolve o problema subjacente. Então eu tentei simplesmente desabilitar o wi-fi para que ele não fizesse uma atualização automática. Isso funciona muito bem para mim! Agora minhas varas duram muito tempo sem problemas.

Etapas cuidadosamente testadas para funcionar:

1. Faça o download da imagem ISO do Ubuntu 16.04 aqui .

2. setar algumas variáveis para usar abaixo:

iso=/path/to/isoimage #e.g. iso=~/Downloads/ubuntu-16.04-desktop-amd64.iso

s=/mnt/isoimage   #Source mount point for ISO files (via loop file system)
t=/media/USBRoot  #Target mount point for USB files in partition #1

!! Next, BE VERY CAREFUL to correctly point to the USB stick, and not to your hard drive, with this next step, as you can accidentally overwrite your hard disk. (Tip: lookup and confirm using lsblk or the like)

dev=/dev/sd?  #set the "?" to your USB drive letter, e.g. /dev/sdb

3. Plugin e, opcionalmente, apagar Se o particionamento falhar abaixo do apagamento é recomendado. (Antes, quando eu tinha dd'ed uma imagem iso para o dispositivo usb, eu tive que zerar antes que eu pudesse fazer o fdisk funcionar corretamente novamente.).

sudo dd if=/dev/zero of=$dev  #bs=2048 is optional and doesn't seem to matter

You'll get a message like this when it's done:

dd: writing to ‘/dev/sdb’: No space left on device
30326785+0 records in
30326784+0 records out
15527313408 bytes (16 GB) copied, 4099.2 s, 3.8 MB/s

The erase step is because I've found that sometimes a quick format won't work. I don't know for sure, but I suspect that 2nd copies of the partition map, or the like are being found and are confusing the partitioning software. So writing all zeros to the USB stick before we begin seems to make sure that you're starting fresh. But, and yes, I know, it takes LONG time to complete.

4. Faça partições. Use uma ferramenta de particionamento para colocar um mapa de partição do tipo msdos no pendrive e particione-o em duas partições da seguinte forma:

Partition 1) VFAT32 partition for the kernel, ramdisk, grub, and persistence via casper-rw file. Use all of the remaining space for this.

Partition 2) bootable partition for the linux iso image. Make it about 2G in size (because that's how big the .iso file is).

The size of the #2 partition needs to be about 2g, so subtract this from the size of the drive and then divide by 512 to get the size of the #1 partition in sectors. In my case that's 16gb - 2gb = 14gb / 512 = about 27343750 sectors.

Tip: unmount the device now if it is mounted or you will get an error when you are done with fdisk. Don't use the graphical unmount button, as it seems to make the device un-findable (until the USB drive is unplugged and then replugged back in), rather use the terminal command as follows:

Pergunta: Não sei por que essas partições não podem ser trocadas, com a partição de inicialização como a primeira partição. Mas pelo que vale a pena, tentei isso e não consegui fazê-lo funcionar.

sudo umount ${dev}1
sudo umount ${dev}2

Here's how: You can use either fdisk, parted, gparted, or cfdisk but I like fdisk.

sudo fdisk $dev
o                             [create partition map], and then

n (p) (1) (2048) 27343750     [new partition #1] 
t c                           [change partition type to type c, or W95 FAT32], and

n (p) (2) (default) (default) [new partition #2]
t 2 83                        [type 83 or linux], then
a (2)                         [set [toggle] the bootable flag], and

p                             [check new table], and finally 

It should look something like this:

Disk /dev/sdb: 14.5 GiB, 15527313408 bytes, 30326784 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
Disklabel type: dos
Disk identifier: 0xa42995f9

Device     Boot   Start      End  Sectors  Size Id Type
/dev/sdb1           2048 27343750 27341703   13G  c W95 FAT32 (LBA)
/dev/sdb2  *    27344896 30326783  2981888  1.4G 83 Linux

Then do this:

w                         [write the partition table to the usb drive]

You should get a response like this:

The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

or if you forgot to unmount it first then you will get this:

The partition table has been altered.
Calling ioctl() to re-read partition table.
Re-reading the partition table failed.: Device or resource busy

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).

In which case you simply go back, unmount it as described above, and then run fdisk again and only hit w, and you're done.

5. Escreva a imagem iso para a segunda partição. Lutei para incluir um parâmetro de tamanho de bloco ou não aqui (por exemplo, bs = 2048), e no final parece que não importa ou tem pouco efeito. Observe também que essa partição não precisa ser formatada, já que a ISO a formatará efetivamente quando copiada diretamente para a partição.

sudo dd if=$iso of=${dev}2

6. Formatar a primeira partição. Note que ele formata isso com o VFAT32 (ou seja, a versão de nomes de arquivo longos do FAT32). Eu estou supondo que isso é para facilitar a leitura dessa partição em qualquer máquina (ou seja, portabilidade). [Pretendo ver se o ext3 também pode funcionar e atualizará isso mais tarde com esse teste].

sudo mkfs.vfat -F 32 -c ${dev}1   # for vFAT32 file system

7. Monte a partição 1 para poder instalar arquivos nela.

sudo mkdir -p      $t
sudo mount ${dev}1 $t

8. Instale o grub no primeiro setor do stick usb e no diretório raiz na partição # 1.

sudo grub-install --no-floppy --root-directory=$t $dev

9. Copie o kernel e ram arquivos de disco. (NOTA, isso é revisado a partir do artigo. O kernel agora vem como uma versão * .efi, (mas ainda é apenas um kernel), e initrd (o disco ram com todos dos pacotes) é agora comprimido com lz em vez de gz). Primeiro, montamos o arquivo de imagem (como um dispositivo de loop), onde obteremos esses dois arquivos de:

sudo mkdir -p           $s
sudo mount -o loop $iso $s
sudo cp                 $s/casper/{vmlinuz.efi,initrd.lz} $t/boot/

10. Crie um arquivo para manter o sistema de arquivos persistente. Ajuste o tamanho, se desejar. Isso é definido como 1024x1mb = 1gb. Note que dentro do arquivo casper-rw é um sistema de arquivos ext3. O nome casper-rw é mágico, então não o mude.

sudo dd if=/dev/zero of=$t/casper-rw bs=1M count=1024  
sudo mkfs.ext3 -F       $t/casper-rw     #takes a long time

11. Crie um arquivo de configuração simples do grub. Certifique-se de dar a ele uma extensão de nome de arquivo conf (possivelmente mais nova?) Cfg não conf para que o grub possa encontrá-lo (ref ). Use seu editor favorito ou use:

sudo nano $t/boot/grub/grub.cfg

12. Cole os seguintes comandos do grub em.

*Notes: you can use echo and read here for more debugging if necessary. Also the "ro" "splash" and "quiet" are optional (but suggested) kernel options with mostly self explanatory behaviors. See this quite helpful post on how to use the GRUB> prompt if necessary. I'm guessing that he had a .conf file because this might have been for GRUB 1.0, rather than GRUB 2.0, and this might also explain the commands he had not working. Also note that the root is partition 1 (i.e. msdos1).

echo LOADING USB DRIVE
echo 
echo To continue press any key
echo To abort press ^-alt-delete
echo
read
echo Proceeding...

set default=0
set timeout=10
set title="Ubuntu (Live)"
set root=(hd0,msdos1)

linux /boot/vmlinuz.efi boot=casper file=/preseed/ubuntu.seed persistent ro splash quiet
echo vmlinuz.efi loaded

initrd /boot/initrd.lz
echo initrd.lz loaded
echo
echo Grub done. Booting...
boot

13. sincronização (recomendado) e limpeza (opcional):

sync

sudo umount $s;  sudo rmdir  $s
sudo umount $t;  sudo rmdir  $t

14. Faça o backup de sua nova unidade USB.

dd if=$dev of=/your/backup/location #takes a long time

To later restore it use the reverse:

dd if=/your/backup/location of=$dev #takes a long time

15. Reinicie e aperte uma tecla para inicializar o pendrive do Ubuntu.

16. Adicione seu script de backup a ele. Aqui está meu script incremental que lida com dois laptops. PRIMEIRO VERIFIQUE-O CUIDADOSAMENTE PARA SEU SISTEMA E AJUSTE-O COMO NECESSÁRIO. Nomeie-o como mybackup e vincule myrestore a ele ( ln mybackup myrestore ). Definir permissões de execução com chmod u+x my{backup,restore} . Execute-o com ./mybackup

#!/bin/bash

#Usage:
#
# mybackup                               - show list of current backups
# myrestore                              - ''
#
# mybackup  <machine> <BackupFolderName> - machine: love2d or sharon-pc
# myrestore <machine> <BackupFolderName> - by convention name is 'nn-descriptiveName' (so it sorts by date)


#################################################################
#################################################################

### PARTITIONS ######################
#Partition labels (also used for mount point folder names):
#  Note: use labels rather than UUID as they might be more controllable.
BackupDrive='Linux backup'              # USB backup drive (I removed space from 'name' & it removed it from 'label')
 BackupBase="$BackupDrive/Backups"      # Backup base folder directory & name
     SubDir="files"


### PARTITIONS LABEL HELP:
#lsblk -o +label        gives  (note older method was blkid, but this suggests we use lsblk):
#NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT                              LABEL
#sda      8:0    0 465.8G  0 disk
#├─sda1   8:1    0   199M  0 part                                         SYSTEM
#├─sda2   8:2    0 288.1G  0 part
#├─sda3   8:3    0     1K  0 part
#├─sda4   8:4    0  29.3G  0 part                                         Shared
#├─sda5   8:5    0  23.3G  0 part                                         d8root
#├─sda6   8:6    0 119.5G  0 part                                         d8home
#└─sda7   8:7    0   5.4G  0 part [SWAP]

#sdc      8:32   0   3.7T  0 disk
#├─sdc1   8:33   0   128M  0 part
#├─sdc2   8:34   0   2.7T  0 part /media/ubuntu/Seagate Backup Plus Drive Seagate Backup Plus Drive
#└─sdc3   8:35   0 976.6G  0 part                                         Linux backup



### MOUNTING 1of2 ######################
 sudo umount "/mnt/$BackupDrive">& /dev/null    # --- cleanup from prior failed attempt:
 sudo mkdir  "/mnt/$BackupDrive">& /dev/null; sudo mount -L "$BackupDrive"      "/mnt/$BackupDrive" -o defaults,suid >& /dev/null #Allow to set user owner of files




########################################################################
### FUNCTIONS #################################################################

####################
function usage          { echo; echo "Usage: ${0##*/} [machine name: Love2d|Sharon-pc] [BackupFolderName]";echo;}

####################

####################
#If parameter just show dirs for that machine, else show for both
function myls {
 echo -n "'$1' existing backups:"
 if [ -d "$2" ]; then echo; ls -lFgG "$2" |grep -v ^total |grep ' [0-9][0-9]-' |sed 's/..................//'; else echo ' (none)'; fi;
}

##################
function currentbackups {
 if [ "$1" ]; then
        myls "$1"               "/mnt/$BackupBase/$1/$SubDir"
 else
        myls 'Love2d'           "/mnt/$BackupBase/Love2d/$SubDir"
        echo
        myls 'Sharon-pc'        "/mnt/$BackupBase/Sharon-pc/$SubDir"
        echo
 fi
}

###################
function badmachine     { echo "Machine type '$1' is invalid.";}

###################
function cleanup        {
 # echo "--- cleaning up --------------------------------------"
 sudo umount "/mnt/$BackupDrive"
}

########################################################################
########################################################################


### CHECK INPUTS #######################################################
#Check if backup name paramter exists:
if [ $# = 0 ]; then usage;                                                                                                              cleanup; exit;     fi

if [ $# = 1 ]; then if [ "$1" != "Love2d" -a "$1" != "Sharon-pc" ]; then badmachine "$1"; usage; else usage; currentbackups "$1"; fi;                       cleanup; exit;     fi

if [ $# = 2 ]; then if [ "$1" != "Love2d" -a "$1" != "Sharon-pc" ]; then badmachine "$1"; usage;                                         cleanup; exit; fi; fi


### MOUNTING 2of2 ######################
if [ "$1" = 'Love2d' ]; then
    MyHome='d8home'             # Love2 Debian /home      partition name
    MyRoot='d8root'             # Love2 Debian /   (root) partition name
  MyShared='Shared'             # Love2 Debian Shared     partition name

 sudo umount "/mnt/$MyRoot"     >& /dev/null    # --- cleanup from prior failed attempt:
 sudo umount "/mnt/$MyHome"     >& /dev/null    #
 sudo umount "/mnt/$MyShared"   >& /dev/null    #

 sudo mkdir  "/mnt/$MyRoot"     >& /dev/null; sudo mount -L "$MyRoot"           "/mnt/$MyRoot"                          >& /dev/null
 sudo mkdir  "/mnt/$MyHome"     >& /dev/null; sudo mount -L "$MyHome"           "/mnt/$MyHome"                          >& /dev/null
 sudo mkdir  "/mnt/$MyShared"   >& /dev/null; sudo mount -L "$MyShared"         "/mnt/$MyShared"                        >& /dev/null

else
#    MyHome='uhome'             # Love2 Ubuntu /home      partition name
#    MyRoot='uroot'             # Love2 Ubuntu /   (root) partition name

    MyHome='a41eaa3e-bd31-4ebc-86d4-cf8ed5f3e779'               # Love2 Ubuntu /home      partition name
    MyRoot='f3b7424c-0144-42a6-8488-62fbee94d245'               # Love2 Ubuntu /   (root) partition name


 sudo umount "/mnt/$MyRoot"     >& /dev/null    # --- cleanup from prior failed attempt:
 sudo umount "/mnt/$MyHome"     >& /dev/null    #

#sudo mkdir  "/mnt/$MyRoot"     >& /dev/null; sudo mount -L "$MyRoot"           "/mnt/$MyRoot"                          >& /dev/null
#sudo mkdir  "/mnt/$MyHome"     >& /dev/null; sudo mount -L "$MyHome"           "/mnt/$MyHome"                          >& /dev/null

 sudo mkdir  "/mnt/$MyRoot"     >& /dev/null; sudo mount -U "$MyRoot"           "/mnt/$MyRoot"                          >& /dev/null
 sudo mkdir  "/mnt/$MyHome"     >& /dev/null; sudo mount -U "$MyHome"           "/mnt/$MyHome"                          >& /dev/null
fi


#=================================================================
BackupDir="$BackupBase/$1/$SubDir/$2"   # /dir/BackupFolderName


#rSync stuff:
MyRsync="sudo rsync -aAXv --delete"
RootExclude=" --exclude={\"/dev/*\",\"/lost+found\",\"/media/*\",\"/mnt/*\",\"/proc/*\",\"/run/*\",\"/sys/*\",\"/tmp/*\"}"
HomeExclude=" --exclude='*cache*'"      #this does not work

if [ "${0##*/}" = "mybackup" ]; then
echo backing up...
        sudo mkdir -p "/mnt/$BackupDir/root"    # Making directories to save backup to
        sudo mkdir -p "/mnt/$BackupDir/home"

        echo "--- Backing up:  / -----------------------------------"
        $MyRsync $RootExclude   "/mnt/$MyRoot/"                 "/mnt/$BackupDir/root/"
        echo "--- Backing up:  /home -------------------------------"

        $MyRsync $HomeExclude   "/mnt/$MyHome/"                 "/mnt/$BackupDir/home/"

   if [ "$MyShared" ]; then             #no shared partion on Sharon's machine
        sudo mkdir -p "/mnt/$BackupDir/shared"
        echo "--- Backing up:  Shared ------------------------------"
        $MyRsync                "/mnt/$MyShared/"               "/mnt/$BackupDir/shared/"
   fi

else

        # Confirm
        read -p "YOU ARE ABOUT TO OVERWRITE YOUR PARTITIONS - CONFIRM (y/N)?" -n 1 -r; echo if [[ ! $REPLY =~ ^[Yy]$ ]]; then echo "Aborting.";exit; fi
        echo;
        read -p "DANGER!  Really overwrite your hard disk partitions? (y/N)?" -n 1 -r; echo if [[ ! $REPLY =~ ^[Yy]$ ]]; then echo "Aborting.";exit; fi

        echo "--- Restoring:   / -----------------------------------"
        $MyRsync                "/mnt/$BackupDir/root/"         "/mnt/$MyRoot"
        echo "--- Restoring:   /home -------------------------------"
        $MyRsync                "/mnt/$BackupDir/home/"         "/mnt/$MyHome"

   if [ "$MyShared" ]; then             #no shared partion on Sharon's machine
        echo "--- Restoring:   Shared ------------------------------"
        $MyRsync                "/mnt/$BackupDir/shared/"       "/mnt/$MyShared"
   fi

fi

cleanup
 sudo umount "/mnt/$MyRoot"     ;sudo rmdir "/mnt/$MyRoot"
 sudo umount "/mnt/$MyHome"     ;sudo rmdir "/mnt/$MyHome"

if [ "$MyShared" ]; then                #no shared partion on Sharon's machine
 sudo umount "/mnt/$MyShared"   ;sudo rmdir "/mnt/$MyShared"
fi

 echo "=== DONE. ============================================"

exit 0
    
por Eliptical view 28.08.2016 / 21:46
0

Acho que estamos fazendo as mesmas coisas. Vamos trocar idéias e ajudar uns aos outros: -)

Talvez a única diferença seja que comecei mais cedo. Dê uma olhada na minha nova ferramenta dus , que espero que em breve seja renomeada para 'mkusb versão 12'.

dus funciona com menus do zenity quando há um ambiente de área de trabalho gráfico e o zenity está disponível, caso contrário funciona com menus de diálogo quando o diálogo está disponível, caso contrário, usa uma interface de usuário texto sem formatação , que é o que você pediu (e fez, porque não houve resposta antecipada).

O

dus consiste em um conjunto de scripts de shell bash, e você pode lê-los e entender como eles funcionam. Os scripts estão disponíveis via ppa: mkusb / unstable ou phillw.net. Veja este link e este link para mais detalhes.

O dump de texto a seguir é o diálogo de texto simples (entrada e saída do terminal), ao fazer um live drive persistente. Eu usei um pendrive USB 2 lento, a velocidade de gravação é de apenas 6 MB / s. Pode ser 4-5 vezes maior com um bom pendrive USB 3 em uma porta USB 2 e ainda mais alto em uma porta USB 3.

$ ssh sudodus@my_server
sudodus@my_server's password: 
Welcome to Ubuntu 16.04.1 LTS (GNU/Linux 4.4.0-45-generic i686)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

0 paket kan uppdateras.
0 uppdateringar är säkerhetsuppdateringar.

*** /dev/sda8 will be checked for errors at next reboot ***

sudodus@xenial32 ~ $ cd /media/multimed-2/test/mkmkusb/dus
sudodus@xenial32 /media/multimed-2/test/mkmkusb/dus $ dus lubuntu-16.04.1-desktop-amd64.iso 
 dus 0.0.0 
[sudo] password for sudodus: 
dus wants the program(s) 
mkusb-common 'to make a persistent live drive and to get a good GUI experience'
usb-pack-efi 'only to make a persistent live drive'
 Please install the corresponding package(s) 
Press Enter to continue, or wait 8 seconds 

 dus 0.0.0 - Cloning, live linux, windows / Persistent live
 ──────────────────────────────────────────────────────────────────────────────


             ┌──────Move between items with the arrow keys────────┐
             │                 - Do USB Stuff -                   │
             │       Welcome and Notice about Overwriting         │
             │ The target device will be completely overwritten   │
             │ ┌────────────────────────────────────────────────┐ │
             │ │c  Cloning iso file, [compressed] image file or │ │
             │ │l  'Live-only' or linux installer from iso file │ │
             │ │p  'Persistent live' - only Debian and Ubuntu   │ │
             │ │w  extracting Windows installer                 │ │
             │ │q  Quit                                         │ │
             │ └────────────────────────────────────────────────┘ │
             │                                                    │
             │                                                    │
             │                                                    │
             │                                                    │
             ├────────────────────────────────────────────────────┤
             │             <  OK  >       <Avbryt>                │
             └────────────────────────────────────────────────────┘

## oops - I have dialog installed - so I had better use the option -t ##
##        to make a demo with the plain text interface                ##

clean if necessary and return
sudodus@xenial32 /media/multimed-2/test/mkmkusb/dus $ dus -t lubuntu-16.04.1-desktop-amd64.iso 
 dus 0.0.0 
dus wants the program(s) 
mkusb-common 'to make a persistent live drive and to get a good GUI experience'
usb-pack-efi 'only to make a persistent live drive'
 Please install the corresponding package(s) 
Press Enter to continue, or wait 8 seconds 
+------------------------  Do USB Stuff  -------------------------+
|              Welcome and Notice about Overwriting               |
|        The target device will be completely overwritten         |
+------------------------  quit with (q)  ------------------------+
Cloning,live-only,windows / Persistent-live / Quit (c/l/p/w/q) p
Drive that contains source file: /dev/sdc
Live drive, that is booted from: /dev/sda
-------------------------------------------------------------------------------
Available drives (mass storage devices)
Dev  Target name/model              Size   Bus  Kind of device    
sdd  SanDisk_Cruzer                  15G   usb  USB or memory card
Example: add 'sdx':  /dev/sdx
Select target device /dev/sdd
p_target: target=/dev/sdd
Select 'MSDOS' partition table - default GPT?               (y/N) 
Select 'usb-pack-efi' - default grub from iso file?         (y/N) 
Select 'download and install' security update - default NO? (y/N) 
Enter 'percentage' for persistence - default 50  (enter: 1 - 100) 75
settings=
percent=75
Prepare  persistent live  system from
'lubuntu-16.04.1-desktop-amd64.iso'
to the target device (drive) '/dev/sdd'
MODEL            NAME   FSTYPE  LABEL                      SIZE
Cruzer           sdd                                        15G
                 ├─sdd1 ntfs    usbdata                    3,5G
                 ├─sdd2                                      1M
                 ├─sdd3 vfat    lub1604164                 122M
                 ├─sdd4 iso9660 Lubuntu 16.04.1 LTS amd64  874M
                 └─sdd5 ext4    casper-rw                 10,5G
 Final checkpoint, go ahead? (g/N) g
lubuntu-16.04.1-desktop-amd64.iso
/dev/sdd
75
settings=
-----
live system or temporary superuser permissions
lubuntu-16.04.1-desktop-amd64.iso
/dev/sdd
75
settings=
source=lubuntu-16.04.1-desktop-amd64.iso
target=/dev/sdd
percent=75
msdos=false
upefi=false
dni=false
source=lubuntu-16.04.1-desktop-amd64.iso
ls -l  lubuntu-16.04.1-desktop-amd64.iso
lrwxrwxrwx 1 olle olle 67 okt 22 21:44 lubuntu-16.04.1-desktop-amd64.iso -> /media/multimed-2/CD/ubuntu/16.04/lubuntu-16.04.1-desktop-amd64.iso
---------------------------------------------------------------------------
start [dus-persistent 0.0.0] @ 2016-11-17 19:15:23
---------------------------------------------------------------------------
Making a USB boot drive or memory card ..........................
ubuntu
grub_n_iso "$source" "$target" "$result"
grub_n_iso lubuntu-16.04.1-desktop-amd64.iso /dev/sdd 
***** tu=/dev/sdd ****************************************************
selected target partition table: 'gpt'
mount: /dev/loop0 is write-protected, mounting read-only
 Lubuntu 16.04.1 LTS "Xenial Xerus" - Release amd64 
mount: /dev/loop0 is write-protected, mounting read-only
select_boot_system: usb-pack_efi is available
select_boot_system: usb-pack_efi: using variable 'upefi=false'
'lubuntu-16.04.1-desktop-amd64.iso' is identified as the source ISO file
<pre>
MODEL            NAME   FSTYPE  LABEL                     MOUNTPOINT  SIZE
Cruzer           sdd                                                   15G
                 |-sdd1 ntfs    usbdata                               3,5G
                 |-sdd2                                                 1M
                 |-sdd3 vfat    lub1604164                            122M
                 |-sdd4 iso9660 Lubuntu 16.04.1 LTS amd64             874M
                 '-sdd5 ext4    casper-rw                            10,5G
</pre>
Using the file '/usr/share/mkusb/grub.cfg'
Clean for a GUID partition table
GPT fdisk (gdisk) version 1.0.1

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.

Command (? for help): This option deletes all partitions and creates a new protective MBR.
Proceed? (Y/N): 
Command (? for help): 
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): OK; writing new GUID partition table (GPT) to /dev/sdd.
The operation has completed successfully.
Wipe the first megabyte (mibibyte) to get a clean boot area
1024+0 records in
1024+0 records out
1048576 bytes (1,0 MB, 1,0 MiB) copied, 0,00227566 s, 461 MB/s
Wait 5 seconds and a little more ...
---------------------------------------------------------------------------
 Selected percentage of remaining space for persistence = 75 
---------------------------------------------------------------------------

preparing /dev/sdd3  ------------------------------------------------
1024+0 records in
1024+0 records out
1048576 bytes (1,0 MB, 1,0 MiB) copied, 0,290228 s, 3,6 MB/s
umount: /dev/sdd3: not mounted
mkfs.fat 3.0.28 (2015-05-16)
/dev/sdd3 has 64 heads and 32 sectors per track,
hidden sectors 0x1000;
logical sector size is 512,
using 0xf8 media descriptor, with 249856 sectors;
drive number 0x80;
filesystem has 2 32-bit FATs and 1 sector per cluster.
FAT size is 1922 sectors, and provides 245980 clusters.
There are 32 reserved sectors.
Volume ID is 3cfbdfa9, no volume label.

preparing /dev/sdd1  ------------------------------------------------
1024+0 records in
1024+0 records out
1048576 bytes (1,0 MB, 1,0 MiB) copied, 0,317438 s, 3,3 MB/s
umount: /dev/sdd1: not mounted
Cluster size has been automatically set to 4096 bytes.
Creating NTFS volume structures.
Creating root directory (mft record 5)
Creating $MFT (mft record 0)
Creating $MFTMirr (mft record 1)
Creating $LogFile (mft record 2)
Creating $AttrDef (mft record 4)
Creating $Bitmap (mft record 6)
Creating $Boot (mft record 7)
Creating backup boot sector.
Creating $Volume (mft record 3)
Creating $BadClus (mft record 8)
Creating $Secure (mft record 9)
Creating $UpCase (mft record 0xa)
Creating $Extend (mft record 11)
Creating system file (mft record 0xc)
Creating system file (mft record 0xd)
Creating system file (mft record 0xe)
Creating system file (mft record 0xf)
Creating $Quota (mft record 24)
Creating $ObjId (mft record 25)
Creating $Reparse (mft record 26)
Syncing root directory index record.
Syncing $Bitmap.
Syncing $MFT.
Updating $MFTMirr.
Syncing device.
mkntfs completed successfully. Have a nice day.
preparing /dev/sdd5  ------------------------------------------------
1024+0 records in
1024+0 records out
1048576 bytes (1,0 MB, 1,0 MiB) copied, 1,7128 s, 612 kB/s
umount: /dev/sdd5: not mounted
mke2fs 1.42.13 (17-May-2015)
Creating filesystem with 2743296 4k blocks and 686784 inodes
Filesystem UUID: 3c0ee31f-b5f2-4b21-8ac8-bb8941c39697
Superblock backups stored on blocks: 
    32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done 

mount: /media/multimed-2/CD/ubuntu/16.04/lubuntu-16.04.1-desktop-amd64.iso is already mounted
fatlabel: warning - lowercase labels might not work properly with DOS or Windows
tune2fs 1.42.13 (17-May-2015)
---------------------------------------------------------------------------
source=lubuntu-16.04.1-desktop-amd64.iso
---------------------------------------------------------------------------
item 60
umount: /dev/sdd3: not mounted
mount /dev/sdd3 /tmp/dus.KMlnQuCB3J
/dev/sdd3       121M   512  121M   1% /tmp/dus.KMlnQuCB3J
item 65
umount: /dev/sdd1: not mounted
/dev/sdd1       3,5G   19M  3,5G   1% /tmp/dus.FkiHYIJh2I
 BIOS Bootloader:  Installing for i386-pc platform.
Installation finished. No error reported.
 64-bit bootloader: copy the boot files from the iso file 
looper=/tmp/dus.zAxhAauNxN
targ1=/tmp/dus.KMlnQuCB3J
rsync: symlink "/tmp/dus.KMlnQuCB3J/ubuntu" -> "." failed: Operation not permitted (1)
rsync: symlink "/tmp/dus.KMlnQuCB3J/dists/stable" -> "xenial" failed: Operation not permitted (1)
rsync: symlink "/tmp/dus.KMlnQuCB3J/dists/unstable" -> "xenial" failed: Operation not permitted (1)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1183) [sender=3.1.1]
rsync:  don't worry,  symlink errors are *expected*
because of the target file system.
Using the file '/tmp/dus.KMlnQuCB3J/boot/grub/grub.cfg'
 set security upgrade action to 'Display immediately' 
umount: /dev/sdd4: not mounted
 Please wait while copying and syncing until 'Done' is written ... 
< "lubuntu-16.04.1-desktop-amd64.iso" pv | dd of=/dev/sdd4 bs=4096
 855MiB 0:02:15 [6,33MiB/s] [================================>] 100%            
218880+0 records in
218880+0 records out
896532480 bytes (897 MB, 855 MiB) copied, 148,466 s, 6,0 MB/s
Syncing the target device ...
Wait 5 seconds and a little more ...
<pre>
parted -s "/dev/sdd" print
Model: SanDisk Cruzer (scsi)
Disk /dev/sdd: 16,0GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name     Flags
 2      1049kB  2097kB  1049kB               primary  bios_grub
 3      2097kB  130MB   128MB   fat32        primary  boot, esp
 4      130MB   1046MB  916MB                primary
 5      1046MB  12,3GB  11,2GB  ext2         primary
 1      12,3GB  16,0GB  3746MB  ntfs         primary  msftdata

lsblk -o MODEL,NAME,FSTYPE,LABEL,MOUNTPOINT,SIZE "/dev/sdd"
MODEL            NAME   FSTYPE  LABEL                     MOUNTPOINT  SIZE
Cruzer           sdd                                                   15G
                 |-sdd1 ntfs    usbdata                               3,5G
                 |-sdd2                                                 1M
                 |-sdd3 vfat    lub1604164                            122M
                 |-sdd4 iso9660 Lubuntu 16.04.1 LTS amd64             874M
                 '-sdd5 ext4    casper-rw                            10,5G
</pre>
 Done :-) 
The target device is ready to use.
'lubuntu-16.04.1-desktop-amd64.iso'
was installed
Cleanup after dus-persistent finished :-)
Cleanup after dus-persistent finished :-)
---------------------------------------------------------------------------
Total time used [by dus-persistent] = 276 s; 00:04:36


Check the result (scroll if possible), press Enter to finish 
p_clean:
live system or temporary superuser permissions
Cloning,live-only,windows / Persistent-live / Quit (c/l/p/w/q) q
clean if necessary and return
sudodus@xenial32 /media/multimed-2/test/mkmkusb/dus $ 
    
por sudodus 17.11.2016 / 19:56