Ubuntuで/dev/sdaパーティションを分割する方法

Ubuntuで/dev/sdaパーティションを分割する方法

/dev/sda1/Ubuntu仮想マシンのパーティションを分割し/dev/sda1て分割する方法を考えています。/dev/sda2

vagrantを使用して新しい仮想サーバーインスタンスを作成するたびに、ここに40 GBのディスク容量を割り当て、すべてのディスク容量を/dev/sda1

/dev/sda1端末(リモートSSH)を使用してパーティションを2つに分割する方法が必要です。

だから私が今まで試したことは

// Step 1
root@server-1:~# fdisk /dev/sda

// Step 2 Delete sda1
Welcome to fdisk (util-linux 2.34).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Command (m for help): d
Selected partition 1
Partition 1 has been deleted.

// Step 3 Create 2 new Partition
Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p):p
Partition number (1-4, default 1):
First sector (2048-83886079, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-83886079, default 83886079): 61440000

Created a new partition 1 of type 'Linux' and of size 29.3 GiB.
Partition #1 contains a ext4 signature.

Do you want to remove the signature? [Y]es/[N]o: N
Command (m for help): n
Partition type
   p   primary (1 primary, 0 extended, 3 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (2-4, default 2):
First sector (61440001-83886079, default 61442048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (61442048-83886079, default 83886079):

Created a new partition 2 of type 'Linux' and of size 10.7 GiB.

// Step 4 and last step is write it to disk
Command (m for help): w

したがって、この方法は必要に応じて機能しますが、fsckを実行すると/dev/sda1ファイルシステムで誤ったチェックサムが発生し、VMを再起動するたびにSSHが接続を拒否します。でも答えなかった。

私がしっかりしているのか?パーティションが破損していますか?この問題を解決する方法はありますか?

ベストアンサー1

あなたは正しい考えを持っていますが、最初のステップを逃しました。まず、sda1パーティションのファイルシステムを縮小してから、パーティション自体を縮小する必要があります。ファイルシステムの縮小は常にサポートされているわけではなく、本質的に危険です(全体の操作と同様)。私の提案は、パーティションを縮小したいよりもファイルシステムを少し小さく縮小し、パーティションを縮小した後にファイルシステムを増やすことです。

おすすめ記事