Difference between pages "Blocks, block devices and block sizes" and "Guacamole 0.8.3"

From Linuxintro
(Difference between pages)
imported>ThorstenStaerk
 
 
Line 1: Line 1:
A [[block device]] is a [[device]] you can read blocks from. For example [[hard disks]], cdrom drives and floppies are block devices, but not the [[keyboard]]. You can receive data from the keyboard and regard them as blocks, but you cannot seek on the keyboard. You can tell a hard disk "give me block 5433", then block 7707, then block 1807 and you cannot do this with a keyboard, so, a keyboard is no block device.
+
Hello! baceakd interesting baceakd site! I'm really like it! Very, very baceakd good!
  
= Block sizes =
+
= Quickstart =
It is important to understand the ideas behind the block sizes.
+
This will show you
 +
* how to install guacamole 0.8.3 on Ubuntu (tested with 10.04 and 12.04)
 +
* how to make this configuration survive a reboot
 +
* how to secure transmission with SSL
 +
* how to make the website accessible from behind a firewall (port 80 or 443)
  
== Disk block sizes ==
+
Here's what you do as root user:
Typically, a hard disk cannot read less than 512 bytes, if you want to read less, read 512 bytes and discard the rest. This is why [[dd]] reads one block à 512 bytes in the following example:
+
* install software that we will need later:
<source>
+
  apt-get update
tweedleburg:~ # dd if=/dev/sda1 of=/dev/null count=1
+
  apt-get install tomcat6 tightvncserver make xterm
  1+0 records in
 
1+0 records out
 
  512 bytes (512 B) copied, 1.8977e-05 s, 27.0 MB/s
 
</source>
 
  
== File system block sizes ==
+
== configure VNC server ==
On the other hand, every file system needs to split up a partition into blocks to store [[file]]s and file parts. This is why there is a different block size for a file system as you can see here:
+
Guacamole does the communication between a VNC server and the web browser. So whatever you see in VNC will be in the browser. Let's use gnome as desktop environment:
<source>
+
* install gnome:
tweedleburg:/mnt/sdb2 # stat -f .
+
  apt-get install gnome-session
  File: "."
+
* activate gnome for your VNC:
    ID: 236d62321492c2ce Namelen: 255    Type: ext2/ext3
+
  cd
Block size: '''4096'''      Fundamental block size: 4096
+
  mkdir .vnc
Blocks: Total: 76899893  Free: 8380419    Available: 4474114
+
  cat >> .vnc/xstartup <<EOF
Inodes: Total: 39075840  Free: 38013010
+
  #!/bin/sh
</source>
+
  gnome-session || xterm
So, if you store a file in this file system, it will be stored in a 4096-byte-block, that means, even if your file only contains 5 bytes, it will take away 4096 bytes from your disk's capacity:
+
  EOF
<source>
+
  chmod 777 .vnc/xstartup
tweedleburg:/mnt/sdb2 # df .
 
  Filesystem          1K-blocks      Used Available Use% Mounted on
 
/dev/sdb2            307599572 274077896  17896456  94% /mnt/sdb2
 
  tweedleburg:/mnt/sdb2 # echo hallo>welt
 
  tweedleburg:/mnt/sdb2 # df .
 
  Filesystem          1K-blocks      Used Available Use% Mounted on
 
  /dev/sdb2            307599572 274077900  17896452  94% /mnt/sdb2
 
  tweedleburg:/mnt/sdb2 # du -csh welt
 
  4.0K    welt
 
  4.0K    total
 
