2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

SystemRescueCDはもう古い.NixOSこそが最強のレスキュー環境である.

Last updated at Posted at 2019-11-27

あらすじ

2019年初頭にGentooベースからArchベースに移行したSystemRescueCD.
その後すぐに音沙汰がなくなり,セキュリティホールなども放置されている模様.

SystemRescueCDを愛用していた難民の方に朗報です.
NixOSのインストールメディアが最高に使いやすい.

最新版はこっち
https://gist.github.com/ijaketak/5996f3d9d2d7fb6adad4c5eb6fe15f8b

使い方

起動

https://nixos.org/nixos/download.html
からisoファイルをダウンロードして,USB等にddとかで焼くだけです.
レスキューならMinimalで十分.

ブートローダでcopytoramが選択できます.
デフォルトでnixosユーザに自動ログインしますが,sudoが使えるので,
passwdsudo systemctl start sshdとかip aとか.

パッケージ追加 その1

パスに実行ファイルgitが存在するようなシェルを開く

$ nix-shell -p git
...
$ git version
git version 2.23.0
$ (Ctrl-D)

パッケージ名で検索

$ nix-env -qaP '.*gpt.*'
nixos.gptfdisk  gptfdisk-1.0.4

パッケージツリーのアップデート

$ sudo nix-channel --update
...

パッケージ名がイマイチ直感的に対応しない場合があるのが唯一の欠点.

パッケージ追加 その2

Minimalの場合/etc/nixosに配置されるconfiguration.nixがコレ.

{ config, pkgs, ... }:
{
  imports = [ <nixpkgs/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix> ];
}

起動中に環境を書き換えるだけなら,configuration.nix

{ config, pkgs, ... }:
{
  imports = [ <nixpkgs/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix> ];
  environment.systemPackages = with pkgs; [
    git zsh
    gptfdisk
    ];
}

のように変更した後,sudo nixos-rebuild testで環境が置き換わります.
つまりenvironment.systemPackagesにパッケージを追加したら,そのパッケージが即座に使えるようになります.

installation-cd-minimal.nixなどはNixOSのパッケージツリーに含まれています.
https://github.com/NixOS/nixpkgs-channels/tree/nixos-19.09/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix

インストール

NixOSは公式のマニュアル見て下さい.マジで全部載ってます.
https://nixos.org/nixos/manual/

大抵のディストリビューションでは,既存の環境からインストールする方法が用意されています.
例えばDebianはdebootstrapでインストールできます.
https://www.debian.org/releases/buster/amd64/apds03.ja.html

起動時の挙動

普通にNixOSを設定するのと同じように設定可能です.
https://nixos.wiki/wiki/Creating_a_NixOS_live_CD

結論

NixOSの世界観が非常に楽ですね.
もう戻れません.

2
2
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
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?