HyperEscape's picture

Hello All,

I am running "turnkey-fileserver-11.2-lucid-x86" on a headless (without display and input) machine acting a network file server using SAMBA. I have two queries at the moment.

 

1. It usually happens that I restart fileserver via the Webmin interface, however its a bit tricky sometimes to know when has it restarted and available again for operation, so as to resume any file operations again.

 

In FreeNAS running in a similar there is a provision of sounds or beeps using the system on-board speaker, which makes separate beep pattern when the server is available for use after a restart and again another beep pattern when the server is going down or restarting.  

 

Can the similar be made possible in TurnKey, which would be really useful for maintenance on headless machines.

 

2. Secondly if I define any USB connected harddisks as  filesystem mount points (which are shared via SAMBA), and for some reason the USB harddisk is disconnected when the server is restarted, then the boot-up sequence is paused near the final steps where it says to wait for the mountpoint availability or to skip or to land in a manual command prompt. Untill a keyboard is connected physically to the machine, the boot up sequence cannot complete and remains halted, which is not a very desired options again in a headless setup.


Is there a possibiilty, that the server always skips the mountpoint availability check during the startup, and later on when the USB disk is connected, the mounting can be done via the WebMin interface once the server becomes available on the network.

 

Thanks in advance for reading and replying.

Forum: 
Jeremy Davis's picture

Then the disks won't automount. You will need to mount them manually everytime though, unless of course you create a mount script to do it for you (like Gerardo suggests). Utilising inithooks (everyboot) would probably be an easy way to launch your script. I'm not sure how Samba will react if resources its trying to share aren't available but at least it won't stop your server from booting.

I like the idea of using system beeps. I can't see why you couldn't write a script to do that!? Not sure how, but I like it!

@Gerardo - I'm not sure what TKL/Ubuntu do as far as /etc/rc.d/init.d is concerned. AFAIK upstart is used for most services these days but there'd be a way to see if Samba is running for sure.

HyperEscape's picture

Thanks Jeremy and Girardo,

Well I am a total novice in Linux. Dont know much about how and where to edit which files to make things work. All the experiments I am doing so far is though the GUI based WebMin interface for CLI handicapped people like me :-).

I thought that since there are much experienced users over here, it would be rather an easy way of doing it by copying/replacing scripts and making necessary changes required.

Maybe if you can run a test installation or a VM of FreeNAS (based on FreeBSD linux) then you can get some clue how is it generating the system beeps, and also how does it boots completely whether the defined mount points are available during boot up or not. Maybe the following can give you some clue

http://blog.freenas.org/2007/03/playing-with-devspeaker.html 

 

FreeNAS presents are rather easy option, that if the connected USB disks are disconnected while boot up, it will boot completely with SAMBA running. It will show them as missing in the disk mount-points with a clickable "Retry" button, as soon as you connect the harddisks and press retry, the volumes would be mounted and the dead SAMBA shares would become alive. Saying that I have to agree that the defined mount points are not included in the fstab, they are loaded afterwards.

 

TKL also presents a similar way, that if during a running system you pull out a USB harddisk and then connect it again, it would not be accessible. You have to go in the Filesystems and Disks menu to choose your defined share/mountpoint and the click the Yes/No button in the second last coulumn on the right. It then refreshes the mount points and they become available. 

So if I remove the entries from fstab (to let it run through the whole booting cycle), how would I ensure that the disks are mounted again with NTFS-3g. I have installed NTFS-3g and using it for mounting harddisk via fstab. Can I make a cron job.??

Any ideas are welcome.

Jeremy Davis's picture

And although I think it's a good idea, I have plenty on my plate at the moment wihtout taking on another project.

As for mounting drives, again I don't have the time or energy to take it on but I can share what I know... I haven't used the Webmin features but it's really easy to mount from the commandline:

mount /dev/sdXx /where/you/want/it/mounted

So assuming that your HDD appears as sdb and only has one partition and you want to mount it to /srv/usbhdd1 you would use this command:

mount /dev/sdb1 /srv/usbhdd1

You can check what devices are connected using the command

fdisk -l 

Unmounting is even easier (using the example from above):

umount /srv/usbhdd1

And to check what is mounted simply

mount

So to do that manually is easy enough, but the folder needs to exist already. If you were only ever using a single USB it'd be pretty easy to script that.

But with multiple devices it gets a little trickier as they may change. So you'd need the script to check that you are mounting the right one. OTTOMH I'm not sure how the best way to do it would be as you want it to be reliable. Each HDD should be able to be identified with a UID (unique ID) number (it's what Grub2 uses when booting) so that could be an option? Possibly the best? Although perhaps you could leverage the automount scripts that the Ubuntu desktop versions use? As long as the volume labels are different they will mount in the same places everytime (just as a USB stick does on an Ubuntu desktop - things get a bit messy though if you have 2 USBs with the same volume name!)

Bottomline is that acheiving your ends is quite doable (the beep thing may be a little tricky - but the mounting thing should be relatively easy). But you'll need to get over your commandline aversion, roll up your sleaves and get your hands dirty! :) Happy to help out where I can.

If you keep in mind that TKL v11.x is based on Ubuntu 10.04/Lucid then you'll just need to hone your google-fu and you'll be a champion bash scripter in no time! The Ubuntu forums are a wealth of info and the docs are quite good too. Plus you should find a ton of tutorials and blogs that will help you on your way. I'd start with the Samba bit to begin with though.

Two final suggestions:
1) Don't muck around on your main machine. Play with something expendable, like a VM. That way you won't be scared to break things and worst case scenario you start again - no harm done!
2) Document your progress as you go . This is easier in a VM too, you can have an SSH session window to your VM window open (I recommend PuTTY for Windows), a text file (Notepad++ again for Windows and your web browser (for resaearch). That way if something works you'll be able to repeat it easily. And if you irrepairably break something then you can get back to where you were quickly (see 1). Also you'll be able to create a bash script with your commands and easily share it with the community so everyone benifits.

Good luck :)

Dubravko's picture

Hello.

Linux is a new experience for me, and I have a question.

How can I mount NTFS partition without losing data (the entire disk is one partition)?

Jeremy Davis's picture

So you mount the drive with the 'mount' command and unmount the drive with the 'umount' command. Some distros (especially older ones) require that you specify the filesystem type on mount but TKL doesn't seem to mind (in my experience).

Note that if you disconnect the drive without clleanly unmounting (or power off the machine without cleanly shutting it down) then you risk data loss. As this suggests the drive will automatically and cleanly unmount during a proper shutdown. If you want the drive to automount on boot then you need to edit the fstab file. I would not recommend adding anything other than fixed internal drives be manually added to fstab, although some distros (generally desktop ones) will have automount scripts that detect and mount drives automatically (when they are plugged in) but you still need to unmount if you wish to physically remove them.

If an NTFS drive is uncleanly unmounted (ie physically removed or power off without proper shutdown) then it will be flagged as 'dirty' and will require a chdsk under Windows before it will operate correctly again (at least under Linux - Windows seems to often ignore Linux 'dirty disk' flag). Strange behaviour where files disapear can usually be rectified with a Windows chkdsk

Add new comment