mirror of
https://github.com/siderolabs/talos.git
synced 2025-08-30 19:11:13 +02:00
core(generate): use first unused loopback device (#112)
This commit is contained in:
parent
ea1edbbfa9
commit
7b12d6f042
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
LOOPBACK_DEVICE=$(losetup -f)
|
||||||
|
|
||||||
function size() {
|
function size() {
|
||||||
du -sm ./ | cut -f1
|
du -sm ./ | cut -f1
|
||||||
}
|
}
|
||||||
@ -27,13 +29,13 @@ function raw() {
|
|||||||
parted -s -a optimal /dianemo.raw mkpart ESP fat32 0 50M
|
parted -s -a optimal /dianemo.raw mkpart ESP fat32 0 50M
|
||||||
parted -s -a optimal /dianemo.raw mkpart ROOT xfs 50M $(($(size) + 100))M
|
parted -s -a optimal /dianemo.raw mkpart ROOT xfs 50M $(($(size) + 100))M
|
||||||
parted -s -a optimal /dianemo.raw mkpart DATA xfs $(($(size) + 100))M 100%
|
parted -s -a optimal /dianemo.raw mkpart DATA xfs $(($(size) + 100))M 100%
|
||||||
losetup /dev/loop0 /dianemo.raw
|
losetup ${LOOPBACK_DEVICE} /dianemo.raw
|
||||||
partx -av /dev/loop0
|
partx -av ${LOOPBACK_DEVICE}
|
||||||
sgdisk /dev/loop0 --attributes=1:set:2
|
sgdisk ${LOOPBACK_DEVICE} --attributes=1:set:2
|
||||||
mkfs.vfat /dev/loop0p1
|
mkfs.vfat ${LOOPBACK_DEVICE}p1
|
||||||
mkfs.xfs -n ftype=1 -L ROOT /dev/loop0p2
|
mkfs.xfs -n ftype=1 -L ROOT ${LOOPBACK_DEVICE}p2
|
||||||
mkfs.xfs -n ftype=1 -L DATA /dev/loop0p3
|
mkfs.xfs -n ftype=1 -L DATA ${LOOPBACK_DEVICE}p3
|
||||||
mount /dev/loop0p1 /mnt
|
mount ${LOOPBACK_DEVICE}p1 /mnt
|
||||||
mkdir -p /mnt/boot/extlinux
|
mkdir -p /mnt/boot/extlinux
|
||||||
extlinux --install /mnt/boot/extlinux
|
extlinux --install /mnt/boot/extlinux
|
||||||
cat <<EOF >/mnt/boot/extlinux/extlinux.conf
|
cat <<EOF >/mnt/boot/extlinux/extlinux.conf
|
||||||
@ -46,14 +48,14 @@ LABEL Dianemo
|
|||||||
EOF
|
EOF
|
||||||
cp -v /rootfs/boot/* /mnt/boot
|
cp -v /rootfs/boot/* /mnt/boot
|
||||||
umount /mnt
|
umount /mnt
|
||||||
mount /dev/loop0p2 /mnt
|
mount ${LOOPBACK_DEVICE}p2 /mnt
|
||||||
cp -Rv ./* /mnt
|
cp -Rv ./* /mnt
|
||||||
rm -rf /mnt/boot
|
rm -rf /mnt/boot
|
||||||
rm -rf /mnt/var/*
|
rm -rf /mnt/var/*
|
||||||
umount /mnt
|
umount /mnt
|
||||||
mount /dev/loop0p3 /mnt
|
mount ${LOOPBACK_DEVICE}p3 /mnt
|
||||||
cp -Rv ./var/* /mnt
|
cp -Rv ./var/* /mnt
|
||||||
dd if=/usr/local/src/syslinux/efi64/mbr/gptmbr.bin of=/dev/loop0
|
dd if=/usr/local/src/syslinux/efi64/mbr/gptmbr.bin of=${LOOPBACK_DEVICE}
|
||||||
cleanup
|
cleanup
|
||||||
cp -v /dianemo.raw /out
|
cp -v /dianemo.raw /out
|
||||||
qemu-img convert -f raw -O vmdk /out/dianemo.raw /out/dianemo.vmdk
|
qemu-img convert -f raw -O vmdk /out/dianemo.raw /out/dianemo.vmdk
|
||||||
@ -64,16 +66,16 @@ function rootfs() {
|
|||||||
parted -s /rootfs.raw mklabel gpt
|
parted -s /rootfs.raw mklabel gpt
|
||||||
parted -s -a optimal /rootfs.raw mkpart ROOT xfs 0 $(($(size) + 50))M
|
parted -s -a optimal /rootfs.raw mkpart ROOT xfs 0 $(($(size) + 50))M
|
||||||
parted -s -a optimal /rootfs.raw mkpart DATA xfs $(($(size) + 50))M 100%
|
parted -s -a optimal /rootfs.raw mkpart DATA xfs $(($(size) + 50))M 100%
|
||||||
losetup /dev/loop0 /rootfs.raw
|
losetup ${LOOPBACK_DEVICE} /rootfs.raw
|
||||||
partx -av /dev/loop0
|
partx -av ${LOOPBACK_DEVICE}
|
||||||
mkfs.xfs -n ftype=1 -L ROOT /dev/loop0p1
|
mkfs.xfs -n ftype=1 -L ROOT ${LOOPBACK_DEVICE}p1
|
||||||
mkfs.xfs -n ftype=1 -L DATA /dev/loop0p2
|
mkfs.xfs -n ftype=1 -L DATA ${LOOPBACK_DEVICE}p2
|
||||||
mount /dev/loop0p1 /mnt
|
mount ${LOOPBACK_DEVICE}p1 /mnt
|
||||||
cp -Rv ./* /mnt
|
cp -Rv ./* /mnt
|
||||||
rm -rf /mnt/boot
|
rm -rf /mnt/boot
|
||||||
rm -rf /mnt/var/*
|
rm -rf /mnt/var/*
|
||||||
umount /mnt
|
umount /mnt
|
||||||
mount /dev/loop0p2 /mnt
|
mount ${LOOPBACK_DEVICE}p2 /mnt
|
||||||
cp -Rv ./var/* /mnt
|
cp -Rv ./var/* /mnt
|
||||||
cleanup
|
cleanup
|
||||||
cp -v ./boot/vmlinuz /out
|
cp -v ./boot/vmlinuz /out
|
||||||
@ -83,8 +85,8 @@ function rootfs() {
|
|||||||
|
|
||||||
function cleanup {
|
function cleanup {
|
||||||
umount /mnt || true
|
umount /mnt || true
|
||||||
partx -dv /dev/loop0 || true
|
partx -dv ${LOOPBACK_DEVICE} || true
|
||||||
losetup -d /dev/loop0 || true
|
losetup -d ${LOOPBACK_DEVICE} || true
|
||||||
}
|
}
|
||||||
|
|
||||||
trap cleanup EXIT
|
trap cleanup EXIT
|
||||||
|
Loading…
x
Reference in New Issue
Block a user