LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-01-2011, 09:37 AM   #1
rng
Senior Member
 
Registered: Aug 2011
Posts: 1,064

Rep: Reputation: 41
blkid help needed


I need help regarding following:

1. How can I get a tabulated output of blkid?

2. The command 'sudo blkid' gives details of all drives. How can I get output of only one device (say /dev/sda) with blkid? If I type 'sudo blkid /dev/sda' it does not produce any output and exits silently.
 
Old 11-01-2011, 09:59 AM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,075
Blog Entries: 14

Rep: Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251
You'll have to explain what you mean by tabulated output - an example of what you want to see would help.

blkid shows you what type of device the block device (e.g. swap, filesystem) so unless you had formatted all of /dev/sda to be a filesystem or swap device it won't show you /dev/sda. It will show you partitions of sda (e.g. /dev/sda1, /dev/sda2) if you have made any of those and they are formatted to be swap or filesystem.

Also note that on occasion systems may not have a /dev/sda. For example I have an old Compaq RAID card in one server so it shows the RAID drive as /dev/cciss/c0d0 instead of /dev/sda as other systems using DELL PERC RAID cards do.

If you run df -h you'll see the devices that blkid is going to report on generally. Of course running blkid without arguments will also show you the devices. If you only want to see a list of devices you can run:
Code:
blkid | awk -F: '{print $1}'
 
Old 11-01-2011, 10:22 AM   #3
kilgoretrout
Senior Member
 
Registered: Oct 2003
Posts: 2,579

Rep: Reputation: 220Reputation: 220Reputation: 220
Assuming you have more than one hard drive and you just want information on all the partitions on sda, then running:
Code:
blkid | grep /dev/sda
should print out only the info for partitions on sda.
 
Old 11-01-2011, 11:47 AM   #4
rng
Senior Member
 
Registered: Aug 2011
Posts: 1,064

Original Poster
Rep: Reputation: 41
Thanks everyone for your help.

boot_info_script ( http://bootinfoscript.sourceforge.net/ ) produces following table which is very clear:

Quote:
Device UUID TYPE LABEL

/dev/sda1 AE9282BD92828A13 ntfs first-part
/dev/sda2 c806bc6c-ce7e-4110-ab62-a4d30fabcf74 ext4 sec-partition
/dev/sda3 066AFB216AFB0C65 swap
It is a proper aligned table but it is not coming properly on this post.
What command can be used to make this or similar output.

Regarding selecting only one device, I can easily understand the grep command: blkid | grep /dev/sda ; but that means blkid itself cannot be made to show all partitions of one device.

Last edited by rng; 11-01-2011 at 11:53 AM.
 
Old 11-01-2011, 12:47 PM   #5
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,075
Blog Entries: 14

Rep: Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251
Apparently you didn't read what I wrote. The blkid command is not a disk parsing utility - it is a utility to identify what you have layed out on a given device as far as known types. Therefore it DOES show you /dev/sda1, /dev/sda2 & /dev/sda3 because you HAVE layed out filesystems on them. If does NOT show you /dev/sda because that is the entire disk not a specific device with a layout.

For example on a test system I see:
fdisk -l

Disk /dev/sda: 146.1 GB, 146163105792 bytes
255 heads, 63 sectors/track, 17769 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 65 522081 83 Linux
/dev/sda2 66 17769 142207380 8e Linux LVM

Disk /dev/sdb: 898.3 GB, 898319253504 bytes
255 heads, 63 sectors/track, 109214 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdb1 * 1 109214 877261423+ 8e Linux LVM

Note that it shows /dev/sda1 has a Linux (filesystem) type so is likely a device as blkid understands it. It then shows /dev/sda2 is a Linunx LVM so /dev/sda2 is NOT a device as blkid understands it. However the logical volumes I created on the system in that second partition's VG (and the second disk's first partition, /dev/sdb1) ARE devices as understood by blkid so it shows me the LVs:

