resize2fs: Permission denied to resize filesystem

0

Hi all, I expanded a non-root EBS volume, but I'm encountering an error with extending the file system. Here's the error:

sudo resize2fs /dev/nvme1n1

resize2fs 1.42.9 (4-Feb-2014)

Filesystem at /dev/nvme1n1 is mounted on /data; on-line resizing required

old_desc_blocks = 4, new_desc_blocks = 7

resize2fs: Permission denied to resize filesystem

When I unmount the volume and try again, I get

Please run 'e2fsck -f /dev/nvme1n1' first.

This will no doubt take a long time, and I depend on the volume for operational processes.

The volume (newly resized to 100G) has no partitions:

lsblk

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT

nvme0n1 259:0 0 8G 0 disk

└─nvme0n1p1 259:1 0 8G 0 part /

nvme1n1 259:2 0 100G 0 disk /data

The volume is only recognized as its old 50G size. I did detach/reattach and also rebooted the instance.

df -hT

Filesystem Type Size Used Avail Use% Mounted on

udev devtmpfs 1.9G 4.0K 1.9G 1% /dev

tmpfs tmpfs 372M 328K 372M 1% /run

/dev/nvme0n1p1 ext4 7.8G 5.5G 1.9G 75% /

none tmpfs 4.0K 0 4.0K 0% /sys/fs/cgroup

none tmpfs 5.0M 0 5.0M 0% /run/lock

none tmpfs 1.9G 0 1.9G 0% /run/shm

none tmpfs 100M 0 100M 0% /run/user

/dev/nvme1n1 ext4 50G 45G 2.1G 96% /data

Anyone have suggestions?

Many thanks, Richard

asked a month ago147 views
2 Answers
1
Accepted Answer

The error resize2fs: Permission denied to resize filesystem is key here.

Red Hat's Knoweldgebase (needs a login) addresses this in https://access.redhat.com/solutions/2420621

Can you run sudo dumpe2fs /dev/nvme1n1 | head -20 and what does it say on the Filesystem state: line? If it's anything other than clean then this is your problem.

FWIW I spun up a new EC2 instance to match your setup, and it works fine for me (growing an ext4 FS from 5GB -> 10GB), so your method is sound.

[root@ip-172-31-15-154 ~]# lsblk
NAME          MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
nvme1n1       259:0    0   5G  0 disk /data
nvme0n1       259:1    0   8G  0 disk 
├─nvme0n1p1   259:2    0   8G  0 part /
├─nvme0n1p127 259:3    0   1M  0 part 
└─nvme0n1p128 259:4    0  10M  0 part /boot/efi
[root@ip-172-31-15-154 ~]# df -hT
Filesystem       Type      Size  Used Avail Use% Mounted on
devtmpfs         devtmpfs  4.0M     0  4.0M   0% /dev
tmpfs            tmpfs     453M     0  453M   0% /dev/shm
tmpfs            tmpfs     182M  444K  181M   1% /run
/dev/nvme0n1p1   xfs       8.0G  1.5G  6.5G  19% /
tmpfs            tmpfs     453M     0  453M   0% /tmp
/dev/nvme0n1p128 vfat       10M  1.3M  8.7M  13% /boot/efi
tmpfs            tmpfs      91M     0   91M   0% /run/user/1000
/dev/nvme1n1     ext4      4.9G   24K  4.6G   1% /data

[ change the EBS volume size in AWS Console here ]

[root@ip-172-31-15-154 ~]# lsblk
NAME          MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
nvme1n1       259:0    0  10G  0 disk /data
nvme0n1       259:1    0   8G  0 disk 
├─nvme0n1p1   259:2    0   8G  0 part /
├─nvme0n1p127 259:3    0   1M  0 part 
└─nvme0n1p128 259:4    0  10M  0 part /boot/efi
[root@ip-172-31-15-154 ~]# resize2fs /dev/nvme1n1
resize2fs 1.46.5 (30-Dec-2021)
Filesystem at /dev/nvme1n1 is mounted on /data; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 2
The filesystem on /dev/nvme1n1 is now 2621440 (4k) blocks long.

[root@ip-172-31-15-154 ~]# df -hT
Filesystem       Type      Size  Used Avail Use% Mounted on
devtmpfs         devtmpfs  4.0M     0  4.0M   0% /dev
tmpfs            tmpfs     453M     0  453M   0% /dev/shm
tmpfs            tmpfs     182M  448K  181M   1% /run
/dev/nvme0n1p1   xfs       8.0G  1.5G  6.5G  19% /
tmpfs            tmpfs     453M     0  453M   0% /tmp
/dev/nvme0n1p128 vfat       10M  1.3M  8.7M  13% /boot/efi
tmpfs            tmpfs      91M     0   91M   0% /run/user/1000
/dev/nvme1n1     ext4      9.8G   24K  9.3G   1% /data
[root@ip-172-31-15-154 ~]# dumpe2fs /dev/nvme1n1 | head -20
dumpe2fs 1.46.5 (30-Dec-2021)
Filesystem volume name:   <none>
Last mounted on:          <not available>
Filesystem UUID:          ef2b157b-0c80-440f-a5e6-604669c2fd50
Filesystem magic number:  0xEF53
Filesystem revision #:    1 (dynamic)
Filesystem features:      has_journal ext_attr resize_inode dir_index filetype needs_recovery extent 64bit flex_bg sparse_super large_file huge_file dir_nlink extra_isize metadata_csum
Filesystem flags:         signed_directory_hash 
Default mount options:    user_xattr acl
Filesystem state:         clean   ********** THIS LINE HERE **********
Errors behavior:          Continue
Filesystem OS type:       Linux
Inode count:              655360
Block count:              2621440
Reserved block count:     120585
Overhead clusters:        63273
Free blocks:              2558161
Free inodes:              655349
First block:              0
Block size:               4096
Fragment size:            4096
[root@ip-172-31-15-154 ~]# 
profile picture
EXPERT
Steve_M
answered a month ago
  • Many thanks indeed for looking into this so generously! Indeed I have

    Filesystem state: clean with errors

    So clearly that would need to be fixed before proceeding.

    As a workaround I simply created a new volume with the planned larger size and sync'd everything over, allowing me to delete the old volume.

    Again, I really appreciate your willingness to help here.

0

I believe you will have to change the size of the partition on the disk first with fdisk to see the new size. After that you can grow the file system with resize2fs.

Run fdisk -l /dev/nvme1n1 to see the current disk partitioning.

This guide walks through the process of resizing the partition.
https://geekpeek.net/resize-filesystem-fdisk-resize2fs/

WARNING!!! This can be a dangerous process. I would recommend creating a snapshot of your volume beforehand so that you can recreate your instance if something goes wrong.

Hope this helps!

profile pictureAWS
EXPERT
iBehr
answered a month ago
profile picture
EXPERT
reviewed a month ago
  • Thanks for the input! The volume does not have a partition and the AWS docs suggest that shouldn't be a problem.

    https://docs.aws.amazon.com/ebs/latest/userguide/recognize-expanded-volume-linux.html

    sudo fdisk -l /dev/nvme1n1

    Disk /dev/nvme1n1: 107.4 GB, 107374182400 bytes

    255 heads, 63 sectors/track, 13054 cylinders, total 209715200 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

    Disk identifier: 0x00000000

    Disk /dev/nvme1n1 doesn't contain a valid partition table

    I tried growpart just in case, and of course it says "unable to determine partition type"...

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions