TransWikia.com

How do I discover the remaining space on disk image FAT32 partition?

Unix & Linux Asked by rubicks on December 15, 2021

Given the current Debian installer hd-media boot image files, how do I find out how much free space is remaining within the contained FAT32-formatted partition?

Here’s what I have so far:

$ curl -fsSLO https://deb.debian.org/debian/dists/stable/main/installer-amd64/current/images/hd-media/boot.img.gz

$ gzip -fdk boot.img.gz

$ stat boot.img
  File: boot.img
  Size: 999997440   Blocks: 1953120    IO Block: 4096   regular file
Device: fd01h/64769d    Inode: 7998443     Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1000/    neil)   Gid: ( 1000/    neil)
Access: 2020-07-23 16:42:25.173516535 +0000
Modify: 2020-07-23 16:41:58.025469623 +0000
Change: 2020-07-23 16:42:35.437534306 +0000
 Birth: -

$ file boot.img
boot.img: DOS/MBR boot sector, code offset 0x58+2, OEM-ID "SYSLINUX", sectors/cluster 8, Media descriptor 0xf8, sectors/track 63, heads 255, sectors 1953120 (volumes > 32 MB), FAT (32 bit), sectors/FAT 1904, serial number 0xdeb00001, label: "Debian Inst"

$ fdisk -l boot.img
Disk boot.img: 953.7 MiB, 999997440 bytes, 1953120 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x20ac7dda

Device     Boot      Start        End    Sectors   Size Id Type
boot.img1       3224498923 3657370039  432871117 206.4G  7 HPFS/NTFS/exFAT
boot.img2       3272020941 5225480974 1953460034 931.5G 16 Hidden FAT16
boot.img3                0          0          0     0B 6f unknown
boot.img4         50200576  974536369  924335794 440.8G  0 Empty

Partition table entries are not in disk order.

$ fatresize -i boot.img
fatresize 1.0.2 (10/15/17)
FAT: fat32
Size: 999997440
Min size: 536870912
Max size: 999997440

Is any of the aforementioned numbers the one I want?

One Answer

Use mdir (from mtools):

$ mdir -i boot.img ::
...
g2ldr    mbr      8192 2020-05-04  19:14
WIN32-~1 INI       178 2020-05-04  19:14  win32-loader.ini
       43 files          76 373 022 bytes
                        921 333 760 bytes free

As you can see, none of the numbers you have match the remaining free space.

Answered by Stephen Kitt on December 15, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP