尝试在AWS上扩展我的分区,但权限被拒绝。

huangapple go评论67阅读模式
英文:

Trying to extend my partition with AWS, but permission denied

问题

最近,我的AWS EC2上的Linux服务器出了问题。由于某些原因,我的Web应用停止加载,经过一些时间的了解,发现可用空间已满(我不知道为什么,似乎没有人会上传任何东西...)
我尝试了一些在Google上找到的方法,但不幸的是,由于设备上没有剩余空间,这些方法都不起作用。唯一剩下的解决办法是增加卷和分区的大小。前者已完成,但我不能进行后者,因为出现了权限被拒绝的问题。我按照AWS网站上的教程正确增加分区大小,但不起作用。以下是我遇到的问题:

ubuntu@***:~$ lsblk
NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
loop0          7:0    0  24.8M  1 loop /snap/amazon-ssm-agent/6563
loop1          7:1    0  24.4M  1 loop /snap/amazon-ssm-agent/6312
loop2          7:2    0  63.3M  1 loop /snap/core20/1879
loop3          7:3    0  55.6M  1 loop /snap/core18/2751
loop4          7:4    0 111.9M  1 loop /snap/lxd/24322
loop5          7:5    0  63.5M  1 loop /snap/core20/1891
loop6          7:6    0  53.3M  1 loop /snap/snapd/19361
loop7          7:7    0  53.2M  1 loop /snap/snapd/19122
loop8          7:8    0  55.6M  1 loop /snap/core18/2745
nvme0n1      259:0    0    25G  0 disk
├─nvme0n1p1  259:1    0  11.9G  0 part /
├─nvme0n1p14 259:2    0     4M  0 part
└─nvme0n1p15 259:3    0   106M  0 part /boot/efi
ubuntu@***:~$ df -hT
Filesystem      Type   Size  Used Avail Use% Mounted on
/dev/root       ext4    12G   12G     0 100% /
tmpfs           tmpfs  471M     0  471M   0% /dev/shm
tmpfs           tmpfs  189M   20M  169M  11% /run
tmpfs           tmpfs  5.0M     0  5.0M   0% /run/lock
/dev/nvme0n1p15 vfat   105M  6.1M   99M   6% /boot/efi
tmpfs           tmpfs   95M  4.0K   95M   1% /run/user/1000
ubuntu@***:~$ growpart /dev/nvme0n1p1 1
mkdir: cannot create directory ‘/tmp/growpart.10717’: No space left on device
FAILED: failed to make temp dir
ubuntu@***:~$ resize2fs /dev/root 1
resize2fs 1.46.5 (30-Dec-2021)
open: Permission denied while opening /dev/root

谢谢你的帮助!

英文:

Lately, I got a problem with my AWS server on EC2 with Linux. For some reason, my web app stopped to load, and after spending some time knowing why, it appears that the available space is full (I have no idea why, it's not like if anyone would upload anything...)
I tried several things I found on google, but sadly, none of them would work since there is no space left on the device. The only solution left was to increase the volume and the partition. The former is done, but I can do the later because it appears that the permission is denied. I followed the tutorial to proper increase the partition in AWS's website itself, but it doesn't work. Here is the problem I'm getting:

ubuntu@***:~$ lsblk
NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
loop0          7:0    0  24.8M  1 loop /snap/amazon-ssm-agent/6563
loop1          7:1    0  24.4M  1 loop /snap/amazon-ssm-agent/6312
loop2          7:2    0  63.3M  1 loop /snap/core20/1879
loop3          7:3    0  55.6M  1 loop /snap/core18/2751
loop4          7:4    0 111.9M  1 loop /snap/lxd/24322
loop5          7:5    0  63.5M  1 loop /snap/core20/1891
loop6          7:6    0  53.3M  1 loop /snap/snapd/19361
loop7          7:7    0  53.2M  1 loop /snap/snapd/19122
loop8          7:8    0  55.6M  1 loop /snap/core18/2745
nvme0n1      259:0    0    25G  0 disk
├─nvme0n1p1  259:1    0  11.9G  0 part /
├─nvme0n1p14 259:2    0     4M  0 part
└─nvme0n1p15 259:3    0   106M  0 part /boot/efi
ubuntu@***:~$ df -hT
Filesystem      Type   Size  Used Avail Use% Mounted on
/dev/root       ext4    12G   12G     0 100% /
tmpfs           tmpfs  471M     0  471M   0% /dev/shm
tmpfs           tmpfs  189M   20M  169M  11% /run
tmpfs           tmpfs  5.0M     0  5.0M   0% /run/lock
/dev/nvme0n1p15 vfat   105M  6.1M   99M   6% /boot/efi
tmpfs           tmpfs   95M  4.0K   95M   1% /run/user/1000
ubuntu@***:~$ growpart /dev/nvme0n1p1 1
mkdir: cannot create directory ‘/tmp/growpart.10717’: No space left on device
FAILED: failed to make temp dir
ubuntu@***:~$ resize2fs /dev/root 1
resize2fs 1.46.5 (30-Dec-2021)
open: Permission denied while opening /dev/root

Thank you for any help!

答案1

得分: 1

  • 首先,从AWS中增加卷大小(通过UI/CLI/API)。
  • 你需要找到任何要从根卷中删除的内容以释放一些空间,因为它已经100%满了,无法执行基本命令。即使是不大的空间,+50/100M也可以。
  • 运行growpart命令(这将增加分区)--> 你的截图显示它未成功执行,所以如果分区未扩展,你就无法调整文件系统的大小,因为没有要调整的内容。通常,如果成功,再次运行lsblk,你应该会看到nvme0n1p1的大小增加。
  • 运行resize2fs命令

另外,运行这些命令时需要使用sudo,这可能是权限被拒绝错误的原因

英文:
  • First increase the volume size from AWS (whether through UI/CLI/API)
  • You will have to find anything to delete from the root volume to free up some space, since it is 100% full that it cannot execute basic command. (nothing big, +50/100M would do it, even less.)
  • run the growpart command (which would increase the partition) --> your screenshots shows it was not executed properly, so you cannot resize your filesystem if the partition is not expanded, as nothing to resize. Normally, if it was successfully, run the lsblk again, you have to see nvme0n1p1 size increased.
  • Run the resize2fs command.

Also, you have to use sudo when running this commands; that actually might have been the reason for the permission denied error.

huangapple
  • 本文由 发表于 2023年6月29日 11:32:20
  • 转载请务必保留本文链接:https://go.coder-hub.com/76577901.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定