This short tutorial sums up how to add a second or third hard drive to an operating system
Here i will add a hard drive (Attach it, or add it to a xen domain), Format the hard drive as EXT3, Mount it, and add it to fstab so that it mounts whenever i boot the Guest os or the computer
First, if we are talking about a bare metal machine, You would probably want to add a hard drive by attaching it with cables to the computer, if we are talking about a XEN Domain (Guest OS), then we need to create a new hard drive image file.
To add a new hard drive image file, we execute something like the following on the command line
dd if=/dev/zero of=/directory/filename.img bs=1M count=20000
Now after executing the above, we have a 20 GB hard disk image file.
Now, if we are adding this to a XEN domain, we would probably want to add the following line to the cfg file of that domain
'tap:aio:/directory/filename.img,hdb,w',
right below the line that looks allot like this one, this tells XEN to add the disk to the machine as hdb (We will partition it inside the guest OS and also format it.)
Now shutdown the guest, then start it again
xm create domain.cfg
All nice up to this minute, fdisk inside the guest should clearly display this drive, So execute
fdisk hdb
Now from that menu, n for new partition, p for primary, then 1, then accept default first and last cylinder, then w to write changes and exit
mkfs -t ext3 /dev/hdb1
Create the directory where you want to mount this hard disk
mkdir /hd2
Now to have the disk mount at power on, We would probably want to add the following line to /etc/fstab
/dev/hdb1 /hd2 ext3 rw 0 1
or
/dev/hdc1 /hd3 ext3 rw 0 1
Now rather than rebooting, to test the above just issue the command
mount -a
Than you can check if your disks are all online, and how much free space is on them with
df -h
![]() |
|
![]() |
|
| .COM | $ 8.49 |
| .NET | $ 6.49 |
| .ORG | $ 7.49 |
| .INFO | $ 1.99 |
| Compare Pricing | |
| Cheap Domains | |