+ dd if=/dev/zero of=foo bs=1M count=1 seek=2000 1+0 records in 1+0 records out 1048576 bytes (1.0 MB, 1.0 MiB) copied, 0.00151753 s, 691 MB/s + sudo kpartx -s -v -a foo + sudo parted foo -s -- mklabel msdos + sudo parted foo -s -- mkpart primary ext4 2M 2G + sudo kpartx -s -v -a /dev/loop0 add map loop0p1 (252:0): 0 4093952 linear 7:0 4096 + sudo mkfs -t ext4 /dev/mapper/loop0p1 mke2fs 1.43.1 (08-Jun-2016) Discarding device blocks: 4096/511744 done Creating filesystem with 511744 4k blocks and 128000 inodes Filesystem UUID: d370161d-e07a-4bc2-85e4-7ef80a29b547 Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912 Allocating group tables: 0/16 done Writing inode tables: 0/16 done Creating journal (8192 blocks): done Writing superblocks and filesystem accounting information: 0/16 done + sudo sfdisk -l foo Disk foo: 2 GiB, 2098200576 bytes, 4098048 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: 0x05fa1637 Device Boot Start End Sectors Size Id Type foo1 4096 4098047 4093952 2G 83 Linux + sudo kpartx -s -v -d foo del devmap : loop0p1 loop deleted : /dev/loop0 + qemu-img resize -f raw foo 8G Image resized. + sudo kpartx -s -v -a foo add map loop0p1 (252:0): 0 4093952 linear 7:0 4096 + sudo kpartx -s -v -d /dev/loop0 del devmap : loop0p1 + sudo growpart /dev/loop0 1 attempt to resize /dev/loop0 failed. sfdisk output below: | Backup files: | MBR (offset 0, size 512): /tmp/growpart.4UjUFH/orig.save-loop0-0x00000000.bak | | Disk /dev/loop0: 8 GiB, 8589934592 bytes, 16777216 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: 0x05fa1637 | | Old situation: | | Device Boot Start End Sectors Size Id Type | /dev/loop0p1 4096 4098047 4093952 2G 83 Linux | | >>> Script header accepted. | >>> Script header accepted. | >>> Script header accepted. | >>> Script header accepted. | >>> Created a new DOS disklabel with disk identifier 0x05fa1637. | Created a new partition 1 of type 'Linux' and of size 8 GiB. | /dev/loop0p2: | New situation: | | Device Boot Start End Sectors Size Id Type | /dev/loop0p1 4096 16777182 16773087 8G 83 Linux | | The partition table has been altered. | Calling ioctl() to re-read partition table. | Re-reading the partition table failed.: Invalid argument | The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8). FAILED: failed to resize ***** WARNING: Resize failed, attempting to revert ****** 512+0 records in 512+0 records out 512 bytes copied, 0.0120644 s, 42.4 kB/s ***** Appears to have gone OK **** + echo 2 2 + sudo kpartx -s -v -a /dev/loop0 add map loop0p1 (252:0): 0 4093952 linear 7:0 4096 + sudo e2fsck -f -y -E discard /dev/mapper/loop0p1 e2fsck 1.43.1 (08-Jun-2016) Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure Pass 3: Checking directory connectivity Pass 4: Checking reference counts Pass 5: Checking group summary information /dev/mapper/loop0p1: 11/128000 files (0.0% non-contiguous), 17736/511744 blocks + sudo resize2fs /dev/mapper/loop0p1 resize2fs 1.43.1 (08-Jun-2016) The filesystem is already 511744 (4k) blocks long. Nothing to do! + sudo zerofree /dev/mapper/loop0p1 + sudo kpartx -s -v -d foo device-mapper: remove ioctl on loop0p1 failed: Device or resource busy loop deleted : /dev/loop0 + rm foo