mirror of
https://github.com/bin456789/reinstall.git
synced 2025-07-07 19:49:51 +00:00
Compare commits
2 Commits
b6bb27882d
...
8b60b7d2df
Author | SHA1 | Date | |
---|---|---|---|
![]() |
8b60b7d2df | ||
![]() |
70fcc01988 |
13
reinstall.sh
13
reinstall.sh
@ -339,7 +339,8 @@ test_url_real() {
|
||||
real_type=$(file_enhanced $tmp_file)
|
||||
echo "File type: $real_type"
|
||||
|
||||
for type in $expect_types; do
|
||||
# debian 9 ubuntu 16.04 可能会将 iso 识别成 raw
|
||||
for type in $expect_types $([ "$expect_types" = iso ] && echo raw); do
|
||||
if [[ ."$real_type" = *."$type" ]]; then
|
||||
# 如果要设置变量
|
||||
if [ -n "$var_to_eval" ]; then
|
||||
@ -1258,7 +1259,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 raw'
|
||||
test_url "$iso" iso
|
||||
eval ${step}_iso=$iso
|
||||
|
||||
# ks
|
||||
@ -1389,13 +1390,12 @@ 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_filetype"; then
|
||||
if test_url_grace "$iso" iso; 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_filetype"
|
||||
test_url "$iso" iso
|
||||
fi
|
||||
|
||||
# 判断 iso 架构是否兼容
|
||||
@ -1502,8 +1502,7 @@ Continue with DD?
|
||||
done
|
||||
|
||||
iso=$(curl -L https://fnnas.com/ | grep -o 'https://[^"]*\.iso' | head -1)
|
||||
# debian 9 下 iso 会被识别为 raw
|
||||
test_url "$iso" 'iso raw'
|
||||
test_url "$iso" iso
|
||||
eval "${step}_iso='$iso'"
|
||||
}
|
||||
|
||||
|
48
trans.sh
48
trans.sh
@ -2224,7 +2224,7 @@ dd_raw_with_extract() {
|
||||
fi
|
||||
}
|
||||
|
||||
get_dick_sector_count() {
|
||||
get_disk_sector_count() {
|
||||
# cat /proc/partitions
|
||||
blockdev --getsz "$1"
|
||||
}
|
||||
@ -2233,6 +2233,10 @@ 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))
|
||||
@ -2314,15 +2318,46 @@ create_part() {
|
||||
# 因此直接用用户输入的分区大小
|
||||
|
||||
# 1. 官方安装器对系统盘大小的定义包含引导分区大小
|
||||
# 2. 官方用的是 100M 而不是 100MiB
|
||||
# 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
|
||||
|
||||
# 需关闭这几个特性,否则 grub 无法识别
|
||||
ext4_opts="-O ^metadata_csum_seed,^orphan_file"
|
||||
if is_efi; then
|
||||
parted /dev/$xda -s -- \
|
||||
mklabel gpt \
|
||||
mkpart BOOT fat32 1MiB 100M \
|
||||
mkpart SYSTEM ext4 100M ${fnos_part_size}iB \
|
||||
mkpart BOOT fat32 1MiB 101MiB \
|
||||
mkpart SYSTEM ext4 101MiB $os_part_end \
|
||||
set 1 esp on
|
||||
update_part
|
||||
|
||||
@ -2333,8 +2368,8 @@ create_part() {
|
||||
# 官方安装器不支持 bios + >2t
|
||||
parted /dev/$xda -s -- \
|
||||
mklabel msdos \
|
||||
mkpart primary 1MiB 100M \
|
||||
mkpart primary 100M ${fnos_part_size}iB \
|
||||
mkpart primary 1MiB 101MiB \
|
||||
mkpart primary 101MiB $os_part_end \
|
||||
set 2 boot on
|
||||
update_part
|
||||
|
||||
@ -3892,6 +3927,7 @@ 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
|
||||
|
Loading…
x
Reference in New Issue
Block a user