I am trying to mount a disk image (consisting of MBR, fat, ext4 partitions) so I can modify the layout using `gparted`. (I am trying to move the partition to a 4M boundary.)

I have tried `sudo mount img mountpoint -o loop` without success.

How can I achieve this?
['https://unix.stackexchange.com/questions/240450', 'https://unix.stackexchange.com', 'https://unix.stackexchange.com/users/47111/']
Normally partitioning tools require that partitions are not mounted. You should use `parted` or `gparted` directly on the image file using:

```
parted /path/to/disk.img

```

Sample output:

```
$ parted VirtualBox\ VMs/centos/VMDK-test-flat.vmdk 
WARNING: You are not superuser.  Watch out for permissions.
GNU Parted 2.3 
Using /home/testuser/VirtualBox VMs/centos/VMDK-test-flat.vmdk
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p                                                                    
Model:  (file)
Disk /home/testuser/VirtualBox VMs/centos/VMDK-test-flat.vmdk: 2147MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size   Type     File system  Flags
 1      32,3kB  535MB   535MB  primary  ext4
 2      535MB   1069MB  535MB  primary  ext4

(parted)

```
I don't know if you may resize or move your partition on an image, but there is a tool for mounting partitions within an image file, **kpartx**. I never used it, but you can take a look here: <http://robert.penz.name/73/kpartx-a-tool-for-mounting-partitions-within-an-image-file/>