blkid
/dev/mapper/VolGroup00-LogVol05: TYPE="swap"
/dev/mapper/VolGroup00-LogVol04: UUID="c9794d8c-1d91-4e40-816a-0b2ce454db2f" TYPE="ext3"
/dev/mapper/VolGroup00-LogVol03: UUID="244edcb1-6716-43cb-bad6-1d9377123f88" TYPE="ext3"
/dev/mapper/VolGroup00-LogVol01: UUID="110ba6b5-bd1c-449c-868f-00734881ec7f" TYPE="ext3"
/dev/mapper/VolGroup00-lvopenv: UUID="52667549-cdd2-4dcc-b1c4-777501369aa1" TYPE="ext3"
/dev/mapper/VolGroup00-LogVol02: UUID="aa99e392-ad64-429a-9930-03fe0f2f796c" TYPE="ext3"
/dev/mapper/VolGroup00-LogVol00: UUID="1b342bc7-8d8d-4617-8d75-985183e1aa58" TYPE="ext3"
/dev/sda1: LABEL="/boot" UUID="77326fc1-39aa-47a0-bd64-502355f72c13" TYPE="ext3"
/dev/hda: LABEL="RHEL/5.4 x86_64 DVD" TYPE="iso9660"
/dev/VolGroup00/LogVol00: UUID="1b342bc7-8d8d-4617-8d75-985183e1aa58" TYPE="ext3"
/dev/VolGroup00/LogVol05: TYPE="swap"
/dev/mapper/vgvision-lvoracle: UUID="3f6580f6-381c-49c9-ba36-aa8e006f803c" TYPE="ext3"

Similarly if you were using software RAID (meta disks) those meta disks should show up in blkid output.

So if you are interested in finding out what is in partitions of a device you should use tools like fdisk or gparted. If you are interested in finding out what swap/filesystems devices exist then you use blkid on those.

If in fact all of your partitions on sda had filesystem or swap directly (not meta disks or LVs) then you could run:
blkid /dev/sda*
 
Old 11-01-2011, 08:34 PM   #6
rng
Senior Member
 
Registered: Aug 2011
Posts: 1,064

Original Poster
Rep: Reputation: 41
Thanks for explaining. I read what you wrote earlier but could not understand.

'blkid /dev/sda*' is the command I needed. I works perfectly when I need info on one disk only (like external hard disk) and do not want other disks to be listed.

I am not able to understand LVM. I tried seeing other links on it, eg http://en.wikipedia.org/wiki/Logical...er_%28Linux%29. It seems a useful but complex feature. Simple partitioning is clearly understood and I currently stick to that.
 
Old 11-02-2011, 11:01 AM   #7
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,075
Blog Entries: 14

Rep: Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251
Quote:
I am not able to understand LVM. I tried seeing other links on it, eg http://en.wikipedia.org/wiki/Logical...er_%28Linux%29. It seems a useful but complex feature. Simple partitioning is clearly understood and I currently stick to that.
I wasn't suggesting you use either LVM or Meta Disks but simply noting that blkid would read information for filesystems/swap devices configured on them as it does for partitions.

One CAN format an entire drive (/dev/sda) as a filesystem and usually would for an external drive as you have mentioned. That is why you can see it with blkid. If you run fdisk -l /dev/sda on that external drive you probably don't see any partitions.

Now that you mentioned it though: LVM has some benefits over partitioning:
1) You can combine multiple disks into a single VolGroup (VG - think of it as a logical disk).
With standard paritioning you can't have anything larger than a single disk.

2) You can add, remove, extend or reduce logical volumes (LVs - think of them as logical partitions) without having to worry about what other LVs are in place or where they are.
With standard partitioning if you needed to increase the size of say /dev/sda2 but already had an sda3 and sda4 you'd have to actually undo or resize sda3 and possibly sda4 depending on how much space you need in sda2. Also partition resizing on the fly is problematical.

3) There is no limit (or rather an extremely high limit) on the number of LVs you can have so long as you have space left in the VG.
With standard partitioning even when you use extended partitions there is a limit of 15 partitions total.

The thing that originally got me before I started using LVM was that conceptually it didn't make sense - My thought was "Why would you combine disks (into VGs) only to break them up again (into LVs)?" After a few months of using them I understood the benefits above and realized my thinking was limited by having been only used to partitions.

Many will tell you that for home use LVM is overly complex but for business use where storage needs change frequently it makes perfect sense. Even for home systems I'd use it as it really isn't that complex once you're used to it. If the reason you're using Linux is to learn new things I'd certainly encourage you to explore LVM.
 
Old 11-02-2011, 12:59 PM   #8
rng
Senior Member
 
Registered: Aug 2011
Posts: 1,064

Original Poster
Rep: Reputation: 41
Thanks for a nice explanation. Just one question. If there is a LVM involving 2 physical hard disks and one of them fails, will the whole file-system get affected? Is it possible one may lose files on the remaining disk also since it was part of the larger system?

