13
13

More than 3 years have passed since last update.

さくらのVPSでやらかしてから復旧させたはなし

Posted at

やらかした

おそらきれい

経緯

さくらのVPSでCentos7でサービス公開中。
メンテナンスのために再起動していろいろいじってた。
よくよく見たらSELINUXがEnforcedになっててブートに失敗してるサービスが何個か。

やらかし

よし。パパvi /etc/selinux/configしてdisabledにしちゃうぞ。

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=enforcing
# SELINUXTYPE= can take one of three two values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

↓↓↓↓↓

これはやらかしてる例です。
これをコピペしたらだめ。ぜったい。

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=enforcing
# SELINUXTYPE= can take one of three two values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
SELINUXTYPE=disabled

↑これはやらかしてる例です。
これをコピペしたらだめ。ぜったい。

よしリブートだ。

発覚

Unable to load SELinux Policy. Machine is in enforcing mode. Halting now.
Kernel panic - not syncing: Attempted to kill init!

あばばばばばばばば

復旧目指して七転八倒

さくらのVPSにはコンソールが付いてるんだからブート時にシングルユーザーモードに入れば楽勝楽勝、と思いつつサーバー強制停止→起動。

起動したら即VNCコンソールに接続・・・

するとすでにGRUBをすっとばしてブートプロセス中でまたカーネルパニック。
download.jpg

VNCコンソールがだめならシリアルコンソールだ

サーバーを強制停止→起動
起動したら即シリアルコンソールに接続・・・

するとすでにGRUBをすっとばしてブートプロセス中でまたカーネルパニック。

download.jpg

VPSの起動が早すぎてカーネルパニックが迂回できないの巻

あれ?これ詰んだんじゃない?

たすけてさくらえもーん

さくらのサポートデスクにお願いするしかない!
お問い合わせ前にご確認ください – さくらのサポート情報

電話窓口にれんらくれんらく。


「お電話ありがとうございます。本日は休業日のためお繋ぎできません

3e7249a24bdde29ffcddd2048c4b129f_600.jpg

まずは落ち着いてググろう。

ほう、カスタムのOSインストールを選択して起動時のプロンプトでTroubleshootingを選ぶと既存のボリュームマウントして編集できるのか。
これだ。

カスタムOSインストールから復旧

 さくらVPSのコントロールパネル
  →OSインストール
  →カスタムOSインストール
  →CentOS7を選択
   →内容を確認するを押す
  →インストールを実行するを押す
    ※バックアップを取ってから作業してね 的なメッセージがでるが無視。。。
  →準備ができるとVNCコンソールを開くボタンが表示される。
 ここからVNCコンソールの作業
 トラブルシューティングを選択
 →レスキューを選択
忘れるためのメモ: さくらVPSのCentos7が起動しなくなった。。。

この通りにすすめてVNCコンソールを開くと
・・・すでにvisual installerのブートプロセス。

3e7249a24bdde29ffcddd2048c4b129f_600.jpg

詰んだ。

復旧編

結局の所ブートが早すぎて復旧メニューまでたどり着けないのが問題なわけで。
ただ、Linuxのインストーラーの自動起動って60秒後だった気がしたのにカスタムOSインストーラーのブートではそこを華麗にスキップされてる気がする。

ならISOイメージインストールで適当なインストーラーをアップロードして読み込ませれば行ける。
というかlivecdでブートしたらいける気がする。
いけるきがする!

livecdをCentos公式からダウンロード

Index of /centos/7/isos/x86_64 からCentOS-7-livecd-x86_64.isoをダウンロード。

さくらのVPSコンソールからISOイメージインストールを選んで「SFTPアカウントを発行する」してisoフォルダにダウンロードしたファイルをアップロード。

アップロードが完了するとさくらのVPSコンソールにイメージが表示されるのでそこから起動。

livecdでブート

Failed to access perfctr msr (msr c1 is 0)

と表示されたきりうんともすんとも。

ならば普通のインストーラならどうだ。

Index of /pub/linux/centos/7/isos/x86_64から
CentOS-7-x86_64-Minimal-1908.isoをダウンロード。

あとはlivecdと同じようにファイルをアップロードして起動

スクリーンショット (18).png

仙道彰 \- Google 検索

スクリーンショット (19).png

キマシタワー

Rescure a CentOS system を実行

Rescure a CentOS system からの操作

Linuxサーバのレスキューモードを用いたfsck実施手順 | さくらのクラウド ドキュメント

The rescue environment will now attempt to find your Linux installation 
and mount it under the directory : /mnt/sysimage . You can then make any changes 
required to your system. Choose '1' to proceed with this step.
You can choose to mount your file systems read-only instead of read-write by choosing '2'
if for some reason this process does not work choose '3' to skip directly to a shell.

1) Continue
2) Read-only mount
3) Skip to shell
4) Quit (Reboot)

Please make a selection from the above:

で1を選ぶと /mnt/sysimageにもとのファイルシステムがマウントされているので間違えた/etc/selinux/configを修正する。

# vi /mnt/sysimage/etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.

SELINUX=disabled



# SELINUXTYPE= can take one of three two values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.

SELINUXTYPE=targeted

で、exitでシェルを抜けるとシャットダウンされるのでコントロールパネルから起動。

CentOS Linux 7 (Core)
Kernel 3.10.0-xxxxxx

hostname login:

キマシタワー

というか

疲れ果てた。
設定ミスってたらデフォルトで起動するぐらいの柔軟性をLinuxは持てないのか(逆ギレ

13
13
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
13