Compare commits

..
6 Commits
Author SHA1 Message Date
wyj f7ccffccf0 new feat: add partition script 2024-04-18 15:54:44 -04:00
wyj c45f1362ed fix: use $DIR instead of ./ 2024-03-30 17:58:39 -04:00
wyj 2fd5c0f094 fix: UUID in systemd-boot 2024-03-30 03:13:40 -04:00
wyj 4044a8e55e fix: apt update, so sources.list make work 2024-03-30 02:58:34 -04:00
wyj ad1fe22d1a fix: bash -c, so chroot has .bashrc PATH 2024-03-30 02:57:46 -04:00
wyj aa9b97dc4f updates: add +x 2024-03-30 02:35:49 -04:00
3 changed files with 45 additions and 2 deletions
Regular → Executable
+2
View File
@@ -1,3 +1,5 @@
apt-get update
ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime
hwclock --systohc
Regular → Executable
+11 -2
View File
@@ -3,6 +3,10 @@
# assume that /mnt and /mnt/boot is mounted
TARGET=/mnt
DEVICE=$(findmnt -n -o SOURCE $TARGET | sed 's/\[.*//')
UUID=$(blkid -s UUID -o value ${DEVICE})
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
echo $DIR
debootstrap stable $TARGET http://deb.debian.org/debian/
@@ -17,8 +21,13 @@ mount --bind /sys/firmware/efi/efivars $TARGET/sys/firmware/efi/efivars
echo "deb http://deb.debian.org/debian stable main non-free-firmware" >$TARGET/etc/apt/sources.list
echo "export PATH=$PATH:/sbin/" >>$TARGET/root/.bashrc
cp ./chroot-commands.sh $TARGET/root/
cp $DIR/chroot-commands.sh $TARGET/root/
chmod +x $TARGET/root/chroot-commands.sh
chroot $TARGET /root/chroot-commands.sh
chroot $TARGET /bin/bash -l -c '/root/chroot-commands.sh'
# fix systemd-boot
for ENTRY in $TARGET/boot/loader/entries/*.conf; do
sed -i "s/root=UUID=[a-zA-Z0-9-]*/root=UUID=${UUID}/" "${ENTRY}"
done
echo "Done! Should be good to reboot now and run post-install scripts."
+32
View File
@@ -0,0 +1,32 @@
#!/bin/bash
# 检查 TARGETDISK 变量是否已定义
if [ -z "$TARGETDISK" ]; then
echo "TARGETDISK is not set. Please run the disk selector script first."
exit 1
fi
# 使用 gum confirm 警告:这将删除目标硬盘上的所有数据
if ! gum confirm --prompt "Warning: This will erase all data on $TARGETDISK. Proceed?"; then
echo "Aborting."
exit 1
fi
# 使用 parted 工具创建新的 GPT 分区表
parted -s "$TARGETDISK" mklabel gpt
# 创建 EFI 分区,大小为 512M,后面是系统分区,占据剩余空间
parted -s "$TARGETDISK" mkpart primary fat32 1MiB 513MiB
parted -s "$TARGETDISK" set 1 esp on
# 计算起始点,为 513MiB 后的第一个 MiB
parted -s "$TARGETDISK" mkpart primary btrfs 513MiB 100%
# 格式化 EFI 分区为 FAT32
mkfs.fat -F32 "${TARGETDISK}1"
# 格式化系统分区为 Btrfs
mkfs.btrfs "${TARGETDISK}2"
echo "Partitioning and formatting complete."