Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm trying to avoid imaging the entire disk but only as much as is occupied by actual data. Using the "count=..." parameter of dd to limit how much is copied. But to do that I have to know that the data is all located at the beginning of the disk ... that's why I'm shrinking the partition.
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680
Rep:
This is confusing. Why would you buy a 64GB SD card to only use the first 8GB, or whatever, of it?
I do understand that it takes a long time to image a card so how about just copying files? Why are you trying to only dd the first few blocks of a card you're not using when a smaller card could likely be had for very little at all? Are you completely sure that dding will work as a backup with only partial data on any card?
Are you completely sure that dding will work as a backup with only partial data on any card?
I'm not sure. That's what I'm trying to determine. I can tell you that I have done this with a 16GB card that contained (so far) less than 3GB of data. I used gparted to resize down to ~3.5GB. I then used dd to copy just the first ~3.5GB (the exact number of sectors that were occupied by the now-reduced partitions) to another SD card. The second card does successfully boot the Pi and so far seems to be fully-functional. I haven't yet found anything on it to be missing or broken.
As far as why ... well in part this is a theoretical question, so I'd just like to know if the method is sound and reliable. But from a more practical point of view, let's say that much more of the card will be used, it just hasn't been used yet. Or let's say maybe I'll create a third partition to store data of a more transient nature -- video files for example -- and I want to create an image of the entire installation (boot partition and root filesystem) excluding the third partition.
Of course there are other ways to accomplish that; there are other ways to do almost anything. I just want to be sure that this particular method is valid.
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680
Rep:
Well, it took long enough but the zipping the the 32GB SD card image has finished and it comes in at around 7.2GB which is smaller than the 8.7GB of files on the card. So, yes, it takes forever to dd and then zip but it does save space.
By way of comparison, after resizing Partition 2 on my 16GB card down to about 3.5GB (which took maybe a minute), dd took 17 minutes to create the 3.7GB .img file, and xz took about 23 minutes to compress it down to a 1GB .img.xz file.
@TXLonghorn:
Thanks, but I don't think any of those tools apply here. We're discussing how to create a raw disk image that can be flashed to an SD card and provide in a single step a ready-to-go system with multiple partitions and complete filesystem. I don't think fsarchiver, rsync or tar can span multiple partitions, can they?
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680
Rep:
A thought occurs -- surely you could. Set if=/dev/sda1 (or whatever) and just dd the partition? I have to admit I'm not sure how that would or, indeed, could be restored but it may work.
A thought occurs -- surely you could. Set if=/dev/sda1 (or whatever) and just dd the partition? I have to admit I'm not sure how that would or, indeed, could be restored but it may work.
Sure that would work, and it would be easy to restore to the same sd card, but to put it on another card (e.g. to prepare multiple RPi's with the same setup) would require backing up both partitions separately, then formatting the next card with the exact same format as the original, and then separately copying those partition backups to the new card. The method I described (post #8) does the whole thing at once (plus a minute to reduce the partition size with gparted, and another minute to expand it again after the copying is done).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.