diff --git a/reinstall.sh b/reinstall.sh index 5f3243a..ac253a4 100644 --- a/reinstall.sh +++ b/reinstall.sh @@ -1622,15 +1622,13 @@ Continue with DD? } setos_fnos() { - if [ "$basearch" = aarch64 ]; then - error_and_exit "FNOS not supports ARM." - fi - # 系统盘大小 min=8 default=8 + echo "请输入系统分区大小,最小 $min GB,但可能无法更新系统。" + echo "Please input System Partition Size. Minimal is $min GB but may not be able to do system updates." while true; do - IFS= read -r -p "Type System Partition Size in GB. Minimal $min GB. [$default]: " input + IFS= read -r -p "Size in GB [$default]: " input input=${input:-$default} if ! { is_digit "$input" && [ "$input" -ge "$min" ]; }; then error "Invalid Size. Please Try again." @@ -1640,16 +1638,25 @@ Continue with DD? fi done - iso=$(curl -L https://fnnas.com/ | grep -o 'https://[^"]*\.iso' | head -1 | grep .) + if [ "$basearch" = aarch64 ]; then + if [ -z "$iso" ]; then + IFS= read -r -p "ISO Link: " iso + if [ -z "$iso" ]; then + error_and_exit "ISO Link is empty." + fi + fi + else + iso=$(curl -L https://fnnas.com/ | grep -o -m1 'https://[^"]*\.iso') - # curl 7.82.0+ - # curl -L --json '{"url":"'$iso'"}' https://www.fnnas.com/api/download-sign + # curl 7.82.0+ + # curl -L --json '{"url":"'$iso'"}' https://www.fnnas.com/api/download-sign - iso=$(curl -L \ - -d '{"url":"'$iso'"}' \ - -H 'Content-Type: application/json' \ - https://www.fnnas.com/api/download-sign | - grep -o 'https://[^"]*') + iso=$(curl -L \ + -d '{"url":"'$iso'"}' \ + -H 'Content-Type: application/json' \ + https://www.fnnas.com/api/download-sign | + grep -o 'https://[^"]*') + fi test_url "$iso" iso eval "${step}_iso='$iso'" diff --git a/trans.sh b/trans.sh index a001c67..c7ae231 100644 --- a/trans.sh +++ b/trans.sh @@ -2523,15 +2523,18 @@ create_part() { sector_size=$(get_disk_logic_sector_size /dev/$xda) total_sector_count=$(get_disk_sector_count /dev/$xda) - # 截止最后一个分区的总扇区数(也就是总硬盘扇区数 - 备份分区表扇区数) - if is_efi; then - total_sector_count_except_backup_gpt=$((total_sector_count - 33)) - else + # 截止最后一个分区的总扇区数(也就是总硬盘扇区数 - 备份分区表扇区数 - 备份 GPT Header) + if ! is_efi && ! is_xda_gt_2t; then + # mbr total_sector_count_except_backup_gpt=$total_sector_count + elif is_4kn; then + total_sector_count_except_backup_gpt=$((total_sector_count - 4 - 1)) + else + total_sector_count_except_backup_gpt=$((total_sector_count - 32 - 1)) fi # 向下取整 MiB - # gpt 最后 33 个扇区是备份分区表,不可用 + # gpt 最后 33 (512n/512e) 或 5 (4Kn) 个扇区是备份分区表,不可用 # parted 结束位置填 100% 时也会忽略最后不足 1MiB 的部分,我们模仿它 max_can_use_m=$((total_sector_count_except_backup_gpt * sector_size / 1024 / 1024)) @@ -2560,9 +2563,20 @@ create_part() { mkfs.fat /dev/$xda*1 #1 efi mkfs.ext4 -F $ext4_opts /dev/$xda*2 #2 os + installer + elif is_xda_gt_2t; then + # bios > 2t + # 官方安装器是 mkpart BOOT 1M 100M,无论 esp 或者 bios_grub 都用这个分区和大小 + parted /dev/$xda -s -- \ + mklabel gpt \ + mkpart BOOT ext4 1MiB 101MiB \ + mkpart SYSTEM ext4 101MiB $os_part_end \ + set 1 bios_grub on + update_part + + echo #1 bios_boot + mkfs.ext4 -F $ext4_opts /dev/$xda*2 #2 os + installer else # bios - # 官方安装器不支持 bios + >2t parted /dev/$xda -s -- \ mklabel msdos \ mkpart primary 1MiB 101MiB \ @@ -4310,7 +4324,14 @@ install_fnos() { mkdir -p $initrd_dir ( cd $initrd_dir - zcat /iso/install.amd/initrd.gz | cpio -idm + suffix=$( + case $(uname -m) in + x86_64) echo amd ;; + aarch64) echo a64 ;; + *) ;; + esac + ) + zcat /iso/install.$suffix/initrd.gz | cpio -idm ) apk del cpio @@ -4346,8 +4367,11 @@ install_fnos() { # 挂载 proc sys dev mount_pseudo_fs /os - # 更新 initrd - # chroot $os_dir update-initramfs -u + # 更新 initrd,官方安装器也有这一步 + # 理论上要设置 1777 权限,但飞牛官方安装器安装后不是 + mkdir -p $os_dir/var/tmp + chmod 1777 $os_dir/var/tmp + chroot $os_dir update-initramfs -u # 更改密码 if is_need_set_ssh_keys; then @@ -4370,10 +4394,14 @@ install_fnos() { chroot $os_dir grub-install /dev/$xda fi + # grub 配置 + # 取自 strings trim-install | grep GRUB_DISTRIBUTOR + sed -i 's/^GRUB_DISTRIBUTOR=.*/GRUB_DISTRIBUTOR="FNOS"/' $os_dir/etc/default/grub + # grub tty ttys_cmdline=$(get_ttys console=) - echo GRUB_CMDLINE_LINUX=\"\$GRUB_CMDLINE_LINUX $ttys_cmdline\" \ - >>$os_dir/etc/default/grub.d/tty.cfg + echo GRUB_CMDLINE_LINUX=\"\$GRUB_CMDLINE_LINUX $ttys_cmdline\" >$os_dir/etc/default/grub.d/tty.cfg + chroot $os_dir update-grub # fstab @@ -4382,8 +4410,9 @@ install_fnos() { uuid=$(lsblk /dev/$xda*2 -no UUID) echo "$fstab_line_os" | sed "s/%s/$uuid/" + # swapfile # 官方安装器即使 swapfile 设为 0 也会有这行 - echo "$fstab_line_swapfile" | sed "s/%s/$uuid/" + echo "$fstab_line_swapfile" # /boot/efi if is_efi; then @@ -5556,12 +5585,6 @@ is_list_has() { echo "$list" | grep -qFx "$item" } -# hivexget 是 shell 脚本,开头是 #!/bin/bash -# 但 alpine 没安装 bash,直接运行 hivexget 会报错 -hivexget() { - ash "$(which hivexget)" "$@" -} - get_windows_type_from_windows_drive() { local os_dir=$1