Image verkleinern mit pishrink
-
raspelman -
18. März 2017 um 14:58 -
Erledigt
-
-
Image verkleinern mit pishrink? Schau mal ob du hier fündig wirst!
-
hier ist die Ausgabe mit Dateipfad:
pi@raspberrypi:~ $ pishrink.sh /media/pi/01CD3068D90B9780/test.img
pishrink.sh v0.1.2
pishrink.sh: ERROR occured in line 127: You need to be running as root
hier ist die Ausgabe von ls -la
pi@raspberrypi:~ $ ls -la
insgesamt 136
drwxr-xr-x 22 pi pi 4096 Okt 10 15:49 .
drwxr-xr-x 3 root root 4096 Jul 10 02:07 ..
-rw------- 1 pi pi 5597 Okt 10 17:47 .bash_history
-rw-r--r-- 1 pi pi 220 Jul 10 02:07 .bash_logout
-rw-r--r-- 1 pi pi 3523 Jul 10 02:07 .bashrc
drwxr-xr-x 2 pi pi 4096 Okt 8 20:30 bin
drwxr-xr-x 9 pi pi 4096 Okt 10 17:41 .cache
drwx------ 13 pi pi 4096 Okt 8 03:22 .config
drwxr-xr-x 2 pi pi 4096 Okt 10 14:49 Desktop
drwxr-xr-x 2 pi pi 4096 Okt 6 03:15 DHT22
-rw-r--r-- 1 pi pi 7376 Okt 6 03:22 DHT22.py
drwxr-xr-x 2 pi pi 4096 Okt 5 16:07 Documents
drwxr-xr-x 2 pi pi 4096 Okt 5 16:07 Downloads
drwx------ 3 pi pi 4096 Jul 10 02:27 .gnupg
-rw-r--r-- 1 pi pi 364 Okt 6 03:44 humidity.py
drwxr-xr-x 3 pi pi 4096 Jul 10 02:15 .local
drwxr-xr-x 2 pi pi 4096 Jul 10 02:15 MagPi
drwxr-xr-x 2 pi pi 4096 Okt 5 16:07 Music
drwxr-xr-x 2 pi pi 4096 Okt 5 16:07 Pictures
drwx------ 3 pi pi 4096 Okt 5 17:04 .pki
drwx------ 3 pi pi 4096 Okt 8 13:28 .pp_backup
-rw-r--r-- 1 pi pi 807 Jul 10 02:07 .profile
drwxr-xr-x 2 pi pi 4096 Okt 5 16:07 Public
drwxr-xr-x 2 pi pi 4096 Okt 6 03:22 __pycache__
drwxr-xr-x 2 pi pi 4096 Okt 5 16:07 Templates
drwx------ 4 pi pi 4096 Okt 10 15:25 .thumbnails
drwxr-xr-x 2 pi pi 4096 Okt 5 16:07 Videos
drwx------ 3 pi pi 4096 Okt 5 17:30 .vnc
-rw-r--r-- 1 pi pi 215 Okt 8 18:55 .wget-hsts
-rw------- 1 pi pi 56 Okt 10 15:49 .Xauthority
-rw------- 1 pi pi 2591 Okt 10 15:49 .xsession-errors
-rw------- 1 pi pi 2591 Okt 10 15:25 .xsession-errors.old
-
pishrink.sh /media/pi/01CD3068D90B9780/test.img
pishrink.sh v0.1.2
pishrink.sh: ERROR occured in line 127: You need to be running as root
Die Meldung sagt es: Du sollst das Script als root aufrufen
-
-
Jetzt kommt die Meldung:
pi@raspberrypi:~ $ sudo pishrink.sh /media/pi/01CD3068D90B9780/test.img
sudo: pishrink.sh: Befehl nicht gefunden
-
framp Wir sollten uns besser abstimmen. Dabei fällt mir gerade ein... heute ist Do.
Oha ... vielen Dank schon wieder fuer den Reminder Haette es sonst wieder vergessen
-
Jetzt kommt die Meldung:
pi@raspberrypi:~ $ sudo pishrink.sh /media/pi/01CD3068D90B9780/test.img
sudo: pishrink.sh: Befehl nicht gefunden
Gib mal den absoluten Pfad zum pishrink Skript an.
-
- Offizieller Beitrag
-
-
Hallo,
danke an alle für eure Hilfe. Jetzt hat es funktioniert.
Code
Alles anzeigenpi@raspberrypi:~ $ sudo /home/pi/bin/pishrink.sh /media/pi/01CD3068D90B9780/test.img pishrink.sh v0.1.2 pishrink.sh: Gatherin data... Creating new /etc/rc.local pishrink.sh: Checking filesystem... rootfs: 113688/475136 files (0.1% non-contiguous), 913649/1898752 blocks resize2fs 1.44.5 (15-Dec-2018) pishrink.sh: Shrinking filesystem... resize2fs 1.44.5 (15-Dec-2018) Resizing the filesystem on /dev/loop0 to 970733 (4k) blocks. Begin pass 2 (max = 234321) Relocating blocks XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Begin pass 3 (max = 58) Scanning inode table XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Begin pass 4 (max = 9285) Updating inode references XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX The filesystem on /dev/loop0 is now 970733 (4k) blocks long. pishrink.sh: Shrinking image... pishrink.sh: Shrunk /media/pi/01CD3068D90B9780/test.img from 7,6G to 4,0G...
-
Perfekt
Vielleicht noch ein Tip. Verschiebe pishrink.sh in /usr/local/bin. Dann brauchst Du nur pishrink.sh angeben und nicht /home/pi/bin/pishrink.sh
-
Hi, ich habe gerade einmal raspibackupWrapper ausprobiert.
Vorab:
1. raspiBackup war bereits installiert und hat funktioniert,
2. pishrink war bereits installiert und hat einwandfrei funktioniert.
3. Cronjob hat bisher einwandfrei funktioniert. (Jeden Montag um 23.55)
4. Alle .sh -Dateien liegen unter /usr/local/bin
Jetzt habe ich wie in folgender Ausgabe raspiBackupWrapper nach deiner Anleitung installiert, die Datei /usr/local/bin/raspiBackupWrapper und den Cronjob nach deiner Anleitung editiert.
Bis auf die Verkleinerung mit pishrink hat alles funktioniert. Diese ist jedoch fehlgeschlagen.
Liegt es vielleicht daran. dass ich bei raspiBackup ein ddz-Backup eingestellt hatte?
Code
Alles anzeigenroot@raspifranz:~# wget https://raw.githubusercontent.com/framps/raspiBackup/master/helper/raspiBackupWrapper.sh --2019-11-11 14:08:06-- https://raw.githubusercontent.com/framps/raspiBackup/master/helper/raspiBackupWrapper.sh Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.112.133 Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.112.133|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 6651 (6.5K) [text/plain] Saving to: 'raspiBackupWrapper.sh' raspiBackupWrapper. 100%[===================>] 6.50K --.-KB/s in 0.003s 2019-11-11 14:08:07 (2.48 MB/s) - 'raspiBackupWrapper.sh' saved [6651/6651] root@raspifranz:~# sudo mv ./raspiBackupWrapper.sh /usr/local/bin root@raspifranz:~# sudo chmod +x /usr/local/bin/raspiBackupWrapper.sh root@raspifranz:~# nano /usr/local/bin/raspiBackupWrapper.sh root@raspifranz:~# nano /etc/cron.d/raspiBackup root@raspifranz:~# raspiBackupWrapper.sh --- /media/raspberry/backup already mounted --- RBK0009I: raspifranz: raspiBackup.sh V0.6.4.3 (2d927a2) Mon Nov 11 14:14:54 CET 2019 gestartet. --- RBK0128I: Logdatei ist /media/raspberry/backup/raspifranz/raspifranz-ddz-backup-20191111-141454/raspiBackup.log. --- RBK0116I: Konfigurationsdatei /usr/local/etc/raspiBackup.conf wird benutzt. --- RBK0031I: Prüfe ob eine neue Version von raspiBackup.sh verfügbar ist. --- RBK0151I: Backuppfad /media/raspberry/backup wird benutzt. --- RBK0008I: Services werden gestoppt: 'systemctl stop smbd && systemctl stop minidlna && systemctl stop mariadb && systemctl stop apache2 && systemctl stop cron'. --- RBK0081I: Backup vom Typ ddz wird in /media/raspberry/backup/raspifranz/raspifranz-ddz-backup-20191111-141454 erstellt. --- RBK0085I: Backuperstellung vom Typ ddz gestartet. Bitte Geduld. 30436+1 records in 30436+1 records out 31914983424 bytes (32 GB, 30 GiB) copied, 2530.72 s, 12.6 MB/s --- RBK0078I: Backupzeit: 00:42:11. --- RBK0159I: 3 Backups werden für den Backuptyp ddz aufbewahrt. --- RBK0007I: Services werden gestartet: 'systemctl start cron && systemctl start apache2 && systemctl start mariadb && systemctl start minidlna && systemctl start smbd'. --- RBK0032I: Bitte warten bis aufgeräumt wurde. --- RBK0049I: Meldungen wurden in /media/raspberry/backup/raspifranz/raspifranz-ddz-backup-20191111-141454/raspiBackup.msg gesichert. --- RBK0026I: Debug Logdatei wurde in /media/raspberry/backup/raspifranz/raspifranz-ddz-backup-20191111-141454/raspiBackup.log gesichert. --- RBK0017I: Backup erfolgreich beendet. --- RBK0010I: raspifranz: raspiBackup.sh V0.6.4.3 (2d927a2) Mon Nov 11 14:57:47 CET 2019 beendet. Backup succeeded :-) pishrink.sh v0.1.2 pishrink.sh: Gatherin data... Error: /media/raspberry/backup/raspifranz/raspifranz-ddz-backup-20191111-141454/raspifranz-ddz-backup-20191111-141454.img.gz: unrecognised disk label losetup: /media/raspberry/backup/raspifranz/raspifranz-ddz-backup-20191111-141454/raspifranz-ddz-backup-20191111-141454.img.gz: Warning: file does not fit into a 512-byte sector; the end of the file will be ignored. tune2fs: Invalid argument while trying to open /dev/loop0 Couldn't find valid filesystem superblock. mount: /tmp/tmp.J8hZF9fq0p: can't read superblock on /dev/loop0. md5sum: /tmp/tmp.J8hZF9fq0p/etc/rc.local: No such file or directory Creating new /etc/rc.local mv: cannot stat '/tmp/tmp.J8hZF9fq0p/etc/rc.local': No such file or directory /usr/local/bin/pishrink.sh: line 179: /tmp/tmp.J8hZF9fq0p/etc/rc.local: No such file or directory chmod: cannot access '/tmp/tmp.J8hZF9fq0p/etc/rc.local': No such file or directory umount: /tmp/tmp.J8hZF9fq0p: not mounted. pishrink.sh: Checking filesystem... e2fsck: Invalid argument while trying to open /dev/loop0 /dev/loop0: The superblock could not be read or does not describe a valid ext2/ext3/ext4 filesystem. If the device is valid and it really contains an ext2/ext3/ext4 filesystem (and not swap or ufs or something else), then the superblock is corrupt, and you might try running e2fsck with an alternate superblock: e2fsck -b 8193 <device> or e2fsck -b 32768 <device> pishrink.sh: Filesystem error detected!... pishrink.sh: Trying to recover corrupted filesystem... e2fsck 1.44.5 (15-Dec-2018) e2fsck: Invalid argument while trying to open /dev/loop0 The superblock could not be read or does not describe a valid ext2/ext3/ext4 filesystem. If the device is valid and it really contains an ext2/ext3/ext4 filesystem (and not swap or ufs or something else), then the superblock is corrupt, and you might try running e2fsck with an alternate superblock: e2fsck -b 8193 <device> or e2fsck -b 32768 <device> pishrink.sh: ERROR occured in line 58: Filesystem recoveries failed. Giving up... root@raspifranz:~#
Nachtrag:
Es lag tatsächlich an dem ddz-Backup.
Ein erneuter Versuch mit einem dd-Backup hat funktioniert.
Code
Alles anzeigenroot@raspifranz:~# raspiBackupWrapper.sh --- /media/raspberry/backup already mounted --- RBK0009I: raspifranz: raspiBackup.sh V0.6.4.3 (2d927a2) Mon Nov 11 15:21:27 CET 2019 gestartet. --- RBK0128I: Logdatei ist /media/raspberry/backup/raspifranz/raspifranz-dd-backup-20191111-152127/raspiBackup.log. --- RBK0116I: Konfigurationsdatei /usr/local/etc/raspiBackup.conf wird benutzt. --- RBK0151I: Backuppfad /media/raspberry/backup wird benutzt. --- RBK0008I: Services werden gestoppt: 'systemctl stop smbd && systemctl stop minidlna && systemctl stop mariadb && systemctl stop apache2 && systemctl stop cron'. --- RBK0081I: Backup vom Typ dd wird in /media/raspberry/backup/raspifranz/raspifranz-dd-backup-20191111-152127 erstellt. --- RBK0085I: Backuperstellung vom Typ dd gestartet. Bitte Geduld. 30436+1 records in 30436+1 records out 31914983424 bytes (32 GB, 30 GiB) copied, 1223.8 s, 26.1 MB/s --- RBK0078I: Backupzeit: 00:20:24. --- RBK0159I: 3 Backups werden für den Backuptyp dd aufbewahrt. --- RBK0007I: Services werden gestartet: 'systemctl start cron && systemctl start apache2 && systemctl start mariadb && systemctl start minidlna && systemctl start smbd'. --- RBK0032I: Bitte warten bis aufgeräumt wurde. --- RBK0049I: Meldungen wurden in /media/raspberry/backup/raspifranz/raspifranz-dd-backup-20191111-152127/raspiBackup.msg gesichert. --- RBK0026I: Debug Logdatei wurde in /media/raspberry/backup/raspifranz/raspifranz-dd-backup-20191111-152127/raspiBackup.log gesichert. --- RBK0017I: Backup erfolgreich beendet. --- RBK0010I: raspifranz: raspiBackup.sh V0.6.4.3 (2d927a2) Mon Nov 11 15:42:32 CET 2019 beendet. Backup succeeded :-) pishrink.sh v0.1.2 pishrink.sh: Gatherin data... Creating new /etc/rc.local pishrink.sh: Checking filesystem... rootfs: 112235/1929536 files (1.3% non-contiguous), 950163/7724160 blocks resize2fs 1.44.5 (15-Dec-2018) pishrink.sh: Shrinking filesystem... resize2fs 1.44.5 (15-Dec-2018) Resizing the filesystem on /dev/loop0 to 927547 (4k) blocks. Begin pass 2 (max = 288) Relocating blocks XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Begin pass 3 (max = 236) Scanning inode table XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Begin pass 4 (max = 16262) Updating inode references XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX The filesystem on /dev/loop0 is now 927547 (4k) blocks long. pishrink.sh: Shrinking image... pishrink.sh: Shrunk /media/raspberry/backup/raspifranz/raspifranz-dd-backup-20191111-152127/raspifranz-dd-backup-20191111-152127.img from 30G to 3.8G... pishrink succeeded :-)
-
...Liegt es vielleicht daran. dass ich bei raspiBackup ein ddz-Backup eingestellt hatte?...
Ja. Es liegt daran dass pishrink nur mit reinen dd Images arbeiten kann. Du musst Dich entscheiden entweder pishrink zu benutzen oder ddz. Ich muss gestehen dass ich nicht weiss welches Image kleiner wird. Das haengt sicherlich auch den Daten ab.
-
Ich muss gestehen dass ich nicht weiss welches Image kleiner wird. Das haengt sicherlich auch den Daten ab
Das pishrink-Image hat eine Größe von 3.980.525 kb, das ddz-Image 5.256.355 kb
-
Danke fuer die Info. Wenn ich haette wetten muessen welches Image kleiner ist haette ich auch auf pishrink gesetzt
-
-
... super Arbeit, die Lösung mit den 3 Scripts. Perfekte Lösung für jeden Geschmack.
Danke fuer die Blumen Sind ja nur Beispiele wie man es machen koennte. Allerdings braucht man um sie anwenden zu koennen etwas bash und Linux Kenntnisse die nicht jeder hat. Man koennte diese Variabilitaet auch noch in raspiBackup einbauen aber das widerspricht der Linux Philosophy ein Programm macht nur eine Sache und die gut und schreibe Programme die gut zusammenarbeiten
-
Allerdings braucht man um sie anwenden zu koennen etwas bash und Linux Kenntnisse die nicht jeder hat
Wenn man nach deiner Anleitung vorgeht, reichen die wichtigsten linux-Befehle, sowie die Fähigkeit mit Copy/Paste umzugehen. Und lesen sollte man können. Die einzelnen bash-dateien muss man ja nicht verstehen. Wer es geschafft hat einen Pi "aufzusetzen" sollte das hinbekommen. Ansonsten braucht er auch kein Backup.
Man koennte diese Variabilitaet auch noch in raspiBackup einbauen aber das widerspricht der Linux Philosophy ein Programm macht nur eine Sache und die gut und schreibe Programme die gut zusammenarbeiten
Ist ja auch vollkommen in Ordnung so.
-
framp Leider funktioniert das Script "raspiBackupWrapper nicht bei deinstalliertem "sudo", da alle Sciptaufrufe mit "sudo erfolgen.
Beim manuellen Start des Scripts in der Konsole erfolgt nach der Erstellung des dd-Backups die Meldung
Code--- RBK0010I: raspifranjo: raspiBackup.sh V0.6.4.3 (2d927a2) Do 21. Nov 20:52:23 CET 2019 beendet. Backup succeeded :-) /usr/local/bin/raspiBackupWrapper.sh: Zeile 148: sudo: Kommando nicht gefunden. root@raspifranjo:/home/franjo# nano /usr/local/bin/raspiBackupWrapper.sh
Beim Start per Cronjob habe ich nach 5 Std abgebrochen.
-
Nimm einfach die sudo aus dem Skript raus, stelle aber sicher, dass dann das Skript mit root Rechten ausgeführt wird
-
Jetzt mitmachen!
Du hast noch kein Benutzerkonto auf unserer Seite? Registriere dich kostenlos und nimm an unserer Community teil!