I'm puzzling over a very simple task. I have an img file which contains a filesystem with 2 partitions. As found in some tutorials I expanded the available space in this way:
dd if=/dev/zero of=./temp_image bs=1 count=1 seek=3G
cat temp_image >> orig_image.img
losetup --offset [offset of the second partition*512] /dev/loop0 orig_image.img
e2fsck -f /dev/loop0
resize2fs -f /dev/loop0
losetup -d /dev/loop0
But I'm afraid the partition table is not resized correctly:
parted orig_image.img > print
Model: (file)
Disk /home/user/orig_image.img: 7255MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 4194kB 67,1MB 62,9MB primary fat16 lba
2 67,1MB 4000MB 3933MB primary ext4
But if I chroot into the system it actually finds new space... Was I miss some steps?
I tried to resize the partition using gparted but it fails complaining about errors during e2fsck.
parted
, for it uses SI unit instead of binary unit by default, which can cause confusion. usefdisk -l
instead.resize2fs
.truncate -s 3G image_for_append
is still better anyway though