Note by Apollia on Nov. 8, 2023: Please join my Patreon if you'd like to support me and my work!

My main personal website is now Apollia.org. I'm still not sure what to do with Astroblahhh.Com, so it's mostly staying as-is for now.





Programming Blog Post:

How I Run VirtualBox 4.3.22 with Lighthouse 64 Puppy Linux as Both Host and Guest
11/23/2017

Post Below
11/23/2017 - How I Run VirtualBox 4.3.22 with Lighthouse 64 Puppy Linux as Both Host and Guest (Programming)

    Hide/Show:


   ▲ Top  ▼ Bottom  △ TOC
How I Run VirtualBox 4.3.22 with Lighthouse 64 Puppy Linux as Both Host and Guest
Thursday, November 23rd, 2017
11:52:35 GMT

Programming

Last modified Nov. 26, 2017, 8:28 AM EST.


Recently, I started using VirtualBox 4.3.22 to help me update, refine, and test my Puppy Linux Setup Kit without having to repeatedly reboot a real computer.

I've been using Lighthouse 64 Puppy Linux 6.02 Beta 2 as both my non-virtual host system, and as my virtual guest system.

This blog post contains notes on how I got that working nicely. I did all this stuff mostly manually, but perhaps someday I'll figure out how to automate a lot of the below.


(Additions, Jan. 9, 2018, 10:47 AM/9:03 PM EST. I finally made some scripts which automate some of the below:

https://github.com/Apollia/VirtualBox-Guest-Setup-Scripts

End of additions.)


Thanks to everyone who put up useful info on the web that helped me figure out how to do all this!


Some Computers Work Better Than Others
For Running GNU/Linux Guests in VirtualBox

Unfortunately, certain computers run GNU/Linux guests terribly slowly. One of them is my HP Compaq dc7700 Convertible Minitower desktop. (Surprisingly, Windows XP guests run quite well on it.)

I was never able to figure out how to fix that.


But, luckily, other computers, such as my Toughbook CF-C1 laptops, and my giant cheese grater-like Mac Pro from 2008, run GNU/Linux guests at quite acceptable speeds - though noticeably slower than non-virtual GNU/Linux.

I don't know why they work so much better, but I guess they're probably both newer than my HP Compaq dc7700.


How I Store My VirtualBox Settings

(Addition, Jan. 9, 2018, 10:54 AM EST. This section is now out of date.

Instead of using symlinks to keep some of my VirtualBox settings in the ramdisk and some of them on a physical disk - I now prefer to keep all of my VirtualBox settings in the ramdisk, and I use Ramize-Physave to occasionally save some of them to a physical disk.

End of addition.)


I like to keep some of my VirtualBox settings on a physical disk, and some in the RAM disk. I accomplish this via symlinks.


On my system, VirtualBox creates two different settings folders:

  1. /root/VirtualBox VMs

    Contains stuff related to specific virtual machines.

    You can actually choose whatever other path you want just by going to VirtualBox's File menu, choosing Preferences, and editing the "Default Machine Folder" in the "General" section.

    But rather than change the path via VirtualBox's settings, I preferred to just copy that folder onto a physical disk, and put a symlink at /root/VirtualBox VMs pointing to the new location.

    Then, inside the new location, I made the Snapshots folder into a symlink pointing to a folder somewhere in my RAM disk, to make it so saving and loading system snapshots will be faster. And any particularly useful snapshots I create, I manually save to a physical disk.


  2. /root/.config/VirtualBox

    Contains quite boring-looking stuff, but I guess it's probably useful somehow.

    I didn't do much with this folder - just copied it to a physical disk, and put a symlink at /root/.config/VirtualBox pointing to the new location.


Settings for My Virtual Machine

I started out by making a new virtual machine with no hard disk, and told VirtualBox the machine's "Type" was Linux, and "Version" was "Other Linux (64-bit)".

