Compare commits

..

No commits in common. "8b60b7d2df35dc2185a4c0f72571a986d17b7ad2" and "b6bb27882d5726d90d7dbc3b93f51ec4a98958aa" have entirely different histories.

2 changed files with 13 additions and 48 deletions

View File

@ -339,8 +339,7 @@ test_url_real() {
real_type=$(file_enhanced $tmp_file)
echo "File type: $real_type"
# debian 9 ubuntu 16.04 可能会将 iso 识别成 raw
for type in $expect_types $([ "$expect_types" = iso ] && echo raw); do
for type in $expect_types; do
if [[ ."$real_type" = *."$type" ]]; then
# 如果要设置变量
if [ -n "$var_to_eval" ]; then
@ -1259,7 +1258,7 @@ Continue?
sort -uV | tail -1 | grep .)
iso=$mirror/$filename
# 在 ubuntu 20.04 上file 命令检测 ubuntu 22.04 iso 结果是 DOS/MBR boot sector
test_url "$iso" iso
test_url $iso 'iso raw'
eval ${step}_iso=$iso
# ks
@ -1390,12 +1389,13 @@ Continue?
if [[ "$iso" = magnet:* ]]; then
: # 不测试磁力链接
else
iso_filetype='iso raw'
iso_tested=false
# 获取 massgrave.dev 直链
if grep -Eiq '\.massgrave\.dev/.*\.(iso|img)' <<<"$iso"; then
# 如果已经是 iso 直链则跳过下面的 iso 测试
if test_url_grace "$iso" iso; then
if test_url_grace "$iso" "$iso_filetype"; then
iso_tested=true
else
msg="Could not find direct link for $iso"
@ -1407,7 +1407,7 @@ Continue?
# 测试是否是 iso
if ! $iso_tested; then
test_url "$iso" iso
test_url "$iso" "$iso_filetype"
fi
# 判断 iso 架构是否兼容
@ -1502,7 +1502,8 @@ Continue with DD?
done
iso=$(curl -L https://fnnas.com/ | grep -o 'https://[^"]*\.iso' | head -1)
test_url "$iso" iso
# debian 9 下 iso 会被识别为 raw
test_url "$iso" 'iso raw'
eval "${step}_iso='$iso'"
}

View File

@ -2224,7 +2224,7 @@ dd_raw_with_extract() {
fi
}
get_disk_sector_count() {
get_dick_sector_count() {
# cat /proc/partitions
blockdev --getsz "$1"
}
@ -2233,10 +2233,6 @@ get_disk_size() {
blockdev --getsize64 "$1"
}
get_disk_logic_sector_size() {
blockdev --getss "$1"
}
is_xda_gt_2t() {
disk_size=$(get_disk_size /dev/$xda)
disk_2t=$((2 * 1024 * 1024 * 1024 * 1024))
@ -2318,46 +2314,15 @@ create_part() {
# 因此直接用用户输入的分区大小
# 1. 官方安装器对系统盘大小的定义包含引导分区大小
# 2. 官方 efi 用的是 1MiB-100M但我们用 1MiB-101MiB
# 预期的系统分区大小,包括引导的 1M + 100M 的引导分区
expect_m=$((${fnos_part_size%[Gg]} * 1024))
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
total_sector_count_except_backup_gpt=$total_sector_count
fi
# 向下取整 MiB
# gpt 最后 33 个扇区是备份分区表,不可用
# parted 会忽略最后不足 1MiB 的部分
max_can_use_m=$((total_sector_count_except_backup_gpt * sector_size / 1024 / 1024))
echo "expect_m: $expect_m"
echo "max_can_use_m: $max_can_use_m"
# 20G 的硬盘,即使用 msdos 分区表parted 也不接受 part end 为 20480MiB因此要用 100%
# The location 20480MiB is outside of the device /dev/vda.
# 但是 100% 分区后 end 就是 20480MiB
os_part_end=${expect_m}MiB
if [ "$expect_m" -ge "$max_can_use_m" ]; then
echo "Expect size is equal/greater than max size. Setting to 100%"
os_part_end=100%
fi
# 2. 官方用的是 100M 而不是 100MiB
# 需关闭这几个特性,否则 grub 无法识别
ext4_opts="-O ^metadata_csum_seed,^orphan_file"
if is_efi; then
parted /dev/$xda -s -- \
mklabel gpt \
mkpart BOOT fat32 1MiB 101MiB \
mkpart SYSTEM ext4 101MiB $os_part_end \
mkpart BOOT fat32 1MiB 100M \
mkpart SYSTEM ext4 100M ${fnos_part_size}iB \
set 1 esp on
update_part
@ -2368,8 +2333,8 @@ create_part() {
# 官方安装器不支持 bios + >2t
parted /dev/$xda -s -- \
mklabel msdos \
mkpart primary 1MiB 101MiB \
mkpart primary 101MiB $os_part_end \
mkpart primary 1MiB 100M \
mkpart primary 100M ${fnos_part_size}iB \
set 2 boot on
update_part
@ -3927,7 +3892,6 @@ install_fnos() {
rm -rf $initrd_dir
# 复制 trimfs.tgz 并删除 ISO 以获得更多空间
echo "moving trimfs.tgz..."
cp /iso/trimfs.tgz /os/installer
umount /iso
rm /os/installer/fnos.iso