With SmartOS the vmadm console
command offers a convenience method for pulling up a text console for a guest VM. This is commonly used for Linux and BSD VMs and it can be enabled for Windows VMs too. The below steps outline how to enable and utilize this feature on Windows 2012 R2 through the use of the Windows Emergency Management Services (EMS).
Configuration
- As an administrator user run the following commands. If you have configured more than one boot entry you may want to tailor this command to target only a specific boot entry. Together these enable EMS and then set it to run on COM1 at a baud rate of 115,200.
C:\>bcdedit /ems on
C:\>bcdedit /emssettings EMSPORT:1 EMSBAUDRATE:115200
- From the SmartOS host start up the console and substitute in the appropriate UUID of the VM from
vmadm list
:
# vmadm console <uuid>
- Reboot the VM.
- On the console window you will see something like the following:
Computer is booting, SAC started and initialized.
Use the "ch -?" command for information about using channels.
Use the "?" command for general help.
SAC>
EVENT: The CMD command is now available.
SAC>
- We’re at a SAC prompt, but it’s not yet the familiar CMD.EXE. The SAC is the Special Administration Console which has some additional functionality, one of which is to start CMD. To do so simple run cmd and then switch to the channel that it created:
SAC>cmd
The Command Prompt session was successfully launched.
EVENT: A new channel has been created. Use "ch -?" for channel help.
Channel: Cmd0001
SAC>ch -si 1
- From here press any key and then enter in the username, domain, and password when prompted and CMD prompt will then be usable as well as PowerShell by running
powershell
at the CMD prompt:
Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.
C:\Windows\system32>
Limitations
This does not appear to work on all versions of Windows. When I tried with Windows 7 the bcdedit
commands completed successfully but the console text never appeared. Older versions will need to use the bootcfg
command instead of bcdedit
.
While functional, the serial console can be a bit sluggish at times. Also, when using this within xterm the text scrolls at the 25 line mark rather than filling up the full terminal window.
This is a quick guide for setting up a CIFS/SMB file server using Samba within a virtualized zone on SmartOS. A couple of the many benefits of doing this on SmartOS are that it can utilize ZFS for file storage and also that the file server can be isolated off as a zone and be run in parallel with various other zones and virtual machines.
On to the setup steps…
- From an installed and running SmartOS system setup a JSON config file for the zone. I tend to create a directory
/opt/vmcfg
and place the file there, in this case named samba01.json
with the following contents. When placed in a directory under /opt
the files will persist across system reboots. This sample config uses the base-64 15.1.1 image. The delegate_dataset=true creates a ZFS filesystem that can be managed within the zone which is a nice feature to have on a file server for separating out users or shares to different filesystems. The alias, hostname, quota, max_physical_memory, ZFS compression, and network configuration can be updated to your environment.
{
"brand": "joyent",
"alias": "samba01",
"hostname": "samba01",
"quota": 50,
"image_uuid": "0edf00aa-0562-11e5-b92f-879647d45790",
"max_physical_memory": 1024,
"delegate_dataset": true,
"zfs_data_compression": "on",
"zfs_root_compression": "on",
"dns_domain": "local",
"resolvers": [
"8.8.8.8",
"8.8.4.4"
],
"nics": [
{
"nic_tag": "admin",
"ip": "10.1.1.211",
"netmask": "255.255.255.0",
"gateway": "10.1.1.1",
"primary": true
}
]
}
- Create the zone from the configuration file.
# vmadm create -f samba01.json
Successfully created VM 6153d789-5697-4ec6-a237-55198fe3c6b8
- Log into the zone and install Samba.
# zlogin 6153d789-5697-4ec6-a237-55198fe3c6b8
# pkgin update
# pkgin install samba
- Setup the ZFS home directories and move the admin user home directory to a ZFS filesystem.
# zfs create zones/6153d789-5697-4ec6-a237-55198fe3c6b8/data/home
# zfs create zones/6153d789-5697-4ec6-a237-55198fe3c6b8/data/home/admin
# cp -a /home/admin/. /zones/6153d789-5697-4ec6-a237-55198fe3c6b8/data/home/admin
# rm -rf /home/admin
# zfs set mountpoint=/home zones/6153d789-5697-4ec6-a237-55198fe3c6b8/data/home
- Create a new user with a separate filesystem for the home directory.
# zfs create zones/6153d789-5697-4ec6-a237-55198fe3c6b8/data/home/ed
# chown ed:other /home/ed
# useradd ed
- Set the user’s Samba password.
# smbpasswd -a ed
- Optionally edit the Samba config file in
/opt/local/etc/samba/smb.conf
.
- Start up Samba. This will also set it to be enabled at startup.
# svcadm enable -r smbd
# svcadm enable -r nmbd
- From a Windows or other computer connect to the user’s home directory/share as
\\10.1.1.211\ed
This will get you a basic file server setup. From here you can add addition users, shared directories, etc.
Joyent’s SmartOS, a fairly recent hypervisor for virtualization, provides a number of prebuilt virtual machine images for various operating systems but doesn’t yet have one available for Ubuntu 12.04 LTS. This post provides the steps required to install it manually including the basic SmartOS commands as well as some Ubuntu-specific customizations.
- Create a JSON file with the virtual machine parameters. Also see the SmartOS Wiki for some additional options and details.
{
"alias": "ubuntu12",
"hostname": "ubuntu12",
"brand": "kvm",
"vcpus": 1,
"autoboot": false,
"ram": 4096,
"resolvers": [ "10.1.1.1" ],
"disks": [
{
"boot": true,
"model": "virtio",
"size": 40960
}
],
"nics": [
{
"nic_tag": "admin",
"model": "virtio",
"ip": "10.1.1.11",
"netmask": "255.255.255.0",
"gateway": "10.1.1.1",
"primary": true
}
]
}
- Create the virtual machine with the
vmadm
command using the JSON file as the input.
# vmadm create -f ubuntu-12.04.json
Successfully created 3b202a79-f148-4c87-bb7f-ff9d64f724ca
- Copy the Ubuntu 12.04 LTS install ISO to the root dataset for this virtual machine. This assumes the ISO has already been copied to the
/zones/isos
directory on the SmartOS server.
# cp /zones/isos/ubuntu-12.04-server-amd64.iso \
/zones/3b202a79-f148-4c87-bb7f-ff9d64f724ca/root/.
- Boot the VM to the ISO.
# vmadm start 3b202a79-f148-4c87-bb7f-ff9d64f724ca \
order=cd,once=d cdrom=/ubuntu-12.04-server-amd64.iso,ide
Successfully started 3b202a79-f148-4c87-bb7f-ff9d64f724ca
- Get the VNC IP and port from the VM.
# vmadm info 3b202a79-f148-4c87-bb7f-ff9d64f724ca vnc
{
"vnc": {
"host": "10.1.1.4",
"port": 63407,
"display": 57507
}
}
- Connect to the VM with VNC and complete the installation as normal, including the reboot at the end.
- Enable the serial console in Ubuntu with the steps from the Ubuntu SerialConsoleHowto. This step is optional but adds some nice administration benefits as demonstrated in the next step.
- Paste the following into
/etc/init/ttyS0.conf
.
# ttyS0 - getty
#
# This service maintains a getty on ttyS0 from the point the system is
# started until it is shut down again.
start on stopped rc or RUNLEVEL=[2345]
stop on runlevel [!2345]
respawn
exec /sbin/getty -L 115200 ttyS0 vt102
- Ask upstart to start the getty.
$ sudo start ttyS0
- The serial console can then be connected to from the SmartOS host with the
vmadm
tool. Exiting from this console is done with CTRL-]
.
# vmadm console 3b202a79-f148-4c87-bb7f-ff9d64f724ca
Unknown command: console
Ubuntu 12.04 LTS ubuntu12 ttyS0
ubuntu12 login: ed
Password:
Last login: Sat Apr 28 22:38:41 CDT 2012 from 10.1.1.4 on pts/0
Welcome to Ubuntu 12.04 LTS (GNU/Linux 3.2.0-23-generic x86_64)
* Documentation: https://help.ubuntu.com/
System information as of Sat Apr 28 22:39:26 CDT 2012
System load: 0.0 Processes: 61
Usage of /: 4.1% of 35.92GB Users logged in: 1
Memory usage: 1% IP address for eth0: 10.1.1.11
Swap usage: 0%
Graph this data and manage this system at https://landscape.canonical.com/
9 packages can be updated.
0 updates are security updates.
ed@ubuntu12:~$