summaryrefslogtreecommitdiff
path: root/initramfs-tools/scripts/samizdat
blob: 3f2ee43cf52b8aad4f3fa7f2795930404df5179e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
mountroot()
{
  set -x
  mkdir /cdrom /btrfs
  mount -t iso9660 /dev/sr0 /cdrom
  mount -t btrfs -o loop,subvol=ROOT /cdrom/live/filesystem.btrfs /btrfs
  modprobe brd rd_size=$((256 * 1024 * 2))
  btrfs device add /dev/ram0 /btrfs
  mount -o rw,remount /btrfs
  mount -o move /btrfs /root
  mkdir /root/cdrom
  mount -o move /cdrom /root/cdrom

  sed -i -e 's/^root:x:/root::/' /root/etc/passwd

  samizdat_install_udev_rules

  openvt -c 13 sh
  sleep 100
  set +x
}

samizdat_install_udev_rules()
{
  mkdir -p /etc/udev/rules.d
  echo 'ACTION=="add", SUBSYSTEM=="block", RUN+="/bin/grok-block $env{DEVNAME}"' \
    > /etc/udev/rules.d/z00_blockdev_mountroot.rules

  # 'udevadm trigger --action=add' does not work here; need to restard udevd
  # first. not sure why
  samizdat_restart_udev

  udevadm trigger -s block --action add
}

samizdat_restart_udev()
{
  mkdir -p /var/log
  ps aux|grep systemd-udevd
  killall systemd-udevd
  /lib/systemd/systemd-udevd --resolve-names=never --debug >/var/log/udevd-systemd.log 2>&1 &
  udevadm hwdb --update  # rule is not executed by 'udevadm trigger' otherwise.  not sure why
}