Monday, January 24, 2011

Setting up Debian with VNC

For this example I am using tightvncserver:

1. Install tightvncserver
sudo aptitude install tightvncserver
2. Start a vnc session:
>$ vncserver :1
   b. Try to connect to the server
      i. using screen share type in 10.1.10.10:590?
      ii. Enter your password
3. Stop the server:
   a. >$ vncserver -kill :1
4. Edit the config file in ~/.vnc/xstartup to have it look like the following:
>$ vim ~/.vnc/xstartup

#!/bin/sh

xrdb $HOME/.Xresources
xsetroot -solid grey
x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#x-window-manager &
gnome-session &
# Fix to make GNOME work
#export XKL_XMODMAP_DISABLE=1
#/etc/X11/Xsession

5. Edit vncserver and make the following change:
>$ sudo vim /etc/alternatives/vncserver

44 #$geometry = "1024x768";
45 $geometry = "1344x840";
46 $depth = 24;
6. Create/Edit the following file:
>$ sudo vim /etc/init.d/vncserver

#! /bin/sh -e
### BEGIN INIT INFO
# Provides:     vncserver
# Required-Start:   $local_fs
# Required-Stop:    
# Should-Start:     vncserver
# Should-Stop:      vncserver
# Default-Start:    2 3 4 5
# Default-Stop:     0 1 6
# Short-Description:    Start vncserver.
### END INIT INFO

# Some things that run always
touch /var/lock/vncserver

# Carry out specific functions when asked to by the system
case "$1" in
start)
echo "Starting script vncserver "
su - test -c "vncserver :1"
;;
stop)
echo "Stopping script vncserver"
su - test -c "vncserver -kill :1"
;;
*)
echo "Usage: /etc/init.d/vncserver {start|stop}"
exit 1
;;
esac

exit 0
   a. Change "test" to your username
7. Change the permissions:
>$ sudo chmod 755 /etc/init.d/vncserver
8. Set the script to start at boot:
>$ sudo update-rc.d vncserver defaults

"Failed to find an unused loop device"

So after spending an entire day trying to install a domU from a bad ISO I finally had one running which I decided to make clones of. After making 7 additional clones I tried to start them all at the same time but received the error of "Failed to find an unused loop device."

After looking around I found the following site:

http://snippets.aktagon.com/snippets/70-Fix-for-Failed-to-find-an-unused-loop-device-when-using-xen

Here it explains that the Xen machine is not setup to handle this many loop devices by default. By default each domU may take at least two loop devices. The solution to the problem was to create the file '/etc/modprobe.d/local-loop' and place the following line in it:

options loop max_loop=64

After creating this file and restarting the machine I am able to create at least 7 domUs and have them running at the same time.

Wednesday, January 5, 2011

sudo and cat

Have you ever wanted to cat something and redirect it to another file but received the error or "Permission denied?" Apparently it is due to the fact that sudo is only applied to the first part of the redirection and not the the file you want to redirect it to.

For example:

$ sudo cat /etc/passwd > /etc/passwd1
-bash: /etc/passwd1: Permission denied

I have found a forum post that gives an explanation and a fix:

http://www.linuxquestions.org/questions/linux-software-2/sudo-and-permission-denied-651619/#post3194983

posts #2 and #3