-
Notifications
You must be signed in to change notification settings - Fork 3
/
kvm-sfs
executable file
·50 lines (43 loc) · 1.13 KB
/
kvm-sfs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/sh
KERNEL=$1
SFS=$2
SCRIPT=$3
DIR=.
EXTRA_ARG="ignore_loglevel debug loglevel=8"
NR_CPU=2
MEM=2048
ROOT_FS=$DIR/appliance/root_fs.img
ROOT_DEV=/dev/vda
SERIAL="-serial telnet::8500,server,nowait \
-serial telnet::8501,server,nowait \
-serial telnet::8502,server,nowait"
# Prepare sfs folder on a separate hdd
RAW_SFS_FS=$DIR/sfs.raw
SFS_FS=$DIR/sfs.img
SFS_MNT=$DIR/sfs_mnt
mkdir -p $SFS_MNT
echo -n >| $RAW_SFS_FS
fallocate -l 1g $RAW_SFS_FS
mkfs -t ext4 $RAW_SFS_FS
mount -t ext4 -o loop $RAW_SFS_FS $SFS_MNT
rsync \
--exclude='*.ko' \
--exclude='*.o' \
--exclude='*.dwo' \
--exclude='Module.*' \
--exclude='modules.*' \
--exclude='mkfs-simplefs' \
-r $SFS/* $SFS_MNT/
umount $SFS_MNT
qemu-img convert -f raw -O qcow2 -o compat=0.10 -c $RAW_SFS_FS $SFS_FS
rm -f $RAW_SFS_FS
modprobe kvm-intel
kvm -boot order=c \
-drive file=$ROOT_FS,if=virtio,snapshot=on \
-drive file=$SFS_FS,cache=none,if=virtio \
-s \
-nographic -smp $NR_CPU -m $MEM \
-serial mon:stdio \
$SERIAL \
--kernel $KERNEL \
--append "root=$ROOT_DEV console=ttyS0,115200 run=$SCRIPT $EXTRA_ARG"