2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

EC2のディスク拡張作業の備忘録

Last updated at Posted at 2021-12-16

ちょいちょい忘れがちなので備忘録として。

ghqでリポジトリ追加したらディスク容量がいっぱいになった

$ ghq get hogefuga

~

remote: Enumerating objects: 5315, done.
remote: Counting objects: 100% (2349/2349), done.
remote: Compressing objects: 100% (967/967), done.
remote: Total 5315 (delta 1165), reused 1954 (delta 882), pack-reused 2966
Receiving objects: 100% (5315/5315), 40.70 MiB | 12.12 MiB/s, done.
Resolving deltas: 100% (2497/2497), done.
fatal: cannot create directory at 'xxxxxxxxxx': No space left on device
warning: Clone succeeded, but checkout failed.

error failed to get "https://github.com/xxx/xxxxxxxx.git": /usr/local/bin/git: exit status 128

ディスク拡張しましょうか。

現状確認

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
~
/dev/nvme0n1p1  7.7G  7.7G     0 100% /
~

AWSコンソールで該当インスタンスのEBSボリュームの容量を変更してから、
パーティション拡張する

拡張した容量「8GB→30GB」が認識できているか確認

$ lsblk
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
~
nvme0n1     259:1    0   30G  0 disk
└─nvme0n1p1 259:2    0    8G  0 part /

拡張したディスク容量は認識できていて、パ-ティションが8GB

パーティション拡張する

sudo growpart /dev/nvme0n1 1

確認

$ lsblk
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
~
nvme0n1     259:0    0   30G  0 disk
└─nvme0n1p1 259:1    0   30G  0 part /

resize2fs コマンドで、「/dev/nvme0n1p1」のサイズをボリュームの上限まで自動的に拡張

$ sudo resize2fs /dev/nvme0n1p1
resize2fs 1.42.13 (17-May-2015)
Filesystem at /dev/nvme0n1p1 is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 2
The filesystem on /dev/nvme0n1p1 is now 7864059 (4k) blocks long.

確認

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
~
/dev/nvme0n1p1   30G  7.7G   22G  27% /
~

OK

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?