科学の箱

科学・IT・登山の話題

Linux

VirtualBoxでディスクを拡張する

投稿日:2021年5月3日 更新日:

Virtual Box => ファイル => 仮想メディアマネージャからディスクを増やす

パーティションを拡張する

root@els01:~# df -h
Filesystem Size Used Avail Use% Mounted on
udev 3.9G 0 3.9G 0% /dev
tmpfs 798M 720K 797M 1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 8.8G 7.2G 1.2G 87% /
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/sda2 976M 79M 831M 9% /boot
tmpfs 798M 0 798M 0% /run/user/1000

 

root@els01:~# lsblk
NAME                      MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda                         8:0    0   13G  0 disk
tqsda1                      8:1    0    1M  0 part
tqsda2                      8:2    0    1G  0 part /boot
mqsda3                      8:3    0    9G  0 part
  mqubuntu--vg-ubuntu--lv 253:0    0    9G  0 lvm  /
sr0                        11:0    1 1024M  0 rom

 

parted /dev/sda

 

unit s

 

(parted) print
Warning: Not all of the space available to /dev/sda appears to be used, you can
fix the GPT to use all of the space (an extra 6291456 blocks) or continue with
the current setting?
Fix/Ignore? Ignore
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sda: 27262976s
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start     End        Size       File system  Name  Flags
 1      2048s     4095s      2048s                         bios_grub
 2      4096s     2101247s   2097152s   ext4
 3      2101248s  20969471s  18868224s

 

(parted) print
Warning: Not all of the space available to /dev/sda appears to be used, you can
fix the GPT to use all of the space (an extra 6291456 blocks) or continue with
the current setting?
Fix/Ignore? Fix
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sda: 27262976s
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number Start End Size File system Name Flags
 1 2048s 4095s 2048s bios_grub
 2 4096s 2101247s 2097152s ext4
 3 2101248s 20969471s 18868224s

 

(parted) p free
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sda: 27262976s
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start      End        Size       File system  Name  Flags
        34s        2047s      2014s      Free Space
 1      2048s      4095s      2048s                         bios_grub
 2      4096s      2101247s   2097152s   ext4
 3      2101248s   20969471s  18868224s
        20969472s  27262942s  6293471s   Free Space

 

(parted) resizepart 3
End?  [20969471s]? 100%
(parted) p free
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sda: 27262976s
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start     End        Size       File system  Name  Flags
        34s       2047s      2014s      Free Space
 1      2048s     4095s      2048s                         bios_grub
 2      4096s     2101247s   2097152s   ext4
 3      2101248s  27262942s  25161695s

 

reboot

 

root@els01:~# pvs
  PV         VG        Fmt  Attr PSize  PFree
  /dev/sda3  ubuntu-vg lvm2 a--  <9.00g    0

 

root@els01:~# pvresize /dev/sda3
  Physical volume "/dev/sda3" changed
  1 physical volume(s) resized / 0 physical volume(s) not resized

 

root@els01:~# lvextend -r -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv
  Size of logical volume ubuntu-vg/ubuntu-lv changed from <9.00 GiB (2303 extents) to <12.00 GiB (3071 extents).
  Logical volume ubuntu-vg/ubuntu-lv successfully resized.
resize2fs 1.44.1 (24-Mar-2018)
Filesystem at /dev/mapper/ubuntu--vg-ubuntu--lv is mounted on /; on-line resizing required
old_desc_blocks = 2, new_desc_blocks = 2
The filesystem on /dev/mapper/ubuntu--vg-ubuntu--lv is now 3144704 (4k) blocks long.

 

root@els01:~# df -h
Filesystem                         Size  Used Avail Use% Mounted on
udev                               3.9G     0  3.9G   0% /dev
tmpfs                              798M  716K  797M   1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv   12G  7.2G  4.0G  65% /
tmpfs                              3.9G     0  3.9G   0% /dev/shm
tmpfs                              5.0M     0  5.0M   0% /run/lock
tmpfs                              3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/sda2                          976M   79M  831M   9% /boot
tmpfs                              798M     0  798M   0% /run/user/1000

 

メタ情報

inarticle



メタ情報

inarticle



-Linux
-

執筆者:


comment

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

関連記事

関連記事はありませんでした

2021年5月
« 3月   6月 »
 12
3456789
10111213141516
17181920212223
24252627282930
31  

side bar top



アーカイブ

カテゴリー