VirtualBox/Preparing a disk image

From Sugar Labs
< VirtualBox
Revision as of 21:52, 27 June 2010 by FGrose (talk | contribs)
Jump to navigation Jump to search

Instructions for preparing a VirtualBox disk image from a SoaS iso image file.

Installing SoaS .iso image

  1. Create a new VM, choose a name, such as Mirabelle
  2. Choose Linux for the Operating System and Version Fedora (use 64 bit, if available)
  3. Choose Base Memory Size: 256 MB to match an XO-1, 512 or 1024 MB to match an XO-1.5
  4. Create a new virtual hard disk image with dynamically expanding storage of 2 GB
  5. Finish.
  6. Download the lastest SoaS, http://spins.fedoraproject.org/soas/#downloads, for Fedora 13.
  7. Mount the SoaS .iso image file as a CD-ROM in the newly created VM.
  8. Change the Network Attached to: Bridged Adapter (This allows for networking with the host computer.)
  9. Start the VM
  10. Enter an account name and startup Sugar.
  11. Open Terminal.
  12. su -
  13. parted
  14. mklabel msdos
    This makes a partition table.
  15. mkpart primary ext2 0 2048
    You will receive this message:
    Warning: The resulting partition is not properly aligned for best performance.
    Ignore/Cancel?
    Enter (I)gnore
  16. toggle 1 boot
  17. quit
  18. mke2fs /dev/sda1
  19. /LiveOS/livecd-iso-to-disk --overlay-size-mb 200 --home-size-mb 200 --delete-home --unencrypted-home /dev/live /dev/sda1
    (for earlier versions of SoaS
    Blueberry - use /media/soas-2-blueberry/LiveOS/livecd-iso-to-disk
    Strawberry - use /mnt/live/LiveOS/livecd-iso-to-disk)
    <Terminal log>
    [root@localhost ~]# parted
    GNU Parted 2.1
    Using /dev/sda
    Welcome to GNU Parted! Type 'help' to view a list of commands.
    (parted) mklabel msdos                                                    
    (parted) mkpart primary ext2 0 2048
    Warning: The resulting partition is not properly aligned for best performance.
    Ignore/Cancel? I                                                          
    (parted) toggle 1 boot                                                    
    (parted) quit                                                             
    Information: You may need to update /etc/fstab.                           
    
    [root@localhost ~]# mke2fs /dev/sda1
    mke2fs 1.41.10 (10-Feb-2009)
    Filesystem label=
    OS type: Linux
    Block size=4096 (log=2)
    Fragment size=4096 (log=2)
    Stride=0 blocks, Stripe width=0 blocks
    125184 inodes, 500000 blocks
    25000 blocks (5.00%) reserved for the super user
    First data block=0
    Maximum filesystem blocks=515899392
    16 block groups
    32768 blocks per group, 32768 fragments per group
    7824 inodes per group
    Superblock backups stored on blocks: 
        32768, 98304, 163840, 229376, 294912
    
    Writing inode tables: done                            
    Writing superblocks and filesystem accounting information: done
    
    This filesystem will be automatically checked every 36 mounts or
    180 days, whichever comes first.  Use tune2fs -c or -i to override.
    [root@localhost ~]# /LiveOS/livecd-iso-to-disk --overlay-size-mb 200 --home-size-mb 200 --delete-home --unencrypted-home /dev/live /dev/sda1
    Verifying image...
    /dev/sr0:   0ce28e3947106fd37bab9317abf09938
    Fragment sums: a3c6e5fd5fba11d2b4da71771e8732b63bcb62b841971f7f39ab5c187f64
    Fragment count: 20
    Checking: 100.0%
    
    The media check is complete, the result is: PASS.
    
    It is OK to use this media.
    Copying live image to USB stick
    Updating boot config file
    Initializing persistent overlay file
    0+0 records in
    0+0 records out
    0 bytes (0 B) copied, 0.000150187 s, 0.0 kB/s
    Initializing persistent /home
    0+0 records in
    0+0 records out
    0 bytes (0 B) copied, 0.0039562 s, 0.0 kB/s
    Formatting unencrypted /home
    mke2fs 1.41.10 (10-Feb-2009)
    Filesystem label=
    OS type: Linux
    Block size=1024 (log=0)
    Fragment size=1024 (log=0)
    Stride=0 blocks, Stripe width=0 blocks
    51200 inodes, 204800 blocks
    10240 blocks (5.00%) reserved for the super user
    First data block=1
    Maximum filesystem blocks=67371008
    25 block groups
    8192 blocks per group, 8192 fragments per group
    2048 inodes per group
    Superblock backups stored on blocks: 
        8193, 24577, 40961, 57345, 73729
    
    Writing inode tables: done                            
    Creating journal (4096 blocks): done
    Writing superblocks and filesystem accounting information: done
    
    This filesystem will be automatically checked every 26 mounts or
    180 days, whichever comes first.  Use tune2fs -c or -i to override.
    tune2fs 1.41.10 (10-Feb-2009)
    Setting maximal mount count to -1
    Setting interval between checks to 0 seconds
    Installing boot loader
    /media/usbdev.XB8shz/syslinux is device /dev/sda1
    USB stick set up as live image!
    
    • the --overlay-size-mb NNN and --home-size-mb NNN options creates space for persistence of changes on the disk; otherwise, a liveOS disk is read-only. See LiveOS image.

    The following optional parameters seem to be incompatible with soas-1-strawberry and soas-2-blueberry released versions. (The script completes successfully, but the virtual machine startup process has trouble finding the home directory and fails to complete.)
    • the --home-size-mb NNN option creates space for file storage in the /home/liveuser folder. (In the case where you you want to update the LiveOS image while keeping the user files, skip the new disk creation and parted steps, leave out the --home-size-mb NNN option at this step, and continue on.)
    • the --unencrypted-home option prevents password protection and encryption on the /home/liveuser folder. This releaves the overhead on the compressed SquashFS, and should be more robust to file system failures (outside of security).
    • the --delete-home option is used to avoid an error message while requesting both a new home (with --home-size-mb) and a persistent home (with --unencrypted-home). (You wouldn't use this option for the LiveOS upgrade case.)
  1. shutdown -h now

Installing VirtualBox Guest Additions

  1. Unmount CD/DVD in VirtualBox settings, select 'Empty' for the CD/DVD device under 'Attributes'
  2. Start the virtual machine
  3. Open Terminal
  4. su -
  5. yum install dkms gcc
    (Other dependencies will be called into the installation.)

Note: The installation fails as of 27 June 2010 testing with 32-bit Fedora-14 while updating to glibc-common-2.12.90-3.i686
error: unpacking of archive failed on file /usr/lib/locale/locale-archive.tmpl: cpio: rename
Traceback (most recent call last):

  File "/usr/lib/python2.6/site-packages/yum/rpmtrans.py", line 387, in callback

  File "/usr/lib/python2.6/site-packages/yum/rpmtrans.py", line 457, in _instCloseFile

  File "/usr/lib/python2.6/site-packages/yum/rpmtrans.py", line 246, in _scriptout

  File "/usr/lib/python2.6/site-packages/yum/rpmtrans.py", line 367, in log_scriptlet_output

  File "/usr/lib/python2.6/site-packages/yum/rpmtrans.py", line 223, in _commit

sqlite3.OperationalError: disk I/O error
error: python callback <bound method RPMTransaction.callback of <yum.rpmtrans.RPMTransaction instance at 0xa088b8c>> failed, aborting!

(With 512 MB of memory allocated, the update seemed to hang on the glibc update. Boosting the memory to 1024 revealed the above failure.)

  • The installation fails as of 27 June 2010 testing with 32-bit Fedora-14 while updating to glibc-common-2.12.90-3.i686
    Using dmsetup status the overlay consumption measured (after rebooting from a hang with 512 MB of memory) moved from 23376/409600 to 406568/409600 sectors.
  • Installed Fedora-14 soas-i386-20100613.15.iso with this command line,
    /LiveOS/livecd-iso-to-disk --overlay-size-mb 1000 --home-size-mb 200 --delete-home --unencrypted-home /dev/live /dev/sda1
    dmsetup status before and after
    yum install dkms gcc
    yielded these results: 21376/2048000 and 868152/2048000 (512-byte segments)
    So it looks like at least 425 MiBytes of overlay is required for that installation.
    After
    ./VboxLinuxAdditions-x86.run
    dmsetup status showed 928872/204800 or 454 MiBytes of the overlay consumed.


<Successful Terminal log from 21 May 2010 with Fedora 64 bit>
[root@localhost ~]# yum install dkms gcc
Loaded plugins: presto, refresh-packagekit
fedora/metalink                                                           |  13 kB     00:00     
fedora                                                                    | 4.3 kB     00:00     
fedora/primary_db                                                         |  13 MB     00:18     
updates/metalink                                                          |  15 kB     00:00     
updates                                                                   | 4.5 kB     00:00     
updates/primary_db                                                        | 867 kB     00:00     
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package dkms.noarch 0:2.1.0.1-1.fc12 set to be updated
--> Processing Dependency: kernel-devel for package: dkms-2.1.0.1-1.fc12.noarch
---> Package gcc.x86_64 0:4.4.4-2.fc13 set to be updated
--> Processing Dependency: cpp = 4.4.4-2.fc13 for package: gcc-4.4.4-2.fc13.x86_64
--> Processing Dependency: cloog-ppl >= 0.15 for package: gcc-4.4.4-2.fc13.x86_64
--> Processing Dependency: glibc-devel >= 2.2.90-12 for package: gcc-4.4.4-2.fc13.x86_64
--> Running transaction check
---> Package cloog-ppl.x86_64 0:0.15.7-1.fc12 set to be updated
--> Processing Dependency: libppl.so.7()(64bit) for package: cloog-ppl-0.15.7-1.fc12.x86_64
--> Processing Dependency: libppl_c.so.2()(64bit) for package: cloog-ppl-0.15.7-1.fc12.x86_64
---> Package cpp.x86_64 0:4.4.4-2.fc13 set to be updated
---> Package glibc-devel.x86_64 0:2.12-1 set to be updated
--> Processing Dependency: glibc-headers = 2.12-1 for package: glibc-devel-2.12-1.x86_64
--> Processing Dependency: glibc-headers for package: glibc-devel-2.12-1.x86_64
---> Package kernel-devel.x86_64 0:2.6.33.4-95.fc13 set to be installed
--> Running transaction check
---> Package glibc-headers.x86_64 0:2.12-1 set to be updated
--> Processing Dependency: kernel-headers >= 2.2.1 for package: glibc-headers-2.12-1.x86_64
--> Processing Dependency: kernel-headers for package: glibc-headers-2.12-1.x86_64
---> Package ppl.x86_64 0:0.10.2-10.fc12 set to be updated
--> Running transaction check
---> Package kernel-headers.x86_64 0:2.6.33.4-95.fc13 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

=================================================================================================
 Package                  Arch             Version                       Repository         Size
=================================================================================================
Installing:
 dkms                     noarch           2.1.0.1-1.fc12                fedora             95 k
 gcc                      x86_64           4.4.4-2.fc13                  fedora             10 M
Installing for dependencies:
 cloog-ppl                x86_64           0.15.7-1.fc12                 fedora             82 k
 cpp                      x86_64           4.4.4-2.fc13                  fedora            3.7 M
 glibc-devel              x86_64           2.12-1                        fedora            959 k
 glibc-headers            x86_64           2.12-1                        fedora            588 k
 kernel-devel             x86_64           2.6.33.4-95.fc13              updates           6.3 M
 kernel-headers           x86_64           2.6.33.4-95.fc13              updates           761 k
 ppl                      x86_64           0.10.2-10.fc12                fedora            1.1 M

Transaction Summary
=================================================================================================
Install       9 Package(s)
Upgrade       0 Package(s)

Total download size: 24 M
Installed size: 60 M
Is this ok [y/N]: y
Downloading Packages:
Setting up and reading Presto delta metadata
fedora/prestodelta                                                        |  419 B     00:00     
updates/prestodelta                                                       | 4.6 kB     00:00     
Processing delta metadata
Package(s) data still to download: 24 M
(1/9): cloog-ppl-0.15.7-1.fc12.x86_64.rpm                                 |  82 kB     00:00     
(2/9): cpp-4.4.4-2.fc13.x86_64.rpm                                        | 3.7 MB     00:06     
(3/9): dkms-2.1.0.1-1.fc12.noarch.rpm                                     |  95 kB     00:00     
(4/9): gcc-4.4.4-2.fc13.x86_64.rpm                                        |  10 MB     00:17     
(5/9): glibc-devel-2.12-1.x86_64.rpm                                      | 959 kB     00:01     
(6/9): glibc-headers-2.12-1.x86_64.rpm                                    | 588 kB     00:00     
(7/9): kernel-devel-2.6.33.4-95.fc13.x86_64.rpm                           | 6.3 MB     00:02     
(8/9): kernel-headers-2.6.33.4-95.fc13.x86_64.rpm                         | 761 kB     00:00     
(9/9): ppl-0.10.2-10.fc12.x86_64.rpm                                      | 1.1 MB     00:02     
-------------------------------------------------------------------------------------------------
Total                                                            718 kB/s |  24 MB     00:33     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing     : cpp-4.4.4-2.fc13.x86_64                                                   1/9 
  Installing     : ppl-0.10.2-10.fc12.x86_64                                                 2/9 
  Installing     : cloog-ppl-0.15.7-1.fc12.x86_64                                            3/9 
  Installing     : kernel-devel-2.6.33.4-95.fc13.x86_64                                      4/9 
  Installing     : kernel-headers-2.6.33.4-95.fc13.x86_64                                    5/9 
  Installing     : glibc-headers-2.12-1.x86_64                                               6/9 
  Installing     : glibc-devel-2.12-1.x86_64                                                 7/9 
  Installing     : gcc-4.4.4-2.fc13.x86_64                                                   8/9 
  Installing     : dkms-2.1.0.1-1.fc12.noarch                                                9/9 

Installed:
  dkms.noarch 0:2.1.0.1-1.fc12                     gcc.x86_64 0:4.4.4-2.fc13                    

Dependency Installed:
  cloog-ppl.x86_64 0:0.15.7-1.fc12               cpp.x86_64 0:4.4.4-2.fc13                       
  glibc-devel.x86_64 0:2.12-1                    glibc-headers.x86_64 0:2.12-1                   
  kernel-devel.x86_64 0:2.6.33.4-95.fc13         kernel-headers.x86_64 0:2.6.33.4-95.fc13        
  ppl.x86_64 0:0.10.2-10.fc12                   

Complete!


  1. cd /media/VBOXADDITIONS_3.2.0_61806/
  2. ./VBoxLinuxAdditions-amd64.run
    • (This fails currently. More testing and debugging needed.)
    • If upgrading from one VirtualBox version to another, start with fresh virtual disks and machines built with the new versions to avoid breakage.
  3. reboot
<Terminal log:>
[root@localhost ~]# cd /media/VBOXADDITIONS_3.2.0_61806/
[root@localhost VBOXADDITIONS_3.2.0_61806]# ./VBoxLinuxAdditions-amd64.run 
Verifying archive integrity... All good.
Uncompressing VirtualBox 3.2.0 Guest Additions for Linux........
VirtualBox Guest Additions installer
Building the VirtualBox Guest Additions kernel modules     [FAILED]
(Your system does not seem to be set up to build kernel modules.
Look at /var/log/vboxadd-install.log to find out what went wrong)
Installing the Window System drivers
Installing X.Org Server 1.8 modules                        [  OK  ]
Setting up the Window System to use the Guest Additions    [  OK  ]
You may need to restart the hal service and the Window System (or just restart
the guest system) to enable the Guest Additions.

Installing graphics libraries and desktop services componen[  OK  ]

Configure Screen

  1. Edit /etc/X11/xorg.conf to match the following section: (This is for 1200x900 (XO) and other resolutions.)
# VirtualBox generated configuration file
# based on /etc/X11/xorg.conf.

Section "Monitor"
  Identifier   "Monitor[0]"
  ModelName    "VirtualBox Virtual Output"
  VendorName   "Sun Microsystems Inc"
EndSection

Section "Device"
  BoardName    "VirtualBox Graphics"
  Driver       "vboxvideo"
  Identifier   "Device[0]"
  VendorName   "Sun Microsystems Inc"
EndSection

Section "Screen"
  Identifier   "Screen[0]"
  Device       "Device[0]"
  Monitor      "Monitor[0]"
  DefaultDepth 16
  SubSection "Display"
    Depth      16
    Modes      "1200x900" "1024x768" "800x600"
  EndSubSection
EndSection

Clear user data

Finally,

  1. Open Terminal
  2. Terminal
  3. rm -rf ~/.sugar (if distributing image)
  4. su -
  5. shutdown -h now
  6. Now you can share the VDI file.

Backup discs

It would be wise to maintain a clone of your virtual disk image to restart if the working copy is damaged:

  1. From host command line (Windows cmd, or Linux terminal) See VirtualBox Help section 8.14.
    • VBoxManage clonehd <uuid>|<filename> <outputfile> [-format VDI|VMDK|VHD|RAW|<other>] [-remember]
  2. Reclone any virtual hard disks you would like to archive.

SSH connections

To enable SSH communications, we need to permit no passwords in the ssh daemon configuration:

  1. in Terminal,
  2. su -
  3. vi /etc/ssh/sshd_config
    1. [add] PermitEmptyPasswords yes
    2. :wq <Enter>
  4. service sshd restart