WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Using mount in bootlocal.sh  (Read 9040 times)

Offline suxi

  • Newbie
  • *
  • Posts: 25
Re: Using mount in bootlocal.sh
« Reply #15 on: September 20, 2012, 11:12:28 AM »
Hey Rich

Wow, that did it. I actually changed your script a bit so that it mounts sdb1 and sdb2 after it found the sdb1 entry in the fstab.

Now where the raid is up and running I would also like to add something like tw_cli in order to check the status with another script. Would this also be possibe with TC and could you maybe point me in the right direction?

Again, thank you all very much for your help. This is a great little community!

Best wishes

suxi

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11178
Re: Using mount in bootlocal.sh
« Reply #16 on: September 20, 2012, 12:24:43 PM »
Hi suxi
Quote
Wow, that did it. I actually changed your script a bit so that it mounts sdb1 and sdb2 after it found the sdb1 entry in the fstab.
You can do that, but suppose the unthinkable happens and sdb1 is not recognized by the system. The script
will block forever and nothing gets mounted. Or suppose the script happens to sample fstab 1 microsecond after
it adds the sdb1 entry and sdb2 has not yet been detected, sdb1 will get mounted but sdb2 might not if the second
mount command executes before sdb2 shows up.
Using two scripts running backgrounded as I showed you ensures that neither drive can block the other from
being detected and avoids a slim but possible race condition.
Quote
.... something like tw_cli in order to check the status ....
I would suggest Googling for source or executable files in tar format and start a new thread if you need help with that.

Offline suxi

  • Newbie
  • *
  • Posts: 25
Re: Using mount in bootlocal.sh
« Reply #17 on: September 20, 2012, 01:21:16 PM »
Quote
... and avoids a slim but possible race condition.
Ok, that sounds very feasable, I'll stick to your suggested solution.

Offline suxi

  • Newbie
  • *
  • Posts: 25
Re: Using mount in bootlocal.sh
« Reply #18 on: September 21, 2012, 01:42:42 AM »
Hey guys!

A new challenge came up: When I connect an USB drive to the box, at boot TC registeres the USB drive as SDB and the raid controller as SDC, while without the usb drive the raid is SDB. Is there a way to reserve SDB for the raid no matter what?

Again, thanks for your help. Have a great day!

suxi

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14516
Re: Using mount in bootlocal.sh
« Reply #19 on: September 21, 2012, 01:47:35 AM »
there should be a way to use uuid to get around this?

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11178
Re: Using mount in bootlocal.sh
« Reply #20 on: September 21, 2012, 07:04:45 AM »
Hi suxi
OK, try this:
mountsdb1.sh
Code: [Select]
#!/bin/sh
RAID1UUID="77f3e5df-806f-480c-b6cc-905cb3132753"
RAID1Dev=""

while [ -z "$RAID1Dev" ]
do
  sleep 1
  RAID1Dev=`blkid -U $RAID1UUID`
done

until cat /etc/fstab | grep $RAID1Dev
do
  sleep 1
done

mount $RAID1Dev
mkdir /mnt/RAID1
ln -sf /mnt/`echo $RAID1Dev | cut -c6-` /mnt/RAID1
Boot up without the USB drive plugged in so your RAID drives are found. Execute:
Code: [Select]
blkid /dev/sdb1Copy the value to the right of  UUID=  and use it to replace the value to the right of  RAID1UUID=  in the script.
Save and reboot to make sure it works. If it worked, you should be able to see the drive at /mnt/sdb1 and /mnt/RAID1.
If it worked, make another script for sdb2, change ALL occurrences of RAID1 to RAID2. Reboot with a USB drive
plugged in. Your /mnt directory should have RAID1 and RAID2 entries in it.

Offline suxi

  • Newbie
  • *
  • Posts: 25
Re: Using mount in bootlocal.sh
« Reply #21 on: September 21, 2012, 08:52:25 AM »
Thank you so much, you all are my new heros!

I'll try this over the weekend. Have a great one!

suxi

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11178
Re: Using mount in bootlocal.sh
« Reply #22 on: September 21, 2012, 09:15:45 AM »
Hi suxi
You are welcome. Let us know if it works. If it works, access the drives through /mnt/RAID1 and /mnt/RAID2 as
these points will never change on you.

Offline suxi

  • Newbie
  • *
  • Posts: 25
