Linux – Do ntfsresize and gparted work on a disk image mounted through the loop device

gpartedhard drivelinuxntfsresizepartitioning

I need to resize an NTFS partition on a disk for which I have an image (dumped with dd).

I mounted it through the loop device on Linux:

# losetup -o 32256 /dev/loop0 disk.img # I got the offset from looking at fdisk's output
# mount /tmp/t /dev/loop0
# ls /tmp/t
[Content of NTFS partition shows correctly]
# umount /tmp/t
# gparted /dev/loop0

gparted shows me the disk correctly; it just contains one large NTFS partition I want to shrink.

I have it had it running for one hour now.

Will this work? There is lots of disk access, but the timestamp and size of the underlying file disk.img remain unchanged.

Best Answer

Yes, loop devices are indistinguishable from 'normal' block devices for higher layer applications (like gparted). Loop device access doesn't change the timestamp of a mounted file: it is a bug.

Also, while the kernel won't create partition subdevices, you can make them with kpartx if you need to (just in case).

Related Question