Last edited by rng; 11-02-2011 at 01:05 PM.
 
Old 11-02-2011, 07:25 PM   #9
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,417

Rep: Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397
You will lose it all, because the files are distributed as the LVM sees fit at the time and may even be spread across both disks. More importantly, the fs you create on the LVM is one fs, so if part goes missing, it can't run.
Either do frequent backups, or consider some sort of RAID under the VG or just go with RAID on its own.
Remember that the more complex you make a system, the harder it is to fix when it breaks...

Recommend you read up on partitions, filesystems, LVM & RAID carefully before committing to a given soln.
Try wikipedia as a starting pt, also http://tldp.org/HOWTO/LVM-HOWTO/ and http://www.linuxtopia.org/online_boo...ion/index.html.

Note that none of these techniques are a substitute for backups...
 
Old 11-02-2011, 08:56 PM   #10
rng
Senior Member
 
Registered: Aug 2011
Posts: 1,064

Original Poster
Rep: Reputation: 41
Thanks. That really clarifies advantages and disadvantages of LVM. If you can similarly give a brief word on RAID also- can I set it up if I have 2-4 hard disks and the major advantage that I will get is automatic backup, so that even if one disk fails, the data can be recovered?
 
Old 11-03-2011, 02:00 AM   #11
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,417

Rep: Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397
As I said, start with wikipedia eg https://secure.wikimedia.org/wikipedia/en/wiki/RAID; consider RAID5 or RAID6.
As above, this is NOT a substitute for backups, just higher availability in in case of HW failure (which happens sooner or later).
The Linux built-in SW tool is mdadm http://linux.die.net/man/8/mdadm
 
Old 11-03-2011, 09:56 AM   #12
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,075
Blog Entries: 14

Rep: Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251
Essentially the point in (most) RAID types is to protect your data. The two most commonly used are:

RAID1 = Mirroring = For each disk there is a second disk which has exactly the same data. With either disk failing everything still continues to run because it is all on the other disk. In this RAID level you only have half the usable space (e.g. if you have 4 disks then you'd only have the usable space of 2 because the other 2 would be mirrors.)

RAID5 = Striping with parity. The data is written with a parity check bit across all your disks. If you lose a single disk then you don't lose any data because it is presented by the parity and data bits that remain. The parity equates to one full disk but is spread across like the data. This means you have the effective usable space of N-1 disks. (e.g. if you have 4 disks then your effective usable space is 3 disks, if you have 7 disks then your effective usable space is 6 disks.)

Of course many will tell you not to use RAID5 because losing 2 disks can lose all your data so other strategies such as RAID 6 (which provides for 2 parity disks) or RAID 10 (which does striping and mirroring) exist but of course they use up more disks.

RAID is broken down into Software and Hardware types. The meta disks I spoke of earlier are the Linux software RAID implementation.

RAID is definitely something you should do to prevent first line failure. Backups is something you should definitely do to allow recovery whether you're doing RAID or not. If your server were to suddenly catch fire or get zapped by lightning it might not matter how many disks you had in it and a backup allow you to restore to a new system.
 
Old 11-03-2011, 11:55 AM   #13
rng
Senior Member
 
Registered: Aug 2011
Posts: 1,064

Original Poster
Rep: Reputation: 41
Thanks for a clear and concise explanation of RAID and for the links. I am sure these will benefit others also.
 
Old 11-03-2011, 10:04 PM   #14
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,417

Rep: Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397
Quote:
If your server were to suddenly catch fire or get zapped by lightning it might not matter how many disks you had in it and a backup allow you to restore to a new system.
... and also fat fingering i.e. deleting the wrong stuff; RAID cannot help you there ...
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
[SOLVED] How to mount by-uuid if the device won't show in /dev/disk/by-uuid untill after blkid /dev/sd* ? masmddr Linux - General 4 01-10-2011 08:38 PM
Cant identify drive with 'blkid' clifford227 Linux - Newbie 3 08-22-2010 09:28 AM
sudo blkid vs. sudo fdisk -l problems alienexplorers Linux - Newbie 1 01-13-2009 01:35 AM
XGL needed for Beryl is conflicting with OpenGL needed for Cedega chunkeydelight Linux - Desktop 2 07-18-2007 06:50 AM
Errors installing Q, which is needed for Lex, which is needed for PHP Virtuality Linux - Software 1 05-29-2007 05:47 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:24 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration