いがにんのぼやき

WEBエンジニアのブログ。IT、WEB、バンド、アニメ。

UbuntuでVirtualbox、Vagrantのエラー

Dockerを使用してnpm runをしようとするとPermission deniedが出る問題あり。やったことを残すためにこの記事は残しておきますが、参考にしないでください。

sh: 1: webpack: Permission denied

自分用メモ。

Virtualboxを入れるのもひと手間だった。 具体的な記述に残していないが、下記で行けた。

askubuntu.com

Secure bootを無効にするとかだった気がする。

また、UbuntuVagrantを使用するときに、外部ディスクを使用するときにパーミッションエラーが出るための対応。
こんな感じのエラーがでる。

The private key to connect to this box via SSH has invalid permissions
set on it. The permissions of the private key should be set to 0600, otherwise SSH will
ignore the key. Vagrant tried to do this automatically for you but failed. Please set the
permissions on the following file to 0600 and then try running this command again:

/media/igatea/TOSHIBA-1TB/Vagrant/centos7/.vagrant/machines/default/virtualbox/private_key

Note that this error occurs after Vagrant automatically tries to
do this for you. The likely cause of this error is a lack of filesystem
permissions or even filesystem functionality. For example, if your
Vagrant data is on a USB stick, a common case is that chmod is
not supported. The key will need to be moved to a filesystem that
supports chmod.

GUIで外部のHDDのマウントの設定をしていたが、パーミッションの変更ができないっぽい。
なので下記を参考にマウント設定のfstabをいじっていく。

hakushisky.blog.shinobi.jp

askubuntu.com

最終的に/etc/fstabに下記の行を追加して再起動。

UUID=B07E713F7E710000 /media/igatea/TOSHIBA-1TB auto auto,users,permissions 0 0

その後、Vagrantディレクトリのprivate_keyがrootの777になっているのでパーミッションを変更してあげて終了。

chown igatea .vagrant/machines/default/virtualbox/private_key 
chmod 600 .vagrant/machines/default/virtualbox/private_key 

ユーザーがrootのままだと下記のエラーが発生する

The private key to connect to the machine via SSH must be owned
by the user running Vagrant. This is a strict requirement from
SSH itself. Please fix the following key to be owned by the user
running Vagrant:

/media/igatea/TOSHIBA-1TB/Vagrant/centos7/.vagrant/machines/default/virtualbox/private_key