Hi, Friends,
I flashed a SD card with OS, update, upgrade, and install some packages. now I want save SD card. so next time, I don't need install package again. I use SD clone generate a image file. the image is the size of my SD card, 32G. I check the SD card files, it only ~80M. How could I just generate the SD card image to reflect files on the SD card, rather than entire SD card.
thanks
Xian
Re: save RPi Micro SD to a image
Take a look at this thread, a user has modified the piclone program so it can create and save a .img file anywhere: viewtopic.php?f=63&t=281190&p=1710151#p1710151
Re: save RPi Micro SD to a image
thanks for reply. but that is not what I m looking for. I don't want clone whole SD card. I just need the necessary OS image. which is much smaller than whole SD card size.
Re: save RPi Micro SD to a image
The image files it creates are far smaller than the SD card, for me, it creates 8GB images. It doesn't matter what size SD card is in the Pi at the time.
- CaptainMidnight
- Posts: 189
- Joined: Sun Nov 03, 2019 4:32 pm
- Location: UK
Re: save RPi Micro SD to a image
Not sure what you are using to tell you that you are only using 80MB? A good way to clarify your understanding of what is actually being used and required to duplicate your current configuration, is to use the command 'df -h' at the cli prompt: -
Code: Select all
pi@phoenix-pi-noc:~ $ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 29G 5.4G 23G 20% /
/dev/mmcblk0p1 253M 55M 198M 22% /boot
The above is a cut-down output of the 'df -h' command - it shows a PiOS 32bit install on a 32GB SDcard, which is currenlty sitting at 5.45GB used (root and boot partitions).
Using the SDcard to Img file utility as referenced by TommyG007, i.e. imgclone https://github.com/tom-2015/imgclone and forum post viewtopic.php?f=63&t=281190, you would be able to create a compressed xxxxxxx.img.bz2 file of 2.05GB in this instance.
The compressed image file could then be used in an image writer to recreate your as of now, fully updated and configured SDcard in the future.
Just a thought

