12
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/loop0       2765720 2393576    231652  92% /
udev              496568      12    496556   1% /dev
tmpfs             202148     796    201352   1% /run
none                5120       0      5120   0% /run/lock
none              505368      80    505288   1% /run/shm
/dev/sda7       13632464 8209984   5422480  61% /host
/dev/loop1       4031680 2452148   1374732  65% /usr

ThIs is the output of df command. How do I increase the avalable in dev/loop0 or may be resize it.

3 Answers 3

13

You can use sudo losetup /dev/loop0 to see what file the loopback device is attached to, then you can increase its size with, for example, sudo dd if=/dev/zero bs=1MiB of=/path/to/file conv=notrunc oflag=append count=xxx where xxx is the number of MiB you want to add. After that, sudo losetup -c /dev/loop0 and sudo resize2fs /dev/loop0 should make the new space available for use.

2
  • This made my ubuntu 14.04 system very unstable.
    – PaulD
    Commented Feb 13, 2017 at 16:55
  • if the file system is xfs try xfs_growfs instead of resize2fs. To identify if the file system of the loop device use blkid Commented Sep 4, 2018 at 20:58
3

To to see what file the loopback device is attached to, execute:

# losetup /dev/loop0

then to increase its size you can give, for example

# dd if=/dev/zero bs=1MiB of=/path/to/file conv=notrunc oflag=append count=xxx

where xxx is the number of MiB you want to add.

If the file system is not currently mounted on /, to make the new space available for use you can give:

# losetup -c /dev/loop0
# resize2fs /dev/loop0

If the image you are trying to resize is Ubuntu Touch/Ubports rootfs (which is found in /data/system.img) and you are trying to do this from the device, now reboot to recovery and then after entering in the device with adb shell, give:

# losetup /dev/block/loop0 /data/system.img
# e2fsck -f /dev/block/loop0
# resize2fs -f /dev/block/loop0     # if your fs is ext
# xfs_growfs /dev/block/loop0       # if your fs is xfs
1
  • This solution works perfect, thanks, i only use a different string for dd dd if=/dev/null of=/userdata/system.img bs=1M seek=3000 count=0, this enlarge my partition to 3G(original was 2G, sic!)
    – elbarna
    Commented Feb 5, 2022 at 10:09
1

worked for me, 4Gb

sudo dd if=/dev/zero bs=1MiB of=/userdata/system.img conv=notrunc oflag=append count=4200
sudo e2fsck -yf /userdata/system.img
sudo resize2fs -f /userdata/system.img 1024000
1
  • This worked for me. It doesn't use the loop device, but it solves the problem (resizing the image). Commented Jan 24, 2021 at 19:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .