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 Fri 31 Oct 2014, 05:14
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 Posts_count  
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

Edited_time_total
Back to top
View user's profile Send_private_message 
musher0


Joined: 04 Jan 2009
Posts: 4278
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_website 
musher0


Joined: 04 Jan 2009
Posts: 4278
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  131 Time(s) 

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

Edited_time_total
Back to top
View user's profile Send_private_message Visit_website 
Karl Godt


Joined: 20 Jun 2010
Posts: 3972
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_website 
musher0


Joined: 04 Jan 2009
Posts: 4278
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_website 
musher0


Joined: 04 Jan 2009
Posts: 4278
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_website 
ASRI éducation


Joined: 09 May 2009
Posts: 2553
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_website 
RetroTechGuy


Joined: 15 Dec 2009
Posts: 2668
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: 4278
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  88 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_website 
musher0


Joined: 04 Jan 2009
Posts: 4278
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  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_website 
Display_posts:   Sort by:   
Page 1 of 1 Posts_count  
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
 Forum index » House Training » Users ( For the regulars )
Jump to:  

Rules_post_cannot
Rules_reply_cannot
Rules_edit_cannot
Rules_delete_cannot
Rules_vote_cannot
You cannot attach files in this forum
You can download files in this forum


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