代码拉取完成,页面将自动刷新
#! /bin/sh
if [ -z "$@" ] ; then
cat << EOF
Usage:
% ${0} block-device-name
e.g. block-device-name is sda.
EOF
exit
fi
if [ ! -b /dev/${1} ] ; then
cat << EOF
/dev/${1} does not exist.
EOF
exit
fi
FSSIZE=$(( $(cat /sys/block/${1}/size)/2048-1 ))
if [ "${FSSIZE}" -gt 8192 ] ; then
cat << EOF
/dev/${1} has more than 8GB space. Enter 4GB to create a 4GB partition or between 8MB and 16MB:
EOF
read PCNT
[ "${PCNT}" = "4GB" ] && FSSIZE=4096
[ "${PCNT%MB}MB" = "${PCNT}" ] && FSSIZE=${PCNT%MB}
fi
cat << EOF
Wipe /dev/${1}? Enter YES to continue:
EOF
read WCNT
if [ "${WCNT}" != "YES" ] ; then
exit
fi
[ -b /dev/${1}2 ] && wipefs -a /dev/${1}2
[ -b /dev/${1}3 ] && dd if=/dev/zero of=/dev/${1}3 count=2014
wipefs -a /dev/${1}
parted /dev/${1} mklabel msdos
parted /dev/${1} mkpart primary fat32 1MiB "${FSSIZE}MiB"
parted /dev/${1} set 1 boot on
partprobe
sync
sleep 3
[ $FSSIZE -gt 16 ] || LABEL="-n DEEPINOS"
if [ "${#1}" -lt 4 ] ; then
mkfs.fat ${LABEL} /dev/${1}1
else
mkfs.fat ${LABEL} /dev/${1}p1
fi
[ $FSSIZE -gt 16 ] || {
parted /dev/${1} mkpart primary ext2 "${FSSIZE}MiB" -- -34s
[ "${#1}" -lt 4 ] && {
partprobe
sync
sleep 3
"${0%/*}/convert-to-gpt.sh" "${1}"
mkfs.f2fs -a 0 -e squashfs -l medium /dev/${1}2
[ -f "$(dirname ${0%/*})/Downloads/Deepin-Live.iso" ] && {
[ -d /tmp/iso ] || mkdir /tmp/iso
[ -d /tmp/usb ] || mkdir /tmp/usb
mount -o ro $(losetup --read-only --show -P -f "$(dirname ${0%/*})/Downloads/Deepin-Live.iso")p1 /tmp/iso
# Setting autoclear manually for the loop device is necessary when -P partition scan is used.
losetup --detach $(losetup -j "$(dirname ${0%/*})/Downloads/Deepin-Live.iso" | cut -d: -f1)
mount /dev/${1}1 /tmp/usb
tar cvf - -C /tmp/iso EFI | tar xf - -C /tmp/usb
tar cvf - --no-recursion -C /tmp/iso boot | tar xf - -C /tmp/usb
umount /tmp/usb
mount /dev/${1}2 /tmp/usb
tar cvf - --exclude EFI --exclude isolinux -C /tmp/iso . | tar xf - -C /tmp/usb
sync
umount /tmp/usb
umount --detach-loop /tmp/iso
rmdir /tmp/iso /tmp/usb
}
cat << EOF
Create BIOS/GPT boot partition? Type YES to continue:
EOF
read WCNT
if [ "${WCNT}" != "YES" ] ; then
exit
fi
parted /dev/${1} mkpart " " fat16 34s 2047s Ignore align-check min 3
parted /dev/${1} set 3 bios_grub on
partprobe
sync
sleep 1
udisksctl mount --block-device /dev/${1}2
findmnt --noheadings --output=target /dev/${1}2 && {
grub-install --target=i386-pc --debug --boot-directory="$(findmnt --noheadings --output=target /dev/${1}2)/boot" /dev/${1}
udisksctl unmount --block-device /dev/${1}2
}
}
exit
}
cat << EOF
Now, run Deepin Boot Maker to install your ISO to disk.
EOF
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。