実行手順の理解

実行手順の理解

次のスクリプトの順序を理解する必要があります。

$command .= "n\n\n\n\nt\n7\nc\nw\n";                        
exec("echo -e \"{$command}\" | /sbin/fdisk {$kernelDevice}");

実際にどのコマンドが使用されたのかわかりませんexec

ベストアンサー1

文字列はfdisk1つずつ提供されます。それぞれは\nキャリッジリターン文字で、次の文字はfdiskで特定の意味を持ちます。

n   add a new partition (default values selected with \n)
t   change partition type (a value of 7 is selected)
c   toggle the dos compatibility flag
w   write table to disk and exit

つまり、新しいパーティションを作成し(空き領域を使用して)、パーティションタイプを7に変更し、dosフラグを切り替えて書き込みを終了します。

おすすめ記事