Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
vm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cs225
vm
Commits
f17d29bf
There was a problem fetching the pipeline summary.
Commit
f17d29bf
authored
9 years ago
by
Jeffrey Tolar
Browse files
Options
Downloads
Patches
Plain Diff
Initial commit
parents
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
create_vm.sh
+168
-0
168 additions, 0 deletions
create_vm.sh
with
168 additions
and
0 deletions
create_vm.sh
0 → 100644
+
168
−
0
View file @
f17d29bf
#!/bin/bash
# x86_64 or x86
ARCH
=
x86_64
DISK
=
vm_
$ARCH
.img
DEFAULT_USER
=
dev
DEFAULT_PASSWORD
=
uiuc
ROOT_PASSWORD
=
uiuc
PACKAGES
=(
# Core packages
base
syslinux
# X things
virtualbox-guest-modules
virtualbox-guest-utils
xfce4
# Nice-to-haves
bash-completion
zsh
htop
# VCS
subversion
# Editors
gvim
gedit
emacs
# Random utilities
sudo
imagemagick
graphviz
openssh
gnuplot
gtkwave
# cs233
qt4
# cs233 (qtspim)
# Browsers
chromium
firefox
# Development (compilers, interpreters, debuggers, etc.)
clang35
libc++
gdb
valgrind
iverilog
# cs233
)
set
-e
-x
m
()
{
echo
"
$@
"
}
rm
-f
$DISK
m
"Creating disk image..."
truncate
$DISK
--size
=
8G
m
"Creating partition table..."
fdisk
$DISK
<<
fdiskEOF
o
n
a
w
fdiskEOF
m
"Mounting virtual drive... (requires sudo)"
loopdev
=
$(
sudo
losetup
-f
)
sudo
losetup
--partscan
"
$loopdev
"
$DISK
trap
"sudo losetup -d
$loopdev
"
EXIT
m
"Creating filesystem... (requires sudo)"
sudo
mkfs.ext3
${
loopdev
}
p1
mkdir
-p
root
m
"Mounting filesystem... (requires sudo)"
sudo
mount
${
loopdev
}
p1 root/
trap
"sudo umount
${
loopdev
}
p1 ; sudo losetup -d
$loopdev
"
EXIT
if
[[
$ARCH
==
"x86_64"
]]
;
then
sudo
pacstrap
-c
-G
root/
"
${
PACKAGES
[@]
}
"
else
sudo
linux32 pacstrap
-c
-G
root/
"
${
PACKAGES
[@]
}
"
--
--arch
=
i686
fi
sudo
arch-chroot root/
<<
chrootEOF
# random setup - hostname, timezone, locales
echo cs2xx-vm > /etc/hostname
ln -s /usr/share/zoneinfo/America/Chicago /etc/localtime
sed -i '/^#en_US/ s/^#//' /etc/locale.gen
locale-gen
echo LANG=en_US.UTF-8 > /etc/locale.conf
/usr/bin/mandb
# networking
ln -s /dev/null /etc/udev/rules.d/80-net-setup-link.rules
cp /etc/netctl/examples/ethernet-dhcp /etc/netctl/wired
systemctl enable netctl@wired.service netctl-sleep.service
# setup pacman keyring
pacman-key --init
pacman-key --populate archlinux
# install bootloader
syslinux-install_update -i -a -m
uuid=
\$
(blkid -o value -s UUID
${
loopdev
}
p1)
sed -i '/APPEND/ s+root=[^ ]*+root=UUID='
\$
uuid'+' /boot/syslinux/syslinux.cfg
# fix a bug when running in QEMU - the 'block' hook has to be included in the initcpio
sed -i '/^HOOKS/ s/autodetect
\\
(.*
\\
) block/block autodetect
\\
1/' /etc/mkinitcpio.conf
mkinitcpio -p linux
# create default user, set passwords
useradd -G wheel -m
$DEFAULT_USER
echo "
$DEFAULT_USER
:
$DEFAULT_PASSWORD
" | chpasswd
echo "root:
$ROOT_PASSWORD
" | chpasswd
echo "%wheel ALL=(ALL) ALL" > /etc/sudoers.d/wheel
# autologin on tty1
mkdir -p /etc/systemd/system/getty@tty1.service.d
cat > /etc/systemd/system/getty@tty1.service.d/override.conf <<"gettyEOF"
[Service]
ExecStart=
ExecStart=-/usr/bin/agetty --autologin
$DEFAULT_USER
--noclear %I 38400 linux
gettyEOF
# autostart X (xfce) on tty1
echo '[[ -z
\$
DISPLAY &&
\$
XDG_VTNR -eq 1 ]] && exec startx' >> /home/
$DEFAULT_USER
/.bashrc
chown
$DEFAULT_USER
:
$DEFAULT_USER
/home/
$DEFAULT_USER
/.bashrc
cat > /home/
$DEFAULT_USER
/.xinitrc <<"xinitrcEOF"
#!/bin/sh
#
# ~/.xinitrc
#
# Executed by startx (run your window manager from here)
if [ -d /etc/X11/xinit/xinitrc.d ]; then
for f in /etc/X11/xinit/xinitrc.d/*; do
[ -x "
\$
f" ] && . "
\$
f"
done
unset f
fi
/usr/bin/VBoxClient-all
exec startxfce4
xinitrcEOF
chown
$DEFAULT_USER
:
$DEFAULT_USER
/home/
$DEFAULT_USER
/.xinitrc
chrootEOF
sudo
arch-chroot root/
#grub-install --recheck --target=i386-pc ${loopdev}
#grub-mkconfig -o /boot/grub/grub.cfg
sudo
umount
${
loopdev
}
p1
sudo
losetup
-d
$loopdev
trap
- EXIT
rm
-f
$DISK
.vmdk
VBoxManage convertfromraw
$DISK
$DISK
.vmdk
--format
VMDK
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment