小容量硬盘方案

This commit is contained in:
tangzhicheng 2022-10-14 16:13:22 +08:00
parent dc0cfa482e
commit b3b8ce54c7
7 changed files with 89 additions and 0 deletions

6
debian/changelog vendored
View File

@ -1,3 +1,9 @@
kylin-os-installer (0.2.1-0k12) yangtze; urgency=medium
* 小容量硬盘方案
-- tangzhicheng <tangzhicheng@kylinos.cn> Fri, 14 Oct 2022 16:12:21 +0800
kylin-os-installer (0.2.1-0k11) yangtze; urgency=medium
* Rebuild from arm64.

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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}"
@ -117,6 +131,17 @@ else
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}"
mkfs.ext4 -Fq -L DATA "${part_data}"

View File

@ -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
}