1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【2024年7月版】論理ボリュームサイズを100%に拡張する【resize2fs, lvextend】

Last updated at Posted at 2024-07-21

はじめに

Ubuntuでデフォルトのインストールしたら、論理ボリュームが100%じゃやないやん。。。

拡張してサイズ100%にしよ。。。というメモ

前提

  • Ubuntu22.04
$ uname -a
Linux test 5.15.0-116-generic #126-Ubuntu SMP Mon Jul 1 10:14:24 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
$ cat /etc/os-release 
PRETTY_NAME="Ubuntu 22.04.4 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.4 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy
$ cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04.4 LTS"
  • ボリュームグループは30G、ubuntu-vg
$ sudo vgs
  VG        #PV #LV #SN Attr   VSize   VFree 
  ubuntu-vg   1   1   0 wz--n- <30.00g 15.00g
  • 論理ボリュームは15Gで、ubuntu-lv
$ sudo lvs
  LV        VG        Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  ubuntu-lv ubuntu-vg -wi-ao---- <15.00g         
  • ファイルシステムはext4
$ lsblk -f
NAME                      FSTYPE      FSVER            LABEL                           UUID                                   FSAVAIL FSUSE% MOUNTPOINTS
loop0                     squashfs    4.0                                                                                           0   100% /snap/core20/2105
loop1                     squashfs    4.0                                                                                           0   100% /snap/lxd/27037
loop2                     squashfs    4.0                                                                                           0   100% /snap/snapd/20671
sda                                                                                                                                          
├─sda1                                                                                                                                       
├─sda2                    ext4        1.0                                              9155fe10-8502-4aca-8ddd-a209d67d407f      1.7G     7% /boot
└─sda3                    LVM2_member LVM2 001                                         lwvfxv-Jwmw-dn6e-22YJ-g1cL-eApd-iqvcGW                
  └─ubuntu--vg-ubuntu--lv ext4        1.0                                              f60bcd8d-967d-436a-8030-162dd2902f78        8G    40% 

手順

  • 論理ボリュームの拡張
  • ファイルシステムの拡張

論理ボリュームの拡張

$ sudo lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
  Size of logical volume ubuntu-vg/ubuntu-lv changed from <15.00 GiB (3839 extents) to <30.00 GiB (7679 extents).
  Logical volume ubuntu-vg/ubuntu-lv successfully resized.

ファイルシステムの拡張

$ sudo resize2fs /dev/ubuntu-vg/ubuntu-lv
resize2fs 1.46.5 (30-Dec-2021)
Filesystem at /dev/ubuntu-vg/ubuntu-lv is mounted on /; on-line resizing required
old_desc_blocks = 2, new_desc_blocks = 4
The filesystem on /dev/ubuntu-vg/ubuntu-lv is now 7863296 (4k) blocks long.

確認

$ sudo vgs
  VG        #PV #LV #SN Attr   VSize   VFree
  ubuntu-vg   1   1   0 wz--n- <30.00g    0 
$ sudo lvs
  LV        VG        Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  ubuntu-lv ubuntu-vg -wi-ao---- <30.00g  
$ lsblk -f
NAME                      FSTYPE      FSVER            LABEL                           UUID                                   FSAVAIL FSUSE% MOUNTPOINTS
loop0                     squashfs    4.0                                                                                           0   100% /snap/core20/2105
loop1                     squashfs    4.0                                                                                           0   100% /snap/lxd/27037
loop2                     squashfs    4.0                                                                                           0   100% /snap/snapd/20671
sda                                                                                                                                          
├─sda1                                                                                                                                       
├─sda2                    ext4        1.0                                              9155fe10-8502-4aca-8ddd-a209d67d407f      1.7G     7% /boot
└─sda3                    LVM2_member LVM2 001                                         lwvfxv-Jwmw-dn6e-22YJ-g1cL-eApd-iqvcGW                
  └─ubuntu--vg-ubuntu--lv ext4        1.0                                              f60bcd8d-967d-436a-8030-162dd2902f78     22.1G    20% /

さいごに

かんたんでしたね

1
0
1

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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?