LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-16-2015, 11:04 PM   #1
Nhatorama
LQ Newbie
 
Registered: Jan 2015
Distribution: Debian 3.2.0-4-amd64
Posts: 3

Rep: Reputation: Disabled
Question ?? How to auto mount logical volume before transmission-daemon starts at start up


I have been using an old computer to download my torrents and this has been my usual routine:

1. Press the power button.
2. Connect to the computer through Putty
3. Log in
4. Gain su privileges

Startup Commands:
Code:
/etc/init.d/transmission-daemon stop
apt-get update
mount -t ext4 /dev/vgTransmission/lvTransmission /mnt/transmissionVault
/etc/init.d/transmission-daemon start
Shutdown Commands:
Code:
/etc/init.d/transmission-daemon stop
umount /dev/vgTransmission/lvTransmission
shutdown -h now
I was wondering if there is a way to configure a computer to automatically mount a logical volume “before” the transmission-daemon starts at boot up (note my first Startup Command).

I think the instructions here are related to what I want to do, but I want to get some advice before I attempt to do anything dangerous:
http://tille.garrels.be/training/tld...#sect_04_02_04


My perfect scenario would be:

Startup Routine:
1. Send WakeOnLan magic packet to computer to turn it on.
2. Computer boots up, mounts the transmissionVault logical volume
3. Wait 10 seconds to ensure that the logical volume has finished mounting
4. Start transmission-daemon

Shutdown Routine:
Send WakeOnLan magic packet to turn off computer, i.e.: Execute “shutdown -h now”
The shutdown command should include:
1. Stop transmission-daemon
2. Wait 10 seconds to ensure that transmission-daemon has finished shutting down
3. Umount transmissionVault logical volume




Recently the Ethernet port of my transmission box has stopped working, so I went ahead and swapped the motherboard with another old motherboard, added a few hard drives, installed a fresh copy of Debian, and re-created the LVM logical volume for transmissionVault. I pretty much have a fairly stock system running at the moment.

Running a headless 3.2.0-4-amd64
 
Old 01-17-2015, 07:04 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
For startup:
- mounting /mnt/transmissionVault can be done automagically via /etc/fstab (no reason why you shouldn't),
- ensure /etc/init.d/transmission-daemon doesn't start on boot,
- create a shell script that performs 'apt-get update; /etc/init.d/transmission-daemon start',
- add script in /etc/crontab as a "@reboot" job.

For shutdown:
- umounting /mnt/transmissionVault can be done automagically via /etc/fstab,
- stopping /etc/init.d/transmission-daemon can be done automagically as well, just depends on how you configured update-rc.d / insserv / whatever else Debian uses.
 
Old 01-17-2015, 09:00 PM   #3
Nhatorama
LQ Newbie
 
Registered: Jan 2015
Distribution: Debian 3.2.0-4-amd64
Posts: 3

Original Poster
Rep: Reputation: Disabled
Lightbulb

Hi unSpawn, thank you for answering. Here's what I've put together so far. I haven't executed any of these on the computer yet.

Output of fdisk -l:
Code:
Disk /dev/mapper/vgTransmission-lvTransmission: 2454.4 GB, 2454376677376 bytes
255 heads, 63 sectors/track, 298394 cylinders, total 4793704448 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/mapper/vgTransmission-lvTransmission doesn't contain a valid partition table
Output of “df -h”:
Code:
/dev/mapper/vgTransmission-lvTransmission               2.2T  201M  2.1T   1% /mnt/transmissionVault
For startup:
- mounting /mnt/transmissionVault can be done automagically via /etc/fstab (no reason why you shouldn't),

Output of “vi fstab”:
Code:
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sda1 during installation
UUID=38c23532-aaa8-4ed7-b34c-9ac4778b3f00 /               ext4    errors=remount-ro 0       1
# swap was on /dev/sda5 during installation
UUID=854c3938-5cf5-458e-a767-881d5f8919f6 none            swap    sw              0       0
/dev/sr0        /media/cdrom0   udf,iso9660 user,noauto     0       0

#ADD THIS
/dev/vgTransmission/lvTransmission /mnt/transmissionVault ext4 defaults 0 1
- ensure /etc/init.d/transmission-daemon doesn't start on boot,
Code:
update-rc.d -f transmission-daemon remove
- create a shell script that performs 'apt-get update; /etc/init.d/transmission-daemon start',
Script:
Create the script inside “bin” folder:
Code:
vi startTransmission
Add the following in the script and save it:
Code:
# Script to update the system and start Transmission
apt-get update
/etc/init.d/transmission-daemon start

exit 0
Make the script executable:
Code:
chmod 755 /etc/init.d/startTransmission
Make the script execute at startup:
Code:
update-rc.d startTransmission defaults
- add script in /etc/crontab as a "@reboot" job.
I don't know how to do this, but this is what my crontab shows.

Output of “vi crontab”:
Code:
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# m h dom mon dow user  command
17 *    * * *   root    cd / && run-parts --report /etc/cron.hourly
25 6    * * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6    * * 7   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6    1 * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
#
For shutdown:
- umounting /mnt/transmissionVault can be done automagically via /etc/fstab,

Does this cover both startup and shutdown?
Code:
update-rc.d startTransmission defaults
- stopping /etc/init.d/transmission-daemon can be done automagically as well, just depends on how you configured update-rc.d / insserv / whatever else Debian uses.
I think I have to modify this, I don't know what to modify though.
Code:
/dev/vgTransmission/lvTransmission /mnt/transmissionVault ext4 defaults 0 1
 
Old 01-29-2015, 06:55 PM   #4
Nhatorama
LQ Newbie
 
Registered: Jan 2015
Distribution: Debian 3.2.0-4-amd64
Posts: 3

Original Poster
Rep: Reputation: Disabled
Can someone check my previous post for errors?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot Mount Logical Volume After Name Change PasBern Linux - Newbie 3 06-09-2014 05:04 AM
LVM Mount Physical Volume/Logical Volume without a working Volume Group mpivintis Linux - Newbie 10 01-11-2014 07:02 AM
mount point of logical volume bilux Linux - Virtualization and Cloud 4 08-11-2011 10:46 AM
external mount of a logical volume cygnus-x1 Linux - General 5 07-27-2006 10:56 AM
In fc3 Can I umount a Logical Volume which is mounted auto in fstab? TomF Linux - Newbie 2 12-16-2004 01:40 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:33 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration