2

I'm currently trying to modify the partition table for an embedded platform. One of the files flashed towards the platform is an .ext4 file. I can mount the file, but I can't increase it's size.

GParted can't open .ext4 files or access them when mounted. I can change the data inside the file. How do I modify it's size?

Mounting and filling up with additional data does not work, since the file is somehow size limited. I suspect I can modify that size in the header.

1

You can use kpartx to be able to use embeded partition in files. For example:

sudo kpartx -a ubuntu-15.04.iso

Will give you additional devices under /dev/mapper like /dev/mapper/loop0p1, ... that you can mount.

This might not be needed in your case as to grow your partition, I suggest (do backup):

dd if=/dev/zero bs=1M count=500 >> yourfile.ext4

to append some zero at the end of your unmounted file. And then proceed to grow the ext4 fs with

resize2fs yourfile.ext4
11
  • +1 for pointing me to kpartx, but this basically mounts the filesystem. It does allow me to access the boot partition, but all except one file on that are unreadable. It does not point me to a filesize header AFAIK. – Mast May 13 '15 at 10:59
  • More information on your exact setup would help. – solsTiCe May 13 '15 at 12:03
  • I usually flash the .ext4 together with .hddimg with the same name and 20 other files (plus a u-boot-envs directory) to an embedded platform. dd and resizing didn't do the trick. What else do you require? – Mast May 13 '15 at 12:07
  • may be try fdisk to modify the partition table. or gdisk if it's GPT – solsTiCe May 13 '15 at 13:32
  • @Mast, If the image is already partitioned and you access the partitions with kpartx, then you need to run resize2fs on the partition device, not the file. Before you use kpartx though, you need to use parted on the file to resize the partition. – psusi May 13 '15 at 13:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.