www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2009/09/23/05:15:21

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-0.6 required=5.0 tests=AWL,BAYES_05,J_CHICKENPOX_23
X-Spam-Check-By: sourceware.org
Message-ID: <4AB9E70D.6080102@bonhard.uklinux.net>
Date: Wed, 23 Sep 2009 10:14:53 +0100
From: Fergus <fergus AT bonhard DOT uklinux DOT net>
User-Agent: Thunderbird 2.0.0.22 (Windows/20090605)
MIME-Version: 1.0
To: Cygwin ML <cygwin AT cygwin DOT com>
CC: Fergus <fergus AT bonhard DOT uklinux DOT net>
Subject: Re: how to let cygwin does not mount /bin /usr/bin automaticlly?
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

> That is great. Thanks for your patient.
> I have another question. Can the first field of fstab use relative
> path. I expect to make the cygwin portable, that is, i need to move it
> to somewhere esle without changing the fstab every time.

If you are using Cygwin in portable mode (presumably on a stick or similar mobile device)
there is a way to achieve what you want - but it is fiddly.
I am guessing that Cygwin is mounted at the root of your device ie /bin, /etc, /usr, and
all the rest are all located under d: or f: or g: or p: or whatever the device might turn out
to be labelled as you move from one host machine to another host machine, and that you do not
want the grief of having to identify the variant drivename every time and manually re-configure
the line in /etc/fstab as

	f:/cygwin_1.7/usr/bin /usr/bin ntfs binary 0 0 
or
	h:/cygwin_1.7/usr/bin /usr/bin ntfs binary 0 0	

accordingly, as might be necessary.

The way I do it (if_there_is_a_better_way_I_would_like_to_know_it) is to start portable Cygwin with
a .cmd file (called go.cmd or something) that resides at the root of the device and starts with the
lines

@set DOS_CMD=%0
@set CWD=%CD%
@set DN=%CWD:~0,2%
@if (%DOS_CMD:~1,1%)==(:) set DN=%DOS_CMD:~0,2%
@if (%DOS_CMD:~2,1%)==(:) set DN=%DOS_CMD:~1,2%

All this is designed so that the variable DN (standing for drivename) is exactly D: or F: or G:
or P: as appropriate, and the reason for the five lines is so that this identification is
correctly made however you start Cygwin, whether by

(i)   typing go.cmd at the prompt in a Command Prompt window located at F:
(ii)  typing f:\go.cmd at the prompt in a Command Prompt window located somewhere else
(iii) double clicking the go.cmd icon in Explorer
(iv)  using Start -> Run -> f:\go.cmd

Yeah, I know, all that effort just so that DN accurately identifies the drivename, but it all has to
be done BEFORE Cygwin is triggered. You can then go on, still in go.cmd, to say something like

@%DN%\bin\echo %DN%/cygwin_1.7/usr/bin /usr/bin ntfs binary 0 0 >  %DN%\etc\fstab
... any other requirements ...                                  >> %DN%\etc\fstab

and then, FINALLY, start Cygwin with (well, in my case: your requirement might differ)

@set SHELL=/bin/bash
@set HOME=/home/user
@%DN%\bin\rxvt

Awfully sorry for long post. A fiddly way to get something rather simple, but it works in all of
W98, XP, Vista and 7. And there are lots of other reasons (if you are running portable Cygwin off 
one device on any number of potential host machines) why you might want to use DN without having
to discover it (or, in fact, even know it) each time.  

Fergus



--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019