WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: changing boot order for media server  (Read 3834 times)

Offline b1ackmai1er

  • Jr. Member
  • **
  • Posts: 95
changing boot order for media server
« on: July 08, 2011, 10:17:35 AM »
Hi Guys,

My TC machines boots of a usb key - sda1, my config files are stored on another usb key - sdb1 and all my media files are store on a external usb hard drive - sdc1.

I have added a new sata drive to my system and it is coming up as sda1 and bumping all my existing drives down one letter. This means my script and config files no longer work.

How can I force the new sata drive to be named as sdd1 so I don't have to rebuild all me scripts and config files?

Thanks

Offline gerald_clark

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 4254
Re: changing boot order for media server
« Reply #1 on: July 08, 2011, 11:47:02 AM »
That is why labels were invented.
Then because some people don't use unique labels, UUIDs.
Use one or the other in your boot options and mount commands.

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11044
Re: changing boot order for media server
« Reply #2 on: July 08, 2011, 01:32:14 PM »
You could do some udev wizardry, but it would be much better to do ^
The only barriers that can stop you are the ones you create yourself.

Offline b1ackmai1er

  • Jr. Member
  • **
  • Posts: 95
Re: changing boot order for media server
« Reply #3 on: July 09, 2011, 03:02:05 AM »
Ok, so I need to add a line to the fstab to recognise and allocate the new sata drive to /mnt/sdd1

Do I create a new fstab file with just the one line (below) in it? Will TC still scan for the other drives and add them to the fstab file?
Will TC automatically create the mount point /mnt/sdd1 ?

UUID="mysatadriveUUID" /mnt/sdd1 ext2 noauto,users,exec,relatime 0 0

I need to save and restore the fstab file but I don't normally use the backup feature in TCE and would only want the fstab file saved.

To do this should I add:

/etc/fstab to /opt/.filetool.lst
/home/* to /opt/.xfiletool.lst

Thanks kindly

Edit. I have been trying to get this to work but am stuck at the backup stage. I can't backup at shutdown because I have no backup location set. If I try to set one using the control panel tool (to /mnt/sda1/tce) then I get an error - Make sure you are using a valid backup/restore device - some errors are logged in /tmp/backup_status"
. The only error in this file says "tar: removing leading / from member names" Any ideas what I am doing wrong ?
« Last Edit: July 09, 2011, 03:22:48 AM by b1ackmai1er »

Offline gerald_clark

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 4254
Re: changing boot order for media server
« Reply #4 on: July 09, 2011, 10:04:11 AM »
Lines in /opt/.filetool.lst must NOT start with "/"
Don't try to save fstab.
Instead add to /opt/bootlocal.sh:
echo "UUID="mysatadriveUUID" /mnt/sdd1 ext2 noauto,users,exec,relatime 0 0" >> /etc/fstab

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11624
Re: changing boot order for media server
« Reply #5 on: July 09, 2011, 12:49:03 PM »
Hi b1ackmai1er
You will probably have to update your scripts and config files. I don't think what gerald_clark suggested
will work, by the time bootlocal.sh runs fstab has already been built. You can however get your scripts
to figure out the correct drives at run time. DISCLAIMER: I don't do scripts so I can't promise that my
syntax is 100% correct. If someone spots an error, please point it out.
At the beginning of the script set up a variable like this
sda1=`blkid -U UUID_for_sda1 | cut -d / -f 3`
This will in your case initialize sda1 to the string sdb1.
Now replace the remaining instances of  sda1 in your script with  "$sda1"
This will cause the script to use  sbd1  when ever it encounters  "$sda1"
Do the same for the other two drives.

Offline gerald_clark

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 4254
Re: changing boot order for media server
« Reply #6 on: July 09, 2011, 01:11:56 PM »
Of course it will work.
It appends to fstab specifically because it has already been built.
You may want to mkdir an entry in /mnt with a name of your choice, and mount to that instead of sdd1
which may not exist.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11624
Re: changing boot order for media server
« Reply #7 on: July 09, 2011, 01:16:48 PM »
H gerald_clark
His problem is that his USB drives have already been bumped up by one by the bootlocal is run.

Offline gerald_clark

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 4254
Re: changing boot order for media server
« Reply #8 on: July 09, 2011, 01:24:00 PM »
UUID does not change.
He could also use a label

mkdir /mnt/mydir
echo "UUID="mysatadriveUUID" /mnt/sdd1 ext2 noauto,users,exec,relatime 0 0" >> /etc/fstab
or
echo "LABEL=mylabel /mnt/sdd1 ext2 noauto,users,exec,relatime 0 0" >> /etc/fstab
mount -a

Problem solved

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11624
Re: changing boot order for media server
« Reply #9 on: July 09, 2011, 01:44:57 PM »
Hi gerald_clark
That solves the problem of creating a new mount point for sdd1, however, there are still four other
entries in fstab that need adjusting. The sda1 entry that has the SATA drive listed needs to be removed.
The sdb1 needs to become sda1,sdc1 needs to become sdb1, and sdd1 needs to become sdc1.
The first one would need to be unmounted and the other three remounted.
I agree UUID or label would have been the way to go right from the beginning but his problem is that
his scripts are looking for the original mount points for sda1,sdb1, and sdc1 before they got shifted
by the SATA drive. By the time bootlocal runs, that shift has already taken place.


Offline b1ackmai1er

  • Jr. Member
  • **
  • Posts: 95
Re: changing boot order for media server
« Reply #10 on: July 10, 2011, 09:21:40 AM »
Hi Guys,

Thanks for your suggestions.Still pondering which way to go. Would it be feasible to unmount all drives after boot and remount them on new mount points? Would this update the fstab?

Thanks.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11624
Re: changing boot order for media server
« Reply #11 on: July 10, 2011, 09:56:38 AM »
Hi b1ackmai1er
While it might be possible, I would strongly advise against it. You can not unmount a drive if there is a
file open on it. Even if you get that to work, somewhere down the line, you will change or update
something and it will break. What counts as an open file? Some things are obvious and some are more
subtle. Obviously any loaded applications from your tce subdirectory. More subtle includes most file
managers viewing a directory on the drive, an open terminal whose prompt is a path to that drive, and
probably others that I am not aware of. There may very well be other pitfalls as well.

Offline gerald_clark

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 4254
Re: changing boot order for media server
« Reply #12 on: July 10, 2011, 10:57:55 AM »
The answer is to fix the "broken" scripts that assumed fixed drive locations.
Label the filesystems, use the lables as mount points in /mnt, and change the script references
from partitions to labels.


Offline b1ackmai1er

  • Jr. Member
  • **
  • Posts: 95
Re: changing boot order for media server
« Reply #13 on: July 11, 2011, 04:47:21 AM »
Thanks for all your suggestions guys, I have fixed all the scripts. I guess I thought there would be some elegantly simple way of adjusting the fstab allocation order.

gerald, using your method is beyond my capability of scripting I think but does sound like the ultimate solution especially as I add and remove other drives.