How to mount hard drives automatically after booting?

Booting, installing, newbie
Message
Author
musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#16 Post by musher0 »

tmm2112 wrote:(...)

For anyone who could help, I'm trying to set up an automount of a partition on my hard
drive. I've tried scripts but they only produce a momentary mount that goes away seconds
after bootup.
Hello, tmm2112.

Strange... All suggestions presented in the posts above "stick" until you deliberately
unmount the partition(s). Maybe review your steps?

Just a thought. BFN.

musher0
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

sheldonisaac
Posts: 902
Joined: Mon 22 Jun 2009, 01:36
Location: Philadelphia, PA

#17 Post by sheldonisaac »

Some snipping was done.
tmm2112 wrote:I'm using Puppy Precise..

For anyone who could help, I'm trying to set up an automount of a partition on my hard drive. I've tried scripts but they only produce a momentary mount that goes away seconds after bootup.
I'll try a Precise to see what I can do, and get back to edit this.

===============

Sorry, didn't succeed.

I booted what I think is Precise 5.7.1 from my sda2 partition, with pfix=ram on the kernel GRUB menu line.
Made a directory /mnt/sda3
Edited /etc/rc.d/rc.local to include

mount -t vfat /dev/sda3 /mnt/sda3

Rebooted (made a savefile on the sda2 boot drive)

The mounting of sda3 did not occur after the reboot.

Don't know why; I vaguely recall that someone helped in the past with a better version of mount or probepart or blkid or ???

Hang in there; someone more knowledgeable will come and help.
Dell E6410: BusterPup, BionicPup64, Xenial, etc
Intel DQ35JOE, Dell Vostro 430
Dell Inspiron, Acer Aspire One, EeePC 1018P

tmm2112
Posts: 12
Joined: Sat 25 Aug 2012, 04:54

#18 Post by tmm2112 »

Puppus Dogfellow wrote:
tmm2112 wrote:I would like to use this startmount, but I cant find it in the pet directory.

Startmount-0.0.5
I somehow missed this post before, but I downloaded the pet, installed and
it worked! Much thanks, pupps dogfellow.

User avatar
rufwoof
Posts: 3690
Joined: Mon 24 Feb 2014, 17:47

#19 Post by rufwoof »

musher0 wrote:Hello, selvam.

Here is a little script that will do that....
Hi Musher0,

Not working for me :cry:

Clean prefix=ram boot, only mounts those partitions that have previously been mounted during the session. When I manually run

# ./rep-dans-mnt.sh

No /mnt/s[d,r]* directory seem to be missing.



Listing the contents of /mnt I see

# ls /mnt
cdrom data dvd flash floppy msdos ram1 sda1 sda4 swap zip
#

My sda2 and sdb1 partitions are left unmounted.

I believe the relevant part of the version of your code that I'm running for the above is

Code: Select all

if [ "`ls -d /mnt/s[d,r]*`" = "" ];then
	probepart | awk -F"|" '$2 ~ /ext|ntfs|vfat|iso/ { print $1 }' | awk -F"/" '{ print "mkdir -p /mnt/"$3 }' > /tmp/DIRS
	chmod ug+rwx /tmp/DIRS
	/tmp/DIRS
	echo
	echo "$NOTANYMORE"
	echo
	else
		echo
		echo "$NOTMISSING"
		echo
fi
probepart returns

# probepart
/dev/sda1|vfat|67584
/dev/sda2|ntfs|345608192
/dev/sda3|swap|4083712
/dev/sda4|ext4|40960000
/dev/sdb1|ntfs|78140096
/dev/sr0|iso9660|261056
/dev/sr1|none|2097150

(Running Slacko 5.3.3t)

User avatar
rufwoof
Posts: 3690
Joined: Mon 24 Feb 2014, 17:47

#20 Post by rufwoof »

What I personally have in mind for wanting all auto-mounted is so that I might include a HD file (script) as part of the startup.

