|Home||Switchboard||Unix Administration||Red Hat||TCP/IP Networks||Neoliberalism||Toxic Managers|
|May the source be with you, but remember the KISS principle ;-)|
|Repartitioning||Grub||Booting into Rescue Mode||Linux Image-based backups and SystemRescueCD||Logical Volume Renaming||How To Manage Your Disk By UUID|
|Linux Multipath||udev||Labeling the partition||Loopback filesystem||Admin Horror Stories||Humor||Etc|
Linux has mind boggling variety of disk mapping schemes. Among them
Logical manager mapping (LVM - mapping)
To label the partition, execute the following as root:
e2label <device> <label>
e2label /dev/sda3 root
To list the label you can use the same utility
# e2label /dev/cciss/c0d0p2 Turbomole
To mount a partition using its label install of device use option -L:
# mount -L Turbomole /Turbomole # df -k Filesystem 1K-blocks Used Available Use% Mounted on /dev/cciss/c0d0p8 11904588 3779612 7510492 34% / /dev/cciss/c0d0p7 23809236 438648 22141620 2% /var /dev/cciss/c0d0p5 63484780 5891780 54316144 10% /home /dev/cciss/c0d0p3 63484808 184376 60023576 1% /tmp /dev/cciss/c0d0p1 497829 29387 442740 7% /boot tmpfs 66042700 0 66042700 0% /dev/shm /dev/cciss/c0d0p2 126969692 4627316 115788660 4% /Turbomole
Unfortunately labels for ext2/ext3 filesystem are not visible in df -k listing. That limits the appeal of using disk labels, but still they are a very good way to ensure that all partitions are mounted correctly as they do not depend on the numbering of partitions within disk, which can change.
You can mount partitions using labels and by default RHEL 5.6 is mounting non-LVM partitions this way in /etc/fstab:
# cat /etc/fstab LABEL=/ / ext3 defaults 1 1 /dev/VolGroup00/var /var ext3 defaults 1 2 /dev/VolGroup00/tmp /tmp ext3 defaults 1 2 LABEL=/boot /boot ext3 defaults 1 2 tmpfs /dev/shm tmpfs defaults 0 0 devpts /dev/pts devpts gid=5,mode=620 0 0 sysfs /sys sysfs defaults 0 0 proc /proc proc defaults 0 0 LABEL=SWAP-sda2 swap swap defaults 0 0
Please not that LABEL=/boot means that label is "/boot", not "boot". If you forget about it filesystem will not be mounted on reboot and sysmtem will go into rescue mode. See Troubleshooting Errors in /etc/fstab
While labeling is not required, partition labels can be useful. For example, when adding the partition to /etc/fstab, the label can be listed instead of the partition device name. This proves useful if the partition number is changed from repartitioning the drive or if the partition is moved.
If the e2label command is used with just the partition device name as an argument, the current label for the partition is displayed.
Relabeling of logical volumes on LVM is a different story and there is a different procedure and different command to use. See Logical Volume Renaming
Labeling of logical volumes is good practice as it simplify understanding how the volume is mapped and helps to prevent some errors.
The Linux kernel is a restless beast, and must continally evolve and change. Especially in ways that mystify us poor end lusers. A recent wrinkle, as of kernel version 2.6.20, is changing the /dev names for ATA devices, so that all ATA and SCSI devices are named /dev/sd*. This is a result of using the shiny new libata subsystem. In the olden days PATA (also called IDE) hard drives and ATAPI devices (CD/DVD, tape drives) were /dev/hd*, and SCSI and SATA devices were /dev/sd*.
However, not all Linux distributions default to using libata. *buntu Feisty and Gutsy are all over the map; some versions of them use the new naming convention, some don't, and I haven't figured out which ones, or why. You can see how your own system handles these names with a couple of simple commands. This example from Kubuntu Gutsy shows the old style:$ ls /dev|grep '[s|h]d[a-z]' hda hda1 hda2 hdc hdd sda sda1 sda2 $ mount|grep ^'/dev' /dev/hda1 on / type ext3 (rw,errors=remount-ro) /dev/sda1 on /home type ext3 (rw) /dev/sda2 on /media/sda2 type ext3 (rw) /dev/hda2 on /var type ext3 (rw)
The first command shows all the ATA and SCSI devices detected by your kernel. The second command shows which ones are mounted. On this system there is one PATA hard disk with two partitions (hda), two CD/DVD drives (hdc, hdd), and one SATA disk with two partitions (sda). When I boot into Fedora 8, which defaults to libata, it looks like this:$ ls /dev|grep '[s|h]d[a-z]' sda sda1 sda2 sdb sdb1 sdb2Where are the two CD/DVD drives? These get /dev/sr* names under libata:$ ls /dev|grep sr sr0 sr1
For creating ext3 and xfs file systems, mkfs.ext3 and mkfs.xfs have the -L option to specify the disk label that should be used. For existing file systems, use e2label to label an ext2/ext3 file system. And for xfs file systems, use xfs_admin. Both of these commands can be used with the device to display the existing disk label.
Examples of initializing new file systems with a label:mkfs.ext3 -L ROOT /dev/sda1 mkfs.xfs -L BIGRAID /dev/sde
Examples of e2label and xfs_admin for existing files systems:e2label /dev/sda1 PRIMARY_ROOT e2label /dev/sda1 xfs_admin -L DATA1 /dev/sdf xfs_admin /dev/sdf
labeling swap devices
You can label a swap device by using the mkswap -L label option.mkswap -L SWAP0 /dev/sdb5
Alternative / by-id
Alternatively, you can use the udev by-id specification (look in /dev/disk/by-id). The ID paths are usually pretty long and less meaningful, but they are device specific and won't change as a result of hardware changes. It's probably best to use a disk label as above. However, for vfat/fat file systems disk labels are not available so the by-id specification
should be used./dev/disk/by-id/scsi-3500000e01632b7d0-part2 swap swap defaults 0 0
Examples of Use
Finally, the following are examples of using disk labels in
two key system files, fstab and grub.conf.
Example of /etc/fstab with disk labels:LABEL=ROOT / ext3 defaults 1 1 LABEL=BOOT /boot ext3 defaults 1 2 LABEL=SWAP swap swap defaults 0 0 LABEL=HOME /home ext3 nosuid,auto 1 2
Example of /boot/grub/grub.conf with disk labels:title astrid CentOS primary system root (hd0,0) kernel (hd0,0)/vmlinuz ro root=LABEL=ASTRID_ROOT0 rhgb quiet initrd (hd0,0)/initrd-astrid.img
Linux systems support disk labels via the udev device manager. Using disk labels avoids hard coding device names which can change if there's a change in the hardware configuration (disk added/removed). This will result
in a more robust system.
In case you might not know already, all entries for disks to be mounted at startup are in the file /etc/fstab. What do these labels look like in your fstab? Well, take a look here:
LABEL=/ / ext3 defaults 1 1
Since this is being displayed in your web browser, the extra white spaces won't be showing up. You will see more space between the items above in the actual fstab file. In the old days, in place of the LABEL= entry, there would have been a device path like /dev/hda1. Now though, you can mount via the label and not worry if /dev/hda1 changes to /dev/hdb2 because you plugged in a USB device or something. It mounts by the label assigned to it, instead of the device name.
What's that? How do we manage the label? I am so glad you asked! The answer is simple, but yet it's not. Basically it depends on what file system you formatted the disk with. For the purposes of this article, I will stick with the two most popular (from my travels anyway), and that is ext2 and reiser.
For ext2 file systems, you use the command e2label to view and set the file system label. So, if you want to view the label assigned to the device /dev/hda1, it would look like this:
and on my dev box it returns simply:
because it's the root file system. If we take a look at the entry in my /etc/fstab, the entry to mount it looks like this (just like above):
LABEL=/ / ext3 defaults 1 1
Notice above that the file system is actually ext3, and not ext2. For anyone who doesn't know, ext3 is really ext2 with journaling turned on, so the e2label command applies to it as well. Journaling simply means that the file system logs all changes to a journal before actually committing the changes to the disk. This means that you are much less likely to suffer from disk corruption in the event of a hard stop, power off, etc. The journal can simply be replayed when it comes back up, therefore catching up on any changes that did not get committed. It's a very cool and highly recommended feature, plus who wants to sit through those lengthy fsck sessions?
Back to labels, if you want to set the label, you use the e2label command still, you simply specify the desired disk label after the path. If I were setting the label on the device in question, it would look like this:
e2label /dev/hda1 /
That tells the e2label command to set the label to "/", whereas when that option is left off, it returns the current label. Nifty, huh?
... ... ...
Google matched content
Linux Partition HOWTO - The Linux Documentation Project
RenameUSBDrive - Community Ubuntu Documentation
Parted User's Manual - 2. Using Parted - The GNU Operating System
Re- How to change a partition's label
parted(8)- partition change program - Linux man page
Linux Partition How-To - Labels - Linux Operating System and Linux
Linux Disk Partitioning Guide - Hillsborough Community
FAIR USE NOTICE This site contains copyrighted material the use of which has not always been specifically authorized by the copyright owner. We are making such material available in our efforts to advance understanding of environmental, political, human rights, economic, democracy, scientific, and social justice issues, etc. We believe this constitutes a 'fair use' of any such copyrighted material as provided for in section 107 of the US Copyright Law. In accordance with Title 17 U.S.C. Section 107, the material on this site is distributed without profit exclusivly for research and educational purposes. If you wish to use copyrighted material from this site for purposes of your own that go beyond 'fair use', you must obtain permission from the copyright owner.
ABUSE: IPs or network segments from which we detect a stream of probes might be blocked for no less then 90 days. Multiple types of probes increase this period.
Groupthink : Two Party System as Polyarchy : Corruption of Regulators : Bureaucracies : Understanding Micromanagers and Control Freaks : Toxic Managers : Harvard Mafia : Diplomatic Communication : Surviving a Bad Performance Review : Insufficient Retirement Funds as Immanent Problem of Neoliberal Regime : PseudoScience : Who Rules America : Neoliberalism : The Iron Law of Oligarchy : Libertarian Philosophy
War and Peace : Skeptical Finance : John Kenneth Galbraith :Talleyrand : Oscar Wilde : Otto Von Bismarck : Keynes : George Carlin : Skeptics : Propaganda : SE quotes : Language Design and Programming Quotes : Random IT-related quotes : Somerset Maugham : Marcus Aurelius : Kurt Vonnegut : Eric Hoffer : Winston Churchill : Napoleon Bonaparte : Ambrose Bierce : Bernard Shaw : Mark Twain Quotes
Vol 25, No.12 (December, 2013) Rational Fools vs. Efficient Crooks The efficient markets hypothesis : Political Skeptic Bulletin, 2013 : Unemployment Bulletin, 2010 : Vol 23, No.10 (October, 2011) An observation about corporate security departments : Slightly Skeptical Euromaydan Chronicles, June 2014 : Greenspan legacy bulletin, 2008 : Vol 25, No.10 (October, 2013) Cryptolocker Trojan (Win32/Crilock.A) : Vol 25, No.08 (August, 2013) Cloud providers as intelligence collection hubs : Financial Humor Bulletin, 2010 : Inequality Bulletin, 2009 : Financial Humor Bulletin, 2008 : Copyleft Problems Bulletin, 2004 : Financial Humor Bulletin, 2011 : Energy Bulletin, 2010 : Malware Protection Bulletin, 2010 : Vol 26, No.1 (January, 2013) Object-Oriented Cult : Political Skeptic Bulletin, 2011 : Vol 23, No.11 (November, 2011) Softpanorama classification of sysadmin horror stories : Vol 25, No.05 (May, 2013) Corporate bullshit as a communication method : Vol 25, No.06 (June, 2013) A Note on the Relationship of Brooks Law and Conway Law
Fifty glorious years (1950-2000): the triumph of the US computer engineering : Donald Knuth : TAoCP and its Influence of Computer Science : Richard Stallman : Linus Torvalds : Larry Wall : John K. Ousterhout : CTSS : Multix OS Unix History : Unix shell history : VI editor : History of pipes concept : Solaris : MS DOS : Programming Languages History : PL/1 : Simula 67 : C : History of GCC development : Scripting Languages : Perl history : OS History : Mail : DNS : SSH : CPU Instruction Sets : SPARC systems 1987-2006 : Norton Commander : Norton Utilities : Norton Ghost : Frontpage history : Malware Defense History : GNU Screen : OSS early history
The Peter Principle : Parkinson Law : 1984 : The Mythical Man-Month : How to Solve It by George Polya : The Art of Computer Programming : The Elements of Programming Style : The Unix Haterís Handbook : The Jargon file : The True Believer : Programming Pearls : The Good Soldier Svejk : The Power Elite
Most popular humor pages:
Manifest of the Softpanorama IT Slacker Society : Ten Commandments of the IT Slackers Society : Computer Humor Collection : BSD Logo Story : The Cuckoo's Egg : IT Slang : C++ Humor : ARE YOU A BBS ADDICT? : The Perl Purity Test : Object oriented programmers of all nations : Financial Humor : Financial Humor Bulletin, 2008 : Financial Humor Bulletin, 2010 : The Most Comprehensive Collection of Editor-related Humor : Programming Language Humor : Goldman Sachs related humor : Greenspan humor : C Humor : Scripting Humor : Real Programmers Humor : Web Humor : GPL-related Humor : OFM Humor : Politically Incorrect Humor : IDS Humor : "Linux Sucks" Humor : Russian Musical Humor : Best Russian Programmer Humor : Microsoft plans to buy Catholic Church : Richard Stallman Related Humor : Admin Humor : Perl-related Humor : Linus Torvalds Related humor : PseudoScience Related Humor : Networking Humor : Shell Humor : Financial Humor Bulletin, 2011 : Financial Humor Bulletin, 2012 : Financial Humor Bulletin, 2013 : Java Humor : Software Engineering Humor : Sun Solaris Related Humor : Education Humor : IBM Humor : Assembler-related Humor : VIM Humor : Computer Viruses Humor : Bright tomorrow is rescheduled to a day after tomorrow : Classic Computer Humor
The Last but not Least
Copyright © 1996-2016 by Dr. Nikolai Bezroukov. www.softpanorama.org was created as a service to the UN Sustainable Development Networking Programme (SDNP) in the author free time. This document is an industrial compilation designed and created exclusively for educational use and is distributed under the Softpanorama Content License.
Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.
FAIR USE NOTICE This site contains copyrighted material the use of which has not always been specifically authorized by the copyright owner. We are making such material available to advance understanding of computer science, IT technology, economic, scientific, and social issues. We believe this constitutes a 'fair use' of any such copyrighted material as provided by section 107 of the US Copyright Law according to which such material can be distributed without profit exclusively for research and educational purposes.
This is a Spartan WHYFF (We Help You For Free) site written by people for whom English is not a native language. Grammar and spelling errors should be expected. The site contain some broken links as it develops like a living tree...
|You can use PayPal to make a contribution, supporting development of this site and speed up access. In case softpanorama.org is down you can use the at softpanorama.info|
The statements, views and opinions presented on this web page are those of the author (or referenced source) and are not endorsed by, nor do they necessarily reflect, the opinions of the author present and former employers, SDNP or any other organization the author may be associated with. We do not warrant the correctness of the information provided or its fitness for any purpose.
Last modified: October 03, 2017