Giter Club home page Giter Club logo

imgclone's People

Contributors

ne0yt avatar nliviu avatar tom-2015 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

imgclone's Issues

"uuid: not found", "parted: not found"

Hi!
I was trying to use imgclone to make a backup of my OSMC image, but I was getting the following message when trying to run the make command:

osmc@HTPC:~/imgclone$ make
gcc -g -I/usr/include -L/usr/lib -L/usr/local/lib -I/usr/lib/arm-linux-gnueabihf -pthread imgclone.c -o imgclone
imgclone.c:32:10: fatal error: stdio.h: No such file or directory
 #include <stdio.h>
          ^~~~~~~~~
compilation terminated.
make: *** [Makefile:8: imgclone] Error 1

I was able to fix this by running sudo apt-get install libc6-dev, as per this SO answer. I am using the version 2021.08-1 of OSMC on a Raspberry Pi 4 B+.
Could this be a missing dependency for this OS?

In any case, after this, I ran the imgclone -d mybackup.img command, but I am getting the following message:

Cloning /dev/mmcblk0 to mybackup.img
uuid | cut -f1 -d-
sh: 1: uuid: not found
sh: 1: parted: not found
Unable to read source.

Any idea what could it be?
Thanks!

The uuid package is required but won't stop if not found

----    Raspberry Pi clone to image V1.8    ---
-----------------------------------------------
---- DO NOT CHANGE FILES ON YOUR SD CARD    ---
---- WHILE THE BACKUP PROGRAM IS RUNNING    ---
---- THE DESTINATION .IMG FILE MUST BE      ---
---- ON AN EXTERNAL STORAGE / NETWORK SHARE ---
-----------------------------------------------
Cloning /dev/mmcblk0 to 15nov2023.img
gzip compress in on.
Show progress is on.
uuid | cut -f1 -d-
sh: 1: uuid: not found
mktemp -d
mktemp -d
-----------------------------------------------
----    READING PARTITIONS               ------
-----------------------------------------------
Partition 1 start: 8192 end: 532479 ptype:primary ftype:fat32 flags: lba
.Partition 2 start: 532480 end: 62333951 ptype:primary ftype:ext4 flags:
.partprobe
Last partition starts at 272629760 bytes.
mount /dev/mmcblk0p2 /tmp/tmp.mg1qgNs8Sa

This would probably lead to problems down the road. I suggest you update the README and assert the existence of the executable at the beginning.

erroneously said not enough space

tried to run it and save to a cifs moutned nas. I have terrabytes of free space, but your app errored out saying not enough free space. Also, i got errors about invalid commands to fdisk.

Progress bar

Hi,

I tried imgclone today to backup the SD card (16 GB, about 75 % full, 5 partitions) from my Rpi4 (ethernet) to my Win10 laptop (wireless). It took a bit more than one hour. It completed successfully. I did not try a restore.

The feature that I would like to see is some kind of progess bar. In my case, the bulk of the data is on partition 5 and the only message is that imgclone is copying data but it gives no indication that it actually is. I was able to see that the time stamp on the img file (on the laptop) was changing, so I assumed it was being written, but that's all.

It does not have to be a progress bar as such, but some kind of reassurance that it is actually copying the large partition would be nice.

Thanks.

Network drive mounted

Hi there, perfect project. Exactly what I was looking for, however I'm still confused.
I have 1T HD attached and auto mounted during boot /home/user/Share.

Can I use imgclone to that folder? It will exclude /home/user/Share from backup?

Gzip not working depending on command line parameter

Post compression seems to work with some commands but not others, backing up from ssd as /dev/sda :

WORKS
sudo imgclone -s /dev/sda -d /home/pi/mnt/Main/Raspbian/backupimages/argon.img -gzip
Outcome - Completes making .img file and then proceeds to make .gz file succesfully

DOESN'T WORK
sudo imgclone -s /dev/sda -d /home/pi/mnt/Main/Raspbian/backupimages/$(hostname).backup.$(date +%Y%m%d%H%M).img -gzip
Outcome - Completes making .img file but doesnt attempt to make gz file.

Obviously would be nice to datestamp these in the file name as well as the attributes

Also - if a gzipped image already exists with the filename chosen, would be good to be able to switch so that it force overwrites rather than having to select yes manually at the terminal.

can't create a backup (raspbian) -> freeze after truncate

