Saturday, December 26, 2009

VirtualBox: Add Second HDD

Two weeks ago I found a 1 TB external drive for $100, couldn't pass it up. Space was the biggest obstacle in following along in John's EBS series (part IV coming soon).

I had purchased a "small" 320 GB HDD about a month ago, but that effort proved futile because I started to save everything off to that after I upgraded to Karmic Koala and received this lovely message:

Finally, I could install EBS without worrying about space...I created a Dynamically Expanding HDD of 300 GB. I then installed Oracle Enterprise Linux (OEL) 5, Update 4 and loaded as many of the known libraries that I could. Then I began downloaded and unzipping all of the required files. I was doing this in parallel, download the file, unzip, remove the zip file. After about 8 total hours, it was done. The VDI had grown to 68.5 GB.

I then ran the script, navigated through the screens until I got through to the system check. It complained I didn't have enough disk space to install. Of course not...there was only 231.5 GB of space left.

Stupidity followed.

What were my options?

OK, I could extend that VDI to 350 GB...VirtualBox doesn't allow that yet.

But for some reason I couldn't just keep that dynamically expanding VDI, I had to shrink it. How?


That would allow me to first zero out the unused space and then use VBoxManage compacthd to shrink it.

That required greater skills than I had though. First of all, you had to mount the root file system in read-only mode. I tried a bunch of different ways and could never get it to work. Looking back, it might be easy(er)...

I then decided to clone the VDI with VBoxManage clonehd thinking (and therein lies the problem) that would do the trick. 12 hours later, I had the cloned VDI. Added it to the Virtual Media Manager but it is just an exact copy of the other one (68.5 used, 300 GB total). Doh.

Enough of this. I'll just add a 350 HD as a Dynamically Expanding primary slave. So I did, booted up OEL and...where is it? Why can't I find it? I guess I have to mount it right?

Instead of researching first, I just start to muck around with the system. Really long story short, I thought it wise to edit /etc/fstab. Upon reboot, it broke. (Shocker)

Amusingly, the root file system was mounted as read-only so I could finally run zerofree.

OK, so I mucked up /etc/fstab, I can fix that right? Just replace my edits with the original...wait, it's a read-only file system.

Twitter to the rescue for the umpteenth time.

Twitter Question from ORACLENERD

Some back and forth with @brad_tumy before finally going to IM.

He pointed me to this link and this command
mount -w -o remount /
Worked! I could now edit the file and get my system back up and running.

"Um, Brad, while I have you..."
Do you know how to add a second HDD using VirtualBox? (Yes, I'm really sneaky).

He then pointed me to this link written by the esteemed Mr. Topper. It was kind of hard for me to believe at first, I am not sure I have read a "live" post by Mr. Topper in quite some time. Ah yes, the last post was June 5, 2008.

Brad: "Check out step 12, that's where you should start."

OK, step 12, Create the Partition. This is a VMWare guide, but the concepts are the same. I'm really not sure, but I opened up the Logical Volume Manager (LVM)

Opening the Logical Volume Manager

Which opened up this. What's this "Uninitialized Entities" section? I haven't seen that before.

I think I'll click on it.

That looks like my second HDD. Initialize Entity? Sure, why not?

LVM - Initialize Entity

Are you sure you want to initialize this entity? Everything on there will be lost!

LVM - Are you sure?

Do you want to create a single partition? Are you sure about that?

LVM - Single partition?  Positive?

OK, that's done. Now it appears iin the Unallocated Volumes section. Let's create a new Volume Group.

LVM - Create new Volume Group

I named it VolumeEBS, I suppose you can name it whatever you want.

LVM - Volume Group - VolumeEBS



How in the hell do I mount this thing?

(Brad is long gone now...we chatted for over an hour into the wee hours of the morning...I can't blame him. He was probably trying to escape after that second question).

Back to Matt's post. Honestly, I have no idea (yet) if this is the same command I performed via the GUI, but I did it anyway after a couple of unsuccessful attempts at mounting the drive.
[root@ebs chet]# /sbin/mkfs -t ext3 /dev/hdb1
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
39321600 inodes, 78643199 blocks
3932159 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
2400 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872, 71663616

Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 39 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
Something good happened...I think.
[root@ebs chet]# mount -t ext3 /dev/hdb1 /install
[root@ebs chet]# ls /install
Win! Or is that FAIL!? I don't care. It's done.

I added the line (correctly this time) to /etc/fstab, rebooted and it's there.

Now, finally (finally), I can begin my install of EBS. The latest version has probably been released and the instructions are probably moot, but I managed something.


SydOracle said...

I got that Disk Has Many Bad Sectors message from Karmic too. A little Googling told me LOTS of people did and the warning is (mostly) an over-reaction. I just disabled the warning

Tom said...

I got the error too! It's dumb. It should take a percentage of bad sectors or see if they are growing over a period of time before warning people. I imagine it will be fixed at some point :)...

oraclenerd said...


Thanks for the heads up...I hadn't bothered to Google the problem yet. I'm glad I don't (yet) have to replace the disk which is only a year old.