LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   resize2fs gives error for decimal value (https://www.linuxquestions.org/questions/linux-newbie-8/resize2fs-gives-error-for-decimal-value-4175634307/)

sysmicuser 07-17-2018 10:29 PM

resize2fs gives error for decimal value
 
Hi Guys,

Need your guidance to understand why I am getting an error for resize2fs command.

Code:

[root@localhost ~]# resize2fs $(cat /etc/fstab |grep "/home"|awk '{print $1}') 2.4G
resize2fs 1.41.12 (17-May-2010)
resize2fs: Invalid new size: 2.4G

The original size of /home was 2.9GB. I want to resize it to be 2.4GB so I can use 500MB for swap space.

When I did with just 2GB it worked fine! why not for 2.4GB then?

Code:

[root@localhost ~]# resize2fs $(cat /etc/fstab |grep "/home"|awk '{print $1}') 2G
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/mapper/vg_localhost-lv_home to 524288 (4k) blocks.
The filesystem on /dev/mapper/vg_localhost-lv_home is now 524288 blocks long.

Please find the evidence below which indicates the size of /home was 2.9GB

Code:

df -h /home
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_localhost-lv_home
                      2.9G  7.8M  2.7G  1% /home

Your assistance is much appreciated.

Thank you very much.

scasey 07-17-2018 11:53 PM

Although it doesn't explicitly say so in the man page, I suspect the size parameter needs to be an integer.

Two thoughts: set one of the -d debug-flags to see what's happening
or
use megabytes instead of gigabites: 2400M (I think that's the same as 2.4G)

see
Code:

man resize2fs

syg00 07-17-2018 11:58 PM

Maybe the devs had better things to concentrate on.
Surely you can figure out how to supply an integral parameter.

scasey 07-18-2018 12:04 AM

Quote:

Originally Posted by syg00 (Post 5880529)
Maybe the devs had better things to concentrate on.

I hear that! Executing code to resize partitions is scary enough...I can't imagine writing it ;)

AwesomeMachine 07-18-2018 12:56 AM

The size must be in cylinders. The program takes the numerical value and converts it to the nearest whole number of cylinders. One cylinder is 512 B/Sector x 64 sectors/track x 255 heads = 8,355,840 Bytes. 4k/sector drives use a different geometry, and GPT uses still a different geometry. The bottom line is, when you specify a certain size for a filesystem, it never is exactly that size.

scasey 07-18-2018 01:09 AM

Quote:

Originally Posted by AwesomeMachine (Post 5880538)
The size must be in cylinders. The program takes the numerical value and converts it to the nearest whole number of cylinders. One cylinder is 512 B/Sector x 64 sectors/track x 255 heads = 8,355,840 Bytes. 4k/sector drives use a different geometry, and GPT uses still a different geometry. The bottom line is, when you specify a certain size for a filesystem, it never is exactly that size.

Without disagreeing with what you say about calculating cylinders, I don't agree that the size used in the command must be in cylinders...man page says:
Code:

      The  size  parameter  specifies the requested new size of the filesystem.  If no units are specified, the units of the size parameter shall be the
      filesystem blocksize of the filesystem.  Optionally, the size parameter may be suffixed by one of the following the units designators:  's',  'K',
      'M', or 'G', for 512 byte sectors, kilobytes, megabytes, or gigabytes, respectively.  The size of the filesystem may never be larger than the size
      of the partition.  If size parameter is not specified, it will default to the size of the partition.



All times are GMT -5. The time now is 04:27 AM.