Linux 4 Windows
Learn And Run Linux On Your Windows Computer

This Linux 4 Windows Tutorial steps you through the process of creating a Damn Small Linux file area on a USB pen drive and shows you how to permanently save and recover your Damn Small Linux files on your Windows computer. You will use the Beaver text editor and apply the mkdir, ls, cp, mv, and rmcommands and some command options.

Saving Damn Small Linux Files To A USB Pen Drive

This relatively complicated tutorial is extremely useful. It enables you to "permanently" save your Damn Small Linux files on a USB Pen Drive. Our source is The Official Damn Small Linux Book, but we show you where we had to make some adaptations. The goal of this tutorial is not to understand every single step but to do something that is very practical.


Before you start you will need a USB Pen Drive with a few hundred free Megabytes. We needed 166 Megabytes to copy our Damn Small Linux installation and used another 64 Megabytes for the Damn Small Linux file area. We chose to make this area 64Mbytes.


Step 1 Physically attach your USB pen drive (Removable Disk) and note its location in Windows. If you need to, access Windows Explorer. We will be using E: in this tutorial.

Step 2 Copy the folder containing Damn Small Linux to the USB drive. In our case the folder name is NewDSL. The results are shown in Figure 1.

Linux save files to usb tutorial Figure 1

Save Damn Small Linux Files To USB Tutorial Figure 1
Copying your Damn Small Linux folder to your USB Pen drive.



Step 3 In Windows click the Start button and then in the Run box enter the cmd command. This will give you access to the DOS command line, however you must reposition yourself prior to entering the desired command. At this point the screen should resemble Figure 2.

Linux save files to usb tutorial Figure 2

Save Damn Small Linux Files To USB Tutorial Figure 2
Initial postion in the Windows file system.



Step 4 Position yourself in the QEMU directory of your Damn Small Linux folder on the pen drive. The commands that I used are shown in Figure 3.

Linux save files to usb tutorial Figure 3

Save Damn Small Linux Files To USB Tutorial Figure 3
Final postion in the Windows file system.



Step 5 Enter the following command: qemu-img.exe create harddisk 64M. You must use the term harddisk but you can choose a different size such as 32M or 128M. (Don't put a space before the M.) Windows will respond with a message such as the following:
Formating 'harddisk', fmt=raw, size=65536 kB

Step 6 You now have an unformated hard drive zone named harddisk.Close your DOS window. Make sure that you are positioned in your Damn Small Linux folder on the pen drive and double click the 1st-boot.bat file. This starts Damn Small Linux in runlevel 2 which means that the customary graphical interface is not available. The results are shown in Figure 4.

Linux save files to usb tutorial Figure 4

Save Damn Small Linux Files To USB Tutorial Figure 4
Ready to format the hard disk.



Step 7 At the Linux shell command prompt # enter the following command mke2fs /dev/hdb and in response to the warning message enter y. The results are shown in Figure 5.

Linux save files to usb tutorial Figure 5

Save Damn Small Linux Files To USB Tutorial Figure 5
The hard disk is now formated.



Step 8 At the Linux shell command prompt enter the following three commands, one at a time: mount /mnt/hdb
mkdir /mnt/hdb/mydsl
and mkdir /mnt/hdb/mydsl/modules
. This step does not produce visual results.

Step 9 This step is long. Furthermore, if it doesn't work you will have to change the numbers in the middle of the command. Damn Small Linux has a habit of updating their files and directories. Don't worry I'll show you what to do. Enter the following command (I'm putting it in bold so it will be easier to see): cp /KNOPPIX/lib/modules/2.4.26/kernel/drivers/block/cloop.o /mnt/hdb/mydsl/modules The original numeric value (per the DSL Linux book) was 2.4.26 and generated the message No such file or directory So I used the up arrow to change the numeric value to 2.4.31 and it worked. The results are shown in Figure 6. You should start with the 2.4.31 version of the command. If it doesn't work get the right numbers using Step 9a. And if it works, proceed to Step 10.

Linux save files to usb tutorial Figure 6

Save Damn Small Linux Files To USB Tutorial Figure 6
One ugly, but necessary command that copies files.



Step 9a At the Linux shell command prompt enter the following three command: ls /KNOPPIX/lib/modules
. The numeric output of this command gives you the values to enter in Step 9. At the time of this writing the values are 2.4.31. But you are ready to handle system changes. Pat yourself on the back. But don't stop, we are not done yet.

Step 10 Shut off Linux with the following command: shutdown -h now. The results are shown in Figure 7.

Linux save files to usb tutorial Figure 7

Save Damn Small Linux Files To USB Tutorial Figure 7
Shutting down Linux.



Step 11 Restart Damn Small Linux by double-clicking the dsl-vhd.bat file in your Damn Small Linux folder on the USB pen drive. In response to the DSL X Setup screen I press the Tab key and then select Cancel. Start DSL as usual. If you have sharp eyes you noticed a message that the runlevel is 5, the graphical user interface is available. There is also a message about restoring backup files. Enter the ls /mnt/hdb command to see the contents of your backup hard drive hdb. Then copy the Events.cal file to the hard drive with the following command: sudo cp Events.cal /mnt/hdb . The sudo part of the command enables a regular user to copy files to the hard drive. Otherwise, the command would fail. Then repeat the ls /mnt/hdb command to see the renewed contents of your backup hard drive. You can now copy files to the harddrive, in essence saving them. The results are shown in Figure 8.

Linux save files to usb tutorial Figure 8

Save Damn Small Linux Files To USB Tutorial Figure 8
Saving a file.



Step 12 The final step in this lengthy tutorial is restoring a file from the backup USB pen drive. Shutdown Linux (you may need to code sudo as in the previous step). Restart Damn Small Linux by double-clicking the dsl-vhd.bat file in your Damn Small Linux folder on the USB pen drive. In response to the DSL X Setup screen I press the Tab key and then select Cancel. Start DSL as usual. Enter the ls command and the ls /mnt/hdb command to see the contents of your home directory and of your backup hard drive hdb. Then copy the Events.cal file from the the hard drive to your home directory with the following command: cp /mnt/hdb/Events.cal /home/dsl/Eventsb.cal . Here it was not necessary to enter sudo. This command does not overwrite the existing Events.cal file but creates a new Eventsb.cal file. The results are shown in Figure 9.

Linux save files to usb tutorial Figure 9

Save Damn Small Linux Files To USB Tutorial Figure 9
Restoring a file.







Conclusion. This was quite a procedure but it only has to be done once. After you have created your hard drive in Steps 1-10, you can access it by starting Damn Small Linux as in Step 11 and then copy files from the hard drive into your Linux system and subsequenly restore them as in Step 12. You can even use the same hard drive for Linux and Windows files. Windows sees a file called harddrive in the QEMU directory of the Linux folder. It doesn't see individual Linux files such as Event.cal. As far as Linux is concerned, the backup drive is hdb accessed via /mnt/hdb .