After getting Gentoo installed on my VirtualBox, I realized that my 20 GB virtual HD wasn’t as big as I had thought. I decided to double my storage.
Figuring out what to do was relatively painless. The Linux Documentation Project has a slightly outdated howto document on hard drive upgrades; the process was almost the same. The first major difference was in the installation of a new drive. Instead of physically installing a new drive, you need to create a new virtual drive image. With VBox running but not booted:
- File -> Virtual Media Manager
- File -> New
- Fill in the details for the new image. Note that, even if you’re going to replace an existing image, you still need to give it a new name.
- OK
- Right-click on the virtual machine, and go to Settings
- Click on “Hard Disks”
- Add the new image as the primary slave
Now you can boot the virtual machine and follow the howto doc.
The second major issue was with the bootloader. The howto was written in 2000, when LILO was the standard Linux bootloader. However, GRUB seems to be more in favour these days, so somewhat different commands are required.
Once the files are copied to the new image (as per the howto instructions), I used the following commands:
# grub
grub> root (hd1,0)
grub> setup (hd1)
grub> quit
Where the code i typed was emphasized. Note also that (hd1,0) is if your virtual drive is the primary slave; your situation may change. GRUB has tab-completion, so typing (hd<TAB> will show you your options.
One more change that may or may not be required, depending on your distribution. If your system uses udev (if /new-disk/dev is empty, you’re using udev), you need to add devices for your console and null (for the few seconds before udev is loaded):
mknod -m600 /new-disk/dev/console 5 1
mknod -m600 /new-disk/dev/tty0 4 0
mknod -m600 /new-disk/dev/tty1 4 1
mknod -m666 /new-disk/dev/null 1 3
These will be hidden by the udev system, but are important for boot.
Once you have done this, shut down the virtual machine. Then go to the virtual machine’s preferences and switch the hard drives around, so the new hard drive is now primary master. After a reboot, you should have a working system with a larger hard drive. Remove the old hard drive image, or keep it as extra storage space.