3

Good afternoon! I am attempting to shrink an ext4 partition and I have found many tutorials online to achieve this, however, when implementing the actual changes, resize2fs is telling me wrong information! Here is the scenario:

# parted -s /dev/sdb unit GB print
Model: Hitachi HTS725050A7E630 (scsi)
Disk /dev/sdb: 500GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start   End     Size    Type     File system  Flags
 1      0.00GB  0.64GB  0.64GB  primary  ext2         boot
 2      0.64GB  500GB   499GB   primary  ext4

Now I am trying to first reduce the filesystem by 30GB:

# resize2fs /dev/sdb2 469G
resize2fs 1.42.13 (17-May-2015)
The containing partition (or device) is only 121940394 (4k) blocks.
You requested a new size of 122945536 blocks.

The partition is not mounted and as you can see from the output, I am actually taking 30GB off the total size (499 - 30 = 469). How is this possible when I am applying a unit (GB in this case)? Am I missing something?

2 Answers 2

2

469G is 469*1024*1024k, which is 491782144k. 122945536 blocks of 4k is also 491782144k.

Parted uses G in terms of 1000, not 1024. Try unit Gi with parted.

5
  • So I tried "resize2fs /dev/sdb2 469Gi" and it gives: "resize2fs: Invalid new size: 469Gi" Commented Aug 11, 2018 at 18:17
  • As a side note, if I convert everything to KB then it appears to work. GB and MB do not... Commented Aug 11, 2018 at 18:20
  • I meant to suggest Gi for parted, not for resize2fs, clarified that. The G to resize2fs already means Gi.
    – RalfFriedl
    Commented Aug 11, 2018 at 18:35
  • That worked! Thanks for the clarification RalfFriedl! Commented Aug 11, 2018 at 18:49
  • I also got "invalid new size: 1.8T". I changed this to 1800G and it worked.
    – Nate
    Commented Feb 19 at 21:37
1

In my case it worked when I changed GB to G

root@ubuntu:/home/ubuntu# resize2fs /dev/ubuntu-vg/root 100GB
resize2fs 1.42.13 (17-May-2015)
resize2fs: Invalid new size: 100GB

root@ubuntu:/home/ubuntu# resize2fs /dev/ubuntu-vg/root 100G
resize2fs 1.42.13 (17-May-2015)
Resizing the filesystem on /dev/ubuntu-vg/root to 26214400 (4k) blocks.
1
  • 1
    OP use G nor GB
    – Archemar
    Commented May 14, 2021 at 8:57

You must log in to answer this question.

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