📜 ⬆️ ⬇️

Full access to all Linux-based file systems on Windows 2000 / XP / Vista / 7 using coLinux

In this article I will tell you how to get almost full access to read and write to all file systems used in Linux (Ext2 / 3/4, ReiserFS, XFS, JFS, etc) from under sabzh operating systems. The article is a free translation of this manual , and it has been written for quite a long time, but I just crawled before it now. :)

What is this method?
Perhaps everyone has heard of the coLinux project. This is the Linux kernel, ported and modified to run from Windows, and includes a driver for converting Linux system calls to Windows calls. Linux applications can run in coLinux without recompiling, with no loss in application performance.
We will use the coLinux system as an intermediate to access the necessary file systems. coLinux will have direct access to file systems, and from under Windows (hereafter, the host system) they will be accessible using a Samba server configured on the coLinux system (the guest system). Communication between the guest and host systems will be implemented using a virtual TAP-network adapter. Compatibility with this will be almost complete, including editing access rights and so on. (of course, in the guest system).

Advantages and disadvantages
The main advantage is that the native Linux file system driver is used (since a complete copy of Linux is actually running, and the driver works in this environment). And so there will be full access to the FS without bugs on the part of Windows, unfinished, if not completely unrealized, features of Windows drivers, etc.
The first drawback follows smoothly from dignity: due to the fact that a full copy of Linux is running with all the drivers, services and programs, the amount of free resources of the host system is sometimes quite reduced, especially when exchanging files.
The second drawback is the low speed of file sharing: the speed of reading from the XFS file system does not exceed an average of 5 megabytes per second, and the write speed is 7 (which is rather strange).
')
Installing and configuring a guest Linux system
  1. Download the coLinux kernel here . Install, for example, into the C: \ coLinux directory (later in the article it will be used as an example).
  2. Download one of the images of the installed Linux system from here . I preferred Debian Lenny , and therefore, when I work in the guest system, commands specific to Debian will be used. You need to unpack the archive with the image in the directory where coLinux is installed, in our case C: \ coLinux.
  3. The correct config-file debian-lenny.conf , located in the coLinux directory (we unpacked the archive with the image into it, right?). Remove comment symbol (#) from the lines # mem = 256 and # eth1 = tuntap
  4. Now it is necessary to register in the config the names of the necessary sections to access them. These names look like \ Device \ Harddisk1 \ Partition2 . The easiest way to find the correct names for the sections you need is to download the Windows dd utility and with the command:
    dd --list
    in the Windows command line with administrator rights (of course, being in the directory with the executable dd file), we look for the partition names we need under the words NT Block Device Objects (a little inconvenient, because the necessary partitions will have to be searched by size, which, moreover, given in bytes).
    So, we found the necessary names, now it is necessary to enter them into the config. At the end of the config we enter the lines of the type:
    cobdX=\Device\HarddiskY\PartitionZ
    where X is the ordinal number of the device file (it will be seen from under the guest system in / dev), starting at 3, and Y and Z are the disk and partition numbers in its Windows name. For example:
    cobd3=\Device\Harddisk1\Partition2
    And so for each section.
  5. Go to the properties of the virtual network adapter "TAP-Win32 Adapter V8 (coLinux)" (in WinXP - Control Panel - Network Connections - PCM on the Adapter - Properties - Internet Protocol (TCP / IP) - Properties , in WinVista / 7 - Control Panel - Network and Sharing Center - Change adapter settings - PCM on the adapter - Properties - Internet Protocol version 4 (TCP / IPv4) - Properties ) and set the IP address 192.168.37.10 and the subnet mask 255.255.255.0 . Save the settings.
  6. The most long-awaited moment - the launch of the guest system. :) Run the debian-lenny.bat file from the coLinux root directory and wait for the system to fully boot. Log in with root login and password colinux . Create directories - mount point sections in the guest system. We edit the / etc / fstab file (using vim or nano, to taste) and enter lines to describe file systems for mounting, for example:
    /dev/cobd3 /mnt/cobd3 xfs defaults 0 0
    Everything is standard here, I will only note that the file name of the desired section matches the section string in the coLinux config. After that, we immediately mount all partitions using the mount -a command.
  7. Configure the virtual network adapter in the host system. To do this, add the following lines to the / etc / network / interfaces file:
    auto eth1
    iface eth1 inet static
    address 192.168.37.20
    network 192.168.37.0
    netmask 255.255.255.0
    broadcast 192.168.37.255
    We enable the network interface with the command:
    ifup eth1
    You can immediately ping the host system (192.168.37.10), everything should work without problems.
  8. Create a regular user with the adduser command (eg adduser user1 ) in order to prevent root access to files from under Windows
  9. Install SSH and Samba servers in the guest system:
    apt-get install openssh-server samba
    In the Samba config (/etc/samba/smb.conf), for each mounted partition, enter a section of the following type:
    [sharename1]
    path=/mnt/cobd3
    users=user1
    read only=no

    We change the necessary parameters in our way. After editing the file, restart Samba with the command /etc/init.d/samba reload
  10. Select in the context menu on the “My Computer” icon the item “Map Network Drive ...”. We register as a path for each section \\ 192.168.37.20 \ ball_name , where the name balls is the name spelled out in square brackets at the beginning of the Samba config section.

Hooray! The section is visible, and everything is successfully read and written (naturally, it is read and written only where there are corresponding rights).

Prescribing coLinux as a Windows service
One problem remains - coLinux has to be started manually, and when you close its console window, access to the disks disappears. The solution is to set coLinux as a Windows service (which will work in the background) and configure it to start automatically when the system starts:
  1. In the Windows command line (with administrator rights) in the coLinux directory, we write the command:
    daemon.exe --install-service colinux @ debian-lenny.conf
    Immediately start the service: net start colinux .
  2. We start services.msc (Win + R - services.msc - OK), we find in the list of colinux services, double click on it, and in the appeared window we select the type of startup - Automatic. We save.

To access the guest system, we will use PuTTY (connect to ip 192.168.37.20).
Finally, I would like to note that this method of accessing Linux FSs is still the best, because, as I noted above, existing drivers cannot yet provide full compatibility, and, moreover, they are often required for money.

Source: https://habr.com/ru/post/70058/


All Articles