[Osaka/Yokohama] Looking for infrastructure/server side engineers!

[Osaka/Yokohama] Looking for infrastructure/server side engineers!

[Deployed by over 500 companies] AWS construction, operation, maintenance, and monitoring services

[Deployed by over 500 companies] AWS construction, operation, maintenance, and monitoring services

[Successor to CentOS] AlmaLinux OS server construction/migration service

[Successor to CentOS] AlmaLinux OS server construction/migration service

[For WordPress only] Cloud server “Web Speed”

[For WordPress only] Cloud server “Web Speed”

[Cheap] Website security automatic diagnosis “Quick Scanner”

[Cheap] Website security automatic diagnosis “Quick Scanner”

[Reservation system development] EDISONE customization development service

[Reservation system development] EDISONE customization development service

[Registration of 100 URLs is 0 yen] Website monitoring service “Appmill”

[Registration of 100 URLs is 0 yen] Website monitoring service “Appmill”

[Compatible with over 200 countries] Global eSIM “Beyond SIM”

[Compatible with over 200 countries] Global eSIM “Beyond SIM”

[If you are traveling, business trip, or stationed in China] Chinese SIM service “Choco SIM”

[If you are traveling, business trip, or stationed in China] Chinese SIM service “Choco SIM”

[Global exclusive service] Beyond's MSP in North America and China

[Global exclusive service] Beyond's MSP in North America and China

[YouTube] Beyond official channel “Biyomaru Channel”

[YouTube] Beyond official channel “Biyomaru Channel”

VirtualBoxの共有フォルダがマウントできなくなった時の対処法

こんにちは。
開発チームのワイルド担当、まんだいです。

VirtualBoxの共有フォルダはとても便利で、とても重宝しています。
でも、ある時急にマウントできなくなったりして、そういう時はどうすればいいか分からないまま、色々別の方法でファイルをやり取りしてやり過ごしていました。

最近、ようやくその原因が分かったので、対応した方法をメモしておこうと思います。

ゲームAPIを開発する場合、本番環境はLinuxという事が多いので、Windowsマシンを使っていますが、VMで近しい環境を手元に置いて、というパターンで未だやり過ごしています。

VM周りの環境ですが、VirtualBoxを利用していて、VMのOSイメージは概ねCentOSです。

 

レベル1 Guest Additions CDからツールを再インストール

まずパッと思いつくのがこれ。

少し古い記事ですが、VirtualBox共有フォルダ覚書 | dark_greenの日記 | スラドにもあるように、カーネルモジュールをyumなどでアップデートした場合に、発生する事が多いですね。
VMなので、もっと雑に扱ってもいいんでしょうか。

VirtualBoxのメニューの「デバイス」から「CDイメージの挿入」という項目を選択すると、インストールツールが自動起動します。
もう既にデスクトップにCDがマウントされている状態なら、CDのアイコンをダブルクリックすればOKです。

紹介しておいて、こう言うのもどうかと思いますが、これで治るくらいなら悩んじゃいませんね。

 

レベル2 共有フォルダの再設定

過去に見えるようになったケースがあったのはこの対処法。

これはVirtualBoxマネージャーにある、VMの設定から設定できます。
もしくは、VMのUIを表示しているなら、右下にフォルダのアイコンがあるのでそちらをクリック。

ホスト側、ゲスト側双方のディレクトリが正しく設定できれば、マウントされる事もあります。

 

レベル3 mount.vboxsfのシンボリックリンクを張り替える

最後に、今回復旧した対処法が、mount.vboxsfのシンボリックリンクのリンク先を変更するというもの。

何がどうなっていたかというと、共有フォルダを実現するための、マウントコマンドとなっている、mount.vboxsfの実体が実は違っていた、というもの。

which mount.vboxsf
/sbin/mount.vboxsf

ls -al | grep vboxsf
mount.vboxsf -> /usr/lib64/VBoxGuestAdditions/mount.vboxsf

これ、ファイルがない訳ではなく、/usr/lib64/VBoxGuestAdditions/mount.vboxsfのパスにファイルは存在します。

で、これをどうするかというと、

# cd /sbin
sudo ln -sf /usr/lib/VBoxGuestAdditions/mount.vboxsf mount.vboxsf

/usr/lib 以下にもある、VBoxGuestAdditions配下のmount.vboxsf へシンボリックリンクの向き先を変更するだけです。

自動マウント設定になっているようなら、VMを再起動すると、dfコマンドなどでちゃんとマウントされているのが分かります。

OSば64ビット版のCentOSなので、/usr/lib64 でも良さそうなものですが、どうやら違うようですね。
これは、Guest Additions CDのインストーラが悪いんじゃないかと思うんですが、どうなんでしょうか、オラクルさん?

これもカーネルモジュールのバージョンアップをした後から起こったような気がします。

やはりVMのカーネルアップデートは色々と危険がありそうです。

以上です。

この記事がお役に立てば【 いいね 】のご協力をお願いいたします!
3
読み込み中...
3 票, 平均: 1.00 / 13
25,919
X facebook はてなブックマーク pocket
[2024.6.30 CentOS support ended] CentOS server migration solution

[2024.6.30 CentOS support ended] CentOS server migration solution

[2025.6.30 Amazon Linux 2 support ended] Amazon Linux server migration solution

[2025.6.30 Amazon Linux 2 support ended] Amazon Linux server migration solution

[Osaka/Yokohama] Actively recruiting infrastructure engineers and server side engineers!

[Osaka/Yokohama] Actively recruiting infrastructure engineers and server side engineers!

The person who wrote this article

About the author

Yoichi Bandai

My main job is developing web APIs for social games, but I'm also fortunate to be able to do a lot of other work, including marketing.
Furthermore, my portrait rights in Beyond are treated as CC0 by him.