- Create a new image with the size that you require. Just give any meaningful name to the image. In this case I will use the name extended.img
- # dd if=/dev/zero of=extended.img bs=1 count=1 seek=20G conv=notrunc
- Add the new image to the configuration file of your DomU. In this example, the name of the domU is xen0
- # vi /etc/xen/xen0
- Add these line to it
- disk = [ 'tap:aio:/path/to/xen/xen0.img,xvda,w','file:/path/to/xen/extended.img,xvdb,w' ]
- Save
- Start your domU
- # xm create xen0
- Access your domU
- # xm console xen0
- Once inside, check whether the new image is detected
- # fdisk -lu
- After confirm that your new hard disk image is detected, it is time we have to work on the lvm
- Create new physical volume (PV) using the new hard disk image
- # pvcreate -v /dev/xvdb
- Check that you have successfully added the PV
- # pvdisplay
- Extend your existing volume group (VG) to include the new PV
- # vgextend -v VolGroup00 /dev/xvdb
- Check that you have successfully add the PV into the VG
- # vgdisplay
- Extend your logical volume (LV)
- # lvextend -L +20G -v /dev/VolGroup00/LogVol00
- Check that the extension has been added
- # lvdisplay
- If all the steps are successfully done, you have to resize the / partition
- # resize2fs /dev/mapper/VolGroup00-LogVol00
- You are done. Check your new hard disk space :)
- # df -lh
Friday, August 29, 2008
Resizing your xen DomU using LVM
To resize the disk space of a xen DomU that is using Logical Volume Manager(LVM) is very easy. Below is step by step on how to do the resizing process.
Monday, August 25, 2008
NFS quick howto for centos 5
To use nfs successfully, you have to configure the server and the client. In this example, the client is 192.168.0.3 and the server is 192.168.0.1. The folder to be shared is /home/sharing, and to be mounted to /mnt on the client
On the server
On the server
- Make directory that you want to use.
- # mkdir /home/sharing
- Edit /etc/exports, insert the client machine's ip
- # vi /etc/exports
- Add this line:
- /home/sharing 192.168.0.3/255.255.255.255(rw,sync)
- Save
- Edit /etc/hosts.allow
- # vi /etc/hosts.allow
- Add this line:
portmap: 192.168.0.0/255.255.255.0
- Save
- Start nfs and portmap
- # /etc/init.d /nfs start
- # /etc/init.d/portmap start
- Start portmap
- # /etc/init.d/portmap start
- Mount the nfs folder
- # mount 192.168.0.1:/home/sharing /mnt
- Check /var/log/messages for any error that might occur
- # tailf /var/log/messages
- Use mount to check if the folder is mounted properly
- # mount
- This should be the output:
- 192.168.0.1:/home/sharing on /mnt type nfs (rw,addr=192.168.0.1)
- Edit /etc/fstab to mount the shared folder on boot
- # vi /etc/fstab
- Add this line
- 192.168.0.1:/mnt/sdb1/backup /mnt nfs rw,hard,intr 0 0
- Save
Wednesday, August 20, 2008
Installing backuppc in centos 5
I have been given the task of setting up one backuppc server, and below are the steps on how I did it :)
Server setup
Server setup
- Download the backuppc 3.1.0 srpm from dev.centos.org
- Rebuild the srpm using rpmbuild. If the command is not there in your pc, install it first using 'yum install rpm-build'
- # rpmbuild --rebuild backuppc-3.1.0-1.el5.centos.src.rpm
- Get your rpm file at /usr/src/redhat/RPMS/i386 and install it. Install all the perl module needed using yum
- # yum install perl-Compress-Zlib perl-Archive-Zip perl-File-RsyncP perl-XML-RSS httpd
- # rpm -Uvh backuppc-3.1.0-1%{dist}.i386.rpm
- User backuppc will be created upon installation. Change apache user to backuppc.
- # vi /etc/httpd/conf/httpd.conf
- Change 'User apache' to 'User backuppc'
- Save
- Edit file /etc/httpd/conf.d/backuppc.conf
- # vi /etc/httpd/conf.d/backuppc.conf
- change 'Allow from 127.0.0.1' to 'Allow from all'
- Save
- Create password for cgi-bin admin user
- # htpasswd -c /var/lib/backuppc/passwd/htpasswd admin
- Edit backuppc config file
- # vi /etc/BackupPC/config.pl
- Find and change accordingly
- $Conf{ServerHost} = 'localhost';
- $Conf{SplitPath} = '/usr/bin/split';
$Conf{CatPath} = '/bin/cat';
$Conf{GzipPath} = '/bin/gzip';
$Conf{Bzip2Path} = '/usr/bin/bzip2'; - $Conf{BackupPCUser} = 'backuppc';
- $Conf{TopDir} = '/var/lib/backuppc';
$Conf{ConfDir} = '/etc/BackupPC';
$Conf{LogDir} = '/var/log/BackupPC';
$Conf{InstallDir} = '/usr';
$Conf{CgiDir} = '/usr/share/backuppc/cgi-bin'; - $Conf{ServerInitdPath} = '/etc/init.d/backuppc';
$Conf{ServerInitdStartCmd} = '$sshPath -q -x -l root $serverHost$serverInitdPath start'; - $Conf{SshPath} = '/usr/bin/ssh';
- $Conf{NmbLookupPath} = '/usr/bin/nmblookup';
- $Conf{PingPath} = '/bin/ping';
- $Conf{CgiAdminUsers} = 'admin';
- Save
- Grant passwordless sudo for user backuppc to run /bin/gtar and /bin/tar
- # visudo
- Add these entries
- Defaults !lecture # to disable lecture
- backuppc ALL=NOPASSWD:/bin/gtar,/bin/tar # enable user backuppc to run /bin/tar and /bin/gtar without authentication.
- Comment this entry
- #Defaults requiretty
- Save
- Restart apache and backuppc service
- # /etc/init.d/http restart
- # /etc/init.d/backuppc restart
- Open your browser and point it to 'http://backuppc_server_ip
/backuppc' and you should see the backuppc web interface - After this, you have to do almost all the configuration through the web interface. To test, you can run localhost backup first. You have to create the host, fill up all the setting and you are ready to go. Record the host and ip in /etc/hosts.
- Create new user
- # useradd backupuser
- # passwd backupuser
- Grant passwordless sudo for user backupuser
- # visudo
- Add these entries
- Defaults !lecture # to disable lecture
- backupuser ALL=NOPASSWD:/bin/gtar,/bin/tar # enable user backuppc to run /bin/tar and /bin/gtar without authentication.
- Comment this entry
- #Defaults requiretty
- Save
- From the server using backuppc user, create ssh public key
- # su -s /bin/bash backuppc
- $ mkdir .ssh
- $ chown backuppc.backuppc .ssh
- $ chmod 700 .ssh
- $ ssh-keygen -t rsa
- $ ssh-copy-id -i .ssh/id_rsa.pub backupuser@client
- To make sure that the 3rd step is a success, try to ssh to backupuser@client using backuppc user from the server. If no password is asked, then you are ready.
- # su -s /bin/bash backuppc
- $ ssh backupuser@client
- You can start entering the client to the list of host and start backing up :)
Monday, August 18, 2008
Saving website on local machine
Sometimes you found a website that is very interesting, but you just do not have enough time to read it on that particular time. You wish you could save it so that you can view it offline without connecting to the internet. This can be done using wget;
$ wget -m -k -K -E http://www.tldp.org/HOWTO/LVM-HOWTO/index.html
where -m for mirror, -k for convert the links so that it will be suitable for local viewing, -K for backup converted files and -E for adding html extension to the files downloaded. This is the result of the above command;
$ ls
www.tldp.org
Use any web browser to view the files offline by opening the .html file inside the above folder
$ wget -m -k -K -E http://www.tldp.org/HOWTO/LVM-HOWTO/index.html
where -m for mirror, -k for convert the links so that it will be suitable for local viewing, -K for backup converted files and -E for adding html extension to the files downloaded. This is the result of the above command;
$ ls
www.tldp.org
Use any web browser to view the files offline by opening the .html file inside the above folder