</source>
 
  
== Kernel block size ==
+
== deploy guacamole client ==
Also the kernel has its own block size. This is relevant e.g. for vmstat. In the [http://unixhelp.ed.ac.uk/CGI/man-cgi?vmstat vmstat man page] you find the statement
+
* download the guacamole webapp from http://sourceforge.net/projects/guacamole/files/current/binary/
<source>
+
* deploy it
All linux blocks are currently 1024 bytes.
+
# mv guacamole-0.8.3.war /var/lib/tomcat6/webapps/
</source>
+
* surf to http://localhost:8080/guacamole-0.8.3. A folder /var/lib/tomcat6/webapps/guacamole-0.8.3 will be created with some content. We will need that later.
So, again another block size when you work with vmstat. This is the block size the Linux kernel uses internally for caching and buffering. It is the most prominent of all block sizes.
+
* although login is not yet possible your browser will show a login screen like that:
  
== Applications ==
+
[[File:guacamole-login.png|250px]]
  
=== vmstat ===
+
== install guacamole server ==
vmstat uses 1k blocks
+
* install some [[dependencies]] that the server will need to build with vnc support:
 +
apt-get install libvncserver-dev libpng-dev libcairo-dev
 +
* download guacamole-server from http://sourceforge.net/projects/guacamole/files/current/source/
 +
* unpack it
 +
tar xvzf guacamole-server-0.8.3.tar.gz
 +
* build the server:
 +
cd guacamole-server-0.8.3
 +
./configure && make -j8 && make install
 +
* the following step is ugly; installation and binary do not completely fit so we must do that:
 +
ln -s /usr/local/lib/libguac.so* /lib
 +
ln -s /usr/local/lib/libguac-client-vnc.so* /lib/
 +
* now we start the guacamole daemon
 +
# guacd
 +
guacd[11581]: INFO:  Guacamole proxy daemon (guacd) version 0.8.3
 +
guacd[11581]: INFO:  Successfully bound socket to host ::1, port 4822
 +
guacd[11581]: INFO:  Exiting and passing control to PID 11582
  
=== iostat ===
+
== configure guacamole ==
iostat uses 512B blocks
+
* create a folder for guacamole's configuration:
 +
mkdir /etc/guacamole
 +
* create a file /etc/guacamole/guacamole.properties with the content
 +
# Hostname and port of guacamole proxy
 +
guacd-hostname: localhost
 +
guacd-port:    4822
 +
 +
# Location to read extra .jar's from
 +
lib-directory:  /var/lib/tomcat6/webapps/guacamole-0.8.3/WEB-INF/classes
 +
 +
# Authentication provider class
 +
auth-provider: net.sourceforge.guacamole.net.basic.BasicFileAuthenticationProvider
 +
 +
# Properties used by BasicFileAuthenticationProvider
 +
basic-user-mapping: /etc/guacamole/user-mapping.xml
 +
* create a file /etc/guacamole/user-mapping.xml with the content
 +
<user-mapping>
 +
    <authorize username="user" password="password">
 +
      <protocol>vnc</protocol>
 +
          <param name="hostname">localhost</param>
 +
          <param name="port">5901</param>
 +
          <param name="password">password</param>
 +
    </authorize>
 +
</user-mapping>
  
= I/O =
+
== configure tomcat ==
There is  
+
* find out your tomcat's user directory:
* buffered I/O and direct I/O
+
# cat /etc/passwd|grep tomcat
* async I/O and sync I/O
+
tomcat6:x:113:116::/usr/share/tomcat6:/bin/false
 +
: in this case it is /usr/share/tomcat6
 +
* create a folder .guacamole in your tomcat's user directory:
 +
mkdir /usr/share/tomcat6/.guacamole
 +
* link guacamole.properties into your tomcat's user directories' guacamole folder
 +
ln -s /etc/guacamole/guacamole.properties /usr/share/tomcat6/.guacamole
  
The difference between buffered I/O and direct I/O is that direct I/O does not use the operating system cache. During the [http://linux.die.net/man/2/open open syscall], you can say that you want direct I/O. [http://unixfoo.blogspot.com/2008/01/what-is-direct-io.html More info...]
+
== finishing ==
 +
* start a vnc server, as password set password (the vnc password given in user-mappings.xml)
 +
vncserver
 +
* restart your tomcat server
 +
/etc/init.d/tomcat6 restart
 +
* point your browser to http://localhost:8080/guacamole-0.8.3
 +
* log in as user, password password (the user given in user-mappings.xml)
 +
* you should see a screen like this:
  
The difference between async I/O and sync I/O is that async I/O reads/writes from/to a file without waiting for the data to actually arrive, but rather having the data sent to a network socket. You must use libaio for this. [http://blog.lighttpd.net/articles/2006/11/09/async-io-on-linux More info...]
+
[[File:Guacamole-after-login.png]]
  
= How to... =
+
* next steps: SSL
 +
* next steps: proxypass
  
== Find out the size of a block device ==
+
= Persist it =
To find out the size of the block device ''/dev/sda'':
+
Add the following lines to /etc/crontab:
<source>
+
  @reboot root /usr/local/sbin/guacd &
  fdisk -l /dev/sda
+
  @reboot root USER=root /usr/bin/vncserver
</source>
 
or, a bit harder to read:
 
<source>
 
  hwinfo --block
 
</source>
 
  
== Find out the file system stored on a block device ==
+
= TroubleShooting =
A file system will typically be stored in a partition, not directly in a block device. To find all partitions on ''/dev/sda'' use
 
<source>
 
fdisk -l /dev/sda
 
</source>
 
To find out what file system is stored on ''/dev/sda1'' use
 
<source>
 
file -s /dev/sda1
 
</source>
 
  
== Find out the elevator algorithm ==
+
== invalid login ==
The elevator algorithm can be found like this:
+
* now the problem is that tomcat does not know where to find the Authentication class:
<source>
 
cat /sys/devices/platform/host7/session1/target7\:0\:0/7\:0\:0\:0/block/sdi/queue/scheduler
 
noop anticipatory [deadline] cfq
 
</source>
 
In this case, the deadline elevator algorithm is active.
 
  
Or it may be found like this:
+
/var/lib/tomcat6/webapps/guacamole/WEB-INF/classes/net/sourceforge/guacamole/net/basic/BasicFileAuthenticationProvider.class
<source>
 
cat /sys/class/block/sdb/queue/scheduler
 
noop deadline [cfq]
 
</source>
 
  
You can switch the scheduler like this:
+
is not in /etc/guacamole/guacamole.properties
<source>
 
# cat /sys/class/block/sdb/queue/scheduler
 
noop deadline [cfq]
 
# echo "noop">/sys/class/block/sdb/queue/scheduler
 
# cat /sys/class/block/sdb/queue/scheduler
 
[noop] deadline cfq
 
</source>
 
  
= Associated commands =
+
* so add it
* [[dd]]
+
* cat /etc/passwd gives me a line
* [[vmstat]]
+
tomcat6:x:113:116::/usr/share/tomcat6:/bin/false
* [http://linux.die.net/man/1/iostat iostat]
+
 
* [[stat]]
+
ll /usr/share/tomcat6/.guacamole/
* [https://www.howtogeek.com/106873/how-to-use-fdisk-to-manage-partitions-on-linux/ fdisk]
+
total 8
* [[hwinfo]] --block
+
drwxr-xr-x 2 root root 4096 Nov 26 07:58 ./
* [[hwinfo]] --partition
+
drwxr-xr-x 6 root root 4096 Nov 26 07:57 ../
* [[file]] -s ''/dev/sda'' : finds out the filesystem type of /dev/sda
+
lrwxrwxrwx 1 root root  35 Nov 26 07:58 guacamole.properties -> /etc/guacamole/guacamole.properties
 +
 
 +
* works now. So the thing is:
 +
** take care that it is called guacamole and not guacamole-0.8.3 (sure?)
 +
** make sure the classpath in /etc/guacamole/guacamole.properties is correct, e.g.
 +
# Location to read extra .jar's from
 +
lib-directory:  /var/lib/tomcat6/webapps/guacamole/WEB-INF/classes
 +
 
 +
== Server error ==
 +
* now I got a server error so I straced guacd:
 +
strace -p 15332
 +
and saw
 +
[pid 20344] open("/usr/lib/x86_64-linux-gnu/libguac-client-vnc.so", O_RDONLY) = -1 ENOENT (No such file or directory)
 +
so the problem is that libguac-client-vnc.so is missing.
 +
* downloaded java version 1.7.45 and compiled guacamole-client using mvn. But there was no *.so* file in it
 +
* so installed libvncserver-dev and rebuild and reinstalled guacamole-server
 +
* and there it is, libguac-client-vnc.so
 +
* now the error message changed from "server error" to "unauthorized"
  
 
= See also =
 
= See also =
* [[paging vs. swapping]]
+
* [[connect to a Linux computer]]
* http://www.linuxforums.org/forum/misc/5654-linux-disk-block-size-help-please.html
+
* [[guacamole 0.8 on SUSE]]
 +
* [[guacamole 0.3.0 on Ubuntu 10.04]]
 +
* [[guacamole on Debian 6]]
 +
* [[guacamole on Ubuntu 11.10 32bit]]
 +
* [[cool things]]
 +
* [[schedule tAsks]]
 +
* http://guac-dev.org/Debian%20Install%20Instructions
 +
* ulteo
 +
* http://www.filegott.se/prd/index.php/how-tos/19-how-to-setup-guacamole-in-linux-ubuntu
 +
* http://guac-dev.org/doc/gug/installing-guacamole.html#idp99200
  
[[Category:Concept]]
+
[[Category:Tool]]
 +
[[Category:Webmaster]]

Revision as of 12:49, 5 December 2013

Hello! baceakd interesting baceakd site! I'm really like it! Very, very baceakd good!

Quickstart

This will show you

  • how to install guacamole 0.8.3 on Ubuntu (tested with 10.04 and 12.04)
  • how to make this configuration survive a reboot
  • how to secure transmission with SSL
  • how to make the website accessible from behind a firewall (port 80 or 443)

Here's what you do as root user:

  • install software that we will need later:
apt-get update
apt-get install tomcat6 tightvncserver make xterm

configure VNC server

Guacamole does the communication between a VNC server and the web browser. So whatever you see in VNC will be in the browser. Let's use gnome as desktop environment:

  • install gnome:
apt-get install gnome-session
  • activate gnome for your VNC:
cd
mkdir .vnc
cat >> .vnc/xstartup <<EOF
#!/bin/sh
gnome-session || xterm
EOF
chmod 777 .vnc/xstartup

deploy guacamole client

# mv guacamole-0.8.3.war /var/lib/tomcat6/webapps/
  • surf to http://localhost:8080/guacamole-0.8.3. A folder /var/lib/tomcat6/webapps/guacamole-0.8.3 will be created with some content. We will need that later.
  • although login is not yet possible your browser will show a login screen like that:

Guacamole-login.png

install guacamole server

  • install some dependencies that the server will need to build with vnc support:
apt-get install libvncserver-dev libpng-dev libcairo-dev
tar xvzf guacamole-server-0.8.3.tar.gz
  • build the server:
cd guacamole-server-0.8.3
./configure && make -j8 && make install
  • the following step is ugly; installation and binary do not completely fit so we must do that:
ln -s /usr/local/lib/libguac.so* /lib
ln -s /usr/local/lib/libguac-client-vnc.so* /lib/
  • now we start the guacamole daemon
# guacd 
guacd[11581]: INFO:  Guacamole proxy daemon (guacd) version 0.8.3
guacd[11581]: INFO:  Successfully bound socket to host ::1, port 4822
guacd[11581]: INFO:  Exiting and passing control to PID 11582

configure guacamole

  • create a folder for guacamole's configuration:
mkdir /etc/guacamole
  • create a file /etc/guacamole/guacamole.properties with the content
# Hostname and port of guacamole proxy
guacd-hostname: localhost
guacd-port:     4822

# Location to read extra .jar's from
lib-directory:  /var/lib/tomcat6/webapps/guacamole-0.8.3/WEB-INF/classes

# Authentication provider class
auth-provider: net.sourceforge.guacamole.net.basic.BasicFileAuthenticationProvider

# Properties used by BasicFileAuthenticationProvider
basic-user-mapping: /etc/guacamole/user-mapping.xml
  • create a file /etc/guacamole/user-mapping.xml with the content
<user-mapping>
   <authorize username="user" password="password">
      <protocol>vnc</protocol>
         <param name="hostname">localhost</param>
         <param name="port">5901</param>
         <param name="password">password</param>
    </authorize>
</user-mapping>

configure tomcat

  • find out your tomcat's user directory:
# cat /etc/passwd|grep tomcat
tomcat6:x:113:116::/usr/share/tomcat6:/bin/false
in this case it is /usr/share/tomcat6
  • create a folder .guacamole in your tomcat's user directory:
mkdir /usr/share/tomcat6/.guacamole
  • link guacamole.properties into your tomcat's user directories' guacamole folder
ln -s /etc/guacamole/guacamole.properties /usr/share/tomcat6/.guacamole

finishing

  • start a vnc server, as password set password (the vnc password given in user-mappings.xml)
vncserver
  • restart your tomcat server
/etc/init.d/tomcat6 restart

Guacamole-after-login.png

  • next steps: SSL
  • next steps: proxypass

Persist it

Add the following lines to /etc/crontab:

@reboot root /usr/local/sbin/guacd &
@reboot root USER=root /usr/bin/vncserver

TroubleShooting

invalid login

  • now the problem is that tomcat does not know where to find the Authentication class:

/var/lib/tomcat6/webapps/guacamole/WEB-INF/classes/net/sourceforge/guacamole/net/basic/BasicFileAuthenticationProvider.class

is not in /etc/guacamole/guacamole.properties

  • so add it
  • cat /etc/passwd gives me a line
tomcat6:x:113:116::/usr/share/tomcat6:/bin/false
ll /usr/share/tomcat6/.guacamole/
total 8
drwxr-xr-x 2 root root 4096 Nov 26 07:58 ./
drwxr-xr-x 6 root root 4096 Nov 26 07:57 ../
lrwxrwxrwx 1 root root   35 Nov 26 07:58 guacamole.properties -> /etc/guacamole/guacamole.properties
  • works now. So the thing is:
    • take care that it is called guacamole and not guacamole-0.8.3 (sure?)
    • make sure the classpath in /etc/guacamole/guacamole.properties is correct, e.g.
# Location to read extra .jar's from
lib-directory:  /var/lib/tomcat6/webapps/guacamole/WEB-INF/classes

Server error

  • now I got a server error so I straced guacd:
strace -p 15332

and saw

[pid 20344] open("/usr/lib/x86_64-linux-gnu/libguac-client-vnc.so", O_RDONLY) = -1 ENOENT (No such file or directory)

so the problem is that libguac-client-vnc.so is missing.

  • downloaded java version 1.7.45 and compiled guacamole-client using mvn. But there was no *.so* file in it
  • so installed libvncserver-dev and rebuild and reinstalled guacamole-server
  • and there it is, libguac-client-vnc.so
  • now the error message changed from "server error" to "unauthorized"

See also