----    Raspberry Pi clone to image V1.6    ---
-----------------------------------------------
---- DO NOT CHANGE FILES ON YOUR SD CARD    ---
---- WHILE THE BACKUP PROGRAM IS RUNNING    ---
---- THE DESTINATION .IMG FILE MUST BE      ---
---- ON AN EXTERNAL STORAGE / NETWORK SHARE ---
-----------------------------------------------
Cloning /dev/mmcblk0 to backup.img
Show progress is on.
uuid | cut -f1 -d-
sh: 1: uuid: not found
mktemp -d
mktemp -d
-----------------------------------------------
----    READING PARTITIONS               ------
-----------------------------------------------
Partition 1 start: 8192 end: 532479 ptype:primary ftype:fat32 flags: lba
.Partition 2 start: 532480 end: 62333951 ptype:primary ftype:ext4 flags:
.partprobe
Last partition starts at 272629760 bytes.
mount /dev/mmcblk0p2 /tmp/tmp.X7kYdEM6sl
df /tmp/tmp.X7kYdEM6sl | tail -n 1 | tr -s " " " " | cut -d ' ' -f 2
df /tmp/tmp.X7kYdEM6sl | tail -n 1 | tr -s " " " " | cut -d ' ' -f 4
Used size of last partition is 3086970880 bytes.
umount /tmp/tmp.X7kYdEM6sl
Required size for destination image: 3437278720 bytes
-----------------------------------------------
----    ALLOCATING SPACE FOR .IMG FILE   ------
-----------------------------------------------
touch "backup.img"
df "backup.img" | tail -n 1 | tr -s " " " " | cut -d ' ' -f 1
/dev/sdc1
df --output=avail -B 1 "backup.img" | tail -n 1
15427166208
truncate --size 3437278720 "backup.img"```

when I cancel using ctrl+c I cna see the file.

Insufficient space. Backup aborted.

Not sure if this is suppose to happen. I have 107G, but I'm trying to build a 3.4G img.

$ pwd
/home/pi/External/backup

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/root       3.4G  2.7G  547M  83% /
devtmpfs        207M     0  207M   0% /dev
tmpfs           239M     0  239M   0% /dev/shm
tmpfs           239M  3.5M  235M   2% /run
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           239M     0  239M   0% /sys/fs/cgroup
/dev/mmcblk0p1  253M   42M  211M  17% /boot
/dev/sda1       113G  112M  107G   1% /home/pi/External
tmpfs            48M     0   48M   0% /run/user/1000

$ sudo imgclone -d mybackup.img
----    Raspberry Pi clone to image V1.8    ---
-----------------------------------------------
---- DO NOT CHANGE FILES ON YOUR SD CARD    ---
---- WHILE THE BACKUP PROGRAM IS RUNNING    ---
---- THE DESTINATION .IMG FILE MUST BE      ---
---- ON AN EXTERNAL STORAGE / NETWORK SHARE ---
-----------------------------------------------
Cloning /dev/mmcblk0 to mybackup.img
uuid | cut -f1 -d-
sh: 1: uuid: not found
.
.
.
mount /dev/loop0p2 /tmp/tmp.38KHM88HJM
mount /dev/mmcblk0p2 /tmp/tmp.5dQKpZBcay
df /tmp/tmp.5dQKpZBcay | tail -n 1 | tr -s " " " " | cut -d ' ' -f 3
df /tmp/tmp.38KHM88HJM | tail -n 1 | tr -s " " " " | cut -d ' ' -f 4
umount /tmp/tmp.38KHM88HJM
umount /tmp/tmp.5dQKpZBcay
Insufficient space. Backup aborted.

Time to clone

Hi, I'm new to this forum.
This is a general question regarding cloning or copying raspberry pi SD cards with applies to imgclone as well, please can anyone tell me why it takes so long to create the .img file, e.g., over 4 hours so create a 12.7Gb from the 16Gb source SD card?
Thanks
Mike

make results in error

imgclone.c: In function ‘clone_to_img’:
imgclone.c:246:3: warning: format not a string literal and no format arguments [-Wformat-security]
  246 |   fprintf(stderr,partition_name (src_dev, dev));
      |   ^~~~~~~
imgclone.c:259:44: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 2 has type ‘char *’ [-Wformat=]
  259 |  printf("Used size of last partition is %lld bytes.\n", src_mnt, partition_size_used);
      |                                         ~~~^            ~~~~~~~
      |                                            |            |
      |                                            |            char *
      |                                            long long int
      |                                         %s
imgclone.c:259:9: warning: too many arguments for format [-Wformat-extra-args]
  259 |  printf("Used size of last partition is %lld bytes.\n", src_mnt, partition_size_used);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
imgclone.c:328:18: warning: format not a string literal and no format arguments [-Wformat-security]
  328 |   fprintf(stderr,dst_dev);
      |                  ^~~~~~~
imgclone.c:630:43: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘char *’ [-Wformat=]
  630 |   fprintf(stderr,"Error releasing device %d.\n", dst_dev);
      |                                          ~^      ~~~~~~~
      |                                           |      |
      |                                           int    char *
      |                                          %s
imgclone.c: In function ‘main’:
imgclone.c:732:4: warning: format not a string literal and no format arguments [-Wformat-security]
  732 |    fprintf(stderr,argv[i]);
      |    ^~~~~~~
imgclone.c: In function ‘clone_to_img’:
imgclone.c:284:25: warning: ‘%s’ directive writing up to 511 bytes into a region of size 252 [-Wformat-overflow=]
  284 |  sprintf (buffer, "df \"%s\" | tail -n 1 | tr -s \" \" \" \" | cut -d ' ' -f 1", dst_file_escaped);
      |                         ^~                                                       ~~~~~~~~~~~~~~~~
imgclone.c:284:2: note: ‘sprintf’ output between 52 and 563 bytes into a destination of size 256
  284 |  sprintf (buffer, "df \"%s\" | tail -n 1 | tr -s \" \" \" \" | cut -d ' ' -f 1", dst_file_escaped);
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
imgclone.c:293:45: warning: ‘%s’ directive writing up to 511 bytes into a region of size 232 [-Wformat-overflow=]
  293 |  sprintf (buffer, "df --output=avail -B 1 \"%s\" | tail -n 1", dst_file_escaped);
      |                                             ^~                 ~~~~~~~~~~~~~~~~
imgclone.c:293:2: note: ‘sprintf’ output between 38 and 549 bytes into a destination of size 256
  293 |  sprintf (buffer, "df --output=avail -B 1 \"%s\" | tail -n 1", dst_file_escaped);
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
imgclone.c:314:39: warning: ‘%s’ directive writing up to 511 bytes into a region of size 237 [-Wformat-overflow=]
  314 |  sprintf(buffer, "losetup --show -f \"%s\"", dst_file_escaped);
      |                                       ^~     ~~~~~~~~~~~~~~~~
imgclone.c:314:2: note: ‘sprintf’ output between 21 and 532 bytes into a destination of size 256
  314 |  sprintf(buffer, "losetup --show -f \"%s\"", dst_file_escaped);
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccPBwPWJ.o: in function `clone_to_img':
/home/ubuntu/imgclone/imgclone.c:543: undefined reference to `pthread_create'
/usr/bin/ld: /home/ubuntu/imgclone/imgclone.c:574: undefined reference to `pthread_join'
collect2: error: ld returned 1 exit status
make: *** [Makefile:8: imgclone] Error 1```

Can't clone if boooting from USB

Hi @tom-2015, the program can't find the sd card to clone. That is true, since I'm not using it.

$ sudo ../imgclone -d mybackup.img
----    Raspberry Pi clone to image V1.8    ---
-----------------------------------------------
---- DO NOT CHANGE FILES ON YOUR SD CARD    ---
---- WHILE THE BACKUP PROGRAM IS RUNNING    ---
---- THE DESTINATION .IMG FILE MUST BE      ---
---- ON AN EXTERNAL STORAGE / NETWORK SHARE ---
-----------------------------------------------
Cloning /dev/mmcblk0 to mybackup.img
uuid | cut -f1 -d-
Error: Could not stat device /dev/mmcblk0 - No such file or directory.
$ lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
sda      8:0    0 119.2G  0 disk 
├─sda1   8:1    0   512M  0 part /boot/firmware
└─sda2   8:2    0 118.7G  0 part /

Is it possible to make it generic somehow, or specify the root partition?

Feature request: bzip2 etc image file compression option.

A great cli based tool for image creation of a live RPi OS. Although the resultant .img file is only slightly more than the original used space source - is there a possibility of including a post image creation bzip2 or similar image compression option within your script.

This would create potentially a much smaller compressed .img file for archive/storage/transport and could be used as is with most of the image writers to recreate boot media from a compressed .img file.

Size of img too large still..

Don't know if this will be seen but I've noticed that using a USB drive (256gb ) it makes an image that's 14gb, even though used space is only around 5gb.

I use another utility and it creates a 5.1gb image ( no compression)

When I cloned by 32gb card it showd as a 5.5gb image. But after restoring that image to aarver card and expanding the file system, I now get 14gb
Img.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.