Wikia

coLinux

Partitions

Talk3
235pages on
this wiki

The following will describe how to access plain partitions from coLinux.

Outline Edit

Unlike using the image method you might use already, you can also directly use partitions from your harddisks. You will add a <block_device> entry with something like "\Device\HarddiskVolume2" to the XML configuration file, and then simply use it inside the coLinux guest linux by the usual partition devices e.g. through /dev/hda2 (the numbering scheme of win and lin can differ, see below!).

/!\ Note: The access to a partition will be exclusive to the first system that uses it:

  • if the partition is mounted under coLinux then it will show as busy under Windowns
  • if it's visible inside of Windows (you can see inside the disk from within Windows Explorer and/or the disk gets a drive letter) then mounting from coLinux is not possible..

{X} Take care while working with partitions!!! It's easy to ruin your valuable data, so making a backup of all your data is a good idea before experimenting with partitions!

Find out the right device name Edit

First of all, you have to find out the Windows device name of the partition to use, something like "\Device\HarddiskVolume2".

XXX - work out the differences between \Device\HarddiskVolume2 and \Device\Harddisk1\Partition2

A *very* useful port of the Unix dd utility to Windows is available at:

http://www.chrysocome.net/dd

The most useful feature of this program is its "list" option:

C:\> dd --list

which shows all the available Windows hard disks and partitions, their mount points, etc. Running this may help clear up some Windows device/drive confusion (or it may cause more...). Note that the cygwin version of dd does not offer this option.

It's not recommended to use the Volume mounts (any that begin with '\\.\Volume{' ). You should be able to use the device mounts (which begin with '\\?\Device' ) by discarding the leading three characters, '\\?'. Note that dd doesn't list the devices as \Device\HarddiskVolumeX (which I believe is a function of the logical volume manager?).

For more information on volume mount points in Windows and some code samples, be sure to check out this helpful MSDN reference page.


The tool form MS dmdiag.exe does a good job of giving the Volume Numbers. XXX - add a weblink here. (I think its this http://download.microsoft.com/download/win2000platform/WebPacks/1.00.0.1/NT5/EN-US/Dmdiag.exe)


One can open Administrative Tools->Computer Management->Disk Management and start counting the Volume number from left starting with first partition as 1 and adding one for each partition shown.

Add it to the XML configuration file Edit

See the block_device page for more information.

<block_device index="2" path="\Device\HarddiskVolume7" enabled="true"/>

/!\ Note: There can be a difference in numbering between windows and linux! Windows only counts used partions. The extended partion is always hidden by windows and will never count.

\HarddiskVolumeN are numbered from 0 or 1 (XXX - there seems to be both possible, maybe this is a difference between windows versions?).

Partitions in coLinux guest linux will be available through the block devices /dev/cobdN, which are numbered from 0 (so in this example, it could be /dev/hda7 or /dev/hda8, depending on the scheme Windows uses).

To access the mapped drive directly as /dev/hda8, you can set an alias. In coLinux guest /dev/cobd2 and /dev/hda8 are the same partion:

<block_device index="2" path="\Device\HarddiskVolume7" alias="hda8" enabled="true"/>
  • /dev/hdaN, /dev/hdbN, ... is for IDE drives.
  • /dev/sdaN, /dev/sdbN, ... is for SCSI drives.

The alias can free set. This is typical for users with dual boot, to set the same device as in native linux booting.

For version 0.7.1 and later, this is the same sample in config file (non XML) or on command line for version 0.6.3:

# Mapping Volume7
cobd2=\Device\HarddiskVolume7
# Alias for /dev/hda6
hda8=:cobd2

Or the short form with automatic cobd:

hda8=\Device\HarddiskVolume7

(Re-)Boot coLinux Edit

In the boot-time messages coLinux prints, it only prints out the filesystem image block_device entries it finds in the XML config file, *not* the raw device entries. For example, it'll print:

cobd0 size: 1048576 kb
cobd1 size: 262080 kb

where cobd0 is a 1GB root filesystem image and cobd1 is a 256MB swap partition image. If the block_device index="2" entry uses path="\Device\CdRom0" (or path="\Device\HarddiskVolume1", path="\Device\Harddisk0\Partition1", etc.), cobd2 *will not* be printed in the boot-time messages, but it *is* still usable (mount, umount, etc.).

mkfs Edit

Skip this part, if you already have a filesystem (FAT32, ext2, ...) on your partition.

The mkfs command will write a filesystem on the new partition, similiar to the DOS format command.

{X} WARNING: using mkfs on a partition will delete all data on it! Be absolute sure to do this on the right partition, you have been warned! To be safe use the read-only mount option when mounting the file system

To prevent formatting an already used partition, you could try to mount it already now. If you can mount it, it might not be the right one!

However, if you are sure that you know the right partition, you might invoke something like:

mkfs.ext3 /dev/hda2

mount the partition Edit

To access the files on the partition, you have to mount it first with something like:

mount -t ext3 /dev/hda2 /mnt

now you should see the files in the /mnt directory.

/!\ Note: If you're accessing a partition (that is, a drive) in Windows, you won't be able to mount it in coLinux because Windows locks the resource. Be sure to close any folder windows or instances of Explorer that are referencing that drive, and change drive letters away from that drive in any open Command Prompt windows. Then your mount command should succeed.

/!\ Big warning, don't mount same partition on windows and linux in same time! Windows uses a buffered file access for read and write and you can not control the buffer. An access to FAT or NTFS partition from coLinux guest is only recommended if Windows has no drive letter for this drive, or if you are absolutely sure that Windows has not written anything in the file system. In other case, you will get corrupted data or damage your whole partition. Better use the CofsDevice to access on FAT or NTFS partitions.

Depending on the coLinux guest linux you use, you might need to load the appropriate kernel module before mounting the partition e.g.:

modprobe vfat

for FAT32 filesystems (XXX - is this really required today?).

Edit /etc/fstab Edit

If you want to make this permanent, you should edit your /etc/fstab and add a line like:

/dev/hda2 /mnt ext3 defaults 0 1

USB Drives Edit

USB thumb drives and USB hard disks are all accesseible as usual disk partitions.

First find out the right device name using the dd utility for Windows. For better orientation you can restrict detection only to removable devices by renaming dd.exe to dd-removable.exe and use the --list option:

c:\dd-removable --list

For us is interresting only the line beginnig with "link to".

Then add a new line with the "link" without the leading "\\?" to the XML configuration file. It could look like this:

<block_device index="2" path="\Device\Harddisk1\DR6" enabled="true" />

Reboot coLinux and mount your USB device:

mount -t vfat /dev/cobd2 /mnt/usb

/!\ Big warning, don't mount same device on windows and linux in same time! Windows use a buffered file access for read and write and you can not control the buffer. As you plug your USB device, close all windows (applications), that can have access to it!

Quick Start For USB drives and COFS Edit

Plug in the USB drive, boot colinux, and then mount the USB drive.

colinux-daemon.exe cofs0=c:\ cofs2=e:\ @config.txt
mount -t cofs cofs2 -o uid=bob,gid=bob /mnt/e

Don't forget to umount before removing the drive.

umount /mnt/e

Works for Cooperative Linux Daemon, 0.8.0, Compiled on Aug 19 2007 15:34:48.


MassTranslated on Sun Apr 23 17:36:40 UTC 2006

Around Wikia's network

Random Wiki