[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Resize a disk image from 32G to 4G or copy u-boot?



On Tuesday 24 March 2020 16:44:42 Alan Corey wrote:

> Downsizing requires that no files are in the part you trim off.
> Upsizing can sometimes be done by deleting the partition and
> recreating letting fdisk use the maximum size.  Don't format between
> or anything and in case you have to type the numbers in you should
> have a copy of them handy like
> Device     Boot     Start        End    Sectors  Size Id Type
> /dev/sda1              63    2056319    2056257 1004M  6 FAT16
> /dev/sda2         2056320   43022069   40965750 19.5G 83 Linux
> /dev/sda3        43022070  657427994  614405925  293G 83 Linux
> /dev/sda4       657427995 1953520064 1296092070  618G  5 Extended
> /dev/sda5       657428058 1953520064 1296092007  618G 83 Linux
> I used to hide a partition on a Windows machine by deleting it then
> recreating it when I wanted it, the data in it was fine.  This scheme
> may not work on GPT especially because it puts the partition table at
> the end of the disk.
>
> I would try using dd to copy the whole device like /dev/sda instead of
> /dev/sda1 which should get the uboot.,  Then you just need to upsize
> the second partition.  Or use dd to copy the uboot partition then
> create and format the 2nd one manually and copy the files over with
> cp.  Unless uboot needs to know the offset of something in the 2nd
> partition.
>
> Such tiny SD cards...

And nothing so far, and I have been watching, in the way of reducing a 
filesystem to only the actual size occupied. Then it can be backed up 
with dd and recovered, rewritten by dd, at a reasonable size for 
storage.  And re-expanded to fit the media it finds. All of my attempts 
to do that with dd alone have been thwarted by the fact that I have yet 
to find two u-sd's marked as such and such a capacity, that actually 
were the same size.

Our tools simply have not kept up with the technology. So I wind up doing 
my backups with amanda and that hasn't kicked my applecart and spilled 
it yet. But amanda works a bit different and most read the docs and run 
screaming to the hills because theres no easy way to make a full backup 
on Friday nights. Amanda doesn't need to, its got your data covered 
anyway.

> On 3/24/20, Nate Bargmann <n0nb@n0nb.us> wrote:
> > Hi All.
> >
> > I have an Olimex LIME2 based Freedombox (Debian Buster) and as I am
> > using an external hard drive with it, less than 2 GB of the 32 GB
> > micro-SD card capacity is being used.  I have a spare 4 GB card that
> > I would like to use instead, but haven't figured out how to downsize
> > the root partition in the disk image file after using dd to make an
> > image from the 32 GB card.
> >
> > I tried the steps at:
> >
> > https://softwarebakery.com/shrinking-images-on-linux
> >
> > and gparted fails at the resize step with an error of:
> >
> >    btrfs filesystem resize 1:2234368K ʼ/tmp/gparted-3ExAC9ʼ 
> > 00:00:05    ( ERROR )
> >
> >    Resize ʼ/tmp/gparted-3ExAC9ʼ of ʼ1:2234368Kʼ
> >    ERROR: unable to resize ʼ/tmp/gparted-3ExAC9ʼ: No space left on
> > device
> >
> > Even if I manually try to use the btrfs command to attempt the
> > resize I get the same error which seems weird as I am *shrinking*
> > the file system..
> >
> > As an alternative, I created the proper partitions on the 4 GB card
> > and used rsync to copy the relevant data over.  That is all well and
> > good except that now I don't have u-boot in the first 1 MB of the 4
> > GB card (the boot partition starts at sector 2048 in both the disk
> > image and the 4 GB card).  I'm unsure of the exact offsets or I
> > would simply use dd to copy that data from the 32 GB image to the 4
> > GB card and be on my way.
> >
> > Ideas?
> >
> > TIA
> >
> > - Nate
> >
> > --
> >
> > "The optimist proclaims that we live in the best of all
> > possible worlds.  The pessimist fears this is true."
> >
> > Web: https://www.n0nb.us
> > Projects: https://github.com/N0NB
> > GPG fingerprint: 82D6 4F6B 0E67 CD41 F689 BBA6 FB2C 5130 D55A 8819


Cheers, Gene Heskett
-- 
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
If we desire respect for the law, we must first make the law respectable.
 - Louis D. Brandeis
Genes Web page <http://geneslinuxbox.net:6309/gene>


Reply to: