LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 04-09-2009, 12:12 AM   #1
rolverm
LQ Newbie
 
Registered: Apr 2009
Posts: 5

Rep: Reputation: 0
Smile How can we detect in Linux a non-formatted disk is been put ?


Hi,

I am working on:

SUSE Linux Enterprise Server 10 (ia64)
VERSION = 10
PATCHLEVEL = 2

According to my implementation I need to detect a non-formatted disk.
I have put two disk one having 5 partitions and the other one is non formatted both are SCSI disk.

Is there any command or way which could be implemented to easily differentiate between a formatted and non-formatted disk.

Any Pointers towards the answers will be welcomed and awaited.
Thanks in advance.
 
Old 04-09-2009, 01:40 AM   #2
Stéphane Ascoët
Member
 
Registered: Feb 2004
Location: Fleury-les-Aubrais, 120 km south of Paris
Distribution: Devuan, Debian, Mandrake, Freeduc (the one I used to work on), Slackware, MacOS X
Posts: 251

Rep: Reputation: 49
Question What do you want exactly?

Are the formatted partitions mounted?
 
Old 04-09-2009, 04:44 AM   #3
rolverm
LQ Newbie
 
Registered: Apr 2009
Posts: 5

Original Poster
Rep: Reputation: 0
Exclusive way to find the diffrence between a formatted and a non formatted disk

It may be possible that formatted disk partitions are mounted or may not be mounted ,That is not what i am concerned in .

I want a command by which i can find if the disk is nonformatted

If I put n disk thay are detected in cat /proc/partitions along with the partions .
How will be a non-formatted disk shown in this case ,Will entry for non-formatted disk be there or not .
If the entry is not there, there must some way or the other which gives me a clear idea of the disk i have put is a non-formatted disk.
 
Old 04-09-2009, 04:53 AM   #4
Stéphane Ascoët
Member
 
Registered: Feb 2004
Location: Fleury-les-Aubrais, 120 km south of Paris
Distribution: Devuan, Debian, Mandrake, Freeduc (the one I used to work on), Slackware, MacOS X
Posts: 251

Rep: Reputation: 49
Question Perhaps an idea?

If you try to use the datas returned by a a partitioning software like fdisk or other in a script?
 
Old 04-09-2009, 05:34 AM   #5
sieira
Member
 
Registered: Dec 2007
Location: Alcalá de Henares (Madrid)
Distribution: Debian
Posts: 40

Rep: Reputation: 16
Cool

I'm not sure about this, but I think you can't.

What makes a disk unformatted?, the absence of any format. If you manage to mount an ext3 disk in windows it will promise that this disk is unformatted, so despite linux recognizes many formats (ext2,ext3,reiser,nfs,fat16,fat32,ntfs,joliet etc.) any disk with a format other than those included in your kernel will be an "unformatted disk".

parted (or any grpahical gui for it "gparted, kparted, xparted...") will give you some clues about what you want to know.

WARNING: I can be wrong
 
Old 04-09-2009, 08:39 AM   #6
farslayer
LQ Guru
 
Registered: Oct 2005
Location: Northeast Ohio
Distribution: linuxdebian
Posts: 7,249
Blog Entries: 5

Rep: Reputation: 191Reputation: 191
fdisk -l

should list all Drives in the system, their partitions, and the filesystem type.
If there are no partitions or filesystems then it will just list an empty dist

I think you can use the file command on a partition
Code:
it-lenny:~# file -s <device>
Code:
fdisk -l - Should list all drives and partitions no matter if they are formatted, unformatted, mounted or unmounted

Disk /dev/sda: 160.0 GB, 160000000000 bytes
255 heads, 63 sectors/track, 19452 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x0e1069f4

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1         851     6835626   83  Linux
/dev/sda2             852       19452   149412532+   5  Extended
/dev/sda5             852        1181     2650693+  82  Linux swap / Solaris
/dev/sda6            1182       19452   146761776   83  Linux

Disk /dev/sdb: 511 MB, 511705088 bytes
33 heads, 32 sectors/track, 946 cylinders
Units = cylinders of 1056 * 512 = 540672 bytes
Disk identifier: 0xf01cd10d

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *           1         947      499696    6  FAT16


--

it-lenny:~# file -s /dev/sda1
/dev/sda1: Linux rev 1.0 ext3 filesystem data, UUID=70165487-7f4f-4a6c-9332-7d907b63976 (needs journal recovery) (large files)

it-lenny:~# file -s /dev/sda2
/dev/sda2: x86 boot sector; partition 1: ID=0x82, starthead 1, startsector 63, 5301387 sectors; partition 2: ID=0x5, starthead 254, startsector 5301450, 293523615 sectors

it-lenny:~# file -s /dev/sda5
/dev/sda5: Linux/i386 swap file (new style), version 1 (4K pages), size 662672 pages, no label, UUID=0-0-0-0-00

it-lenny:~# file -s /dev/sda6
/dev/sda6: Linux rev 1.0 ext3 filesystem data, UUID=24b1bd67-de9-4782-9644-a088a434c562 (needs journal recovery) (large files)

it-lenny:~# file -s /dev/sdb1
/dev/sdb1: x86 boot sector
Sorry I don't have any unformatted partitions to view, but fdisk -l would list the Drive info with no partitions under it.. or it would show unallocated space on a drive with free space
also looks like I'm due for a reboot for some journal maintenance .

Hope that was useful info for you. .

Last edited by farslayer; 04-09-2009 at 08:41 AM.
 
Old 05-17-2009, 01:40 PM   #7
archtoad6
Senior Member
 
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 234Reputation: 234Reputation: 234
A) Yes file works on a partition; in fact, the following will make an interesting inventory of your drives:
Code:
file -s /dev/sd{a..g}{,{1..19}} |grep -v 'ERROR' |less -S
Adjust "g" & "19" to values reasonably beyond your expectations.


B) I believe "x86 boot sector, code offset 0x48" indicates an unformatted partition;
while "x86 boot sector; partition 1: ..." is an extended partition.
 
Old 05-18-2009, 01:40 AM   #8
hw-tph
Senior Member
 
Registered: Sep 2003
Location: Sweden
Distribution: Debian
Posts: 3,032

Rep: Reputation: 58
Also, do not forget about the utility blkid, however I do not know how this program lists block devices without partitions - if at all.
 
Old 05-18-2009, 09:43 AM   #9
archtoad6
Senior Member
 
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 234Reputation: 234Reputation: 234
I don't find a blkid pkg. in the repos. for MEPIS 7 -- any idea where I can get it?
 
Old 05-18-2009, 07:23 PM   #10
farslayer
LQ Guru
 
Registered: Oct 2005
Location: Northeast Ohio
Distribution: linuxdebian
Posts: 7,249
Blog Entries: 5

Rep: Reputation: 191Reputation: 191
blkid is in e2fsprogs package in Debian, Maybe a similar package name in Mepis...
 
Old 05-19-2009, 06:39 AM   #11
archtoad6
Senior Member
 
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 234Reputation: 234Reputation: 234
Yes it's there & already installed -- it's just "hiding" in /sbin, which is no longer in the path of regular users, like fdisk & ifconfig.
Both of those used to be available for informational purposes w/o having to be root.

Anyway, I found blkid & tried it out, & it's definitely good to know about.
 
Old 05-19-2009, 07:48 AM   #12
farslayer
LQ Guru
 
Registered: Oct 2005
Location: Northeast Ohio
Distribution: linuxdebian
Posts: 7,249
Blog Entries: 5

Rep: Reputation: 191Reputation: 191
still can use em without being root, just have to specify the full path..

Code:
user@it-lenny:~$ /sbin/blkid -L
device                             fs_type      label         mount point                            UUID
-----------------------------------------------------------------------------------------------------------------------------------------
/dev/sda1                          ext3                       /                                      70165487-7f4f-4a6c-9332-07d907b63976
/dev/sda5                          swap                       <swap>                                 
/dev/sda6                          ext3                       /home                                  24b1bd67-0de9-4782-9644-a088a434c562
/dev/sdb1                          vfat         USB DISK      /media/usbdrive                        5CA6-6E33
Interestingly enough fdisk only showed the flash drive the regular user mounted, not the system drive.. so maybe just specifying the full path to the executable won't always cut it, even for just purely informational purposes.

blkid is a slick utility though.

Thanks hw-tph for the heads up on this one.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
help with formatted disk valdivaldor Linux - Newbie 4 11-09-2008 03:29 AM
Put Linux Disk to Sleep from Windows? benhanson Linux - Hardware 1 11-13-2007 07:47 AM
Recover data on formatted hd; installed linux to 'wrong' disk rmark999 Linux - Newbie 2 07-26-2007 06:19 AM
Linux formatted disk in MS-computer ekkins Linux - General 3 04-30-2005 09:22 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 06:57 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration