Create template with plain root.img without partitions (#118)
Additionaly provide clean-volatile.img
This commit is contained in:
parent
946012e091
commit
7054456eb7
Binary file not shown.
BIN
clean_images/clean-volatile.img.tar
Normal file
BIN
clean_images/clean-volatile.img.tar
Normal file
Binary file not shown.
@ -13,7 +13,7 @@ if ! [ -f $IMG ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
ls -als $IMG
|
ls -als $IMG
|
||||||
mount -o loop,offset=$((63*512)) $IMG mnt || exit 1
|
mount -o loop $IMG mnt || exit 1
|
||||||
INSTALLDIR=`pwd`/mnt/
|
INSTALLDIR=`pwd`/mnt/
|
||||||
yum clean packages --installroot=$INSTALLDIR
|
yum clean packages --installroot=$INSTALLDIR
|
||||||
dd if=/dev/zero of=mnt/fillme bs=1M
|
dd if=/dev/zero of=mnt/fillme bs=1M
|
||||||
|
@ -11,17 +11,18 @@ fi
|
|||||||
|
|
||||||
if [ -f $IMG ]; then
|
if [ -f $IMG ]; then
|
||||||
echo "-> Image file already exists, assuming *update*..."
|
echo "-> Image file already exists, assuming *update*..."
|
||||||
mount -o loop,offset=$((63*512)) $IMG mnt || exit 1
|
mount -o loop $IMG mnt || exit 1
|
||||||
INSTALLDIR=`pwd`/mnt/
|
INSTALLDIR=`pwd`/mnt/
|
||||||
else
|
else
|
||||||
|
|
||||||
echo "-> Initializing empty image with part table and filesystems..."
|
echo "-> Initializing empty image..."
|
||||||
tar kOxf clean_images/clean-starter.img.tar > $IMG
|
truncate -s 10G $IMG || exit 1
|
||||||
|
|
||||||
touch $IMG || exit 1
|
echo "-> Creating filesystem..."
|
||||||
|
mkfs.ext4 -F $IMG || exit 1
|
||||||
|
|
||||||
mkdir -p mnt
|
mkdir -p mnt
|
||||||
mount -o loop,offset=$((63*512)) $IMG mnt || exit 1
|
mount -o loop $IMG mnt || exit 1
|
||||||
|
|
||||||
INSTALLDIR=`pwd`/mnt/
|
INSTALLDIR=`pwd`/mnt/
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ cp $CLEANIMG $IMG || exit 1
|
|||||||
echo "--> Mouting $IMG"
|
echo "--> Mouting $IMG"
|
||||||
|
|
||||||
mkdir -p mnt
|
mkdir -p mnt
|
||||||
mount -o loop,offset=$((63*512)) $IMG mnt || exit 1
|
mount -o loop $IMG mnt || exit 1
|
||||||
|
|
||||||
echo "--> Installing RPMs..."
|
echo "--> Installing RPMs..."
|
||||||
rpm --force --root=$(pwd)/mnt -ihv rpms_to_install/*
|
rpm --force --root=$(pwd)/mnt -ihv rpms_to_install/*
|
||||||
|
@ -40,6 +40,8 @@ for i in qubeized_images/root.img.part.* ; do ln $i $RPM_BUILD_ROOT/%{dest_dir}/
|
|||||||
touch $RPM_BUILD_ROOT/%{dest_dir}/root.img # we will create the real file in %post
|
touch $RPM_BUILD_ROOT/%{dest_dir}/root.img # we will create the real file in %post
|
||||||
touch $RPM_BUILD_ROOT/%{dest_dir}/private.img # we will create the real file in %post
|
touch $RPM_BUILD_ROOT/%{dest_dir}/private.img # we will create the real file in %post
|
||||||
|
|
||||||
|
cp clean_images/clean-volatile.img.tar $RPM_BUILD_ROOT/%{dest_dir}/clean-volatile.img.tar
|
||||||
|
|
||||||
cp vm_conf_files/appvm-template.conf $RPM_BUILD_ROOT/%{dest_dir}/appvm-template.conf
|
cp vm_conf_files/appvm-template.conf $RPM_BUILD_ROOT/%{dest_dir}/appvm-template.conf
|
||||||
cp vm_conf_files/netvm-template.conf $RPM_BUILD_ROOT/%{dest_dir}/netvm-template.conf
|
cp vm_conf_files/netvm-template.conf $RPM_BUILD_ROOT/%{dest_dir}/netvm-template.conf
|
||||||
cp vm_conf_files/templatevm.conf $RPM_BUILD_ROOT/%{dest_dir}/templatevm.conf
|
cp vm_conf_files/templatevm.conf $RPM_BUILD_ROOT/%{dest_dir}/templatevm.conf
|
||||||
@ -78,6 +80,9 @@ mv %{dest_dir}/%{template_name}-root.img %{dest_dir}/root.img
|
|||||||
chown root.qubes %{dest_dir}/root.img
|
chown root.qubes %{dest_dir}/root.img
|
||||||
chmod 0660 %{dest_dir}/root.img
|
chmod 0660 %{dest_dir}/root.img
|
||||||
|
|
||||||
|
echo "--> Processing the clean-volatile.img..."
|
||||||
|
tar --sparse -xf {dest_dir}/clean-volatile.img.tar -C %{dest_dir}
|
||||||
|
|
||||||
if [ "$1" = 1 ] ; then
|
if [ "$1" = 1 ] ; then
|
||||||
# installing for the first time
|
# installing for the first time
|
||||||
echo "--> Creating private.img..."
|
echo "--> Creating private.img..."
|
||||||
@ -126,6 +131,8 @@ rm -rf $RPM_BUILD_ROOT
|
|||||||
%dir %{dest_dir}
|
%dir %{dest_dir}
|
||||||
%ghost %{dest_dir}/root.img
|
%ghost %{dest_dir}/root.img
|
||||||
%{dest_dir}/root.img.part.*
|
%{dest_dir}/root.img.part.*
|
||||||
|
%ghost %{dest_dir}/clean-volatile.img
|
||||||
|
%{dest_dir}/clean-volatile.img.tar
|
||||||
%ghost %{dest_dir}/private.img
|
%ghost %{dest_dir}/private.img
|
||||||
%{dest_dir}/appvm-template.conf
|
%{dest_dir}/appvm-template.conf
|
||||||
%{dest_dir}/netvm-template.conf
|
%{dest_dir}/netvm-template.conf
|
||||||
|
@ -12,8 +12,7 @@ name = "%VMNAME%"
|
|||||||
|
|
||||||
disk = [ 'snapshot:%TEMPLATEDIR%/root.img:%TEMPLATEDIR%/root-cow.img,xvda,r',
|
disk = [ 'snapshot:%TEMPLATEDIR%/root.img:%TEMPLATEDIR%/root-cow.img,xvda,r',
|
||||||
'file:%VMDIR%/private.img,xvdb,w',
|
'file:%VMDIR%/private.img,xvdb,w',
|
||||||
'file:%VMDIR%/root-cow.img,xvdc,w',
|
'file:%VMDIR%/volatile.img,xvdc,w',
|
||||||
'file:%VMDIR%/swap-cow.img,xvdd,w'
|
|
||||||
]
|
]
|
||||||
|
|
||||||
vcpus = %VCPUS%
|
vcpus = %VCPUS%
|
||||||
|
@ -14,8 +14,7 @@ pci = [ %PCIDEVS% ]
|
|||||||
|
|
||||||
disk = [ 'snapshot:%TEMPLATEDIR%/root.img:%TEMPLATEDIR%/root-cow.img,xvda,r',
|
disk = [ 'snapshot:%TEMPLATEDIR%/root.img:%TEMPLATEDIR%/root-cow.img,xvda,r',
|
||||||
'file:%VMDIR%/private.img,xvdb,w',
|
'file:%VMDIR%/private.img,xvdb,w',
|
||||||
'file:%VMDIR%/root-cow.img,xvdc,w',
|
'file:%VMDIR%/volatile.img,xvdc,w',
|
||||||
'file:%VMDIR%/swap-cow.img,xvdd,w'
|
|
||||||
]
|
]
|
||||||
|
|
||||||
vcpus = %VCPUS%
|
vcpus = %VCPUS%
|
||||||
|
@ -12,6 +12,7 @@ name = "%VMNAME%"
|
|||||||
|
|
||||||
disk = [ 'file:%VMDIR%/root.img,xvda,w',
|
disk = [ 'file:%VMDIR%/root.img,xvda,w',
|
||||||
'file:%VMDIR%/private.img,xvdb,w'
|
'file:%VMDIR%/private.img,xvdb,w'
|
||||||
|
'file:%VMDIR%/volatile.img,xvdc,w'
|
||||||
]
|
]
|
||||||
|
|
||||||
vcpus = %VCPUS%
|
vcpus = %VCPUS%
|
||||||
|
@ -12,6 +12,7 @@ name = "%TEMPLATENAME%"
|
|||||||
|
|
||||||
disk = [ 'origin:/var/lib/qubes/vm-templates/%TEMPLATENAME%/root.img:/var/lib/qubes/vm-templates/%TEMPLATENAME%/root-cow.img,xvda,w',
|
disk = [ 'origin:/var/lib/qubes/vm-templates/%TEMPLATENAME%/root.img:/var/lib/qubes/vm-templates/%TEMPLATENAME%/root-cow.img,xvda,w',
|
||||||
'file:/var/lib/qubes/vm-templates/%TEMPLATENAME%/private.img,xvdb,w',
|
'file:/var/lib/qubes/vm-templates/%TEMPLATENAME%/private.img,xvdb,w',
|
||||||
|
'file:/var/lib/qubes/vm-templates/%TEMPLATENAME%/volatile.img,xvdc,w',
|
||||||
]
|
]
|
||||||
|
|
||||||
vcpus = 1
|
vcpus = 1
|
||||||
|
@ -13,25 +13,19 @@ modprobe xenblk || modprobe xen-blkfront || echo "Qubes: Cannot load Xen Block F
|
|||||||
|
|
||||||
echo "Waiting for /dev/xvda* devices..."
|
echo "Waiting for /dev/xvda* devices..."
|
||||||
while ! [ -e /dev/xvda ]; do sleep 0.1; done
|
while ! [ -e /dev/xvda ]; do sleep 0.1; done
|
||||||
while ! [ -e /dev/xvda1 ] ; do sleep 0.1; done
|
|
||||||
while ! [ -e /dev/xvda2 ] ; do sleep 0.1; done
|
|
||||||
|
|
||||||
if [ `blockdev --getro /dev/xvda` = 1 ] ; then
|
if [ `blockdev --getro /dev/xvda` = 1 ] ; then
|
||||||
echo "Qubes: Doing COW setup for AppVM..."
|
echo "Qubes: Doing COW setup for AppVM..."
|
||||||
|
|
||||||
while ! [ -e /dev/xvdc ]; do sleep 0.1; done
|
while ! [ -e /dev/xvdc ]; do sleep 0.1; done
|
||||||
while ! [ -e /dev/xvdd ]; do sleep 0.1; done
|
while ! [ -e /dev/xvdc2 ]; do sleep 0.1; done
|
||||||
|
|
||||||
echo "0 `blockdev --getsz /dev/xvda1` snapshot /dev/xvda1 /dev/xvdc P 16" | \
|
echo "0 `blockdev --getsz /dev/xvda` snapshot /dev/xvda /dev/xvdc2 P 16" | \
|
||||||
dmsetup create dmroot || { echo "Qubes: FATAL: cannot create dmroot!"; }
|
dmsetup create dmroot || { echo "Qubes: FATAL: cannot create dmroot!"; }
|
||||||
echo "0 `blockdev --getsz /dev/xvda2` snapshot /dev/xvda2 /dev/xvdd P 16" | \
|
|
||||||
dmsetup create dmswap || { echo "Qubes: FATAL: cannot create dmswap!"; }
|
|
||||||
echo Qubes: done.
|
echo Qubes: done.
|
||||||
else
|
else
|
||||||
echo "Qubes: Doing R/W setup for TemplateVM..."
|
echo "Qubes: Doing R/W setup for TemplateVM..."
|
||||||
echo "0 `blockdev --getsz /dev/xvda1` linear /dev/xvda1 0" | \
|
echo "0 `blockdev --getsz /dev/xvda` linear /dev/xvda 0" | \
|
||||||
dmsetup create dmroot || { echo "Qubes: FATAL: cannot create dmroot!"; exit 1; }
|
dmsetup create dmroot || { echo "Qubes: FATAL: cannot create dmroot!"; exit 1; }
|
||||||
echo "0 `blockdev --getsz /dev/xvda2` linear /dev/xvda2 0" | \
|
|
||||||
dmsetup create dmswap || { echo "Qubes: FATAL: cannot create dmswap!"; exit 1; }
|
|
||||||
echo Qubes: done.
|
echo Qubes: done.
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user