Qemu
Qemu
Snapshots
To Create snapshots:
# lvcreate (Volume) -s -n (name of the snapshot) (location to store the snapshot)
$ lvcreate -L300G -s -n ecc-b-01v.snap /dev/vm/ecc-b-01v
To Remove snapshots:
# lvremove (name of snapshot @ stored location)
$ lvremove /dev/vm/ecc-b-01v.snap
To Restore snapshots:
# lvconvert --merge (Logical Volume Path)
$ lvconvert --merge /dev/vg0/win10.snap
Required Packages
$ sudo apt install nano util-linux linux-tools-common cpufrequtils lm-sensors \ libusb-dev git libglib2.0-dev libfdt-dev libpixman-1-dev zlib1g-dev git-email \ libcap-dev libcap-ng-dev libcurl4-gnutls-dev libgtk-3-dev valgrind xfslibs-dev \ libnfs-dev libiscsi-dev libsdl2-dev libncurses5-dev libaio-dev libjemalloc-dev \ libjemalloc* libusb-1.0-0-dev libusbredirparser-dev opus-tools qemu-user-static \ samba vde2 qemu-efi openbios-ppc openhackware sgabios ovmf debootstrap \ sharutils-doc python libbluetooth-dev libbrlapi-dev libbz2-dev libibverbs-dev \ libjpeg8-dev libnuma-dev librbd-dev librdmacm-dev libsasl2-dev libsdl1.2-dev \ libseccomp-dev libsnappy-dev libssh2-1-dev libvde-dev libvdeplug-dev \ libvte-2.90-dev libxen-dev liblzo2-dev
Test Environment
ecc-admin@lkramer:~$ dd if=/dev/zero of=./disc.img bs=1M count=8096 #Copies 8096 blocks from /dev/zero to ./disc.img at 1MB ecc-admin@lkramer:~$ sudo -i #Switch to super user root@lkramer:~# apt install lvm2 #Installs the lvm2 package ecc-admin@lkramer:~$ sudo pvcreate /home/ecc-admin/disc.img #Creates physical volume at file location ecc-admin@lkramer:~$ sudo losetup /dev/loop0 disc.img #Creates a "fake" file that acts as a block-device ecc-admin@lkramer:~$ sudo fdisk -l /dev/loop0 #Lists the partition tables for the loop ecc-admin@lkramer:~$ sudo pvcreate /dev/loop0 #Creates physical volume ecc-admin@lkramer:~$ sudo pvdisplay #Shows details of physical volume ecc-admin@lkramer:~$ sudo vgcreate vg37 /dev/loop0 #Creates a new volume group named "vg37" in the directory /dev/loop0 ecc-admin@lkramer:~$ sudo lvcreate -L 2G -nVol vg37 #Creates logical volume. Size 2G, named Vol, placed in vg37 volume group. ecc-admin@lkramer:~$ sudo mkfs.ext4 /dev/mapper/vg37-Vol #Creates an ext4 file system /dev/mapper/vg37-Vol ecc-admin@lkramer:~$ sudo mount /dev/mapper/vg37-Vol /mnt #Mounts the filesystem /dev/mapper/vg1-root to the directory /mnt ecc-admin@lkramer:~$ mount #Shows the details ecc-admin@lkramer:~$ df -h #Displays Disk Info in "Human Readable" format
LVM Setup
#!/bin/bash DISK=/dev/sdd #Setting up the disk drive #Partitions the disk parted ${DISK} -s mklabel gpt #Scripts to make a new disk label of type gpt parted ${DISK} -s mkpart "" fat32 0% 512MB #Scripts to make a partition of filesystem fat32 that starts at the beginning of the existing disk and ends at 512MB parted ${DISK} -s mkpart "" ext4 512MB 100% #Scripts to make a partition of filesystem ext4 that starts at 512MB and stops at the end of the existing disk parted ${DISK} -s set 1 boot on #Scripts the first partition flag to "boot" and the state to "on" parted ${DISK} -s set 2 lvm on #Scripts the second partition flag to "lvm" (logical volume management) and the state to "on" sync #Writes data in the buffer to the disk mkfs.vfat ${DISK}1 #Creates a FAT file system?? pvcreate ${DISK}2 #Creates physical volume vgcreate vg1 ${DISK}2 #Creates 1 copy of a new volume group lvcreate -L 60GB -n root vg1 #Creates a new logical volume in the volume group created in the last command. Allocates 60GB named "root". lvcreate -L 16GB -n var vg1 #Creates a new logical volume. Allocates 16GB named "var". dd if=/dev/mapper/vg0-root of=/dev/mapper/vg1-root bs=1M status=progress #Copies data from /dev/mapper/vg0-root to /dev/mapper/vg1-root at 1M #Gives a warning if the previous copy command failed and exits the program if [[ $? != 0 ]]; then echo "root dd failed" exit 1 fi dd if=/dev/mapper/vg0-var of=/dev/mapper/vg1-var bs=1M status=progress #Copies data from /dev/mapper/vg0-var to /dev/mapper/vg1-var at 1M #Gives a warning if the previous copy command failed and exits the program if [[ $? != 0 ]]; then echo "var dd failed" exit 1 fi mount /dev/mapper/vg1-root /mnt && \ #Mounts the filesystem /dev/mapper/vg1-root to the directory /mnt mount /dev/mapper/vg1-var /mnt/var && \ #Mounts the filesystem /dev/mapper/vg1-var to the directory /mnt/var mount ${DISK}1 /mnt/boot/efi && \ #Mounts the created file system to the EFI partition mount --bind /dev /mnt/dev && \ #Connects the file systems /dev and /mnt/dev to make them both accessible from either location mount --bind /run /mnt/run && \ #Connects the file systems /run and /mnt/run to make them both accessible from either location mount --bind /sys /mnt/sys && \ #Connects the file systems /sys and /mnt/sys to make them both accessible from either location mount --bind /proc /mnt/proc #Connects the file systems /proc and /mnt/proc to make them both accessible from either location #Gives a warning if the mount failed and exits the program if [[ $? != 0 ]]; then echo "failed to mount" exit 1 fi # Modify /etc/hostnmae # Modify /etc/hosts # Modify /etc/fstab # Install grub # Update grub
Tags
None
Subscribers
None
- Last Author
- ericolson
- Last Edited
- Jul 14 2017, 10:12 AM