Posted by Matteo Mattei / 10th June 2011
Few days ago I spent some times to try to shrink my Ubuntu 11.04 appliance with root partition formatted with EXT4 filesystem.
The main problem is that the current VMware tools (8.4.6, build-385536) does not support the ext4 shrink. If you run sudo vmware-toolbox, your root partition is formatted in ext4 and you try to execute the shrink an error message like the following could appear.

Anyway there is a trick to streamline the final vmdk size.
Run this command within a shell into the guest system:
sudo dd if=/dev/zero of=/zero.raw bs=20480
rm -f /zero.raw
Then, shutdown the virtual image and download the vdiskmanager tool from VMware website.
Now run the vmware-vdiskmanager with the -k parameter:
vmware-diskmanager -k /path/to/image.vmdk
This operation will take a while, but at the end you will get a considerable smaller vmdk image file.
Posted by Matteo Mattei / 4th February 2011
I’m usually to configure vsftp on web servers to allow FTP access based on domains. Few days ago my client asked me to create multiple FTP users for a single domain every one with a different root folder into that domain.
This is my usual configuration of my /etc/vsftpd.conf
listen=YES
anonymous_enable=NO
local_enable=YES
virtual_use_local_privs=YES
write_enable=YES
connect_from_port_20=YES
xferlog_enable=YES
pam_service_name=vsftpd
guest_enable=YES
guest_username=www-data
user_sub_token=$USER
local_root=/var/www/$USER
chroot_local_user=YES
hide_ids=YES
force_dot_files=YES
ftpd_banner=Welcome to my private FTP service.
local_umask=022
and this is my /etc/pam.d/vsftpd
auth required pam_pwdfile.so pwdfile /etc/ftpd.passwd
account required pam_permit.so
The first time I’ve created the file /etc/ftpd.passwd in this way:
htpasswd -c -d -b /etc/ftpd.passwd domain1.com <password>
For the future users simply avoid the ‘-c’ parameter:
htpasswd -d -b /etc/ftpd.passwd domain2.com <password>
With this simple configuration all users have these credentials:
- host: domain1.com
- username: domain1.com
- password: password
- port: 21
- Root folder: /var/www/domain1/
Now the point is: how can we create multiple users for a single domain each one with a different root folder?
The answer is pretty simple, follow me!
Create the folder /var/www/users and add the following line at the end of /etc/vsftpd.conf
user_config_dir=/var/www/users
Into the folder /var/www/users create a file for each virtual user (for example the user user1.domain1.com) containing a line the root directory for that user:
echo "local_root=/var/www/domain1.com/pub/user1" > /var/www/users/user1.domain1.com
Now add the new user/password in /etc/ftpd.passwd as usual:
htpasswd -d -b /etc/ftpd.passwd user1.domain1.com <password>
Restart vsftpd server and test your new configuration!