GRUBレガシーが不明なファイルシステムについて文句を言いますか?

GRUBレガシーが不明なファイルシステムについて文句を言いますか?

OpenStack クラスター (KVM) に複数の仮想マシンがあり、1 つの 5 GB パーティションを持つイメージで構築される場合、同じ HDD 構造で構成されます。私は実際のOpenStackホストでサイズを変更するいくつかの方法を見つけましたが、VMの内部でサイズを変更してその方法も使用できることを願っています。

1つの方法は、fdiskパーティションメタデータを削除し、パーティションメタデータを再作成して記録し、VMで再起動し、再起動してサイズ変更することです。私は最近これを試しましたが、期待どおりに動作しませんでした。 GRUBプロンプトで仮想マシンが停止します。これはCentOS 6.7 VMなので、ブートローダはGRUBレガシーです。

           SS1

この仮想マシンからファイルシステムを取得するにはどのようなオプションが必要ですか? virtmanagerを使用してVMにアクセスし、LiveCD ISOを公開してVMを「起動」してから関連ファイルシステムをインポートできますが、アクセスを復元してVMを起動するより直接的な方法はありますか?

引用する

ベストアンサー1

だから私の質問は、パーティションを削除して再作成する方法です。fdisk表示された開始位置がそのセクタにないため、転倒しました。次のように正しく呼び出すとfdisk

$ sudo fdisk -c -u /dev/vda

Command (m for help): p

Disk /dev/vda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders, total 83886080 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0004064e

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048    31459327    15728640   83  Linux

明らかに、新しいパーティションを作成するときに開始セクタをソートしていないようです。

fdiskユーザーガイドから:

Options:
 -c                        switch off DOS-compatible mode
 -u <size>                 give sizes in sectors instead of cylinders

そのため、この部分に特に注意を払った結果、使用可能なHDDスペースをすべて活用して仮想マシンのパーティションを拡張する過程を次のように実行することができました。

サイズ変更プロセス

既存のパーティションの削除:

Command (m for help): d
Selected partition 1

今新しいものを追加してください:

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First sector (2048-83886079, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-83886079, default 83886079):
Using default value 83886079

起動可能にする:

Command (m for help): a
Partition number (1-4): p
Partition number (1-4): 1

これらすべてを確認してください。

Command (m for help): p

Disk /dev/vda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders, total 83886080 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0004064e

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048    83886079    41942016   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.

次に、システムを再起動し、必要に応じてresize2fsを実行します。

$ sudo resize2fs /dev/vda1
resize2fs 1.41.12 (17-May-2010)
The filesystem is already 10485504 blocks long.  Nothing to do!

そして確認してください:

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/vda1        40G  807M   37G   3% /
tmpfs           1.9G     0  1.9G   0% /dev/shm

おすすめ記事