Difference between revisions of "Ubuntu VM Lab"
Jump to navigation
Jump to search
Michael.mast (talk | contribs) |
Michael.mast (talk | contribs) |
||
(4 intermediate revisions by the same user not shown) | |||
Line 14: | Line 14: | ||
==Process== | ==Process== | ||
+ | ===Install Packages=== | ||
+ | <pre> | ||
+ | sudo apt install virt-manager | ||
+ | sudo systemctl start libvirtd | ||
+ | sudo systemctl enable libvirtd | ||
+ | sudo apt install libzfs2linux | ||
+ | sudo apt install zfs-dkms | ||
+ | </pre> | ||
+ | ===Prepare Storage=== | ||
+ | ====Partition disk==== | ||
+ | (Not really needed, but I got into the habbit) | ||
+ | <pre> | ||
+ | sudo fdisk /dev/sdb | ||
+ | |||
+ | Command (m for help): p | ||
+ | Disk /dev/sdb: 465.8 GiB, 500107862016 bytes, 976773168 sectors | ||
+ | Units: sectors of 1 * 512 = 512 bytes | ||
+ | Sector size (logical/physical): 512 bytes / 4096 bytes | ||
+ | I/O size (minimum/optimal): 4096 bytes / 4096 bytes | ||
+ | Disklabel type: dos | ||
+ | Disk identifier: 0x970f8931 | ||
+ | |||
+ | Command (m for help): n | ||
+ | Partition type | ||
+ | p primary (0 primary, 0 extended, 4 free) | ||
+ | e extended (container for logical partitions) | ||
+ | Select (default p): | ||
+ | |||
+ | Using default response p. | ||
+ | Partition number (1-4, default 1): | ||
+ | First sector (2048-976773167, default 2048): | ||
+ | Last sector, +sectors or +size{K,M,G,T,P} (2048-976773167, default 976773167): | ||
+ | |||
+ | Created a new partition 1 of type 'Linux' and of size 465.8 GiB. | ||
+ | |||
+ | Command (m for help): w | ||
+ | The partition table has been altered. | ||
+ | Calling ioctl() to re-read partition table. | ||
+ | Syncing disks. | ||
+ | </pre> | ||
+ | ====Encrypt Disk==== | ||
+ | This is really just to make disposing of the drive easier. If the drive dies I can throw it away without worrying about physically destroying it. | ||
+ | <pre> | ||
+ | sudo cryptsetup luksFormat --type luks2 /dev/sdb1 | ||
+ | |||
+ | WARNING! | ||
+ | ======== | ||
+ | This will overwrite data on /dev/sdb1 irrevocably. | ||
+ | |||
+ | Are you sure? (Type uppercase yes): YES | ||
+ | Enter passphrase for /dev/sdb1: | ||
+ | Verify passphrase: | ||
+ | |||
+ | sudo dd if=/dev/random bs=32 count=1 of=/root/random_data_keyfile1 | ||
+ | sudo cryptsetup luksAddKey /dev/sdb1 /root/random_data_keyfile1 | ||
+ | sudo echo "enc500GB UUID=f7e9e2ff-244a-4316-a794-cade2535d90a /root/random_data_keyfile1 luks" >> /etc/crypttab | ||
+ | sudo cryptdisks_start enc500GB | ||
+ | </pre> | ||
+ | ====ZFS Config==== | ||
+ | <pre> | ||
+ | sudo zpool create storage1 /dev/mapper/enc500GB | ||
+ | sudo zfs create storage1/vm | ||
+ | sudo zfs set mountpoint=/mnt/500GB storage1/vm | ||
+ | </pre> |
Latest revision as of 14:27, 13 May 2018
Contents
Purpose
To build a simple VM lab in Ubnuntu. Nothing fancy.
Hardware
My primary personal computer, a Lenovo X220 laptop with
- 3rd gen i5
- 8GB RAM
- 256GB Crucial BX200 low end SSD
- 500GB HGST Travelstar Z7K500
Software
- OS is obviously Ubuntu. At the time of writing I am using Bionic Beaver.
- ZFS Filesystem tweaked to use 2GB of ARC
- Red Hat libvirt
Process
Install Packages
sudo apt install virt-manager sudo systemctl start libvirtd sudo systemctl enable libvirtd sudo apt install libzfs2linux sudo apt install zfs-dkms
Prepare Storage
Partition disk
(Not really needed, but I got into the habbit)
sudo fdisk /dev/sdb Command (m for help): p Disk /dev/sdb: 465.8 GiB, 500107862016 bytes, 976773168 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disklabel type: dos Disk identifier: 0x970f8931 Command (m for help): n Partition type p primary (0 primary, 0 extended, 4 free) e extended (container for logical partitions) Select (default p): Using default response p. Partition number (1-4, default 1): First sector (2048-976773167, default 2048): Last sector, +sectors or +size{K,M,G,T,P} (2048-976773167, default 976773167): Created a new partition 1 of type 'Linux' and of size 465.8 GiB. Command (m for help): w The partition table has been altered. Calling ioctl() to re-read partition table. Syncing disks.
Encrypt Disk
This is really just to make disposing of the drive easier. If the drive dies I can throw it away without worrying about physically destroying it.
sudo cryptsetup luksFormat --type luks2 /dev/sdb1 WARNING! ======== This will overwrite data on /dev/sdb1 irrevocably. Are you sure? (Type uppercase yes): YES Enter passphrase for /dev/sdb1: Verify passphrase: sudo dd if=/dev/random bs=32 count=1 of=/root/random_data_keyfile1 sudo cryptsetup luksAddKey /dev/sdb1 /root/random_data_keyfile1 sudo echo "enc500GB UUID=f7e9e2ff-244a-4316-a794-cade2535d90a /root/random_data_keyfile1 luks" >> /etc/crypttab sudo cryptdisks_start enc500GB
ZFS Config
sudo zpool create storage1 /dev/mapper/enc500GB sudo zfs create storage1/vm sudo zfs set mountpoint=/mnt/500GB storage1/vm