lzkelley / bkup_rpimage

Script to backup a Raspberry Pi disk image
GNU General Public License v3.0
162 stars 54 forks source link

Getting bunch of errors #16

Closed fingust closed 5 years ago

fingust commented 5 years ago

I have a freshly installed Raspbian Stretch Lite apart from installing git and enabling SSH. It's installed on a USB instead of a SD Card so I've changed the SDCARD variable on the top of the script to point to the rootfs partition of the USB, which is /dev/sda2.

I ran the script with the following command: ./bkup_rpimage.sh start -s 4000 -c /mnt/JetFlash16/rpi_stage_1.img

Script output:

Starting SD Image backup process Creating sparse /mnt/JetFlash16/rpi_stage_1.img, the apparent size of /dev/sda2 0+0 records in 0+0 records out 0 bytes copied, 0.000842968 s, 0.0 kB/s Attaching /mnt/JetFlash16/rpi_stage_1.img to /dev/loop0 Copying partition table from /dev/sda2 to /dev/loop0 Checking that no-one is using this disk right now ... OK

Disk /dev/loop0: 3.9 GiB, 4194304000 bytes, 8192000 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: 0xa6e4b0cf

Old situation:

sfdisk: /dev/sda2: does not contain a recognized partition table

Done.

New situation:

The partition table has been altered. Calling ioctl() to re-read partition table. Re-reading the partition table failed.: Invalid argument 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). Syncing disks. Formatting partitions mkfs.fat 4.1 (2017-01-24) mkfs.vfat: unable to open /dev/loop0p1: No such file or directory mke2fs 1.43.4 (31-Jan-2017) The file /dev/loop0p2 does not exist and no size was specified. e2fsck 1.43.4 (31-Jan-2017) e2fsck: No such file or directory while trying to open /dev/loop0p2 Possibly non-existent device? tune2fs 1.43.4 (31-Jan-2017) tune2fs: option requires an argument -- 'U' Usage: tune2fs [-c max_mounts_count] [-e errors_behavior] [-f] [-g group] [-i interval[d|m|w]] [-j] [-J journal_options] [-l] [-m reserved_blocks_percent] [-o [^]mount_options[,...]] [-p mmp_update_interval] [-r reserved_blocks_count] [-u user] [-C mount_count] [-L volume_label] [-M last_mounted_dir] [-O [^]feature[,...]] [-Q quota_options] [-E extended-option[,...]] [-T last_check_time] [-U UUID] [-I new_inode_size] [-z undo_file] device

Welcome to fdisk (util-linux 2.29.2). Changes will remain in memory only, until you decide to write them. Be careful before using the write command.

Command (m for help): Disk /dev/loop0: 3.9 GiB, 4194304000 bytes, 8192000 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: 0xa6e4b0cf

Command (m for help): Expert command (m for help): Enter the new disk identifier: Incorrect value.

Expert command (m for help): Command (m for help): Disk /dev/loop0: 3.9 GiB, 4194304000 bytes, 8192000 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: 0xa6e4b0cf

Command (m for help): The partition table has been altered. Calling ioctl() to re-read partition table. Re-reading the partition table failed.: Invalid argument

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

Mounting /dev/loop01 and /dev/loop02 to /mnt/rpi_stage_1.img/ mount: special device /dev/loop0p2 does not exist mount: special device /dev/loop0p1 does not exist Skipping rsync since /mnt/rpi_stage_1.img/ is not a mount point df: /dev/loop0p1: No such file or directory df: /dev/loop0p2: No such file or directory Flushing to disk Unmounting /dev/loop01 and /dev/loop02 from /mnt/rpi_stage_1.img/ umount: /mnt/rpi_stage_1.img//boot: not mounted umount: /mnt/rpi_stage_1.img/: not mounted rmdir: failed to remove '/mnt/rpi_stage_1.img/': Directory not empty Detaching /mnt/JetFlash16/rpi_stage_1.img from /dev/loop0 partx: specified range <1:0> does not make sense SD Image backup process completed.

I've tried to execute suggested methods of the "kernel still uses the old table" message, but with no luck. Anything else is beyond my knowledge at this point, so I would appreciate the help.

dolorosus commented 5 years ago

Same as in #14.

If the system doesn't reside on the sdcard the name of the loopbackdevice will not be correct determined.

You may change all occurences of ${LOOPBAK} referencing the loopback device/partitions to your needs. But be warned: Take a closer look to line 98 (sfdisk --dump ${SDCARD} | sfdisk --force ${LOOPBACK}) This is dangerous rubbish! Although I contributed some code to this script I can't recommend it anymore. It may work correct, but has some flaws.

The whole part of creating the destination partitions needs some rework. Maybe you take a look for another raspi backup solution on github.

Best wishes Dolorosus

ephestione commented 5 years ago

@dolorosus what are you currently using as a backup solution?

I just recently checked several other scripts, and on top are: 1) Raspibackup (is able to do the same, but if you just need rsync into an image, it's greatly overblown, and it first creates rsync, then image out of it, while this one rsync directly into the image) 2) This one which also does roughly the same thing, yet it's more convoluted, and still needs to first create rsync, and then image from it

I think rpimage is brilliant in the way it fuses two different procedures into one, and I would rather see it, or release it, updated. But I have so many other little projects going on, and as it is, this still works for me, that I don't "need" it upgraded, so I don't know if I will be putting my hands on the code anytime soon

ephestione commented 5 years ago

Silly me, I just peeked into your repository and it appears you already released a similar script! Studying the source right now