 |
|
 |
|
Next: [PATCH] x86 uaccess_32.h typo
|
| Author |
Message |
External

Since: Nov 22, 2008 Posts: 53
|
(Msg. 1) Posted: Thu Sep 17, 2009 11:20 am
Post subject: Probing unmounted partitions Archived from groups: alt>os>linux>slackware (more info?)
|
|
|
How would I probe an unmounted partition for file system info?
For instance, how to find out (in a bash script) if an ext2 partition
exists prior to mounting?
This will be done on a system that might not have had anything other than
the root system mounted yet, so there won't be any /etc/fstab records or
similar.
Come to think of it, probing for partitions would be useful too.
Suggestions? (The simpler the better?)
--
*===( http://www.400monkeys.com/God/
*===( http://principiadiscordia.com/
*===( http://www.slackware.com/ |
|
| Back to top |
|
 |  |
External

Since: Jun 11, 2004 Posts: 114
|
(Msg. 2) Posted: Thu Sep 17, 2009 11:20 am
Post subject: Re: Probing unmounted partitions [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
On 2009-09-17, Mike Jones <Not DeleteThis @Arizona.Bay> wrote:
>
> How would I probe an unmounted partition for file system info?
>
> For instance, how to find out (in a bash script) if an ext2 partition
> exists prior to mounting?
>
> This will be done on a system that might not have had anything other than
> the root system mounted yet, so there won't be any /etc/fstab records or
> similar.
Just as a point of order, if / is mounted, then /etc/fstab had better be
readable.  You might be thinking about the initrd being mounted, in
which case yes, you may not have the correct fstab file available.
> Come to think of it, probing for partitions would be useful too.
You can get the list of partitions from fdisk -l. And I found a nice
trick: you can use file -s to try to detect the filesystem!
# file -s /dev/sda9
/dev/sda9: SGI XFS filesystem data (blksz 4096, inosz 256, v2 dirs)
# file -s /dev/sda8
/dev/sda8: Linux/i386 swap file (new style) 1 (4K pages) size 200803 pages
By my reading of the man page, the filesystem does not need to be
mounted for this to work.
--keith
--
kkeller-usenet DeleteThis @wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://www.therockgarden.ca/aolsfaq.txt
see X- headers for PGP signature information |
|
| Back to top |
|
 |  |
External

Since: Nov 22, 2008 Posts: 53
|
(Msg. 3) Posted: Thu Sep 17, 2009 11:20 am
Post subject: Re: Probing unmounted partitions [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Responding to Keith Keller:
> On 2009-09-17, Mike Jones <Not RemoveThis @Arizona.Bay> wrote:
>>
>> How would I probe an unmounted partition for file system info?
>>
>> For instance, how to find out (in a bash script) if an ext2 partition
>> exists prior to mounting?
>>
>> This will be done on a system that might not have had anything other
>> than the root system mounted yet, so there won't be any /etc/fstab
>> records or similar.
>
> Just as a point of order, if / is mounted, then /etc/fstab had better be
> readable. You might be thinking about the initrd being mounted, in
> which case yes, you may not have the correct fstab file available.
>
>> Come to think of it, probing for partitions would be useful too.
>
> You can get the list of partitions from fdisk -l. And I found a nice
> trick: you can use file -s to try to detect the filesystem!
>
> # file -s /dev/sda9
> /dev/sda9: SGI XFS filesystem data (blksz 4096, inosz 256, v2 dirs) #
> file -s /dev/sda8
> /dev/sda8: Linux/i386 swap file (new style) 1 (4K pages) size 200803
> pages
>
> By my reading of the man page, the filesystem does not need to be
> mounted for this to work.
>
Jackpot!
Y'know, I must have used 'file' at some time, as I recall it now. How
irritating!
Cheers!
--
*===( http://www.400monkeys.com/God/
*===( http://principiadiscordia.com/
*===( http://www.slackware.com/ |
|
| Back to top |
|
 |  |
External

Since: Jun 25, 2009 Posts: 21
|
(Msg. 4) Posted: Thu Sep 17, 2009 11:20 am
Post subject: Re: Probing unmounted partitions [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Keith Keller wrote:
> You can get the list of partitions from fdisk -l. And I found a nice
> trick: you can use file -s to try to detect the filesystem!
See also the recent discussion about "blkid" to detect file system
types. The "file command doesn't work when you got the boot loader
in the partition's boot blok - as shown here:
# file -s /dev/sda2
/dev/sda2: x86 boot sector; GRand Unified Bootloader, stage1 version
0x3, 1st sector stage2 0x342f58a, GRUB version 0.97, code offset 0x48
# file -s /dev/sda3
/dev/sda3: Linux rev 1.0 ext3 filesystem data (needs journal recovery)
(large files)
so you see the root (sda2) partition is not recognized as being ext3,
while the data (sda3) partition IS.
--
Eef Hartman, Delft University of Technology, dept. SSC/ICT |
|
| Back to top |
|
 |  |
External

Since: Jun 11, 2004 Posts: 114
|
(Msg. 5) Posted: Thu Sep 17, 2009 11:20 am
Post subject: Re: Probing unmounted partitions [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
On 2009-09-17, Mike Jones <Not.TakeThisOut@Arizona.Bay> wrote:
>
> Y'know, I must have used 'file' at some time, as I recall it now. How
> irritating!
I use file frequently, but never read the man page or thought to use it
on a filesystem till I ran into it on google.
--keith
--
kkeller-usenet.TakeThisOut@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://www.therockgarden.ca/aolsfaq.txt
see X- headers for PGP signature information |
|
| Back to top |
|
 |  |
External

Since: Dec 18, 2004 Posts: 139
|
(Msg. 6) Posted: Thu Sep 17, 2009 1:20 pm
Post subject: Re: Probing unmounted partitions [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
On Thu, 17 Sep 2009 14:40:22 GMT, Mike Jones wrote:
>
>
> How would I probe an unmounted partition for file system info?
>
> For instance, how to find out (in a bash script) if an ext2 partition
> exists prior to mounting?
I use blkid to fetch information about partitions.
$ blkid /dev/sda10
/dev/sda10: LABEL="2008_1" UUID="1daded20-04a1e" TYPE="ext3" SEC_TYPE="ext2"
$ blkid -o value -s LABEL /dev/sda10
2008_1
$ blkid -o value -s TYPE /dev/sda10
ext3
in a script it would be something like
$_dev=/dev/sda10
_lbl=$(blkid -o value -s LABEL $_dev)
_type=$(blkid -o value -s TYPE $_dev) |
|
| Back to top |
|
 |  |
External

Since: Nov 22, 2008 Posts: 53
|
(Msg. 7) Posted: Thu Sep 17, 2009 1:20 pm
Post subject: Re: Probing unmounted partitions [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Responding to Eef Hartman:
> Keith Keller wrote:
>> You can get the list of partitions from fdisk -l. And I found a nice
>> trick: you can use file -s to try to detect the filesystem!
>
> See also the recent discussion about "blkid" to detect file system
> types. The "file command doesn't work when you got the boot loader in
> the partition's boot blok - as shown here: # file -s /dev/sda2
> /dev/sda2: x86 boot sector; GRand Unified Bootloader, stage1 version
> 0x3, 1st sector stage2 0x342f58a, GRUB version 0.97, code offset 0x48 #
> file -s /dev/sda3
> /dev/sda3: Linux rev 1.0 ext3 filesystem data (needs journal recovery)
> (large files)
> so you see the root (sda2) partition is not recognized as being ext3,
> while the data (sda3) partition IS.
Dayam! I recall that too, now!
I need more coffee!
Cheers!
--
*===( http://www.400monkeys.com/God/
*===( http://principiadiscordia.com/
*===( http://www.slackware.com/ |
|
| Back to top |
|
 |  |
External

Since: Nov 22, 2008 Posts: 53
|
(Msg. 8) Posted: Thu Sep 17, 2009 1:20 pm
Post subject: Re: Probing unmounted partitions [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Responding to Bit Twister:
> On Thu, 17 Sep 2009 14:40:22 GMT, Mike Jones wrote:
>>
>>
>> How would I probe an unmounted partition for file system info?
>>
>> For instance, how to find out (in a bash script) if an ext2 partition
>> exists prior to mounting?
>
> I use blkid to fetch information about partitions.
>
> $ blkid /dev/sda10
> /dev/sda10: LABEL="2008_1" UUID="1daded20-04a1e" TYPE="ext3"
> SEC_TYPE="ext2"
>
> $ blkid -o value -s LABEL /dev/sda10
> 2008_1
> $ blkid -o value -s TYPE /dev/sda10
> ext3
>
> in a script it would be something like $_dev=/dev/sda10
> _lbl=$(blkid -o value -s LABEL $_dev) _type=$(blkid -o value -s TYPE
> $_dev)
Eef just mentioned blkid too, and I should have remembered it from a
while back, on this very NG. %|
Cheers!
--
*===( http://www.400monkeys.com/God/
*===( http://principiadiscordia.com/
*===( http://www.slackware.com/ |
|
| Back to top |
|
 |  |
External

Since: Nov 02, 2008 Posts: 81
|
(Msg. 9) Posted: Thu Sep 17, 2009 3:20 pm
Post subject: Re: Probing unmounted partitions [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
On Thu, 17 Sep 2009 18:07:21 GMT, Mike Jones <Not.RemoveThis@Arizona.Bay> wrote:
>Eef just mentioned blkid too, and I should have remembered it from a
>while back, on this very NG. %|
So for fun, looping:
root@deltree:~# for n in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16; \
do blkid /dev/hda$n | \
gawk '{printf"%s",$1;sub(/^.*TYPE=/,"");gsub(/"/,"");print" "$1}'; \
done
/dev/hda1: reiserfs
/dev/hda2: reiserfs
/dev/hda3: reiserfs
/dev/hda5: reiserfs
/dev/hda6: reiserfs
/dev/hda7: reiserfs
/dev/hda8: swap
/dev/hda10: reiserfs
/dev/hda11: reiserfs
/dev/hda12: reiserfs
/dev/hda14: reiserfs
/dev/hda15: reiserfs
Grant.
--
http://bugsplatter.id.au |
|
| Back to top |
|
 |  |
External

Since: Jul 06, 2006 Posts: 35
|
(Msg. 10) Posted: Thu Sep 17, 2009 3:20 pm
Post subject: Re: Probing unmounted partitions [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
On Thu, 17 Sep 2009 08:47:56 -0700
Keith Keller <kkeller-usenet.RemoveThis@wombat.san-francisco.ca.us> wrote:
....
> You can get the list of partitions from fdisk -l. And I found a nice
> trick: you can use file -s to try to detect the filesystem!
>
> # file -s /dev/sda9
> /dev/sda9: SGI XFS filesystem data (blksz 4096, inosz 256, v2 dirs)
> # file -s /dev/sda8
> /dev/sda8: Linux/i386 swap file (new style) 1 (4K pages) size 200803 pages
A great way! It seems it doesn't work with JFS though:
# mount | grep jfs
/dev/hda3 on /home/art type jfs (rw,nosuid,nodev)
# file -s /dev/hda3
/dev/hda3: data
# umount /dev/hda3
# file -s /dev/hda3
/dev/hda3: data
--
Regards,
Mikhail |
|
| Back to top |
|
 |  |
External

Since: Jun 11, 2004 Posts: 114
|
(Msg. 11) Posted: Thu Sep 17, 2009 3:20 pm
Post subject: Re: Probing unmounted partitions [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
On 2009-09-17, Mikhail Zotov <invalid_muxaul DeleteThis @lenta.ru> wrote:
>
> A great way! It seems it doesn't work with JFS though:
>
> # mount | grep jfs
> /dev/hda3 on /home/art type jfs (rw,nosuid,nodev)
> # file -s /dev/hda3
> /dev/hda3: data
> # umount /dev/hda3
> # file -s /dev/hda3
> /dev/hda3: data
Oh, that's too bad! Does using blkid work? I'd test it, except for not
having a JFS filesystem here.
--keith
--
kkeller-usenet DeleteThis @wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://www.therockgarden.ca/aolsfaq.txt
see X- headers for PGP signature information |
|
| Back to top |
|
 |  |
External

Since: Sep 11, 2009 Posts: 10
|
(Msg. 12) Posted: Thu Sep 17, 2009 5:20 pm
Post subject: Re: Probing unmounted partitions [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
I use blkid often to get the UUID's of partitions. Set up all my
Linuxes' /etc/fstab's and bootloaders to use UUID's instead of device
names. Makes things a whole lot easier when you add new partitions,
OS's, etc later and the device names change. You don't have to do the
remote mount dance and change every Linux's /etc/fstab and bootloader.
As installed, Slackware uses device names and not UUID's.... |
|
| Back to top |
|
 |  |
External

Since: Nov 19, 2008 Posts: 37
|
(Msg. 13) Posted: Thu Sep 17, 2009 5:20 pm
Post subject: Re: Probing unmounted partitions [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Fri, 18 Sep 2009 04:51:50 +1000, Grant did cat :
> On Thu, 17 Sep 2009 18:07:21 GMT, Mike Jones <Not RemoveThis @Arizona.Bay> wrote:
>
>>Eef just mentioned blkid too, and I should have remembered it from a
>>while back, on this very NG. %|
>
> So for fun, looping:
>
> root@deltree:~# for n in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16; \
> do blkid /dev/hda$n | \
> gawk '{printf"%s",$1;sub(/^.*TYPE=/,"");gsub(/"/,"");print" "$1}'; \
> done
> /dev/hda1: reiserfs
> /dev/hda2: reiserfs
> /dev/hda3: reiserfs
> /dev/hda5: reiserfs
> /dev/hda6: reiserfs
> /dev/hda7: reiserfs
> /dev/hda8: swap
> /dev/hda10: reiserfs
> /dev/hda11: reiserfs
> /dev/hda12: reiserfs
> /dev/hda14: reiserfs
> /dev/hda15: reiserfs
>
> Grant.
playing golf?-) try a par two:
# blkid -s TYPE| gawk '{sub(/TYPE=\"/,"");sub(/\"/,"")}1'
and, sorry Hans, been there changed that:
# blkid -s TYPE| gawk '{sub(/TYPE=\"/,"");sub(/\"/,"")}1' | grep -c reiser
0
# blkid -s TYPE| gawk '{sub(/TYPE=\"/,"");sub(/\"/,"")}1' | grep -c jfs
12
(the rest being either thumbdisks and/or LV+DM containers
# blkid -s TYPE| gawk '{sub(/TYPE=\"/,"");sub(/\"/,"")}1' | egrep -cv '(reiser|jfs)'
29 |
|
| Back to top |
|
 |  |
External

Since: Dec 18, 2004 Posts: 139
|
(Msg. 14) Posted: Thu Sep 17, 2009 5:20 pm
Post subject: Re: Probing unmounted partitions [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
On Thu, 17 Sep 2009 20:27:42 GMT, bc20 wrote:
> I use blkid often to get the UUID's of partitions. Set up all my
> Linuxes' /etc/fstab's and bootloaders to use UUID's instead of device
> names. Makes things a whole lot easier when you add new partitions,
> OS's, etc later and the device names change. You don't have to do the
> remote mount dance and change every Linux's /etc/fstab and bootloader.
> As installed, Slackware uses device names and not UUID's....
Heheh, wait until you have to do a format/recovery.
You get to change the UUID in grub/fstab for the newly formatted partition.
I use partition labels myself.
$ grep beta /boot/grub/menu.lst
title beta
kernel (hd0,11)/boot/vmlinuz BOOT_IMAGE=beta root=LABEL=beta vga=791
$ grep beta /etc/fstab
LABEL=beta / ext3 relatime 1 1 |
|
| Back to top |
|
 |  |
External

Since: Nov 02, 2008 Posts: 27
|
(Msg. 15) Posted: Thu Sep 17, 2009 5:20 pm
Post subject: Re: Probing unmounted partitions [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Hallo, Bit,
Du meintest am 17.09.09:
> I use partition labels myself.
Me too ...
> $ grep beta /boot/grub/menu.lst
> title beta
> kernel (hd0,11)/boot/vmlinuz BOOT_IMAGE=beta root=LABEL=beta vga=791
What about LABELs in "/etc/lilo.conf"? My first tries had no success.
Viele Gruesse
Helmut
"Ubuntu" - an African word, meaning "Slackware is too hard for me". |
|
| Back to top |
|
 |  |
|
You can post new topics in this forum You can 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
|
|
|
|
 |
|
|