Ubuntu 16.04には読み取り専用ファイルシステムと書き込み可能なレイヤがあります

Ubuntu 16.04には読み取り専用ファイルシステムと書き込み可能なレイヤがあります

(この記事はクロスポストです。アクベントなぜなら、ここではそれをどのように機能させるかを知っている人が多いと思うからです)

Live CDのようにUbuntu 16.04を設定したいです。これはUbuntu 12.04ではうまく機能しますが、16.04では問題があります。サービスがクラッシュし、CRONが機能せず、Xが機能せず、シェルにログインすることもできません。だから16.04にはいくつかの修正が必要だと思います。ルートドライブを読み取り/書き込みでマウントすると、すべてがうまく機能します。したがって、オペレーティングシステム自体は大丈夫です。

読み取り専用モードでUbuntuブートを作成するために、カーネルパラメータ「rw」を「ro」に置き換え、initramfsでスクリプトを使用しました。

/etc/initramfs-tools/scripts/init-bottom/ro_root

#!/bin/sh

PREREQ=''

prereqs() {
  echo "$PREREQ"
}

case $1 in
prereqs)
  prereqs
  exit 0
  ;;
esac

ro_mount_point="${rootmnt%/}.ro"
rw_mount_point="${rootmnt%/}.rw"

# Create mount points for the read-only and read/write layers:
mkdir "${ro_mount_point}" "${rw_mount_point}"

# Move the already-mounted root filesystem to the ro mount point:
mount --move "${rootmnt}" "${ro_mount_point}"

# Mount the read/write filesystem:
mount -t tmpfs root.rw "${rw_mount_point}"

# Mount the union:
mount -t aufs -o "dirs=${rw_mount_point}=rw:${ro_mount_point}=ro" root.union "${rootmnt}"

# Correct the permissions of /:
chmod 755 "${rootmnt}"

# Make sure the individual ro and rw mounts are accessible from within the root
# once the union is assumed as /.  This makes it possible to access the
# component filesystems individually.
mkdir "${rootmnt}/ro" "${rootmnt}/rw"
mount --bind "${ro_mount_point}" "${rootmnt}/ro"
mount --bind "${rw_mount_point}" "${rootmnt}/rw"

# ro_root end

roルートドライブとrw fsレイヤーでUbuntu 16.04を正しく設定するには?

ベストアンサー1

標準のUbuntuパッケージ「overlayroot」を使用してください。 Ubuntu 16.04では、このパッケージが自動的にインストールされます。 /etc/overlayroot.confを編集して次の設定を追加すると、簡単に有効にできます。

overlayroot="tmpfs"

Ubuntu 16.04システムを再起動すると完了です。パッチなどの読み取り専用ルートファイルシステムを一時的に簡単に無効にするには、grub設定にカーネルブートエントリを追加できます。これを行う方法は、次のようにカーネルパラメータを渡す grub エントリを追加することです。

overlayroot=disabled

詳しくは以下をご覧ください。 https://spin.atomicobject.com/2015/03/10/protecting-ubuntu-root-filesystem/

おすすめ記事