[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?



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...


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
>
>


-- 
-------------
No, I won't  call it "climate change", do you have a "reality problem"? - AB1JX
Cities are cages built to contain excess people and keep them from
cluttering up nature.
Impeach  Impeach  Impeach  Impeach  Impeach  Impeach  Impeach  Impeach


Reply to: