Skip to main content
added 365 characters in body; added 71 characters in body
Source Link
Anul
  • 185
  • 2
  • 9

I have a btrfs filesystem of about 7G in a 10G image file img.btrfs (I shrank it using btrfs fi resize -3G /mnt). How can I find the total size (end byte offset) of the filesystem, so that I can shrink the image size? I.e. find out $SIZE for

truncate -s $SIZE img.btrfs

A mechanism that applies to any other filesystem inside an image file would be a plus.

NOTE: one thing that does work is:

INITIAL=$(stat -c %s img.btrfs)
mount img.btrfs /mnt
btrfs fi resize -$NBYTES /mnt
umount /mnt
truncate -s $((INITIAL - NBYTES + 1024*1024)) img.btrfs
mount /img.btrfs /mnt
btrfs fi resize max /mnt

i.e. shrink the btrfs, shrink the image by a little bit less (leaving a 1M overhead), then grow the btrfs to the maximum afforded by the shrunk image.

I have a btrfs filesystem of about 7G in a 10G image file img.btrfs (I shrank it using btrfs fi resize -3G /mnt). How can I find the total size (end byte offset) of the filesystem, so that I can shrink the image size? I.e. find out $SIZE for

truncate -s $SIZE img.btrfs

A mechanism that applies to any other filesystem inside an image file would be a plus.

I have a btrfs filesystem of about 7G in a 10G image file img.btrfs (I shrank it using btrfs fi resize -3G /mnt). How can I find the total size (end byte offset) of the filesystem, so that I can shrink the image size? I.e. find out $SIZE for

truncate -s $SIZE img.btrfs

A mechanism that applies to any other filesystem inside an image file would be a plus.

NOTE: one thing that does work is:

INITIAL=$(stat -c %s img.btrfs)
mount img.btrfs /mnt
btrfs fi resize -$NBYTES /mnt
umount /mnt
truncate -s $((INITIAL - NBYTES + 1024*1024)) img.btrfs
mount /img.btrfs /mnt
btrfs fi resize max /mnt

i.e. shrink the btrfs, shrink the image by a little bit less (leaving a 1M overhead), then grow the btrfs to the maximum afforded by the shrunk image.

added 92 characters in body; edited title
Source Link
Gilles 'SO- stop being evil'
  • 866.2k
  • 205
  • 1.8k
  • 2.3k

btrfs filesystem end offset (image size) (btrfs)?

I have a btrfs filesystem of about 7G in a 10G image file img.btrfs (I shrank it using btrfs fi resize -3G /mnt). How can I find the total size (end byte offset) of the filesystem, so that I can shrink the image size? I.e. find out $SIZE for

truncate -s $SIZE img.btrfs

truncate -s $SIZE img.btrfs

A mechanism that applies to any other filesystem inside an image file would be a plus.

filesystem end offset (image size) (btrfs)?

I have a btrfs filesystem of about 7G in a 10G image file img.btrfs (I shrank it using btrfs fi resize -3G /mnt). How can I find the total size (end byte offset) of the filesystem, so that I can shrink the image size? I.e. find out $SIZE for

truncate -s $SIZE img.btrfs

btrfs filesystem end offset (image size)

I have a btrfs filesystem of about 7G in a 10G image file img.btrfs (I shrank it using btrfs fi resize -3G /mnt). How can I find the total size (end byte offset) of the filesystem, so that I can shrink the image size? I.e. find out $SIZE for

truncate -s $SIZE img.btrfs

A mechanism that applies to any other filesystem inside an image file would be a plus.

Tweeted twitter.com/#!/StackUnix/status/612826329646505984
added 47 characters in body
Source Link
Anul
  • 185
  • 2
  • 9

I have a btrfs filesystem of about 7G in a 10G image file img.btrfs (I shrank it using btrfs fi resize -3G /mnt). How can I find the total size (end byte offset) of the filesystem, so that I can shrink the image size? I.e. find out $SIZE for

truncate -s $SIZE img.btrfs

I have a btrfs filesystem of about 7G in a 10G image file img.btrfs. How can I find the total size (end byte offset) of the filesystem, so that I can shrink the image size? I.e. find out $SIZE for

truncate -s $SIZE img.btrfs

I have a btrfs filesystem of about 7G in a 10G image file img.btrfs (I shrank it using btrfs fi resize -3G /mnt). How can I find the total size (end byte offset) of the filesystem, so that I can shrink the image size? I.e. find out $SIZE for

truncate -s $SIZE img.btrfs

edited title
Link
Anul
  • 185
  • 2
  • 9
Loading
Source Link
Anul
  • 185
  • 2
  • 9
Loading