Re: Using mount in bootlocal.sh
« Reply #23 on: September 21, 2012, 09:43:07 AM »
It sort of worked. Now I have a sdb1 folder inside the raid1 folder, which means I'll run into problems with my samba shares. I need the drive's contents to be located just below the raid1 directory. Does this make sense?

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11178
Re: Using mount in bootlocal.sh
« Reply #24 on: September 21, 2012, 09:53:28 AM »
Hi suxi
One more time:
Code: [Select]
#!/bin/sh
RAID1UUID="77f3e5df-806f-480c-b6cc-905cb3132753"
RAID1Dev=""

while [ -z "$RAID1Dev" ]
do
  sleep 1
  RAID1Dev=`blkid -U $RAID1UUID`
done

until cat /etc/fstab | grep $RAID1Dev
do
  sleep 1
done

sudo mkdir /mnt/RAID1
sudo mount $RAID1Dev /mnt/RAID1
Now the drive will be mounted directly to /mnt/RAID1

Offline suxi

  • Newbie
  • *
  • Posts: 25
Re: Using mount in bootlocal.sh
« Reply #25 on: September 21, 2012, 03:56:18 PM »
Hi Rich, that's very strange, I don't get your last solution to work. Nothing gets mounted and if I start the mount script after boot manually, I get the following error:

mount: mounting /dev/sdc1 on /mnt/raid1 failed: Invalid argument

What was your idea behind your first script and why did that work? What a bummer and thank you for your patience.

suxi

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11178
Re: Using mount in bootlocal.sh
« Reply #26 on: September 21, 2012, 05:57:18 PM »
Hi suxi
I'm not sure why that failed. If you execute:
Code: [Select]
ls -l /mntwhat does it show?

Offline suxi

  • Newbie
  • *
  • Posts: 25
Re: Using mount in bootlocal.sh
« Reply #27 on: September 22, 2012, 01:12:20 AM »
Hi Rich, this comes up:

Code: [Select]
tc@suxi:~$ ls -l /mnt
total 5
drwxr-xr-x    2 root     root            40 Sep 22 00:50 raid1/
drwxr-xr-x    2 root     root            40 Sep 22 00:50 raid2/
drwxr-xr-x    4 root     root          1024 Sep 14 18:40 sda1/
drwxrwxrwx    4 root     root          4096 Sep 19 12:37 sda3/
drwxr-xr-x    2 root     root            40 Sep 22 00:49 sdb1/
drwxr-xr-x    2 root     root            40 Sep 22 00:50 sdc1/
drwxr-xr-x    2 root     root            40 Sep 22 00:50 sdc2/
tc@suxi:~$

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11178
Re: Using mount in bootlocal.sh
« Reply #28 on: September 22, 2012, 07:17:39 AM »
Hi suxi
Make sure you have:
Code: [Select]
ntfsprogs.tcz
fuse.tcz
installed. Then change:
Code: [Select]
sudo mount $RAID1Dev /mnt/RAID1 to
Code: [Select]
sudo mount.ntfs-fuse $RAID1Dev /mnt/RAID1 and see if that works.

I see you changed RAID1 to lower case, which is OK. Just remember that Linux is case sensitive, so if you changed
it in the mkdir line, it has to match in the mount line.

Offline suxi

  • Newbie
  • *
  • Posts: 25
Re: Using mount in bootlocal.sh
« Reply #29 on: September 22, 2012, 10:15:18 AM »
Ok, thank you. This really seems to get complicated.

I changed the scripts, rebooted and the second raid partition (named godzilla2, I called the mount points by their device labels) got mounted but not the first one.

I then executed the mount script of the first partition manually and received the following error:

Code: [Select]
root@suxi:~# /opt/mount_godzilla1.sh
/dev/sdc1       /mnt/sdc1       ntfs     noauto,users,exec,ro,umask=000 0 0 # Added by TC
mkdir: can't create directory '/mnt/godzilla1': File exists
Volume is scheduled for check.
Please boot into Windows TWICE, or use the 'force' option.
NOTE: If you had not scheduled check and last time accessed this volume
using ntfsmount and shutdown system properly, then init scripts in your
distribution are broken. Please report to your distribution developers
(NOT to us!) that init scripts kill ntfsmount or mount.ntfs-fuse during
shutdown instead of proper umount.
Mount failed.
root@suxi:~#

This worries me, because I did manually mount and work with the drives before, whithout getting any errors.

Thanks a lot for your help

suxi

EDIT: I have found a working solution: using mount with the -t option

I am now using the following mount command in the script: sudo mount -t ntfs $RAIDDev1 /mnt/godzilla1

Rich, I would love to learn what your thoughts were on recommending ntfsprogs.tcz and
fuse.tcz and what the differences are between that and  mount and mount -t

Thank you!
« Last Edit: September 22, 2012, 11:07:23 AM by suxi »