Boot from read only CD/DVD (pfix=ram), that mounts all drives and if a file xyz.sh exists in any of the root directory of the HD partitions then run that script (extension of Startup directory contents). So a RAM boot - available 'disk' space is all of the available memory (1.5GB in my case), but with some additional automated tuning possible (optional load of load nvidia.sfs, flash.sfs etc - or not, according to whether that's set in the xyz HD script).

User avatar
rufwoof
Posts: 3690
Joined: Mon 24 Feb 2014, 17:47

#21 Post by rufwoof »

Further info :

Code: Select all

# probepart | awk -F"|" '$2 ~ /ext|ntfs|vfat|iso/ { print $1 }' | awk -F"/" '{ print "mkdir -p /mnt/"$3 }'
mkdir -p /mnt/sda1
mkdir -p /mnt/sda2
mkdir -p /mnt/sda4
mkdir -p /mnt/sdb1
mkdir -p /mnt/sr0


# ls /mnt
cdrom  data  dvd  flash  floppy  msdos  ram1  sda1  sda4  swap  zip
# 
/tmp seems to have ok to write/exec

drwxrwxrwx 10 root root 1360 2014-04-06 20:46 tmp

but there's no DIRS file in /tmp !!!


Ahh! Your code has

Code: Select all

if [ "`ls -d /mnt/s[d,r]*`" = "" ];then
	probepart | awk -F"|" '$2 ~ /ext|ntfs|vfat|iso/ { print $1 }' | awk -F"/" '{ print "mkdir -p /mnt/"$3 }' > /tmp/DIRS
	chmod ug+rwx /tmp/DIRS
	/tmp/DIRS
	echo
	echo "$NOTANYMORE"
	echo
	else
		echo
		echo "$NOTMISSING"
		echo
fi
and if I

# ls -d /mnt/s[d,r]*
/mnt/sda1 /mnt/sda2 /mnt/sda4 /mnt/sdb1 /mnt/sr0

So that part of the code isn't being executed ??? (not equal to "empty")

User avatar
8-bit
Posts: 3406
Joined: Wed 04 Apr 2007, 03:37
Location: Oregon

#22 Post by 8-bit »

If one does not ask, then they may not know.
So when I manually mount a partition, ROX pops up with a window displaying the contents of said partition.
Do the automount utilities also do this?
Or do they just mount the partitions chosen bypassing ROX displaying the contents.
In my case, I feel more secure in knowing that my partitions remain unmounted unless I mount them and protects them to an extent from snoopers when unmounted.
But this is Puppy and it is designed to give the user control as to what they want to happen.
As a for instance of control, if one is browsing the internet and gets into a situation where you think you may be under attack, you can right click on the taskbar network icon and select "disconnect from network" for a quick exit.

User avatar
Puppus Dogfellow
Posts: 1667
Joined: Tue 08 Jan 2013, 01:39
Location: nyc

#23 Post by Puppus Dogfellow »

8-bit wrote:If one does not ask, then they may not know.
So when I manually mount a partition, ROX pops up with a window displaying the contents of said partition.
Do the automount utilities also do this?

Or do they just mount the partitions chosen bypassing ROX displaying the contents.
In my case, I feel more secure in knowing that my partitions remain unmounted unless I mount them and protects them to an extent from snoopers when unmounted.
But this is Puppy and it is designed to give the user control as to what they want to happen.
As a for instance of control, if one is browsing the internet and gets into a situation where you think you may be under attack, you can right click on the taskbar network icon and select "disconnect from network" for a quick exit.
startmount doesn't, but it does give a two button (cancel, yes)
popup at boot that says it's activated and asks if you want to adjust settings. (you can also use it to automount programs).

i couldn't get musher0's script to work, but from a description i remember reading, it doesn't either.

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#24 Post by musher0 »

@rufwoof

I'll have another look at the script and get back to you.

BFN.

musher0
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

User avatar
rufwoof
Posts: 3690
Joined: Mon 24 Feb 2014, 17:47

#25 Post by rufwoof »

musher0 wrote:@rufwoof

I'll have another look at the script and get back to you.
I'm thinking it perhaps needs changing of the code in rep-dans-mnt.sh to something like

Code: Select all

probepart | cut -f1 -d"|" | sed 's/\/dev/\mkdir \/mnt/' >/tmp/createdirs

chmod a+x /tmp/createdirs
/tmp/createdirs 2>&1
rm /tmp/createdirs
probepart | awk 'BEGIN { FS = "|" } ; { print "mount -o rw -t " $2 " " $1 }' | grep -E 'vfat|ext|ntfs' | awk 'BEGIN { FS = "/" } ; { print $1 "/" $2 "/" $3 " /mnt/" $3}' >/tmp/mount
chmod a+x /tmp/mount
/tmp/mount
rm /tmp/mount
But my linux and linux scripting abilities/skills are very low

User avatar
rufwoof
Posts: 3690
Joined: Mon 24 Feb 2014, 17:47

#26 Post by rufwoof »

This is as far as I've got so far for a script that's burnt with the puppy ISO and that's stored in /root/Startup

The idea being that a fixed CD that's booted pfix=ram can be a bit more dynamic - such as perhaps loading appropriate graphics drivers for the PC the CD is being run in (I rotate between three very different types (one uses Nvidia, another uses messa) and its a pain to ram boot, set locale, install graphics drivers ...etc each time) and rather than having 3 different CD's it would be nice to use just the one for all three machines.

Code: Select all

#!/bin/bash

# if not a first time (ram) boot then ignore (exit)
[ `cat /etc/rc.d/PUPSTATE | grep PUPMODE` != "PUPMODE=5" ] && exit

# create /mnt directories (no checking, just tries to create even if exists)
probepart probepart | cut -f1 -d"|"| cut -f1 -d"|" | sed 's/\/dev/\mkdir \/mnt/' >/tmp/createdirs
chmod a+x /tmp/createdirs
/tmp/createdirs 2>&1
rm /tmp/createdirs

# mount all vfat, ext and ntfs type partitions
probepart | awk 'BEGIN { FS = "|" } ; { print "mount -o rw -t " $2 " " $1 }' | grep -E 'vfat|ext|ntfs' | awk 'BEGIN { FS = "/" } ; { print $1 "/" $2 "/" $3 " /mnt/" $3}' >/tmp/mount
chmod a+x /tmp/mount
/tmp/mount 2>&1
rm /tmp/mount

# Exec any occurrences of file "puprambo.ot" if if exists in the root directory of any of the mounted partitions
probepart | cut -f1 -d"|" | sed 's/dev/mnt/' | awk '{print $1 "/\puprambo.ot" }' >/tmp/run
chmod a+x /tmp/run
/tmp/run
rm /tmp/run 

User avatar
rufwoof
Posts: 3690
Joined: Mon 24 Feb 2014, 17:47

#27 Post by rufwoof »

Created a boot CD/DVD with a version of the earlier code I posted in a script in /root/Starup folder and then created another script on my HD containing the following code, and it works well.

CD boots, puppy asks for locale etc data, but minimise that initially, and all of the nvidia, firefox, flash SFS's, a flash patch and abiword PET's all start loading. Just click the prompts to OK etc as they pop up.

Then maximise the locale window again, adjust as required, click the xorgwizard option also, and it drops to terminal mode, accept the PROBE choice, set the resolution level and xwin restarts OK.

The code could be extended to do other tasks as desired, maybe apply a patch or copy in directories to /root as desired etc.

Sort of DIY save/load file in some respects.

I'm increasingly using ram boot more often now. Green space box/control in the taskbar showing how much out of 1.7GB is remaining (not sure why it shows 1.7GB when I only have 1.5GB of RAM, but guess that's perhaps because I've also a 2GB swap partition, or maybe due to things being compressed ???).

Code: Select all

#!/bin/bash
#
# I've added a script to the Puppy boot CD's Startup
# directory that calls this script that can be on
# any of the root directory of a partition
# Useful for loading things semi automatically
# when running pfix=ram
# Only called when running pfix=ram
# but I include another test here just in case

# if not second time around (locale been configured) then load sfs's 
# otherwise 2nd time around asks if you want to unload them
# I only check for the first one in order to determine if continue or not
[ `cat /etc/rc.d/PUPSTATE | grep PUPMODE` != "PUPMODE=5" ] && exit
var=`cat /etc/rc.d/BOOTCONFIG | grep -E "EXTRA" | grep -E "nvidia"`
if [ -n "$var" ]; then
    exit
fi

# I did try backgrounding so simultaneous loading, but didn't work well
sfs_load -q /mnt/sda4/nvidia-glx-sdl-295.53-slacko.sfs
sfs_load /mnt/sda4/firefox-28.0.sfs
petget /mnt/sda4/533t-SFSs/SFSs/abiword-2.8.6-gnumeric-1.10.17-goffice-0.8.17-dpup.pet
sfs_load /mnt/sda4/flash10_.sfs 
# flash10 patch 
/mnt/sda4/fix-flash.sh

# Could perhaps even grap things via the net
# but would need to have set up network first 
#
#wget -c http://URL/package.pet
#pet2tgz package.pet
#tar -xf package.tar.gz /
#/.pinstall.sh
#rm /.pinstall.sh
Mostly I don't touch/use folders/directories under /root - other than for configuration changes. All the things I do use are stored on the HD, so generally from session to session everything under /root stays much the same for me.

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#28 Post by musher0 »

Hi, rufwoof.

Try this. It works with the BusyBox blkid present in all Puppies. I realized my previous
version needed the real blkid, not the BusyBox contraption.

Code: Select all

#!/bin/sh
# monter5.sh
# for rufwoof
# This one works with the BusyBox blkid (default in Puppies).
####
for i in `blkid | awk -F":" '$2 !~ /swap|squash|ntfs/ { print $1 }' | cut -d'/' -f3`;do mkdir -p /mnt/$i;mount /dev/$i /mnt/$i;done
for i in `blkid | awk -F":" '$2 ~ /ntfs/ { print $1 }' | cut -d'/' -f3`;do mkdir -p /mnt/$i;ntfs-3g /dev/$i /mnt/$i;done
rox /mnt
First pass opens all vfat, ext? and reiserfs partitions. (All Linux file systems recognized by Puppy)
Second pass opens ntfs partitions. (Needs ntfs-3g utility to be present in the Puppy)

I tried it and it worked fine on a fresh (no savefile) Triton 5.7.
(French variant of Puppy Precise 5.7.1, by petihar.)

Tell me how it goes? Thanks.

BFN.

musher0
Attachments
monter5.sh.zip
(379 Bytes) Downloaded 117 times
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

User avatar
rufwoof
Posts: 3690
Joined: Mon 24 Feb 2014, 17:47

#29 Post by rufwoof »

Sorry musher - I've only just seen your post.

Works ok provided nothing already mounted in which case it mounts only some (and then brings up ROX). For a newly booted then that should be OK. THX.

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#30 Post by musher0 »

My pleasure!
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

User avatar
Puppus Dogfellow
Posts: 1667
Joined: Tue 08 Jan 2013, 01:39
Location: nyc

#31 Post by Puppus Dogfellow »

Puppus Dogfellow wrote:
[...]

i couldn't get musher0's script to work, but from a description i remember reading, it doesn't either.
after a few x-restarts and reboots, it seems the script works as it's supposed to--the machine i'm using is f2fs incompatible, so i'm guessing that's why those partitions haven't been mounted--the drives i added after installing startmount are recognized and mounted, a little message pops up to say it's been done.

going to up/mirror version .5, but .4a seems to work fine...

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#32 Post by musher0 »

Hi, Puppus.

Just a note relative to your post above.

I excluded f2fs on purpose for now, since I don't enough about the format.
I did try it once on an SD card, but with so-so success. Also, older Puppies
are not equipped to recognize the format, so it's difficult to evaluate how to
include the format in the script.

I'll add it in due time, when I'm more familiar with it. BFN.

musher0
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

User avatar
Puppus Dogfellow
Posts: 1667
Joined: Tue 08 Jan 2013, 01:39
Location: nyc

#33 Post by Puppus Dogfellow »

musher0 wrote:Hi, Puppus.

Just a note relative to your post above.

I excluded f2fs on purpose for now, since I don't enough about the format.
I did try it once on an SD card, but with so-so success. Also, older Puppies
are not equipped to recognize the format, so it's difficult to evaluate how to
include the format in the script.

I'll add it in due time, when I'm more familiar with it. BFN.

musher0


cool. it's already an elegant little solution to the problem.


i wonder if the older puppies can be patched to use f2fs, but if you already have an install (the partitions it's not reading are the second partitions of two cards formatted 1/99 vfat/f2fs for use as future installations), it's probably not needed. still, if you're intent on using an old pup for flash media, it may be worth looking into. having to reformat all your stuff to use it for storage may be more work than it's worth.

saves to the media really seem faster with it imho.

and thanks again for the program(s).

Post Reply