Refracta Development, Scripts, etc.
Thu Dec 11, 2014 11:43 am
Hi there,
since I installed on a desktop with ssd, I've moved my /var over to the rotating disk so that the ssd doesn't get all the file writes /var makes (I'm a bit fussy I guess).
Could an option be added in the installer to select where /var goes? If not it means editing fstab and rsync'ing the files in /var out to other partition after the install.
maybe there's a way to do it already??
thanks
Thu Dec 11, 2014 12:21 pm
Wow. Not a bad idea. I don't relish the thought of adding that in - too much code would need to be changed, and I hate messing with it when it's working. An easy way to do it would be to write a post-install script that makes the changes. Especially easy if you know ahead of time where you're moving it to.
The post-install scripts go in /usr/lib/refractainstaller/post-install/, and they run after grub is installed and right before /target gets unmounted.
Something like this might work.
- Code:
new-target-var="/dev/the-partition-on-the-spinning-disk"
mount $new-target-var /mnt
rsync -av /target/var/ /mnt/
echo <appropriate line> >> /target/ e t c /fstab # modified for stupid forum rules
rm - r f /target/var/*
umount /mnt
Is this something you're going to do often, and will the final location of /var be different in every case? If so, it wouldn't be too hard to make it ask you which partition to use. Note that this assumes the partition is already formatted. You can do it at the beginning of the installer when you run the partition editor.
Thu Dec 11, 2014 1:08 pm
that looks like a good way to do it - with a post script
new-target-var="/dev/`yad --text='Enter the correct disk name for the \/var partition, e.g. sda6' --form --field=:TXT --undecorated --width=400 --height=200`"
then
echo "UUID=`blkid -o value -s UUID $new-target-var` /var ext3 defaults,noatime 0 2" >>
not yet tested it.
I wouldn't be doing this often, no, only for installing my own, desktop and laptop (if with ssd).
Thu Dec 11, 2014 1:26 pm
It would be ideal to have a confirm dialogue to go before the script...
do you wish to install /var on another partition?
if value returned is 0 (yes) then goes ahead with the script, if 1 (no) then the var script is not run
if the disk name dialogue is left blank (ie changed mind and cancels moving /var) will /dev mount on /mnt? or will nothing happen?
but mounting /dev wouldn't harm as /target will be umounted after that - and blkid will return nothing but add a strange line to fstab (with no UUID).
prob need a cancel button as best way to cancel it and not move /var (safer).
Thu Dec 11, 2014 1:33 pm
You'll get two buttons unless you define a single button (or three or more)
A test to make sure the var is not empty would also be good. Instead of entering sda6, you'd have to enter /dev/sda6, which is in line with the way partitions are entered in the cli installer.
- Code:
if [[ -z $new_target_var ]] ; then
exit 0
fi
Without that test, mount would complain about a missing argument.
To get the tabs into fstab...
- Code:
echo -e "UUID=`blkid -o value -s UUID $new-target-var`\t /var\text3\tdefaults,noatime\t0\t2" >>
I just tested the dialog box on the command line. Two things: the value is followed by a pipe that would need to be stripped out, and if you hit ENTER instead of clicking on OK, then there's also "\n" added to the output. If you're ambitious, you could lift out the partition selection code from the script and modify it to fit this case. If I get a little bit more ambitious (and have the time) you'll get a simple script with a variable or two in the head. If you use the expert install option, you'll be shown the names of the pre- and post-install scripts in the options selection window, so you have a chance to disable all the post-install scripts or make that one not executable or move it.
A second variable could be added - the directory you want to move to another partition. In case someone wants to move /usr or other.
Thu Dec 11, 2014 2:28 pm
well I thought /dev/ was in the script just needed to input "sdaX" into yad
so the test if...fi comes after the parameter new-target-var line to exit out if the yad dialogue is returned empty?
fstab tabs, yes, needed
pipe at end sorted with
- Code:
new-target-var="/dev/`yad --text='Enter the correct disk name for the \/var partition, e.g. sda6' --form --field=:TXT --undecorated --width=400 --height=200 --separator=''`"
selecting pre/post scripts would be v good
selecting file system to move - sounds v good - some might opt to move a sub dir of /var or /usr.
Thu Dec 11, 2014 2:33 pm
but script will need to run x times for x dir's to be moved,
a question box, Do you need to move another file system? to run script again with file sys selection using yad
Thu Dec 11, 2014 2:44 pm
oops, I'm not thinking!
its entry we need with yad not form
- Code:
new-target-var="/dev/`yad --text='Enter the correct disk name for the \/var partition, e.g. sda6' --entry --undecorated --width=400 --height=200`"
then hitting Enter is fine
and no pipe problem
Thu Dec 11, 2014 3:26 pm
Here ya go...
changed some var names and the test. You can plug in yad if you want, or just fill in the vars in the script.
Use blkid -c /dev/null... in case the partition was just formatted, so you get the right uuid.
https://gist.github.com/fsmithred/931b0ccf0964a6fde2d9
Thu Dec 11, 2014 3:55 pm
One more piece -
Put all that stuff in a function. Make a second function that asks "Do it again?", and that either calls the first function again or exits.
do_stuff () {
<select partition and mountpoint, mount, copy, echo, unmount, delete>
}
ask_again () {
if yes; then
do_stuff
if no; then
exit 0
For the test that looks for empty variables, instead of exiting, run ask_again. Optional: turn the echo into a warning text and include $warning_text in the text of the ask_again dialog window.
warning_text="Error: Empty variable. Nothing was done. Want to try again?"
and then yad --text="${warning_text}\nClick OK to move another dir or Cancel to exit."
Powered by phpBB © phpBB Group.
phpBB Mobile / SEO by Artodia.