Qemu example archlinux

From wikinotes

The following is a really simple, start-to-finish archlinux install within qemu. The purpose of this example is to highlight changes between a regular install, and a qemu install.

Create Disk, Boot Install Media

qemu-img create -f raw hdd.disk 4G     # Create Virtual image
qemu-img resize        hdd.disk +10G   # You can increase disk size if needed

## pop in your arch installation usb, and run the following (sdb being thedisk wih your install media)
sudo qemu-system-x86_64 \
    -hda /dev/sdb \
    -hdb /home/will/dev/megaton.disk \
    -m 2G

NOTE:

You cannot use ping, and nc isn't installed!!

NOTE:

User-Mode networking (slow) will be started automatically as long as no -netdev flag is used when the VM is started. Try pacman -Syu to see it working

Perform Normal Archlinux Install

Normal Install


cfdisk                   # Create partition
mkfs.ext4 /dev/sdb1      # Format partition
mount /dev/sdb1 /mnt
pacstrap -i /mnt base
genfstab -p /mnt >> /mnt/etc/fstab

arch-chroot /mnt

pacman-db-upgrade
pacman -Syu
pacman -S grub-bios vim git zsh sudo tmux
visudo
useradd -m will        # create user and home dir

#### /etc/pacman.d/mirrorlist
#uncomment mirrors
####

#### /etc/locale.gen
en_CA_.UTF-8
####

#### /etc/hostname
myarchlinux
####

ln -s "/usr/share/zoneinfo/Canada/Eastern" "/etc/localtime"	## Set Timezone

#### /etc/vconsole.conf
KEYMAP=us.map
FONT=Lat2-Terminus16
####

#### /etc/pacman.conf
# Uncomment multilib
####

### IMPORTANT, BOTH GRUB-MKCONFIG AND GRUB-INSTALL NEED TO BE RUN
### FROM THE DISK IT IS BEING INSTALLED TO
grub-install /dev/sda                   # install grub into MBR
grub-mkconfig -o /boot/grub/grub.cfg    # generate grub.cfg from /etc/grub.d/*

enabling virtio devices (hdd, network, etc)


#### /etc/mkinitcpio.conf
MODULES="virtio virtio_blk virtio_pci virtio_net"
####

https://wiki.archlinux.org/index.php/QEMU#Preparing_an_(Arch)_Linux_guest