INTRODUCTION:

There have been a great deal of questions, ideas and discussions regarding the sharing of partitions (e.g. windows partitions) on Linux systems. I myself went through the 'mill' on several machines here and hopefully developed something of an understanding of the process and the structure behind it. So I thought I would give a few 'pointers' for those wanting to get a quick view of the issues.

To paint a picture of the context within which I'm working, this is the situation I've been dealing with:- Here, at home, I have (admittedly unusually) 6 computers running Fedora Linux, distributions F18, F21 and F22 (alpha at this moment). On a number of those machines I have a dual-boot setup since they deal with peripherals or packages that require a windows OS but also need to be able to work with packages which I have that are intended for Linux OS environments. I also have a couple of other computers which are used sporadically, e.g. in my workshop and portable around my amateur radio station, and there are some Windows machines as well.

SHARING:

The two most common network sharing options in use are NFS for Linux <> Linux and Samba for Windows <> Linux sharing. There are, in both environments, security issues which must be addressed with their options being set according to individual needs: in my own case I chose not to rely on the SELinux package but this can still be used if desired without preventing the sharing of partitions for both NFS and Samba - it just takes a few more steps with a few more considerations (e.g. telling SELinux what directories are Samba-shared, setsebool).

Whilst it is too much work to put every single option into this one document, I shall show an example of a working solution for a dual-boot system which also works over a network together with others of these systems.

Let's start off with a requirement to have a system with a dual-boot capability to be able to boot up into Linux (Fedora) and also into Windows (let's also say for the sake of those who may have the need that there is a pre-existing disk with some data and files on it that is also wanted in the final configuration); we shall also assume that the user is not necessarily knowledgeable of the intricacies of these operating systems but does know the basics of its working. Just skim through the steps below if you already have done what's in them, taking any notes as necessary.

STEP 1: Computer Assembly.

