Linux - NewbieThis 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!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
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.
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:
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:
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:
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:
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.
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?
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...
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?
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.