Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Tue 22 Jul 2014, 07:24
All times are UTC - 4
 Forum index » House Training » Users ( For the regulars )
How to find the format of a not mounted drive? (Solved)
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [10 Posts]  
Author Message
der-schutzhund

Joined: 26 Nov 2007
Posts: 781
Location: Blomberg / Germany

PostPosted: Sun 03 Mar 2013, 16:00    Post subject:  How to find the format of a not mounted drive? (Solved)  

Hi,

i want to mount all drives automatically to mount them in a script.
Do you now how a script can test the format?

With this script i can mount all drives but the ntfs drives are then read only!

Code:
!/bin/bash -a
# Sort out swap and mounted partitions
blkid  | egrep '(hd|sd)' | egrep -v "/dev/loop*" | egrep -v "swap" | cut -f 1 -d ':' | sed 's/\/dev\///'>/tmp/list_of_drives
for drive in  `cat /tmp/list_of_drives` ; do
   mkdir -p /mnt/$drive
   mount /dev/$drive /mnt/$drive
   echo $drive
done
exit 0


With this i can mount a ntfs but I do not know if it's a ntfs drive or not!

Code:
   mount -t ntfs /dev/$drive /mnt/$drive


The solution: --------------------------------------
Code:
blkid  | egrep '(hd|sd)' | egrep -v "/dev/loop*" | egrep -v "swap" | cut -f 1 -d ':' | sed 's/\/dev\///'>/tmp/list_of_drives
for drive in  `cat /tmp/list_of_drives` ; do
   mkdir -p /mnt/$drive
   if [ "`blkid /dev/$drive | grep -o "TYPE=.*" | cut -f2 -d '"'`" = "ntfs" ]; then
     mount -t ntfs /dev/$drive /mnt/$drive
   else
     mount /dev/$drive /mnt/$drive
   fi
   echo $drive
done 


Special thangs to SFR !

Greetings

Wolfgang

Last edited by der-schutzhund on Mon 04 Mar 2013, 11:27; edited 1 time in total
Back to top
View user's profile Send private message 
musher0


Joined: 04 Jan 2009
Posts: 4226
Location: Gatineau (Qc), Canada

PostPosted: Sun 03 Mar 2013, 23:05    Post subject:  

I don't know the reason, and I'm no great specialist, but I believe you need an utility or a group of utilties called "ntfs-3g" to deal with ntfs disk format from a Linux distro.

Best regards.

musher0

_________________
"Logical entities must not be multiplied needlessly." / "Il ne faut pas multiplier les êtres logiques inutilement." (Ockham)
Back to top
View user's profile Send private message Visit poster's website 
musher0


Joined: 04 Jan 2009
Posts: 4226
Location: Gatineau (Qc), Canada

PostPosted: Mon 08 Jul 2013, 14:10    Post subject:  

Incidentally, here's what I did to/with it!

I use it to mount everything. Thanks, guys.

musher0

~~~~~~~~~~~~~~~

Code:
#!/bin/bash -a
# $MBINS/mount-all-drives.sh
# Sort out swap and mounted partitions
# Auteurs : der-schutzhund, avec l'aide de SFR (D-S/SFR)
# Source : http://murga-linux.com/puppy/viewtopic.php?t=84759, 2013-03-04, 10 h 47.
####
blkid  | egrep '(hd|sd)' | egrep -v "/dev/loop*" | egrep -v "swap" | cut -f 1 -d ':' | sed 's/\/dev\///'>/tmp/list_of_drives
 for drive in  `cat /tmp/list_of_drives` ; do
    mkdir -p /mnt/$drive
    if [ "`blkid /dev/$drive | grep -o "TYPE=.*" | cut -f2 -d '"'`" = "ntfs" ]; then
      mount -t ntfs /dev/$drive /mnt/$drive >/dev/null 2>&1
    else
      mount /dev/$drive /mnt/$drive >/dev/null 2>&1
    fi
    echo $drive
 done 
mount-all-drives.sh.zip
Description  Goes in ~/my-applications/bin
zip

 Download 
Filename  mount-all-drives.sh.zip 
Filesize  635 Bytes 
Downloaded  113 Time(s) 

_________________
"Logical entities must not be multiplied needlessly." / "Il ne faut pas multiplier les êtres logiques inutilement." (Ockham)

Last edited by musher0 on Wed 10 Jul 2013, 01:04; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website 
Karl Godt


Joined: 20 Jun 2010
Posts: 3953
Location: Kiel,Germany

PostPosted: Mon 08 Jul 2013, 21:42    Post subject:  

Code:
if [ "`blkid /dev/$drive | grep -o "TYPE=.*" | cut -f2 -d '"'`" = "ntfs" ]; then

can give errors in case of a pre -non-actual format formatted partition .
In such a case blkid might say something like this :
Code:
 /dev/sdb1: UUID="4CC6405D47D90582" SEC_TYPE="vfat" TYPE="ntfs"

Therefore it is needed that there is a space before TYPE in the grep string :
Code:
if [ "`blkid /dev/$drive | grep -o " TYPE=.*" | cut -f2 -d '"'`" = "ntfs" ]; then
Back to top
View user's profile Send private message Visit poster's website 
musher0


Joined: 04 Jan 2009
Posts: 4226
Location: Gatineau (Qc), Canada

PostPosted: Wed 10 Jul 2013, 01:06    Post subject:  

Thanks, Karl.

I'll keep your edit in mind if something goes wrong. (It hasn't yet, and I use this script at every launch.)

BFN.

musher0

_________________
"Logical entities must not be multiplied needlessly." / "Il ne faut pas multiplier les êtres logiques inutilement." (Ockham)
Back to top
View user's profile Send private message Visit poster's website 
musher0


Joined: 04 Jan 2009
Posts: 4226
Location: Gatineau (Qc), Canada

PostPosted: Mon 22 Jul 2013, 01:18    Post subject:  

Hello, all.

Here is an edit to
    o - include utf-8 reading vfat drives.
    o - Also removed the display of the list of drives, which clogged xerrs.log.
    o - Finally did away with the sed call: another "cut" was sufficient.

Credits are mentioned within the script.

BFN.

musher0

Code:
#!/bin/sh
# $MBINS/mount-all-drives2.sh
# Modif. par / by musher0, 21 juillet 2013
# de / of
# $MBINS/mount-all-drives.sh
# Sort out swap and mounted partitions
# Par / by  : der-schutzhund, avec l'aide de SFR (D-S/SFR)
# Source : http://murga-linux.com/puppy/viewtopic.php?t=84759, 2013-03-04, 10 h 47.
####
blkid  | egrep '(hd|sd)' | egrep -v "/dev/loop*" | egrep -v "swap" | cut -f 1 -d ':' | cut -d '/' -f 3 > /tmp/list_of_drives
# orig. : sed 's/\/dev\///'>/tmp/list_of_drives # modif. par musher0
 for drive in  `cat /tmp/list_of_drives` ; do
    mkdir -p /mnt/$drive
# modification par musher0
   A="`blkid /dev/$drive | grep -o "TYPE=.*" | cut -f2 -d '"'`"
    case $A in
   ntfs) mount -t ntfs /dev/$drive /mnt/$drive >/dev/null 2>&1 ;;
   vfat) mount -t vfat -o iocharset=utf8,codepage=850,shortname=mixed,quiet /dev/$drive /mnt/$drive >/dev/null 2>&1 ;;
# Merci à / Thanks to Médor, http://murga-linux.com/puppy/viewtopic.php?p=712828&sort=lastpost#712828
   *) mount /dev/$drive /mnt/$drive >/dev/null 2>&1 ;;
    esac
#    echo $drive # Pas besoin, encombre xerrs.log. / Not needed, clogs xerrs.log.
 done 

_________________
"Logical entities must not be multiplied needlessly." / "Il ne faut pas multiplier les êtres logiques inutilement." (Ockham)
Back to top
View user's profile Send private message Visit poster's website 
ASRI éducation


Joined: 09 May 2009
Posts: 2335
Location: France

PostPosted: Mon 22 Jul 2013, 05:15    Post subject: Re: How to find the format of a not mounted drive? (Solved)  

der-schutzhund wrote:
i want to mount all drives automatically to mount them in a script.

Hello,
Pmsd (Puppy mount storage devices) could be a solution.
http://murga-linux.com/puppy/viewtopic.php?t=87434
Cordialement,
Back to top
View user's profile Send private message Visit poster's website 
RetroTechGuy


Joined: 15 Dec 2009
Posts: 2666
Location: USA

PostPosted: Mon 22 Jul 2013, 13:20    Post subject:  

musher0 wrote:
I don't know the reason, and I'm no great specialist, but I believe you need an utility or a group of utilties called "ntfs-3g" to deal with ntfs disk format from a Linux distro.

Best regards.

musher0


The other "type" may mount it, but it might mount read-only.

_________________
Add swapfile
Back to top
View user's profile Send private message 
musher0


Joined: 04 Jan 2009
Posts: 4226
Location: Gatineau (Qc), Canada

PostPosted: Mon 09 Dec 2013, 21:21    Post subject:  

Hello, all.

I'd like to share a discovery I made this week-end:
with help from awk, we mount all ext* partitions in 198 bytes!

BFN.

musher0
MonterPartitions.zip
Description  Unzip in ~/my-applications/bin, make executable and run.
zip

 Download 
Filename  MonterPartitions.zip 
Filesize  507 Bytes 
Downloaded  75 Time(s) 

_________________
"Logical entities must not be multiplied needlessly." / "Il ne faut pas multiplier les êtres logiques inutilement." (Ockham)
Back to top
View user's profile Send private message Visit poster's website 
musher0


Joined: 04 Jan 2009
Posts: 4226
Location: Gatineau (Qc), Canada

PostPosted: Fri 13 Dec 2013, 18:02    Post subject:  

Hello again, puppyists!

This one is even more compact, thanks to awk.

TWYL.

musher0
MonterPartitions.zip
Description 
zip

 Download 
Filename  MonterPartitions.zip 
Filesize  453 Bytes 
Downloaded  67 Time(s) 

_________________
"Logical entities must not be multiplied needlessly." / "Il ne faut pas multiplier les êtres logiques inutilement." (Ockham)
Back to top
View user's profile Send private message Visit poster's website 
Display posts from previous:   Sort by:   
Page 1 of 1 [10 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » House Training » Users ( For the regulars )
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0808s ][ Queries: 12 (0.0083s) ][ GZIP on ]