Joe Schmoe
Posts: 4277
Joined: Sun Jan 15, 2012 1:11 pm

Re: How to reduce the Pi image on the SDcard?

Mon Oct 05, 2015 6:30 pm

RaTTuS wrote:it is fairly easy to script it
but there are quite a lot gotya's that will crash and burn so the script ends up being much more complicated than learning how to do it in a good way ;)
Exactly. Well put.

As I said, once you've gotten far enough down the road to know how to do it right, there's just no incentive to go back and do it in Windows.
And some folks need to stop being fanboys and see the forest behind the trees.

(One of the best lines I've seen on this board lately)

Heater
Posts: 13083
Joined: Tue Jul 17, 2012 3:02 pm

Re: How to reduce the Pi image on the SDcard?

Mon Oct 05, 2015 6:38 pm

Joe Schmoe,
Besides, you know perfectly well that when they say "my PC", they mean Windows.
Yep, I do. However this is the place you come to learn that there is another world out there.

rpdom,
To be honest, with all the programming experience of some people on here, I'm very surprised that someone hasn't written a utility for Windows that will back up a Pi SD card...
I think it has been said before but such people, having acquired such skills by whatever means, have no interest in supporting a multi-billion dollar corporation attract users to their pay for OS. Makes no sense.

Some have said it's really simple to script in Windows. I look forward to seeing what they can do.

Bosse_B
Posts: 776
Joined: Thu Jan 30, 2014 9:53 am

Re: How to reduce the Pi image on the SDcard?

Mon Oct 05, 2015 7:05 pm

Bosse_B wrote: Right now I have installed and tested VNC and retrieved the sources for FPC via svn and am ready to start compiling version 3.1.1 using version 2.6.4 :cool:
Will be done after dinner me thinks.
Now up and running Lazarus on the pi with the new 8GB SDcard. Took about 2 hours and change to do the complete installation. :D
Mission accomplished.
Bo Berglund
Sweden

Bosse_B
Posts: 776
Joined: Thu Jan 30, 2014 9:53 am

Re: How to reduce the Pi image on the SDcard?

Mon Oct 05, 2015 7:17 pm

To be honest, with all the programming experience of some people on here, I'm very surprised that someone hasn't written a utility for Windows that will back up a Pi SD card...

I think it has been said before but such people, having acquired such skills by whatever means, have no interest in supporting a multi-billion dollar corporation attract users to their pay for OS. Makes no sense.

Some have said it's really simple to script in Windows. I look forward to seeing what they can do.
I would have been satisfied if there was a script in Linux that could create an image file from the SDcard on a disk drive on the Pi itself. For example an attached thumb drive. The image should also be possible to write back to another SDcard like the Windows utility does.
A boon would be "intelligent" handling of the zeroed or FF:ed areas of the disk (unused sectors) so they would not consume so much space in the image file.

That would not be drawing people to Windows but help those that try to do it on Linux/RPi.....

But no one suggested as much only use of these very complex and hard to understand general tools (fdisk, cfdisk, parted, dd, rsync etc)
Could not someone package this into say a Python program for Linux?
Or else a command line script with a minimum of user input; that could run via an SSH terminal connection too.

Right now I could use a utility like that to make an image of my newly built SDcard with the Lazarus IDE and all but before I have wrecked it with Pascal programming and tests...

Reminds me that I really should shut down the pi and extract the SDcard and make that image using Win32DiskImager on Win7.
Bo Berglund
Sweden

Heater
Posts: 13083
Joined: Tue Jul 17, 2012 3:02 pm

Re: How to reduce the Pi image on the SDcard?

Mon Oct 05, 2015 8:09 pm

There is nothing hard about "dd". It does the simplest possible operations on disks and file systems one can imagine. Copy blocks from one place to another.

On could wrap that up in Python, but I don't see it getting any easier to use.

I could say the same for the other tools you mentioned there.

plugwash
Forum Moderator
Forum Moderator
Posts: 3439
Joined: Wed Dec 28, 2011 11:45 pm

Re: How to reduce the Pi image on the SDcard?

Mon Oct 05, 2015 10:10 pm

copying a running system is tricky to do right.

You can of course do

dd if=/dev/mmclk0 of=/path/to/image/file/on/external/drive bs=32M

but t he trouble with doing a block level copy on a live filesystem is you can get corruption of the image if stuff writes to the filesystem during the copy. It's something i'd do on my own systems after taking steps to minimise the risk but not something i'd want to wrap up in a UI for newbies.

A file level copy is generally a safer (though not 100% safe) option for backing up a running system but is a bit more complicated to do.

Bosse_B
Posts: 776
Joined: Thu Jan 30, 2014 9:53 am

Re: How to reduce the Pi image on the SDcard?

Mon Oct 05, 2015 10:17 pm

OK,
but for me as a Linux non-guru it would have helped if I could have inserted a USB flash drive into the Pi and then started a program (shellscript or Python does not matter) which would be told which disk to image and to place the image file on the thumb drive. Or to write an image file onto an SDcard, which then also must be attached via a card reader of course.
Two operations:
1) Create image file of a specific SDcard (not including the active one running the Pi at the moment)
2) Write a previously created image file to an SDcard in an attached card reader (also here the Pi:s own SDcard is out of bounds of course).

In the process of doing this it should minimize the size of the written file and maximize the file system on the target SDcard when writing it. This way one can move between physically different SDcards sizewise.

Would this be possible or not?
I think it would be a very nice utility if it were a program that could be loaded into the Pi via for example apt-get or similar.
Bo Berglund
Sweden

Higgs
Posts: 43
Joined: Tue May 26, 2015 2:17 pm

Re: How to reduce the Pi image on the SDcard?