Assemble the computer hardware, especially disks (if necessary) with one hard disk containing a spare empty / unallocated partition large enough for the operating systems. It can be a totally empty or new disk, of course. Boot up the system and enter the BIOS before it attempts to do anything else. Check all the usual things such as date and time, (gets used by any install procedure so we want that right), check that it 'sees' the disks you have in the box, and go to the 'boot options' options in the BIOS. (That is nearly always there in most of the modern BIOS's). Ensure that the first boot option is the drive or USB stick that you are going to use for installing the new operating system, followed by the hard disk that is going to be used as the destination for the operating system. Choose the BIOS option to save your selections and exit to re-boot.

*** If you already have a Windows operating system on the main disk, you will need to check that it does not occupy the whole of that disk, i.e. that there is an unused/unallocated partition available for the Linux installation. If the whole disk is allocated to Windows already then either you need a second disk with an empty/unallocated partition or you must arrange the first disk such that you free up enough space for an unallocated partition for Linux.

*** Whatever you do, if you have pre-existing operating systems or other user data / files that you want to keep then MAKE AN ARCHIVE to keep all that safe if it needs to be recovered!

Make sure your network cable or wireless adapter is plugged into the system and workable.

STEP 2: Windows Install.

*** You can skip this step if you already have a working bootable Windows operating system on disk - if there's still an unallocated / unused partition or drive in the system.

Let's assume a 250Gb disk for a first one and a 500Gb disk as a second one (for this example). Boot up the system with your Windows install media in its drive (e.g. CD, DVD or USB) and install the operating system as you would on any other everyday system - BUT when the installer asks how much space and where you want for the install, choose just a part (e.g. 100Gb) of the main disk for the install, and leave another partition free, with no formatting or anything else. If you've a second disk or space for further partitions then ask for these too from the installer, e.g. ask it to format a second partition of 250Gb on the second disk for "drive D:" which you will use as a windows data partition.

For networking, choose a name for the system that is representative - in our case here we could use "DesktopWIN" - and choose the grope name (workgroup) such as "thegales" for example. Go further with the install as normal, ending up with a Windows bootable system with (in this example) a 100Gb C:\ drive containing Windows and a 250Gb D:\ drive for data directories ('folders' in windows!).

You'll now have another 150Gb on the first drive unallocated and 250Gb on the second drive unallocated, this is fine.

Returning to networking, bring up the network connection 'properties' using the 'control panel' or equivalent and ensure that the necessary sharing protocols are included, the group name is set ("thegales" here), and that the IP addresses are correct for your network - here you'll be using something like DHCP for machine IP assignment, 192.168.3.xxx for one of your DNS lookups (e.g. your router if capable), a possible gateway like (e.g.) 192.168.3.9 if you are using one.

For the Windows drive or directory which we want to share over the network, we shall give that a name - in the file manager (e.g. 'My Computer') we right-click the drive / partition we wish to share and click on 'Rename' and give it the name ("ourwin_d" for our example).

Shut down Windows for the time being.

STEP 3: Linux Install.

Replacing the bootable drive media (the CD/DVD/USB stick) with the Linux distribution bootable image, boot up the system once again. Boot up the system from this distribution disk and follow the various steps the installer routes you through until it asks for partition information: check (for our example) that the hard-disk boot partition will be correct (probably on /dev/sda2 in our scenario since we'll use the second partition of the first disk). Ensure that the unallocated partition on the second hard disk is also set up (/dev/sdb2 here). Allow the installation process to complete, with the admin/root ID & password set and a user ID & password set. The installer should include a boot manager, this will allow you at boot-up time to choose which operating system to boot into, within a time limit (which can be changed in the config file at a later stage if desired).

Now check that the system boots up as expected - restart it and wait, checking that the boot loader presents the choice of OS to you. Select the Linux operating system, and let it bring up the GUI which you selected when you downloaded the distributuin 'spin'. Otherwise, let it boot up to the text-line terminal interface if that is what you wanted.

STEP 4: Directories.

You now have a dual-boot system with both Windows and Linux operating systems successfully installed, and a Windows data partition plus a Linux data partition: remember that whilst Windows uses "drive letter" assignments for paths in its file system, Linux uses a "large tree" where you do not necessarily need to be aware of actual disk placement for files. If you *do* wish, it is easy to place (e.g. a directory) on a particular disk, with a name (e.g. /dev/sdb2/data) using a mountpoint which you define somewhere else for reference.

First, let us examine what disk directories seem to be available: change directory to / and use ls -h -o -g -L (if you want more on using 'ls' then type 'man ls') and you should see the usual set rather like below:-

[tgale@DesktopF22 ~]$ cd /
[tgale@DesktopF22 /]$ ls -h -o -g -L
total 214K
dr-xr-xr-x.   2  44K Mar 16 03:39 bin
dr-xr-xr-x.   5 1.0K Apr  4  2013 boot
drwxr-xr-x   19 3.6K Mar 15 19:42 dev
drwxr-xr-x. 122  12K Mar 30 03:36 etc
drwxr-xr-x.   4 4.0K Apr  4  2013 home
dr-xr-xr-x. 150  68K Mar 16 03:39 lib
drwx------.   2  16K Jan  9  2013 lost+found
drwxr-xr-x.   2 4.0K Jul 19  2012 mnt
drwxr-xr-x.   2 4.0K Jul 19  2012 opt
dr-xr-xr-x  220    0 Mar 15 19:41 proc
dr-xr-x---.  19 4.0K Mar 25 13:06 root
dr-xr-xr-x.   2  24K Mar 16 03:39 sbin
drwxr-xr-x.   2 4.0K Jul 19  2012 srv
dr-xr-xr-x   12    0 Mar 15 19:41 sys
drwxrwxrwt   10  220 Mar 30 03:56 tmp
drwxr-xr-x.  14 4.0K Apr  5  2013 usr
drwxr-xr-x.  18 4.0K Jan  9  2013 var

To this, let us add a new directory which we shall eventually share over the network with other users: first we must make that directory, which we shall do as root:

[tgale@DesktopF22 ~]$ su -
Password: 
[root@DesktopF22 ~]# cd /
[root@DesktopF22 ~]# mkdir ourdata
[root@DesktopF22 ~]# ls -h -o -g -L | grep ourdata
drwxr-xr-x    2 4.0K Mar 30 12:10 ourdata

Since we want it to be available for read, write & execute access (for this example!) we issue:

[root@DesktopF22 /]# chmod 777 ourdata
[root@DesktopF22 /]# ls -h -o -g -L | grep ourdata
drwxrwxrwx    2 4.0K Mar 30 12:10 ourdata

Plus, for problem-free Samba access etc. we change 'ownership' of 'ourdata':

[root@DesktopF22 /]# ls -h -o | grep ourdata
drwxrwxrwx    2 root   4.0K Mar 30 12:10 ourdata
[root@DesktopF22 /]# chown nobody:nobody ourdata
[root@DesktopF22 /]# ls -h -o | grep ourdata
drwxrwxrwx    2 nobody 4.0K Mar 30 12:10 ourdata

So there's the Linux directory which we shall end up sharing over our network.

Now we come to the Windows partition which we can treat as another directory here on the Linux system (it should be mounted):

We find where the Windows directory source "ourwin_d" appears as follows:

[root@DesktopF22 /]# mount | grep ourwin_d
/dev/sdb1 on /run/media/tgale/ourwin_d type fuseblk(rw,nosuid,nodev,relatime,
userid=0,groupid=0,default_permissions,allow_other,blksize=4096,uhelper=udis
ks2)
[root@DesktopF22 /]# 

This shows us that it is located on the disk /dev/sdb1 but it has a different file system 'fuseblk' (e.g. NTFS instead of EXT4 which can be used in Linux), but there is a solution for this which comes below.

To mount a disk in Linux it has naturally to have a mount point, and we can establish this by creating it in the root directory as follows:-

[root@DesktopF22 /]# cd /
[root@DesktopF22 /]# mkdir OurFolder
[root@DesktopF22 /]# 

This will be used when we include it in /etc/fstab for automatic mounting on boot.

STEP 5: Configuration.

For handling the NTFS file system often used in Windows installation we can make use of a tool called 'ntfs-3g' - this we can download using the 'yum' (yellowdog update manager) facility, and this avoids tending to the deeper dependencies issues. It is very commonly used in such circumstances and should be included in the distribution you have installed.

Therefore, as root, we proceed:

[root@DesktopF22 /]# yum -y install ntfs-3g

(output varies according to actual system situation and configuration)

[root@DesktopF22 /]# 

BEFORE we reference this in the /etc/fstab file for automounting, we should check that the directory can indeed be mounted without problems:

[root@DesktopF22 /]# mount -f -t fuseblk /dev/sdb1 /OurFolder
[root@DesktopF22 /]#

The above mount command 'fakes' the mount (-f) rather than actually executing it, and parses (-t) the NTFS filesystem as 'fuseblk' for this test. If there is no further error output then we appear to be able to include this in our /etc/fstab file for automounting at boot-time: BEFORE editting this file a copy should be made of this file so that it can easily be recovered if something goes wrong - you'll see this on boot and might wonder where the heck you've landed!!! (If that happens, you'll typically be dropped into a console terminal from which you can change to root and copy back the saved file which was originally a good working one, and then re-boot).

[root@DesktopF22 /]# cd /etc
[root@DesktopF22 etc]# cp fstab keepfstab
[root@DesktopF22 etc]#

*** We'll wait with editting fstab until we've done these next few small things *** Now before we get to the ending step we shall set up the system in this example to ignore the SELinux security feature - for this we must edit the /etc/selinix/config file to disable it: use your favourite text editor to change it thus:

[root@DesktopF22 /]# cd /etc/selinux
(then edit the file 'config', specifically the line SELINUX=disabled)...
[root@DesktopF22 selinux]# more config

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected. 
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted 

[root@DesktopF22 selinux]#

While we are here, we should check the hostname entry, it should be:

[root@DesktopF22 selinux]# cd ..
[root@DesktopF22 etc]# cat hostname
DesktopF22

[root@DesktopF22 etc]#

You will need the reference for your network connection in the Samba configuration file so that it knows where to connect to the network through:

[root@DesktopF22 etc]# ip route
default via 192.168.3.9 dev em1  proto static 
192.168.3.0/24 dev em1  proto kernel  scope link  src 192.168.3.34 
[root@DesktopF22 etc]# 

...this shows you the network link name used here is 'em1'. Here, we might as well deal with the Samba configuration: it is best if we ensure that we have the latest version, complete, so the following removal and subsequent download commands should take care of that:

[root@DesktopF22 etc]# cd /
[root@DesktopF22 /]# yum remove samba
[root@DesktopF22 /]# yum -y install cups-lib samba samba-common samba-client
(outputs vary)
[root@DesktopF22 /]#

So then we edit the configuration file for Samba, /etc/samba/smb.conf, using your favourite text editor - here I'm only going to highlight the necessaries, not include all the comments amd advice given itself in that file which has become rather verbose:

[root@DesktopF22 /]# cd /etc/samba
(... then, after we edit this file ...):
[root@DesktopF22 samba]# more smb.conf


[global]
# ------------------------- Global Options ---------------------------

	workgroup = thegales
	server string = DesktopF22
;
	interfaces = lo em1

	hosts allow = 192.168.3. 127.

	follow symlinks = yes
	unix extensions = no
;
# --------------------------- Logging Options -----------------------------

	log file = /var/log/samba/log.%m
	# max 50KB per log file, then rotate
	max log size = 50

# -------------------- Standalone Server Options -----------------------

	security = user
	passdb backend = tdbsam
#

# ------------------------- Name Resolution ----------------------------
#
# - WINS Support: Tells the NMBD component of Samba to enable it's WINS 
#   Server
#
# - DNS Proxy - tells Samba to try to resolve NetBIOS names
#   via DNS nslookups.

	wins support = yes
	dns proxy = yes
# --------------------------- Printing Options -----------------------------
#
# Load Printers let you load automatically the list of printers rather
# than setting them up individually
# Cups Options let you pass the cups libs custom options, setting it to raw
# for example will let you use drivers on your Windows clients

	load printers = yes
	cups options = raw
	printing = cups

# ------------------- Share Definitions ------------------------

[printers]
	comment = All Printers
	path = /var/spool/samba
	browseable = No
	guest ok = Yes
	printable = Yes

[ourlinuxstuff]
	path = /ourdata
# (the linux directory we will be sharing for all)
	public = yes
	guest ok = yes
	guest only = yes
	writeable = yes
	browseable = yes
	comment = our Linux directory

[ourwinstuff]
	path = /OurFolder
# (the mounted windows partition we will be sharing)
	public = yes
	guest ok = yes
	guest only = yes
	writeable = yes
;	printable = no
	browseable = yes
	comment = Shared Public Area
[root@DesktopF22 samba]# 

When Samba is running, over the network we should now see "ourlinuxstuff" as one space available on this machine (the 'ourdata' directory) and also "ourwinstuff" which is the windows drive D:\ ('ourwin_d' from Windows) as another space.

Now finally we edit /etc/fstab so that it contains the following (for our example here):

[root@DesktopF22 etc] # cat fstab
#
# /etc/fstab
# Created by anaconda on Sun Mar 22 08:36:29 2015
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/fedora_DesktopF22-root        /           ext4    defaults  1 1
UUID=eff8e75a-8c19-4569-ad46-d5025e18cab4 /boot       ext4    defaults  1 2
/dev/mapper/fedora_DesktopF22-home        /home       ext4    defaults  1 2
/dev/mapper/fedora_DesktopF22-swap         swap       swap    defaults  0 0
#
/dev/sdb1	                        /OurFolder   ntfs-3g  defaults  0 0

[root@DesktopF22 etc] #

That last line is the line that we added for our example here.

Now we should be all set to finalize and try out the new set-up over our network, for this it is time to re-boot the machine once more - for an orderly shutdown and reboot we don't just press the 'reset' button, there's a command we issue for it all:

[root@DesktopF22 etc] # shutdown -r now

whereupon the machine will close open files, stop services and reboot properly. Of course, when the bootloader shows, choose the Linux option for boot.

STEP 6: Services, checkout.

Once we have rebooted and we have a terminal screen (in a GUI such as KDE or 'xfce', click on 'terminal emulator') we can start the NMB and SMB services that get Samba running, on my machine here we do this (as root) as follows:

[tgale@DesktopF22 ~] $ su -
Password:
[root@DesktopF22 /] # systemctl start nmb.service
[root@DesktopF22 /] # systemctl start smb.service
[root@DesktopF22 /] #

Now go to *another* machine in your network, a Windows one, and look at the network where you should find our machine available as "DesktopF22" amongst any others that you have in the same group, e.g. using a command prompt:

C:\> net view
Server Name            Remark
---------------------------------------------
\\ATVSYS-F22         atvsys-F22-ATV-system
\\DESKTOP-F22        Desktop-F22-system
\\GALE_NAS1 
\\ANGELA-F18         Angela-F18-for-video
\\NETADMIN-F21       Netadmin-F21
\\RADIOOPSYS         RADIO-OPERATING-SYSTEM
\\PRINTSERVE_1
\\W-XP-ALTERNATE     Alternate-XP-system
The command completed successfully.
C:\>

On that system we should be able to 'click', in the network window, the "Desktop-F22" computer icon and see the available directories "ourwinstuff" and "ourlinuxstuff", we can now put some files in those directories as we wish if all is well. This tells us that Samba is at least running on our Linux system which we have been setting up.

Back on our Linux system, we can now finalise things and make the Samba service automatically invokable on boot, we do this as root:

[root@DesktopF22 /] # systemctl enable nmb.service
[root@DesktopF22 /] # systemctl enable smb.service
[root@DesktopF22 /] #

which sets up the init.rc related procedures so that the necessary services are started at bootup.

We can also, as a check, issue the 'smbtree' command (part of the Samba package) to view the available resources on the network through Samba, it will generate quite a long list if there are many directories and/or many machines on your network, but a (shortened here) output might look like this:

[root@DesktopF22 /] # smbtree
Enter root's password: 

PRIVATE
	\\W-XP-ALTERNATE	   	Alternate-XP-system
		\\W-XP-ALTERNATE\Printer        DYMO LabelWriter 400
		\\W-XP-ALTERNATE\DRIVE_D    	
		\\W-XP-ALTERNATE\Printer2       HP LaserJet 1536dnf
		\\W-XP-ALTERNATE\SharedDocs     	
		\\W-XP-ALTERNATE\D$             Default share   		\\W-XP-ALTERNATE\DRIVE_E    	
		\\W-XP-ALTERNATE\E$             Default share
	\\RADIOOPSYS      		A-V_Radio-Operating
		\\RADIOOPSYS\C$             	Default share
		\\RADIOOPSYS\F$             	Default share
		\\RADIOOPSYS\pegasys        	
		\\RADIOOPSYS\roxio_video	Produced videos
		\\RADIOOPSYS\SharedDocs     	
		\\RADIOOPSYS\D$             	Default share
		\\RADIOOPSYS\resources_D    	
		\\RADIOOPSYS\E$             	Default share
	\\PRINTSERVE_1			Intel Printserver
		\\PRINTSERVE_1\DJ990C		DeskJet 990c via Netport   		 
	\\ANGELA-F18         		Angela-F18-for-video
		\\ANGELA-F18\data           	Angela-ATV Data Space
		\\ANGELA-F18\public         	Angela-ATV Public PC Files
		\\ANGELA-F18\oldpublic      	Archived Public Files
	\\NETADMIN-F21   		Netadmin-F18
		\\NETADMIN-F21\HP-DeskJet-990C	DeskJet 990C via Intel Printserver
		\\NETADMIN-F21\systems         	Systems status (Netadmin-F21)
		\\NETADMIN-F21\public         	Common Public Files
		\\NETADMIN-F21\info           	Shared Main Info Area
		\\NETADMIN-F21\fixedIP		Fixed IPs information
	\\GALE_NAS1      		
		\\GALE_NAS1\INFO           	NAS general info.
		\\GALE_NAS1\Installs       	Common installs resource.
		\\GALE_NAS1\Downloads        	Downloads archive
		\\GALE_NAS1\Transfers      	For intra-machine updates.
	\\DESKTOP-F22     		Desktop-F22
		\\DESKTOPF22\ourwinstuff       	Shared Public Area
		\\DESKTOPF22\ourlinuxstuff	Common Data Directories
	\\ATVSYS-F22     		atvsys-F22
		\\ATVSYS-F22\angela-xp      	Angelas Win-XP files
		\\ATVSYS-F22\angela-F18     	Angelas F18 files
		\\ATVSYS-F22\angelstill		Still picture files
		\\ATVSYS-F22\data           	atvsys Data Space
[root@DesktopF18 etc]# 

FINALLY:

All of the above steps, hints and examples are based upon my own environment here at home, using Fedora 18, 21 and 22 (alpha release at this current time) and Windows XP and 7 - as such some of the commands which you will find necessary to use may differ slightly from what is shown - e.g. in earlier Fedora distributions one might issue "service nmb start" instead of "systemctl start nmb.service", and the contents of some configuration files will differ a little depending upon versions. However the principles are the same, and it should not be found difficult to resolve any minor differing issues; what we do in the above is, after all, fairly logical and the main aim I have here is to show how various 'issues' that appear to pop up (in forums, FAQ's, discussion groups) quite often can be explained and addressed.

I hope that some or all of the above has been of assistance to those with such issues or questions regarding the networking of Linux and Windows boxen together in a home or small business environment; I have not covered the various security aspects which in any commercial or other sensitive environment *must* be addressed, such as the use of SELinux with the enabling of Samba directory access and many other points. These are far too many to include in the scope of these pages.

Also, various examples above will no doubt be changeable for your own wishes, such as limiting access to directories to read-only in Samba, establishing a printer set-up, and so on - with a bit of adaptation such matters are easily dealt with.

If you have read up to this point then I recommend a strong cup of tea or a pleasant glass of wine to take with you as you sit down and relax for a while! I wish you happy networking.


* * *