diff --git a/debian/changelog b/debian/changelog index 0dc9fd6..23dd1e4 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +kylin-os-installer (0.2.1-0k12) yangtze; urgency=medium + + * 小容量硬盘方案 + + -- tangzhicheng Fri, 14 Oct 2022 16:12:21 +0800 + kylin-os-installer (0.2.1-0k11) yangtze; urgency=medium * Rebuild from arm64. diff --git a/scripts/autopart-efi.sh b/scripts/autopart-efi.sh index 61c5a84..8af4888 100755 --- a/scripts/autopart-efi.sh +++ b/scripts/autopart-efi.sh @@ -17,6 +17,23 @@ disk=$(get_value devpath) size=$(fdisk -s "${disk}") real_size=$(( size / 1024 )) + +if [ $real_size -lt ${DISK_MINSIZE} ]; then + ### efi + efi=512 + ### boot + boot=1024 + + ### root + root_size=$(( real_size - efi - boot )) + + echo "efi: $efi" + echo "boot: $boot" + echo "root_size: $root_size" + return 0 + +fi + disk_custom=$(get_value disk-custom) if [[ "${disk_custom}" == "true" ]]; then diff --git a/scripts/autopart.sh b/scripts/autopart.sh index 87a6484..9e9c551 100755 --- a/scripts/autopart.sh +++ b/scripts/autopart.sh @@ -16,6 +16,19 @@ disk=$(get_value devpath) size=$(fdisk -s "${disk}") real_size=$(( size / 1024 )) +if [ $real_size -lt ${DISK_MINSIZE} ]; then + ### boot + boot=1024 + + ### root + root_size=$(( real_size - boot )) + + echo "boot: $boot" + echo "root_size: $root_size" + return 0 + +fi + disk_custom=$(get_value disk-custom) if [[ "${disk_custom}" == "true" ]]; then diff --git a/scripts/prepare/10partition b/scripts/prepare/10partition index cc09bdd..570ee51 100755 --- a/scripts/prepare/10partition +++ b/scripts/prepare/10partition @@ -32,6 +32,13 @@ start=$((start + 1)) if [[ "${isluks_lvm}" == "true" ]]; then parted -s "${disk}" mkpart logical ext4 "${start}"MiB 100% else + if [ $real_size -lt ${DISK_MINSIZE} ]; then + parted -s "${disk}" mkpart logical ext4 "${start}"MiB 100% + parted -s "${disk}" set 1 boot on + partprobe "${disk}" + sync + return 0 + fi parted -s "${disk}" mkpart logical ext4 "${start}"MiB "${end}"MiB fi @@ -55,6 +62,12 @@ if [[ "${isluks_lvm}" == "true" ]]; then echo "${disk##*/}5_crypt UUID=${root_uuid} none luks" >/etc/crypttab pvcreate -ffy /dev/mapper/"${disk##*/}"5_crypt vgcreate kylin-vg /dev/mapper/"${disk##*/}"5_crypt + + if [ $real_size -lt ${DISK_MINSIZE} ]; then + lvcreate --wipesignatures n -l 100%free -n root kylin-vg + return 0 + fi + lvcreate --wipesignatures n -L "${root_size}" -n root kylin-vg lvcreate --wipesignatures n -L "${backup_size}" -n backup kylin-vg lvcreate --wipesignatures n -L "${data_size}" -n data kylin-vg diff --git a/scripts/prepare/10partition-efi b/scripts/prepare/10partition-efi index 21f9182..2e71a13 100755 --- a/scripts/prepare/10partition-efi +++ b/scripts/prepare/10partition-efi @@ -34,6 +34,13 @@ end=$((end + root_size)) if [[ "${isluks_lvm}" == "true" ]]; then parted -s "${disk}" mkpart "SYSROOT" ext4 "${start}"MiB 100% else + if [ $real_size -lt ${DISK_MINSIZE} ]; then + parted -s "${disk}" mkpart "SYSROOT" ext4 "${start}"MiB 100% + parted -s "${disk}" set 1 esp on + partprobe "${disk}" + sync + return 0 + fi parted -s "${disk}" mkpart "SYSROOT" ext4 "${start}"MiB "${end}"MiB fi @@ -58,6 +65,12 @@ if [[ "${isluks_lvm}" == "true" ]]; then echo "${disk##*/}3_crypt UUID=${root_uuid} none luks" >/etc/crypttab pvcreate -ffy /dev/mapper/"${disk##*/}"3_crypt vgcreate kylin-vg /dev/mapper/"${disk##*/}"3_crypt + + if [ $real_size -lt ${DISK_MINSIZE} ]; then + lvcreate --wipesignatures n -l 100%free -n root kylin-vg + return 0 + fi + lvcreate --wipesignatures n -L "${root_size}" -n root kylin-vg lvcreate --wipesignatures n -L "${backup_size}" -n backup kylin-vg lvcreate --wipesignatures n -L "${data_size}" -n data kylin-vg diff --git a/scripts/prepare/13mount-target b/scripts/prepare/13mount-target index 07478bb..7861519 100755 --- a/scripts/prepare/13mount-target +++ b/scripts/prepare/13mount-target @@ -70,6 +70,20 @@ if [[ "${is_efi}" == "true" ]]; then part_swap="/dev/mapper/kylin--vg-swap" fi + if [ $real_size -lt ${DISK_MINSIZE} ]; then + + mkfs.ext4 -Fq -L SYSROOT "${part_root}" + + mkdir -p /target + mount "${part_root}" /target + mkdir -p /target/boot + mount "${disk}2" /target/boot + mkdir -p /target/boot/efi + mount "${disk}1" /target/boot/efi + + return 0 + fi + mkfs.ext4 -Fq -L SYSROOT "${part_root}" mkfs.ext4 -Fq -L KYLIN-BACKUP "${part_backup}" mkfs.ext4 -Fq -L DATA "${part_data}" @@ -116,6 +130,17 @@ else part_data="/dev/mapper/kylin--vg-data" part_swap="/dev/mapper/kylin--vg-swap" fi + + if [ $real_size -lt ${DISK_MINSIZE} ]; then + + mkfs.ext4 -Fq -L SYSROOT "${part_root}" + mkdir -p /target + mount "${part_root}" /target + mkdir -p /target/boot + mount "${disk}1" /target/boot + + return 0 + fi mkfs.ext4 -Fq -L SYSROOT "${part_root}" mkfs.ext4 -Fq -L KYLIN-BACKUP "${part_backup}" diff --git a/scripts/utils b/scripts/utils index 9221737..4b428d7 100644 --- a/scripts/utils +++ b/scripts/utils @@ -6,6 +6,8 @@ CONFIGFILE=/tmp/ky-installer.cfg LOG_FILE=/var/log/installer/kylin-os-installer.log IN_TARGET=/tmp/k-i/ +DISK_MINSIZE=32799 + msg() { echo "$(date +'%Y-%m-%d %H:%M:%S') $*" >&2 }