Mon Oct 05, 2015 10:26 pm

Just to backup what I have, I've just stuck the SD in a pc with a card reader and booted off a CD of Clonezilla just to do what I wanted to just get done.

User avatar
rpdom
Posts: 14984
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: How to reduce the Pi image on the SDcard?

Tue Oct 06, 2015 6:21 am

Bosse_B wrote:Would this be possible or not?
Yes, it is possible. I worked on something that generated a reduced-size image of the currently running system. It could do with tiding up a bit and some error checking and stuff put in. Also I don't know if it will work with jessie as some options in fdisk (which it uses) seem to have changed since I wrote it.

User avatar
r3d4
Posts: 967
Joined: Sat Jul 30, 2011 8:21 am
Location: ./

Re: How to reduce the Pi image on the SDcard?

Fri Oct 09, 2015 8:49 pm

Higgs wrote:Just to backup what I have, I've just stuck the SD in a pc with a card reader and booted off a CD of Clonezilla just to do what I wanted to just get done.
FTW
Image
*applause*

aoakley
Posts: 66
Joined: Fri May 11, 2012 10:27 pm
Contact: Website

Re: How to reduce the Pi image on the SDcard?

Mon Oct 12, 2015 2:21 pm

I've written a how-to on roughly this subject:

http://aoakley.com/articles/2015-10-09- ... images.php

It requires a Linux PC, unless you're feeling particularly masochistic and insist on doing it (slowly) entirely on a Pi.

This takes you through:
* Making the image - I recommend dcfldd over vanilla dd, simply for the progress meter
* Mounting the image file on the loopback device
* Resizing the root partition
* Resizing the entry in the partition table
* Truncating the image file
Andrew Oakley - Cotswold Raspberry Jam, Gloucestershire - http://www.cotswoldjam.org

tpylkko
Posts: 381
Joined: Tue Oct 14, 2014 5:21 pm

Re: How to reduce the Pi image on the SDcard?

Mon Oct 12, 2015 6:32 pm

I don't have a running NOOBS install right now, but I think you can boot to the tinycore part of noobs, enter a terminal with something like ctrl-alt-F2 and issue

Code: Select all

dd if=/dev/mmclk0pX of=/path/to/image/file/on/external/drive bs=32M
there? That is, avoid the copying of a live filesystem, as the partitions will be all unmounted. Or better yet, maybe in future versions there could be a button there that does this (or using bmap-tools) and perhaps another one that can use e2fsck to check for corruption... that way Windows using people that don't want to boot a laptop into a live linux session could easily create copies of the partitions on the sd-card to, say, a usb stick?

User avatar
r3d4
Posts: 967
Joined: Sat Jul 30, 2011 8:21 am
Location: ./

Re: How to reduce the Pi image on the SDcard?

Tue Oct 13, 2015 12:47 pm

tpylkko wrote:I don't have a running NOOBS install right now, but I think you can boot to the tinycore part of noobs, enter a terminal with something like ctrl-alt-F2 and issue
Unless im mistaken or some thing changed you mean
the bussybox part of noobs,
;)

tpylkko
Posts: 381
Joined: Tue Oct 14, 2014 5:21 pm

Re: How to reduce the Pi image on the SDcard?

Tue Oct 13, 2015 2:02 pm

r3d4 wrote:
tpylkko wrote:I don't have a running NOOBS install right now, but I think you can boot to the tinycore part of noobs, enter a terminal with something like ctrl-alt-F2 and issue
Unless im mistaken or some thing changed you mean
the bussybox part of noobs,
;)

yes, you are correct there

G109B
Posts: 21
Joined: Thu Sep 12, 2013 9:57 am

Re: How to reduce the Pi image on the SDcard?

Fri Nov 06, 2015 11:06 pm

[quote="RaTTuS"]1) stuff a usb sd card adapter into the RPI
2) make 2 partitions using fdisk one vfat and one ext2
3) format them both
4) mount both partitions somewhere i.e. /mnt & /mnt/boot
4) sudo cp /boot to /mnt/boot
5) sudo rsync -ax / /mnt
6) sudo sync
7) sudo umount both partitions
8) remove sdcard and use that to boot elsewhere[/quote]

Many thanks for the procedure, but maybe some people (like me) will find it confusing - not helped by the man pages or by forum postings, so here is my interpretation:
"sudo fdisk -l /dev/mmcblk0" producing:
/dev/mmcblk0p1 8192 122879 114688 56M c W95 FAT32 (LBA)
/dev/mmcblk0p2 122880 15523839 15400960 7.4G 83 Linux
"sudo fdisk /dev/sda" using the following internal commands:
d - to delete any existing partitions
n - to create a new partition
p - for primary
1 - for partition 1
First sector hit return (2048 default)
Last sector +64M for boot partition
t - change type
c - for W95 FAT32 (LBA)
then as above n, p, 2, defaults for start and end
type defaults to 83 so no need to change
w - to write info to sd and exit fdisk.
"sudo fdisk -l /dev/sda" producing:
/dev/sda1 2048 133119 131072 64M c W95 FAT32 (LBA)
/dev/sda2 133120 15548415 15415296 7.4G 83 Linux
"sudo mkfs.vfat /dev/sda1"
"sudo mkfs.ext4 /dev/sda2"
"sudo mkdir mnt-boot"
"sudo mount /dev/sda1 /mnt-boot"
"sudo mount /dev/sda2 /mnt"
"sudo cp -r /boot/* /mnt-boot"
"sudo rsync -ax / /mnt"
(rsync took long enough for me to write this, now to test it)
sudo sync
sudo umount /dev/sda1
sudo umount /dev/sda2

Return to “General discussion”