(I prefer to use VirtualBox shared folders rather than a virtual hard disk, so I won't be stuck having to use VirtualBox or any other fancy tricks to access whatever files I have inside a virtual hard disk file.)


  • In the System settings, I gave the virtual machine 2048 MB of RAM, and 1 of my real computer's 8 processors. (Tried 2, but not sure it makes anything faster.)


  • In the General settings, in the Advanced tab, in the "Mini ToolBar" section, I put a check in the box next to "Show at Top of Screen".

    I set Shared Clipboard to Bidirectional.

    And I set Drag'n'Drop to "Host to Guest", since nothing else works, except disabling drag and drop.


  • I prefer my virtual machine to use only 1 monitor, since that's less confusing, and if I use 2 monitors, seamless mode and mouse integration become kind of glitchy. But they work great with 1 monitor (once those features are enabled by installing VirtualBox Guest Additions inside the guest system).

    But, if I ever do want to use 2 monitors - in the Video settings, I can set "Monitor Count" to 2. (However, multiple monitors is another feature that doesn't start working until you install VirtualBox Guest Additions inside the guest system.) And while running my guest system, I can disable mouse integration via the Machine menu, and avoid seamless mode.

    And here's the command I used to make my virtual right monitor act like it's below my virtual left monitor:


  • In the Display Settings, I set "Video Memory" to the maximum - 128 MB - though I don't know if that was really necessary.

    And I put a check in the box next to "Enable 3D Acceleration".


  • To remove my virtual machine's internet access - in the Network settings, I unchecked the box next to "Enable Network Adapter" in the "Adapter 1" tab.

    (I did that because the only part of my Puppy Linux Setup Kit which requires internet access is the downloader scripts, and I'm not working on those yet.)


  • To remove my virtual machine's ability to access USB devices - in the "USB" settings, I unchecked "Enable USB Controller".


    Virtual Disc Drives and Discs for My Virtual Machine

  • In the Storage settings, I removed the IDE controller which was added by default, and added a SATA controller instead. (I did that because the IDE controller only let me have 4 virtual optical disc drives, but the SATA controller let me have many more.)


  • To create numerous new virtual optical disc drives, I repeatedly clicked the small icon that looks like a CD with a plus sign over it, and clicked the "Leave empty" button when VirtualBox asked me if I wanted to choose a virtual CD/DVD disk to put in the drive.

    I created 8 virtual optical disc drives - probably more than I'll need.


  • In the 1st virtual disc drive, I put the live CD ISO I wanted to boot my system with - a Lighthouse 64 Puppy Linux 6.02 Beta 2 ISO - and put a check in the box next to "Live CD/DVD".

    (Actually, I used an ISO I slightly modified, but I haven't released that, one reason being because I haven't used it enough yet to know if my modifications caused any serious glitches or not.)


    You can get an official Lighthouse 64 Puppy Linux 6.02 Beta 2 ISO from:

    http://lhpup.org/beta/L64-602


  • In the 2nd virtual disc drive, I put the VirtualBox Guest Additions ISO for VirtualBox 4.3.22, which can be downloaded from:

    http://download.virtualbox.org/virtualbox/4.3.22


  • In the 3rd virtual disc drive, I put a custom ISO file I made which only contained one file - the DevX SFS file of software development tools for Lighthouse 64 Puppy Linux 6.02 Beta 2.

    (This is necessary because the VirtualBox Guest Additions installer won't work unless the DevX SFS file is mounted inside the guest system. And my guest system can't download the DevX from the internet because I removed my guest system's internet access.)


    The official DevX SFS file for Lighthouse 64 Puppy Linux 6.02 Beta 2 can be downloaded from this page:

    http://lhpup.org/sfs/602-x86_64


    To put the DevX file into my own custom ISO file, I put the DevX file in a folder named "DevX", and ran this command line, with my console's working directory set to the folder containing the "DevX" folder:


    The -V option sets the disc's name (which will be visible on the desktop of the virtual Puppy) to "DevX".

    The -o option specifies the filepath where the ISO file will be output to.

    The "DevX" text at the end of the command line refers to the "DevX" folder which I wanted mkisofs to put into an ISO file.


    Settings for Shared Folders for My Virtual Machine

    Shared folders can't be mounted and accessed until you install VirtualBox Guest Additions inside the virtual system.


  • With each shared folder I made, I put no check in the "Auto-mount" checkbox.


  • I was reluctant to give my virtual Puppy full read/write access to certain external disks, so, instead, I gave my virtual Puppy read-only access.

    In the "Folder Name" field for each shared folder, I put descriptive names like "ReadOnly-LegacySetupKit" and "ReadOnly-RenovSetupKit".


  • I made 1 readable/writable shared folder which immediately saves things to a folder in one of my host system's physical disks.


  • I also made 1 readable/writable shared folder inside my host system's RAM disk, for things I want to share with my host system that aren't important enough to save immediately to a physical disk.


    Making It Possible For the Guest System to Create Symlinks Inside a Shared Folder

    (Warning: Possibly Dangerous)

    I read here that "Symbolic link creation from within a guest has been disabled in VirtualBox 4.1.8 for security reasons."

    However, anytime I've run a Puppy Linux guest system, symlinks located in shared folders and pointing to files in the host system usually appear to be broken. Or, if the guest system actually contains a file or folder at the symlink's destination path, the guest system interprets the symlink to be referring to that guest system file or folder, and it can't access the host system's file or folder through that symlink.

    So, I'm not sure there's a security issue here with Puppy Linux guests, though I easily could be wrong.


    Things are very different with a Puppy Linux host and a Windows XP guest. With VirtualBox 4.1.8, a Lucid Puppy Linux 5.2.8 version 004 host and a Windows XP guest, any symlinks located in a shared folder and pointing to files or folders in the host system make those files and folders totally accessible to the Windows XP guest! Which was actually useful to me back in the days when my primary use for VirtualBox was to use Astroblahhh Desktop in a Windows XP guest.

    But, if my Windows XP guest had been capable of creating its own symlinks in shared folders, I'm guessing it probably would have been able to have access to probably any file at all in my host Puppy Linux system, which could have been quite bad, if my Windows XP guest was infected with malware.


    Anyway, since I usually don't let my Puppy Linux guests have internet access, and I sometimes need to be able to create symlinks in shared folders, and symlinks in shared folders maybe aren't as dangerous with a Puppy Linux guest as they definitely are with a Windows XP guest, I was willing to take the risk that there might actually be major security problems with enabling my Puppy Linux guest to create symlinks in shared folders.

    I learned how to do it from this page's comment #14.

    I wasn't able to enable symlink creation in every shared folder all at once. Instead, I have to enable symlink creation for each individual shared folder I want my guest system to be able to create symlinks in.

    Which wasn't that much of a nuisance, since I only have 2 writable shared folders.


    So, in my host system's console, I ran these two command lines.

    Please only use these commands at your own risk, because maybe there are worse security problems than I think.

    Actually, my shared folders aren't named "Physical_Disk" and "RAM_Disk", but I renamed them here for clarity's sake.

    To use the above command lines, you'll need to change those names to whatever your shared folders' names are - whatever label you put in the "Folder Name" section of their settings.

    Also, you'll need to change "APSK" (the name of my virtual machine) to the name of your virtual machine.

    You don't need to restart the entire VirtualBox program for the new settings to take effect, but if your virtual machine is running, you'll have to turn it off and on again. The new settings should start working right away, even if you restore a system snapshot instead of rebooting without a snapshot.


    How to Install VirtualBox Guest Additions Inside the Guest System

    1. First, you must start up the virtual machine and go through the Puppy Linux startup process.

    2. After Puppy Linux's desktop appears - click the "DevX" CD drive icon near the bottom of the desktop to view the contents of the DevX ISO.

    3. Inside that folder, right-click on "devx-l64.sfs" and choose "sfs-load" from the menu. In the "SFS-Load" dialog box that appears, click the "SFS-Load" button.

    4. In the "sfs-load" dialog box that appears after that, select "NOCOPY" from the dropdown box, then click OK.

    5. When it asks you if you want to add a new mount point for the SFS file, click OK. Eventually, a dialog box will appear and tell you the SFS file is successfully loaded.


    6. Click the "VBOXADDITIO" CD drive icon near the bottom of the desktop to view the contents of the VirtualBox Guest Additions ISO.

    7. While inside the folder that appears (with /media/VBOXADDITIONS_4.3.22_98236 in the title), press the ~ key on your keyboard. (This will open a console with its working directory set to this folder.)


    8. To run the VirtualBox Guest Additions installer - type this command line in the console window you just opened in the previous step:

      ./VBoxLinuxAdditions.run


    9. Gradually, the installer will print out the below details about what it's doing.

      I don't know why this happens: "Installing graphics libraries and desktop services components ...fail!"

      But, it seems to work fine for me anyway.


    10. To temporarily enable various VirtualBox Guest Additions features, you can run these command lines:

      Those features will go away the next time you restart the X server.

      If you want to keep those features enabled, you can add the above command lines to the file /root/.xinitrc, so they'll get run automatically every time the X server is restarted.

      (Here's the forum thread where I learned about the above command lines and the idea of adding them to .xinitrc.)


      • The --clipboard option makes it so you can copy and paste between the guest and host.

        To choose how you want the shared clipboard to behave (bidirectional, guest to host, host to guest, or disabled), go to VirtualBox's Devices menu, then its Shared Clipboard submenu.


      • The --draganddrop option gives you an easy way to share files between your host and guest. (Except on my computer, it only works when drag/dropping files from my host to the guest. So, to get files out of the guest system, I have to put them in a shared folder.)

        To choose how you want the drag and drop feature to behave (bidirectional, guest to host, host to guest, or disabled), go to VirtualBox's Devices menu, then its Drag'n'Drop submenu.


      • Seamless mode makes it look like windows from your host and guest are sharing the same desktop, even though they're really not.

        Sometimes you have to fiddle with the guest windows and/or switch out of Seamless mode and get back into it to make everything display properly.


    Mounting Shared Folders

  • To set up shared folders, go to the "Shared Folders" section of the virtual machine's settings.

    To my surprise, it is possible to add new shared folders while the virtual machine is running - either permanent folders (which you can make by putting a check in the box next to "Make Permanent") which will go in the "Machine Folders" list permanently, or "Transient Folders".


  • To make the guest system capable of mounting shared folders, the VirtualBox Guest Additions software must be installed inside the guest system. See above for how to do that.


  • To make the guest system mount a shared folder - inside your guest system, you need to make an empty folder, which will serve as a mountpoint. You can put that folder wherever you want.

    Here's a command line I used to make an empty folder. (But you can create the empty folder any way you want, even using a graphical file manager.)


  • To mount a shared folder, you must know the "Folder Name" you assigned to that shared folder. (The "Folder Name" is an arbitrary label that actually can be totally different from the shared folder path it's associated with.)

    You can find out the "Folder Name" by going to the "Shared Folders" section of the virtual machine's settings, which you can view and edit even while the virtual machine is running.


  • Then, you can mount the shared folder to the empty mountpoint folder with a command line resembling this:

    The name you put after "vboxsf" should be your shared folder's "Folder Name", and the folderpath after that should be the folderpath (located inside your guest system) which you want to use as a mountpoint for that shared folder.


  • If that command line worked, there won't be any confirmation message displayed in response to your command.

    But, when you go to the folder you specified, you'll hopefully see the external files you were expecting to see.

    You can open that folder from a console with command line like this:


    Creating and Restoring a VirtualBox Snapshot

    VirtualBox's Snapshot feature makes it possible for me to easily test my Puppy Linux Setup Kit repeatedly on a fresh, mostly pristine, almost default system, without having to repeatedly reboot a real computer and/or go through the somewhat slow Puppy Linux startup process.

    Instead, I can just shut down my virtual system and restore a snapshot in about 10 seconds. (I assume the fact that I keep snapshots in my RAM disk makes them save and load faster.)


  • After doing the various things I explained above, such as installing VirtualBox Guest Additions, editing the .xinitrc file, mounting shared folders - and also not-yet-mentioned things, such as unmounting the DevX SFS file, unmounting the DevX SFS disc and VBOXADDITIONS disc, etc. - I created a VirtualBox snapshot by going to the Machine menu and choosing "Take Snapshot".

    After about 15 seconds, that resulted in a large snapshot file around 1 GB.


  • To restore that snapshot, I go the Machine menu, choose Close, and put a check in the box next to "Restore current snapshot 'Snapshot 1'", and select "Power off the machine", and click OK.

    Then I relaunch my virtual machine, and after about 10 seconds, my snapshot is restored. (I assume the fact that I keep snapshots in my RAM disk makes them save and load faster.)


  • If I create any particularly useful snapshots, I save them manually to one of my physical disks.




    So far, I've actually spent more time on this blog post than actually working on my Puppy Linux Setup Kit with the help of VirtualBox.

    But, that will probably soon change, and I think this new way of doing things will hopefully enable me to make a lot more progress much faster, assuming my health continues to improve.

       ▲ Top  ▼ Bottom  △ TOC


    • Hide/Show:





    Note by Apollia on Nov. 8, 2023: Please join my Patreon if you'd like to support me and my work!

    My main personal website is now Apollia.org. I'm still not sure what to do with Astroblahhh.Com, so it's mostly staying as-is for now.