dCore Linux is a minimal Linux system based on the Tiny Core Linux system. Like Tiny Core Linux, dCore loads its file system entirely into RAM, which should provide good performance in large network emulation scenarios running on a single host computer.
dCore Linux allows users to install additional software from the Debian or Ubuntu repositories, instead of using the pre-built (and often out-of-date) TCE extensions provided for Tiny Core Linux. This should simplify the process of building network appliances for use in a network emulator, as you will not need to compile and build your own extensions, or use out-of-date pre-built extensions.
dCore Linux is designed to run as a “live” Linux system from removable media such as a CD or a USB drive but, for my use, I need to install it on a hard drive. Currently available instructions for installing dCore Linux onto a hard drive are incomplete and hard to follow. This post lists a detailed procedure to install dCore Linux on a virtual disk image connected to a virtual machine. I use VirtualBox in this example, but any other virtual machine manager would also be suitable.
Notes about dCore
Because dCore Linux is a small, lightweight Linux operating system, it is suitable for use in network emulators that use a full virtualization stack such as Qemu/KVM or VirtualBox. dCore Linux provides the functionality of Tiny Core Linux but also makes it easier to use the latest versions of networking software because it is designed to use the Debian software repositories.
When using dCore, it is important to understand how the dCore filesystem works. Since dCore loads the entire Linux system into RAM, changes to the filesystem — such as installing new software or updating configuration files — will be lost if the system is restarted. You must understand how to save configuration changes in dCore. I discussed the topic of Tiny Core Linux persistent configuration changes in a previous post. dCore works in a similar way, but the commands used are different.
While dCore may import software from the Debian or Ubuntu repositories, it does not install software in the same way the Debian or Ubuntu installs software. dCore Linux is a version of Tiny Core Linux so it also uses the concept of extensions to install new software. dCore converts Debian or Ubuntu packages into usable SCEs (self-contained extensions). SCEs are similar to Tiny Core Linux TCZ extensions, with some additional features.
Why install dCore to a hard drive?
Why not just boot dCore from an attached virtual optical drive? Why go through the trouble of installing it on a hard drive when it was designed to run from a CDROM or USB thumb drive?
We want to run dCore in a virtual machine in a way that supports persistent configuration changes and is self-contained. We want to support cloned disk images, which is the easiest way to replicate many systems in a network emulation tool like GNS3. Installing dCore on the VM’s virtual disk, instead of attaching the dCore CD ISO image to the machine, better supports our requirements.
Problems with packages
While I was working on this post, I found some packages did not work after importing them. The dCore system uses scripts to import the Debian packages and sometimes the scripts do not take into account all dependencies — especially for uncommon packages (like special networking software).
Fortunately, the dCore developers are very responsive. If you believe you have a problem with an imported package, post a question to the dCore forums — specifically, the dCore Imported Extensions forum. All the problems I found were quickly fixed by the dCore developers.
How to install dCore
To install dCore, we perform the following steps, which are described in detail later in this post:
- Download the dCore ISO image from the dCore web site
- Create a virtual machine and attach the ISO image to it.
- Partition the VM’s virtual disk and build the filesystem
- Mount the ISO disk image and copy its contents to the VM’s virtual disk
- Install boot loader files on the VM’s virtual disk
- Create a boot loader configuration file with the required dCore boot codes
- Save all configuration changes
- Remove the ISO image from the VM
- Reboot the VM
This above steps creates a dCore system that boots from the VM’s virtual disk. In the rest of this tutorial we will demonstrate loading Ubuntu packages to create a desktop environment with a web browser by doing the following:
- Use the sce-import and sce-load commands to install additional software
- Save the new software and configuration files in the persistent filesystem
- Reboot the VM
Detailed dCore install steps
Below is the detailed procedure to install dCore Linux on virtual disk attached to a VirtualBox virtual machine.
Download the dCore ISO image
dCore files are usually available at the dCore download repository. Note that in this post, we are working with the release candidate for Ubuntu 16.04 (xenial) because it is not yet available in the standard repository so, instead of the standard releases repository, we use the release candidate repository.
Download the ISO file. For example, in this case, download dCore-xenial.iso.
Create a virtual machine and attach the ISO image to it.
In VirtualBox, create a new virtual machine named dCore (or a name of your choice). Click on the “New VM” icon and then enter the VM name and type. dCore is a 32-bit operating system.
Next, set the memory size. I chose 256 MB. You may modify this later if you need to.
Create a virtual hard disk onto which we will install dCore for the VM.
The disk file type can be any of the available options. I chose the VDI format because it is the default setting.
Either dynamically allocated disk size of fixed disk size is OK to use. I chose to use a fixed disk size because it should offer slightly better performance, in terms of memory and processor resources used, when the VM is running.
Next, give the virtual hard disk a name and set its size. I chose 1 GB because I will split it into two partitions and also need space to install a desktop environment. If I was just installing network software, I would choose 512 MB.
Now we have created a new virtual machine. We need to attach to the VM the dCore ISO file we previously downloaded as a virtual optical drive image. Click on the Settings icon.
In settings, go to the Storage panel and select the empty virtual optical drive. Then click on the little optical disk icon on the far right side of the panel. Select Choose Virtual Optical Disk File from the drop-down menu that appears.
Navigate to the folder that contains the dCore ISO file and select it. Click on Open.
Now we see the dCore-xenial.iso file is attached to the virtual optical disk drive. Click OK.
Now we are ready to start the VM. Click on the Start icon.
The VM will start booting. It will prompt you for boot options. At this point, we do not need any boot options so press the Enter key to proceed with booting the VM.
Now the VM has started. The system loaded from the virtual optical disk drive and is full loaded into RAM.
Remember that the entire file system is in RAM so any changes you make to files will be lost when you shut down or restart the VM, unless you save your changes to a persistent disk, which we will set up in the next sections.
Partition the VM’s virtual disk and build the filesystem
Partition the virtual disk image. Create a partition sda1 and a swap partition sda2. USe the fdisk command, which comes already installed in dCore.
$ sudo fdisk /dev/sda
In the fdisk command-line interface, type “m” to see the list of available commands.
Enter “n” to create a new partition on the virtual disk. Choose Partition 1 and set it’s size so it uses up 90 of 130 available cylinders on the disk.
n
Type “p” for primary partition
p
The partition number is “1”
1
Select the first cylinder on the disk for the new partition (1 to 130). I chose “1”.
1
Select the last cylinder for this partition. This will determine the partition size of the main filesystem partition. I chose “90”.
90
Repeat the process for the second partition. Start with the “n” command and create Partition 2. In this case, I chose the default values for cylinders to use up the rest of the virtual disk.
n
p
2
91
130
Make the first partition bootable. Use the “a” command and select Partition 1.
a
1
Make the second partition a swap partition. Use the “t” command, choose partition 2 and set the partition type to “82”.
t
2
82
Check the setup with the “p” command, which will list all partitions and show which ones are bootable:
p
Write the changes with the “w” command:
w
Quit fdisk with the “q” command:
q
Format Partition 1, which is now device sda1, with an ext4 filesystem. The swap partition, device sda2, does not need a filesystem so we do nothing for sda2
$ sudo mkfs.ext4 /dev/sda1
Rebuild the filesystem table file, fstab. The rebuildfstab command adds the new partition /dev/sda1 to the /etc/fstab file.
$ sudo rebuildfstab
See that the new disk has mount point /mnt/sda1 defined in the fstab file.
$ cat /etc/fstabsudo
To list your devices another way, use the blkid command. This shows the device UUID and label.
$ blkid
Mount the ISO disk image and copy its contents to the VM’s virtual disk
Mount the first partition we created, device sda1:
$ mount /mnt/sda1
Create a /boot directory for the dCore files:
$ sudo mkdir /mnt/sda1/boot
Copy the kernel and initrd files into the /boot folder. Get these files from the ISO disk image, which we previously attached to this VM as a CDROM in the VirtualBox Manager.
First check the device name of the CDROM:
$ blkid
This shows that the CDROM device is sr0. Mount the CDROM:
$ mount /mnt/sr0
Now look at the contents of the boot directory on the CDROM:
$ ls /mnt/sr0/boot/
We see the dCorexenial.gz initRD file and the vmlinuzxenial kernel file. Copy these files from the CDROM to the boot directory on the new hard disk:
$ sudo cp -p /mnt/sr0/boot/* /mnt/sda1/boot
Ignore any warnings about omitting directories. List the /boot directory to verify the correct files are there:
$ ls /mnt/sda1/boot/
Install a bootloader on the VM’s virtual disk
In this case, we will install the extlinux bootloader because it is commonly used for small distributions like TinyCore Linux and because it is simple to configure. For more details, see How to Install Extlinux and How to Install Extlinux on a USB Drive.
First, configure the hard disk partition with a label. This makes it easier to refer to the partition in configuration files.
We need the e2label program to label the disk partition. The e2label program is in the e2fsprogs package.
$ sce-import e2fsprogs
$ sce-load e2fsprogs
We choose to use the label dCore. Any name may be used for the label.
$ sudo e2label /dev/sda1 "dCore"
Rebuild the filesystem table so the system learns about the new label.
$ sudo rebuildfstab
Check for a label again. Run the blkid command again. See that /dev/sda1 has the label dCore.
Next, make a directory for extlinux.
$ sudo mkdir /mnt/sda1/boot/extlinux
Use the sce-import command to install extlinux from the Ubuntu repositories:
$ sce-import extlinux
Load the new extlinux extension.
$ sce-load extlinux
Now, use extlinux to install the files that will create a bootloader on the partition sda1.
$ sudo extlinux --install /mnt/sda1/boot/extlinux
This installs extlinux bootloader files onto the virtual disk drive.
Install the master boot record (MBR) file
$ sudo dd if=/usr/lib/EXTLINUX/mbr.bin of=/dev/sda
Create a bootloader configuration file
Create a bootloader configuration file with the required dCore boot codes. In the extlinux directory we previously created, create and edit the file extlinux.conf:
$ cd /mnt/sda1/boot/extlinux
$ sudo vi extlinux.conf
Then enter the following text in the file:
default dCore
label dCore
kernel /boot/vmlinuzxenial
append initrd=/boot/dCorexenial.gz tce=sda1
Save the file and quit the editor.
Save all configuration changes
Set the TCE drive. dCore needs to know which to partition it should save persistent configuration changes. In this scenario, the tce-setdrive command will select the sda1 partition.
$ tce-setdrive
This creates a tce directory on /mnt/sda1 and populates it with the TCE and SCE files.
Save the configuration changes on persistent storage on sda1. Use the backup command:
$ backup
Remove the ISO image from the VM
We no longer need the original ISO image connected to the virtual machine. To remove the ISO image in VirtualBox, first power off the VM:
$ sudo poweroff
In VirtualBox manager, select the dCore VM and click on Settings. Go to the Storage panel. Remove the dCore ISO file from the virtual optical drive. This way, the VM will always boot from the virtual hard drive we have set up.
Verify the virtual optical disk drive is now empty.
Boot the VM
Start the VM again by clicking on the Start icon in VirtualBox.
The new dCore system will boot up from the virtual disk. Ignore warning about floppy disk drivers. This is not a serious issue and I have not yet found out how to stop the system from looking for a floppy drive.
The system is ready to use. Now we may install any extra software we require.
Install additional software
Let us install new software in this dCore image. For example, we will install a desktop environment and a GUI application, such as a web browser. Use the sce-import and sce-load commands to install additional software
When installing software that shares a lot of dependencies, you can use up less disk space if you create one extension from multiple packages. Create a file listing the packages you wish to install and then use the -l option to install the packages listed in that file.
First create the file in a temporary directory. We do not need the file after the install is completed.
$ vi /tmp/xdesk
We will install packages required for the FLWM desktop environment and the Midori web browser. Enter the following text into the file:
Xprogs
xorg-all
wbar
flwm
midori
Save the file and exit the editor.
Then, run the sce-import command to load all the packages described into the files as one combined extension. The -l option specifies we will look for the package names in a file. The -b option tell the program to add the new extension to the boot list file. The name of the extension will be the same name as the file.
$ sce-import -lb /tmp/xdesk
Press Enter key at prompt to begin (or Ctrl-C to abort).
When the install is completed, view the boot list file, sceboot.lst.
$ cat /etc/sysconfig/tcedir/sceboot.lst
Check that the new extension name is in the file. The file contents should be:
xdesk
Next, edit the boot codes in the extlinux.conf file. Add the boot code desktop=flwm.
$ cd /mnt/sda1/boot/extlinux
$ sudo vi extlinux.conf
The file should now look like:
default dCore
label dCore
kernel /boot/vmlinuzxenial
append initrd=/boot/dCore xenial.gz tce=sda1 desktop=flwm
Save the new software and configuration files
Save the new software and configuration files in the persistent filesystem. The backup command will save system changes to the hard drive.
$ backup
Reboot the VM
Reboot the VM with the reboot command:
$ sudo reboot
When this system reboots, it will start with the FLWM desktop environment.
Now you should see a desktop. We previously installed the Midori web browser so you may launch it to demonstrate that the software will run correctly.
Conclusion
We installed dCore Linux on a VirtualBox virtual machine so that is will boot from the virtual machine’s virtual disk image (VDI). This system should be useful as a lightweight virtual network appliance in network emulation tools such as GNS3.
Remember to post your questions to the dCore forums if you have issues importing specific Debian or Ubuntu packages.
Summary of steps
Below, I list all the commands I used above in one place for those who want to follow the process more quickly.
After setting up dCore ISO disk on new VM image and starting the VM, enter the following commands:
sudo fdisk /dev/sda
sudo mkfs.ext4 /dev/sda1
sudo rebuildfstab
mount /mnt/sda1
sudo mkdir /mnt/sda1/boot
mount /mnt/sr0
sudo cp -p /mnt/sr0/boot/* /mnt/sda1/boot
sce-import e2fsprogs
sce-load e2fsprogs
sudo e2label /dev/sda1 "dCore"
sudo rebuildfstab
sudo mkdir /mnt/sda1/boot/extlinux
sce-import extlinux
sce-load extlinux
sudo extlinux --install /mnt/sda1/boot/extlinux
sudo dd if=/usr/lib/EXTLINUX/mbr.bin of=/dev/sda
cd /mnt/sda1/boot/extlinux
sudo vi extlinux.conf
Then enter the following text in the extlinux.conf file:
default dCore
label dCore
kernel /boot/vmlinuzxenial
append initrd=/boot/dCorexenial.gz tce=sda1
Then enter the remaining commands:
tce-setdrive
backup
sudo poweroff
Remove the ISO disk image from the VM and start it again.
Thank you, it’s very helpful.
What can you say about dcore as a real host-based system?
Can it manage all features that lubuntu, for example, can? I mean, can I build some program by gcc?
Hi Vadim,
I have not tried it as a host OS, but dCore is based on Tinycore so you should be able to compile software. Just be sure you know which directories you need to save.
DCore and TinyCore would be suitable for a host system, if you are an advanced Linux user.
Brian
Wow what a great tutorial. Just wanted to say thanks for such a great detailed explanation. Gives a really great insight and answers many questions I had about persistency in general and bootloaders. I will bookmark your page and read the other article about TinyCore. Just wanted to say thanks for everybody who read it to the end and was to lazy to left a few words. That’s how every tutorial in the world should be made. Do you have a special workflow when writing these brian?
Hi, Thanks for your encouragement. I don’t have a special workflow. I usually write about a problem I need to solve, after I have figured it out. I usually write about topics for which it was difficult to find good resources online.
Thanks again,
Brian
Excellent post. thanks!
Really concise post. Very insightful. Thanks for taking the time to write this!
Bookmarked your site.