Creating VM image is working
This commit is contained in:
parent
82c27b7221
commit
6ad86cf1d4
1 changed files with 26 additions and 13 deletions
|
|
@ -1,6 +1,8 @@
|
||||||
#!/usr/bin/env zsh
|
#!/usr/bin/env zsh
|
||||||
|
|
||||||
export LINUX_DISK_IMG=/home/artur/winux/VM/linux/linux.img
|
#export LINUX_DISK_IMG=/home/artur/winux/VM/linux/linux.img
|
||||||
|
export LINUX_DISK_IMG=/home/artur/winux/VM/deb-orig/debian.img
|
||||||
|
|
||||||
export WINUX_DISK_IMG=./winux.img
|
export WINUX_DISK_IMG=./winux.img
|
||||||
|
|
||||||
# Mount the image of oryginal
|
# Mount the image of oryginal
|
||||||
|
|
@ -9,6 +11,14 @@ export WINUX_DISK_IMG=./winux.img
|
||||||
# Mounting the image
|
# Mounting the image
|
||||||
function wxumount {
|
function wxumount {
|
||||||
echo "unmounting :$1"
|
echo "unmounting :$1"
|
||||||
|
while lsof +D $1 >/dev/null 2>&1 || fuser $1 >/dev/null 2>&1
|
||||||
|
do
|
||||||
|
fuser -a $1
|
||||||
|
echo "Waiting for $1 to be free..."
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
mkdir -p $1
|
mkdir -p $1
|
||||||
if mountpoint -q $1; then
|
if mountpoint -q $1; then
|
||||||
echo "Unmounting $1..."
|
echo "Unmounting $1..."
|
||||||
|
|
@ -74,7 +84,7 @@ export LINUX_LOOP_DEV="$(losetup --find --show --partscan $LINUX_DISK_IMG)"
|
||||||
mount ${LINUX_LOOP_DEV}p1 /mnt/linux
|
mount ${LINUX_LOOP_DEV}p1 /mnt/linux
|
||||||
|
|
||||||
# copying files
|
# copying files
|
||||||
|
SAVED_PWD=`pwd`
|
||||||
cd /mnt/linux
|
cd /mnt/linux
|
||||||
tar --numeric-owner --xattrs --acls -cpf - \
|
tar --numeric-owner --xattrs --acls -cpf - \
|
||||||
--exclude='lost+found' \
|
--exclude='lost+found' \
|
||||||
|
|
@ -89,13 +99,16 @@ tar --numeric-owner --xattrs --acls -cpf - \
|
||||||
--exclude='run/*' \
|
--exclude='run/*' \
|
||||||
. | tar --numeric-owner --xattrs --acls -xpf - -C /mnt/winux
|
. | tar --numeric-owner --xattrs --acls -xpf - -C /mnt/winux
|
||||||
|
|
||||||
|
cd "$SAVED_PWD"
|
||||||
|
|
||||||
#### TESTTING CODE
|
#### TESTTING CODE
|
||||||
# losetup -j $WINUX_DISK_IMG
|
# losetup -j $WINUX_DISK_IMG
|
||||||
|
|
||||||
# Clean up after building
|
# Clean up after building
|
||||||
|
|
||||||
|
sync
|
||||||
|
sleep 1
|
||||||
|
|
||||||
wxumount /mnt/winux
|
wxumount /mnt/winux
|
||||||
wxumount /mnt/linux
|
wxumount /mnt/linux
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue