LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Debian (https://www.linuxquestions.org/questions/debian-26/)
-   -   how can I automate my usb drive to be read/write (https://www.linuxquestions.org/questions/debian-26/how-can-i-automate-my-usb-drive-to-be-read-write-493560/)

abrand888 10-18-2006 12:13 PM

how can I automate my usb drive to be read/write
 
Hello,

I am using Knoppix 3.8 live CD. As soon as it loads, it sees my USB external drive, I mount it and configure it to be read/write and when I do any
downloading, I direct it to be saved in my USB drive.

Is there a simple way to make it do it automatically as soon as it boots up ?

I tried Knoppix 5.0 and it wouldn't let me mount and make my USB drive read and write. Is there a way to do in in 5.0 ?

I also plugged in my USB antenna and neither Knoppix 3.8 or 5.0 sees my antenna.

Thanks..

Arthur

Dutch Master 10-19-2006 08:15 AM

Yes, you could write a script and put that in the /etc/rc directories. Writing a script isn't that difficult, basically you're telling the kernel to execute the same commands as you would do from the commandline. Basic syntax:
Code:

#!/bin/bash
<command_1><options>
<command_2><options>
....
exit 0

Simple, isn't it? Save it in your home-directory with an appropiate name and make it executable. Then create a sym-link from the /etc/rc directory to your script. The name of that sym-link should be something like
Code:

S<2 digit bootcode>scriptname
The 2 digit bootcode determines when in the boot sequence the script is called. Mind you, you'd have to make sure it doesn't call on services not started yet! So I suggest to have a bootcode of 25 or higher. Keep the scriptname as short but meaningful as possible, preferable max 8 characters. It'll probably work with more characters, but better to play on the safe side.

basileus 10-19-2006 12:31 PM

Some versions of Knoppix that I've used mount removable drives read-only by default. Right-clicking on the drive icon and choosing "Remount read-write" (or something) should help.

To make this the default behavior you probably need a persistent home directory where you can save your boot-time settings.

abrand888 10-19-2006 04:04 PM

Dutchmaster :

Excuse my ignorance but could you explain in simple english what each line means ?

#!/bin/bash
<command_1><options>
<command_2><options>
....
exit 0

What does each line tell the kernel. Please bear in mind that I am using a live cd so I would like to just go to terminal mode if possible and run a script giving it instructions if possible. Please explain to me in laymans terms what this line means

S<2 digit bootcode>scriptname

and where does one put this line in the script.

Thanks a lot.

Arthur

Basileus :

In 3.8 ver of Knoppix I can change the read to write and did it by mounting and doing actions, but Knoppix 5.0 didn't let me dp that yet. Will try over the weekend again.

Thanks.

Arthur

Dutch Master 10-19-2006 06:58 PM

Ok, I kinda overlooked that you're on a Live CD and not familiar with the commandline. That isn't a problem as Basileus already explained the way to do it from your desktop.

You asked what the various lines in my syntax example mean. But, as you're new to this, I'm a bit worried that it might be to much in one go.
Code:

#!/bin/bash
<command_1><options>
<command_2><options>
....
exit 0

The first line tells the kernel that to execute the script properly it needs to use a specific interface with it's syntax. In this case, the interface is named "BASH". There are a few others, but bash is the most widespread in Linux.

The second and third line are basicaly equal. This is an abstract way to tell the reader that (s)he needs to replace that line with the command that needs to be executed, followed by the command's options.

The fourth line is the (my) way to tell the reader to continue with the previous lines as necesary.

The last line tells the kernel that it reached the end of the script and that if it could be executed normaly it should exit with an error status of 0 (as in zero) That is standard behaviour and IMHO a good programmer should always end a script nicely (for the kernel, not me ;))

Next, you where a bit confused about
Code:

S<2 digit bootcode>scriptname
Again, the way I wrote it tells the understanding reader to replace the part between the < and > with a 2 digit number and the name of the script. It's not used inside the script, it's intended to give the script a name and a place in the sequence of execution by the kernel when booting. Actually, it's a link to the actual script in your home directory.

As I've said, I'm afraid that this might be a bit to much to comprehend in one go for a newbee. So if you don't understand it's not a problem. I too needed time to understand this. Use it as a brief introduction to writing scripts and read it again when you've got to grips with Linux and it's versatility.


All times are GMT -5. The time now is 08:16 AM.