Skip to content

Instantly share code, notes, and snippets.

@jtornero
Created June 5, 2023 07:45
Show Gist options
  • Save jtornero/8ea9990962b5d2ca8c4f277dd3b98d23 to your computer and use it in GitHub Desktop.
Save jtornero/8ea9990962b5d2ca8c4f277dd3b98d23 to your computer and use it in GitHub Desktop.
Process of reducing an img file size
root@antares:/# truncate --size=$[(430079+1+33)*512] SD.img <--- Notice the adding of 1+33 sectors to the end of the partition
root@antares:/# gdisk SD.img
GPT fdisk (gdisk) version 1.0.8
Warning! Disk size is smaller than the main header indicates! Loading
secondary header from the last sector of the disk! You should use 'v' to
verify disk integrity, and perhaps options on the experts' menu to repair
the disk.
Caution: invalid backup GPT header, but valid main header; regenerating
backup header from main header.
Warning! Error 25 reading partition table for CRC check!
Warning! One or more CRCs don't match. You should repair the disk!
Main header: OK
Backup header: ERROR
Main partition table: OK
Backup partition table: ERROR
Partition table scan:
MBR: protective
BSD: not present
APM: not present
GPT: damaged
****************************************************************************
Caution: Found protective or hybrid MBR and corrupt GPT. Using GPT, but disk
verification and recovery are STRONGLY recommended.
****************************************************************************
Command (? for help): v <--- Verify the image
Caution: The CRC for the backup partition table is invalid. This table may
be corrupt. This program will automatically create a new backup partition
table when you save your partitions.
Problem: The secondary header's self-pointer indicates that it doesn't reside
at the end of the disk. If you've added a disk to a RAID array, use the 'e'
option on the experts' menu to adjust the secondary header's and partition
table's locations.
Problem: Disk is too small to hold all the data!
(Disk size is 430113 sectors, needs to be 11001258 sectors.)
The 'e' option on the experts' menu may fix this problem.
Problem: GPT claims the disk is larger than it is! (Claimed last usable
sector is 11001224, but backup header is at
11001257 and disk size is 430113 sectors.
The 'e' option on the experts' menu will probably fix this problem
Partition(s) in the protective MBR are too big for the disk! Creating a
fresh protective or hybrid MBR is recommended.
Identified 5 problems!
Command (? for help): x <--- Expert mode
Expert command (? for help): e <--- Relocation of GPT partition table
Relocating backup data structures to the end of the disk
Expert command (? for help): w <--- Writing changes
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!
Do you want to proceed? (Y/N): y
OK; writing new GUID partition table (GPT) to SD.img.
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot or after you
run partprobe(8) or kpartx(8)
The operation has completed successfully.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment