This repository has been archived by the owner on Jan 4, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsilverblueize.sh
executable file
·89 lines (72 loc) · 2.76 KB
/
silverblueize.sh
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/bash
# TODO
# - [ ] take a look at any Linux OS to Silverblue (e.g Ubuntu)
# - [ ] install previous user installed packages as overlay
# - [ ] install previous system Flatpaks
# RUN AS ROOT
# USE AT YOUR OWN RISK
# inspired by https://asamalik.fedorapeople.org/fedora-docs-translations/en-US/fedora-silverblue/installation-dual-boot/
set -o errexit
set -o nounset
set -o pipefail
if [ ! "$(id -u)" = 0 ]; then
echo "this script must be run as root" >/dev/stderr
exit 1
fi
CMDN="${1:-}"
COUNTER=0
cmd() {
if [ -n "${CMDN}" ] && [ ! "$COUNTER" -ge "${CMDN}" ]; then
COUNTER=$((COUNTER += 1))
return
fi
CMD=$*
(
echo "$(date): exec[$COUNTER]: ${CMD}"
eval "${CMD}" 2>&1
) | tee -a "${FWS2SBLOG:-/var/log/fedora-ws2sb.log}"
COUNTER=$((COUNTER += 1))
}
. /etc/os-release
case "${ID} ${VARIANT_ID}" in
"fedora workstation") ;;
*)
echo "this script must be run on Fedora Workstation" >/dev/stderr
exit 1
;;
esac
cat <<EOF
Welcome to Silverblueize, where you convert your existing Fedora Workstation install into Fedora Silverblue.
This process may be harmful and is irreversable without disk or partition snapshots (see LVM or btrfs).
User data, via home partition will persist and programs or other system configurations will likely not.
The procedure will feel like a new install but with persisting user data
By proceeding, you understand the risk.
Press [enter] to proceed.
EOF
read -r -p ''
cmd dnf install -y ostree ostree-grub2
cmd ostree admin init-fs /
cmd ostree remote add --set=gpgkeypath="/etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-38-$(uname -m)" fedora https://ostree.fedoraproject.org --set=contenturl=mirrorlist=https://ostree.fedoraproject.org/mirrorlist
cmd ostree --repo=/ostree/repo pull "fedora:fedora/38/$(uname -m)/silverblue"
cmd rm -r /boot/loader
cmd ostree admin os-init fedora
cmd mv /boot/grub2/grub.cfg /boot/grub2/grub.cfg.bak
cmd cp /boot/efi/EFI/fedora/grub.cfg /boot/efi/EFI/fedora/grub.cfg.bak
cmd ostree admin deploy --os=fedora --karg-proc-cmdline "fedora:fedora/38/$(uname -m)/silverblue"
OSTREE_DEPLOY_ROOT="$(find /ostree/deploy/fedora/deploy -mindepth 1 -maxdepth 1 -type d)"
# TODO add /etc/passwd /etc/shadow ?
for i in /etc/fstab /etc/default/grub /etc/locale.conf /etc/ostree/remotes.d/fedora.conf; do
cmd cp "${i}" "${OSTREE_DEPLOY_ROOT}/${i}"
done
cmd sed -i -e 's,/home,/var/home,g' /ostree/deploy/fedora/deploy/*.0/etc/fstab
cmd cp /boot/loader/grub.cfg /boot/grub2/grub.cfg || true
cat <<EOF
Automatic migration complete.
Depending on your system config, you may have addition changes or preparations you may wish to make.
The OSTree deploy root is "${OSTREE_DEPLOY_ROOT}"
IMPORTANT: after reboot, create a user account with the same username as your current one ($USER)
To reboot run
\`\`\`
systemctl reboot
\`\`\`
EOF