Linux Red Hat Virtual Machineのサイズを10Gig増やしようとしています。これは私が作成しようとしている私が作成したテストサーバー上にあります。
このコマンドでVMを10ギガ増加しました[root @ rh01 images]#qemu-img resize TestServer.img + 10G Image resized。
次に、このリンクをたどって https://Gist.github.com/larsks/393398 終了しました
最後のコマンドがresize2fsであるところまですべて取得しましたが、このエラーが発生します
[root@TestServer bmac]# resize2fs /dev/vda2
resize2fs 1.41.12 (17-May-2010)
resize2fs: Device or resource busy while trying to open /dev/vda2
Couldn't find valid filesystem superblock.
ここに私が取ったすべてのステップがあります:
[root@rh01 admin]# virt-df -h /home/admin/images/TestServer.img
Filesystem Size Used Available Use%
TestServer.img:/dev/sda1 484M 63M 396M 14%
TestServer.img:/dev/vg_template/lv_root 40G 4.0G 34G 10%
[root@rh01 admin]# virt-list-partitions -lh /home/admin/images/TestServer.img
/dev/sda1 ext4 500.0M
/dev/sda2 pv 48.3G
[root@rh01 admin]# cd images/
[root@rh01 images]# qemu-img resize TestServer.img +10G
Image resized.
[root@rh01 images]# virt-df -h /home/admin/images/TestServer.img
Filesystem Size Used Available Use%
TestServer.img:/dev/sda1 484M 63M 396M 14%
TestServer.img:/dev/vg_template/lv_root 40G 4.0G 34G 10%
[root@rh01 images]# virt-list-partitions -lh /home/admin/images/TestServer.img
/dev/sda1 ext4 500.0M
/dev/sda2 pv 48.3G
[root@rh01 images]# ls -l TestServer.img
-rw-------. 1 root root 63166218240 May 1 08:55 TestServer.img
[root@rh01 images]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/vg_rh01-lv_root 51606140 7845612 41139088 17% /
tmpfs 99166276 296 99165980 1% /dev/shm
/dev/sda1 495844 92445 377799 20% /boot
/dev/mapper/vg_rh01-lv_home 3305120248 494277716 2642952000 16% /home
[root@rh01 images]# df -B 4k
Filesystem 4K-blocks Used Available Use% Mounted on
/dev/mapper/vg_rh01-lv_root
12901535 1961403 10284772 17% /
tmpfs 24791569 74 24791495 1% /dev/shm
/dev/sda1 123961 23112 94450 20% /boot
/dev/mapper/vg_rh01-lv_home
826280062 123569429 660738000 16% /home
[root@rh01 images]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_rh01-lv_root
50G 7.5G 40G 17% /
tmpfs 95G 296K 95G 1% /dev/shm
/dev/sda1 485M 91M 369M 20% /boot
/dev/mapper/vg_rh01-lv_home
3.1T 472G 2.5T 16% /home
Boot VM and Login
[bmac@TestServer ~]$ su
Password:
[root@TestServer bmac]# cd
[root@TestServer ~]# fdisk /dev/vda
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): p
Disk /dev/vda: 63.2 GB, 63166218240 bytes
16 heads, 63 sectors/track, 122392 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000cd4ad
Device Boot Start End Blocks Id System
/dev/vda1 * 3 1018 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/vda2 1018 101588 50686976 8e Linux LVM
Partition 2 does not end on cylinder boundary.
Command (m for help): d
Partition number (1-4): 2
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (1-122392, default 1): 1018
Last cylinder, +cylinders or +size{K,M,G} (1018-122392, default 122392): 122392
Command (m for help): p
Disk /dev/vda: 63.2 GB, 63166218240 bytes
16 heads, 63 sectors/track, 122392 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000cd4ad
Device Boot Start End Blocks Id System
/dev/vda1 * 3 1018 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/vda2 1018 122392 61172544 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
[bmac@TestServer ~]$ su
Password:
[root@TestServer bmac]# df -h /
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_template-lv_root
40G 4.0G 34G 11% /
[root@TestServer bmac]# resize2fs /dev/vda2
resize2fs 1.41.12 (17-May-2010)
resize2fs: Device or resource busy while trying to open /dev/vda2
Couldn't find valid filesystem superblock.
[root@TestServer bmac]# resize4fs /dev/vda2
bash: resize4fs: command not found
[root@TestServer bmackenzie]# resize2fs /dev/mapper/vg_template-lv_root
resize2fs 1.41.12 (17-May-2010)
The filesystem is already 10622976 blocks long. Nothing to do!
[root@TestServer bmac]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_template-lv_root
40G 4.0G 34G 11% /
tmpfs 3.9G 80K 3.9G 1% /dev/shm
/dev/vda1 485M 64M 397M 14% /boot
情報MadHatterをありがとう。誰かがこれを探している場合のために私が働いた正確な手順は次のとおりです
[root@TestServer bmac]# pvresize /dev/vda2
Physical volume "/dev/vda2" changed
1 physical volume(s) resized / 0 physical volume(s) not resized
[root@TestServer bmac]# lvextend /dev/mapper/vg_template-lv_root -L +10G
Extending logical volume lv_root to 50.52 GiB
Logical volume lv_root successfully resized
[root@TestServer bmackenzie]# resize2fs /dev/mapper/vg_template-lv_root
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/vg_template-lv_root is mounted on /; on-line resizing required
old desc_blocks = 3, new_desc_blocks = 4
Performing an on-line resize of /dev/mapper/vg_template-lv_root to 13244416 (4k) blocks.
The filesystem on /dev/mapper/vg_template-lv_root is now 13244416 blocks long.
メモリが機能する場合、実行する必要のある一連の手順があります。
最初に、pvresize
を使用して、既存のPVを新しいパーティションのトップに拡張する必要があります。
次に、lvresize
またはlvextend
を使用して、既存のLVボリュームのサイズを拡大されたPVに変更する必要があります。
次に、resize2fs
ファイルシステムのサイズを新しい拡大されたボリュームに変更します。