"Never get out of the boat." Absolutely goddamn right!
Unless you were goin' all the way...
Unless you were goin' all the way...
Re: save RPi Micro SD to a image
I tried imgclone. failed. see below.
check usb driver capacity. it's big enough.pi@raspberrypi:/media/pi/x $ sudo imgclone -d xxx.img
---- Raspberry Pi clone to image V1.2 ---
-----------------------------------------------
---- 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 xxx.img
uuid | cut -f1 -d-
mktemp -d
mktemp -d
-----------------------------------------------
---- READING PARTITIONS ------
-----------------------------------------------
Partition 1 start: 8192 end: 532479 ptype:primary ftype:fat32 flags: lba
.Partition 2 start: 532480 end: 15415295 ptype:primary ftype:ext4 flags:
.partprobe
Last partition starts at 272629760 bytes.
mount /dev/mmcblk0p2 /tmp/tmp.3RgFzhVKOG
df /tmp/tmp.3RgFzhVKOG | tail -n 1 | tr -s " " " " | cut -d ' ' -f 2
df /tmp/tmp.3RgFzhVKOG | tail -n 1 | tr -s " " " " | cut -d ' ' -f 4
Used size of last partition is 6534172672 bytes.
umount /tmp/tmp.3RgFzhVKOG
Required size for destination image: 6953424384 bytes
-----------------------------------------------
---- ALLOCATING SPACE FOR .IMG FILE ------
-----------------------------------------------
touch "xxx.img"
df "xxx.img" | tail -n 1 | tr -s " " " " | cut -d ' ' -f 1
/dev/sda1
df --output=avail -B 1 "xxx.img" | tail -n 1
15589818368
truncate --size 6953424384 "xxx.img"
truncate: failed to truncate 'xxx.img' at 6953424384 bytes: File too large
Could not create file large enough on destination disk.
pi@raspberrypi:/media/pi/x $ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 7.0G 5.8G 858M 88% /
devtmpfs 431M 0 431M 0% /dev
tmpfs 464M 0 464M 0% /dev/shm
tmpfs 464M 13M 452M 3% /run
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 464M 0 464M 0% /sys/fs/cgroup
/dev/mmcblk0p1 253M 87M 166M 35% /boot
tmpfs 93M 0 93M 0% /run/user/1000
/dev/sda1 15G 68M 15G 1% /media/pi/x
Re: save RPi Micro SD to a image
Lxw2015 wrote: ↑Wed Aug 12, 2020 2:52 pmI flashed a SD card with OS, update, upgrade, and install some packages. now I want save SD card. so next time, I don't need install package again. I use SD clone generate a image file. the image is the size of my SD card, 32G. I check the SD card files, it only ~80M. How could I just generate the SD card image to reflect files on the SD card, rather than entire SD card.
image-backup
Re: save RPi Micro SD to a image
I second that. Image-Backup revolutionized my systems. What used to take hours now takes seconds or, worst case, couple minutes. I don't care if SD corrupts or crashes anymore. lol
Re: save RPi Micro SD to a image
Lxw2015 wrote: ↑Thu Aug 13, 2020 5:08 pmI tried imgclone. failed. see below.check usb driver capacity. it's big enough.pi@raspberrypi:/media/pi/x $ sudo imgclone -d xxx.img
---- Raspberry Pi clone to image V1.2 ---
-----------------------------------------------
---- 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 xxx.img
uuid | cut -f1 -d-
mktemp -d
mktemp -d
-----------------------------------------------
---- READING PARTITIONS ------
-----------------------------------------------
Partition 1 start: 8192 end: 532479 ptype:primary ftype:fat32 flags: lba
.Partition 2 start: 532480 end: 15415295 ptype:primary ftype:ext4 flags:
.partprobe
Last partition starts at 272629760 bytes.
mount /dev/mmcblk0p2 /tmp/tmp.3RgFzhVKOG
df /tmp/tmp.3RgFzhVKOG | tail -n 1 | tr -s " " " " | cut -d ' ' -f 2
df /tmp/tmp.3RgFzhVKOG | tail -n 1 | tr -s " " " " | cut -d ' ' -f 4
Used size of last partition is 6534172672 bytes.
umount /tmp/tmp.3RgFzhVKOG
Required size for destination image: 6953424384 bytes
-----------------------------------------------
---- ALLOCATING SPACE FOR .IMG FILE ------
-----------------------------------------------
touch "xxx.img"
df "xxx.img" | tail -n 1 | tr -s " " " " | cut -d ' ' -f 1
/dev/sda1
df --output=avail -B 1 "xxx.img" | tail -n 1
15589818368
truncate --size 6953424384 "xxx.img"
truncate: failed to truncate 'xxx.img' at 6953424384 bytes: File too large
Could not create file large enough on destination disk.
pi@raspberrypi:/media/pi/x $ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 7.0G 5.8G 858M 88% /
devtmpfs 431M 0 431M 0% /dev
tmpfs 464M 0 464M 0% /dev/shm
tmpfs 464M 13M 452M 3% /run
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 464M 0 464M 0% /sys/fs/cgroup
/dev/mmcblk0p1 253M 87M 166M 35% /boot
tmpfs 93M 0 93M 0% /run/user/1000
/dev/sda1 15G 68M 15G 1% /media/pi/x
What format is your USB drive in?
If it's FAT32, you can't create files with more than 4GB size on FAT32 filesystems.
-
- Posts: 6
- Joined: Thu Sep 06, 2018 3:01 pm
Re: save RPi Micro SD to a image
I just published a step-by-step on how to do this:
https://www.tomshardware.com/how-to/bac ... disk-image
https://www.tomshardware.com/how-to/bac ... disk-image
Re: save RPi Micro SD to a image
yeah, I just figured that out. I need format USB to NTFS format. it take loooong time to generate image. and the generated image is bigger than I expected.
for example
pi@phoenix-pi-noc:~ $ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 29G 5.4G 23G 20% /
/dev/mmcblk0p1 253M 55M 198M 22% /boot
I was hoping the generated image is 5.5G, but it generated 6.0G image.
for example
pi@phoenix-pi-noc:~ $ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 29G 5.4G 23G 20% /
/dev/mmcblk0p1 253M 55M 198M 22% /boot
I was hoping the generated image is 5.5G, but it generated 6.0G image.
Re: save RPi Micro SD to a image
I'll try it. thanksgeekinchief wrote: ↑Fri Aug 14, 2020 8:23 pmI just published a step-by-step on how to do this:
https://www.tomshardware.com/how-to/bac ... disk-image
Re: save RPi Micro SD to a image
Lxw2015 wrote: ↑Fri Aug 14, 2020 8:29 pmyeah, I just figured that out. I need format USB to NTFS format. it take loooong time to generate image. and the generated image is bigger than I expected.
for example
pi@phoenix-pi-noc:~ $ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 29G 5.4G 23G 20% /
/dev/mmcblk0p1 253M 55M 198M 22% /boot
I was hoping the generated image is 5.5G, but it generated 6.0G image.
You'll get much faster speeds if you format the USB drive to ext4.
For example, when I create a backup to my NAS SSD drive formatted in ext4, it takes about 4 minutes to create the 8GB image file.
Re: save RPi Micro SD to a image
geekinchief wrote: ↑Fri Aug 14, 2020 8:23 pmI just published a step-by-step on how to do this:
https://www.tomshardware.com/how-to/bac ... disk-image
Yours is a guide on using PiShrink (great guide btw).
We're talking about using the modified version of PiClone which a user has created over on this thread: viewtopic.php?f=63&t=281190&p=1703077#p1703077
https://github.com/tom-2015/imgclone