User:Misterhaan/Linux Virtual Machine Setup

From auWiki
Jump to: navigation, search

i use ubuntu as my workstation gnu/linux distribution running through virtualbox on the latest version of windows. this guide is what i did to set up an ubuntu 15.10 virtual machine.

set up virtualbox and create virtual machine

first off, start downloading the latest 64-bit ubuntu desktop iso from [ubuntu.com](http://www.ubuntu.com/download/desktop). it’ll take a while so leave it going while setting up the virtual machine. i recommend using the bittorrent download through [qbittorrent](http://www.qbittorrent.org/download.php) for faster, easily-resumable downloading.

i use virtualbox to run the virtual machine i install ubuntu on. get the latest version for windows along with the extension pack from [virtualbox.org](https://www.virtualbox.org/wiki/Downloads) and install it. the installer has options for bridged networking and host-only networking, but bridged doesn’t work and host-only isn’t useful for me, so neither needs to be selected. after the install is completed, run the extension pack.

create a new virtual machine either from the toolbar or machine menu in virtualbox. i name mine with the ubuntu version number and name, so Ubuntu 16.04 Xenial Xerus. it should automatically switch type to linux and version to ubuntu (64 bit) when you type ubuntu in the name box, but select them if it doesn’t. i set the memory size to 4096 mb since that’s half my physical memory. create a virtual hard drive using vdi file type, dynamically allocated, sized 20 gb.

the new machine should now show in the virtualbox manager window and show a powered off status. select it and choose settings either from the toolbar, the machine menu, or the context menu. under general/advanced you can enable shared clipboard and drag'n'drop. under system/processor you can enable pae/nx. under display/screen crank up video memory to 32 mb and enable 3d acceleration. if you have a solid-state drive you can select the virtual drive under storage and check the solid-state drive box (not sure if this is useful). under network/adapter 1, expand the advanced section and change the adapter type away from the ridiculously slow intel pro/1000 mt desktop to pcnet-fast iii. everything else should be fine.

once the ubuntu desktop iso has finished downloading, start your virtual machine. since all it has is a freshly-created virtual hard drive, it will ask for a start-up disk. select the ubuntu desktop iso and it will load up ubuntu from the iso. alternately, go to settings for the virtual machine and select storage on the left. select the line that says empty and has a cd icon next to it, then click the other cd icon in the upper right to drop down a menu and choose virtual optical disc file and then select the ubuntu iso. i had to use the settings method because it kept aborting startup before i could set up the iso.

once ubuntu starts up, choose your language and then the install ubuntu option to install to your virtual hard drive. the graphical installer starts and has you choose a language again. tell it to download updates and install the restricted extras. i let it do what it wants to with the whole virtual disk (“erase disk and install ubuntu” — note it can’t access your physical hard drive so it won’t affect your windows install). i don’t bother with encryption and lvm isn’t useful provided you stick with the single virtual disk, so click install now. set your time zone, keyboard layout, and user and computer name (i usually tack the ubuntu version onto the name of my windows computer for the virtual machine name, something like WinName-Ubuntu-16.04) and wait for it to finish installing and reboot.

configure ubuntu and install and remove applications

after the system reboots it will probably have some updates it wants to install, but before that i want to create my users and group(s) to match my server. this is done largely the same way as described in the linux server setup, except admin users here should also be part of some additional groups (use with -G in either useradd or usermod). when logged in as your user, run the groups command in terminal to get the list of groups (ignore the group named the same as your user). be sure to run passwd to set passwords for the other users, then log in as one of them. use usermod to change your user’s id, move the home directory, and set the default group. now you can install all the updates, which might take a while especially if you’re installing months after that version of ubuntu was released.

remove stuff

i remove some things i don’t like. the command for that looks like this:

``` sudo apt-get remove packages ```

where packages is at least one package to remove. to remove more than one package, separate their names with spaces. here are the packages i remove:

  • *rhythmbox* - a music player that doesn’t do all that well with my read-only mp3 share from my file server. i’ll install audacious instead.
  • *simple-scan* - an oversimplified scanner interface, missing important basic features like preview. install xsane instead if you have a scanner that works with linux
  • *ubuntuone** - a moderate amount of free online storage. i have plenty of my own local storage and don’t need this. there are a number of packages so the wildcard helps find all of them.
  • *unity-lens-shopping* - eff said this has to do with amazon product search results showing up in the dash, but removing it doesn’t seem to change anything.

here’s the full command to remove everything i remove:

``` sudo apt-get remove rhythmbox simple-scan ubuntuone* ```

if you choose the minimal install, these packages won’t be there anyway.

install stuff

of course there are also a few things i use that aren’t in ubuntu by default. add them with a command that looks like this:

sudo apt-get install <packages>

where packages again is at least one package to install, and multiple packages can be specified separated with spaces. ubuntu can find most software i want — i’ll discuss those it can’t find or that it finds an older version of than i want later. here are the packages i install with apt-get:

  • avidemux - simple video editor i have used to convert mkv to avi.
  • compizconfig-settings-manager - advanced display effects settings tool, which also configures some unity settings. unity handles the menu and running programs list.
  • gnome-tweak-tool - gives back some basic display options, like font sizes and themes.
  • handbrake-gtk - dvd ripping program handy for getting movies from disc to an ipad, for example. it wouldn’t install for me on 12.10 though.
  • konqueror - a khtml-based browser (safari and chrome use webkit, which is based on khtml). i have installed this in the past to test my web development in it, but it has so few people using it that it’s not worth the trouble. it adds a bunch of kde stuff to the menus, with konqueror in the internet section.
  • mixxx - dj software i’m playing around with on my laptop.
  • myunity - some customization options for the unity desktop. it’s easier to use than compizconfig-settings-manager, but also doesn’t have as many options. seems to not exist as of 12.10.
  • nfs-common - support for connecting to network filesystems, which is the easiest way to share a disk from one linux machine to another.
  • openshot - video editor i’ve used to fade two video clips together.
  • puddletag - mp3 tag editor. no longer available through apt since the official release doesn't support python3 yet. install instructions later.
  • python-rgain - loudness analyzer for mp3 files. replaygain attempts to figure out how loud an mp3 file sounds, and then adds gain information to the file so that it sounds like it has the same loudness as the other mp3s (provided you use this on all of them). it’s a command-line tool so won’t put anything in the applications menu.
  • rpcbind' - not entirely sure what this is or if it needs to be installed explicitly, but it’s for nfs.
  • sound-juicer - cd ripper. shows up as audio cd extractor in the menu.
  • soundconverter - just as it sounds like, this program can load up a bunch of sound files and convert them to a different format. i don’t typically do this, so i wait to install it until i’m about to use it.
  • sux - switch user and forward x context. handy when i want to run a gui application as a different user.
  • ubuntu-restricted-extras - mp3, flash, java, and dvd playback. these changes affect browsers and players that are installed (or will be installed later) so nothing is added to the applications menu.
  • virtualbox-guest-dkms virtualbox-guest-utils virtualbox-guest-x11 - helps ubuntu be a better guest on virtualbox. mostly for the video driver that lets resizing the virtualbox window set the screen resolution.

here’s the full command to install everything i install:

sudo apt-get install handbrake nfs-common openshot python-rgain rpcbind soundconverter ubuntu-restricted-extras virtualbox-guest-dkms virtualbox-guest-utils virtualbox-guest-x11

before i started using ubuntu through a virtual machine i would dual-boot with windows, so i wanted a few other things that make less sense now that i can run the same or similar programs non-virtualized on the windows host. in case i ever go back, or if you’re a dual-booter looking for useful stuff, here’s that list:

  • audacious - sound player derived from xmms (similar to winamp).
  • audacity - sound editor.
  • eclipse - programming environment that i use for building websites with php, mysql, html, css, and javascript. i need to install more features from within eclipse later on, but this simplifies the core eclipse install at least.
  • filezilla - ftp client. i use this for transferring files to my website that aren’t managed by subversion.
  • gimp - graphics editor. this was in the default ubuntu install until 10.04 where they decided that fspot handles all the photo enhancing that most users want, but i want more than that so i install gimp.
  • gnome-gmail - creates a menu entry for gmail which launches it in firefox. can also be used as a preferred application (sort of).
  • pidgin - instant messaging client with more important features than the default empathy.
  • screenlets - desktop widgets/gadgets/whatever you want to call them. i used this to get weather and a slideshow of my photos on the desktop.
  • screenlets-pack-all - more screenlets, including the weather one i like.
  • subversion - command-line subversion client. mostly i use subversion through an eclipse plugin, but sometimes it’s handy to have the svn command available at the command line. since it’s a command-line utility it doesn’t show up in the applications menu.
  • xsane - scanner interface that works with gimp. as far as i know my current scanner isn’t supported but my old one is, so sometimes i’ll install it on my laptop in case i want to bring it and the scanner somewhere.

update settings

click the power icon in the upper right and choose the system settings icon in the bottom left of the dropdown. under privacy, click screen lock and set automatic screen lock to off since the host handles locking. under power, set blank screen to never since the host handles the screen. under details > users, click the unlock button at the top and enter your password to unlock, then turn on automatic login for your account.

enable nfs network shares

for some reason my workstations never see my server, so i have to add it to the hosts file. in linux this file is at /etc/hosts — add a line to the end that contains the server’s ip address, a tab or space, and the name of the server:

192.168.1.2 server

only root can edit this file. you can launch the text editor (gedit) with sudo:

sudo gedit /etc/hosts

ubuntu doesn’t support nfs by default, so install it (if you didn’t already — it’s in my default install command) with `sudo apt-get install rpcbind nfs-common`. edit /etc/fstab as root and add one line for each nfs share in this format:

server:/nfs_share /local/mount/point nfs noexec 0 0

make sure your local mount point directories exist (create them with `sudo mkdir /local/mount/point`), then reboot or manually mount everything with `sudo mount /local/mount/point`.


install puddletag

i use puddletag to normalize mp3 and ogg file tags and artwork. as of ubuntu 20.04 it’s no longer available through apt (because it uses python 2.5 which is outdated) but there’s a github branch that seems to work just fine but needs to be installed manually. install prerequisites and download puddletag from github with the following commands.

``` sudo apt-get install git python3 python3-mutagen python3-configobj python3-pyparsing python3-pyqt5 python3-pyqt5.qtsvg cd /opt/ sudo git clone https://github.com/sandrotosi/puddletag ```

you can now run it from a command line with `/opt/puddletag/source/puddletag` but that’s not convenient, so add it to the launcher by placing the following text in a new file at `/usr/share/applications/puddletag.desktop` (either create as root or create somewhere else and copy as root):

``` [Desktop Entry] Name=puddletag GenericName=Audio Tag Editor Comment=Edits tags in audio files Exec=/opt/puddletag/source/puddletag Icon=/opt/puddletag/source/puddletag.xpm Terminal=false Type=Application Category=AudioVideo;Audio;Qt ```

as i set up new ubuntu virtual machines i want to apply my puddletag settings, which are split across two directories: `~/.config/puddletag/` and `~/.local/shared/puddletag/`. i keep tarballs of those directories on my server and extract them both after installing puddletag so i don’t have to reconfigure with each new ubuntu version.

install makemkv

i’ve ran into some trouble ripping some of my dvds so i can put them on a tablet or whatever. normally i’d use handbrake but it sometimes quits almost right away, so in those cases i run it through makemkv first and then handbrake afterward. it’s not in the ubuntu repositories so i install it from a ppa:

``` sudo add-apt-repository ppa:heyarje/makemkv-beta sudo apt-get update sudo apt-get install makemkv-bin makemkv-oss ```

it’s not available for bionic beaver yet.

set preferences

there are a couple more settings in system settings i’ll point out:

under *appearance* i set my background image. the other settings i mess with are under user accounts (under system). select a user and then you can click the placeholder picture and set a better one. also any users created with useradd probably won’t show a name unless you click next to the picture and enter one. to enable auto-login, select the user you want to log in from user accounts and change automatic login to on.


run puddletag as alternate user

puddletag is an mp3 (and other audio formats) tag editor. i use it after i rip an audio cd or after i download music to embed cover art and make sure my iphone will sort albums in the correct order. as of 12.04 it’s available in ubuntu’s standard repositories. since my music files are owned by a different user, i need to be able to run puddletag as someone else. copy the following into a file (i put it in my home directory named puddletag-somebody) and replace somebody with the other user account:

xhost +SI:localuser:somebody
gksudo -u somebody puddletag

then make it executable with chmod:

chmod 755 puddletag-somebody

then add a menu entry to run that script, or just run it from a terminal. the easiest way i’ve found to add it to the menu is get to `/usr/share/applications/` and copy the existing puddletag.desktop to puddletag-somebody.desktop, then edit the copy and update the name, tryexec, and exec values.