Datamation content and product recommendations are
editorially independent. We may make money when you click on links
to our partners.
Learn More
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
sdb2
Where are the two CD/DVD drives? These get /dev/sr* names under libata:
$ ls /dev|grep sr
sr0
sr1
So why did this happen? Is it because kernel developers have cruel senses of humor, and delight in tormenting us? While that is a possibility, the real reason, as always, is to improve the kernel. The Linux kernel has evolved considerably since the bad old days of ide-scsi, the old ide subsystem, and the ATAPI subsystem. All of these had their problems. This has all been replaced by libata, which is easier to maintain, supports more devices, and works better.
In addition to cleaning up a pile of old kernel messes, libata supports power management, SMART (Self-Monitoring, Analysis and Reporting Technology System), and SATA port multiplier (PMP). PMP means you can use a single controller with multiple SATA devices. The one downside is you don’t get as many partitions on PATA disks- under the old IDE subsystem you could have 64 partitions, but you only get 15 under libata. So if you like to carve your PATA disks into vast numbers of partitions, you’ll either need to use the old subsystems and drivers, or join the 21st century and use LVM. (Or try the experimental kernel patch by Carl-Daniel Hailfinger that lets you have 127 partitions on a single hard disk; see Resources.)
Just like in the olden days, udev may change your device names. While udev has a lot of advantages, it often means spending time figuring out how to nail down device names and mountpoints. Most Linux distributions ship with default udev configurations that create persistent names for hard drives. Look for something like /etc/udev/rules.d/65-persistent-storage.rules to see how your system is configured. However, /etc/fstab can still get bollixed, or you might want a removable USB storage device to have a persistent name and mountpoint, so your best tactic is to use UUIDs instead of /dev names. An example entry looks like this, except in real life the UUID line is unbroken:
# /dev/sda1
UUID=b099f554-db0b-45d4-843e-0d6a1c43ba44
/home ext3 defaults 0 2
Yes, UUIDs are long and unattractive. But they are unique, so no matter what udev or anything else on your system tries to do with them, they will always be the same. How do you know what the UUID is?
# vol_id -u /dev/sda1
b099f554-db0b-45d4-843e-0d6a1c43ba445
On Fedora it’s /lib/udev/vol_id.
Another option is to use filesystem labels. Red Hat, Fedora, and all of their extended family like to use them. Labels are quick and easy to create or change. An entry in /etc/fstab looks like this:
LABEL=/1 / ext3defaults 1 1
vol_id –export [device name] displays complete information, including labels. Where does this label come from? Fedora creates it at installation. To create or change filesystem labels, you need to use a command specific to your filesystem. e2label is for Ext3. For ReiserFS, use reiserfstune, and you must unmount the filesystem first. On XFS use xfs_admin, and for JFS you need jfs_tune. For FAT filesystems use mlabel, which is part of mtools.
With libata, how do you know which of your PATA drives are masters or slaves, and on which IDE controller? Just look at the output of dmesg|grep ata, and then use this table to figure out what’s what:
ata1.00 primary master
ata1.01 primary slave
ata2.00 secondary master
ata2.01 secondary slave
dmesg also tells you if the kernel sees your PATA and ATAPI drives as hd or sd. Run dmesg|grep ‘[s|h]d[a-z]’ to find out.
Resources
Carla Schroder is the author of the Linux Cookbook and the newly-released Linux Networking Cookbook, and is a regular contributor to LinuxPlanet.
This article was first published on LinuxPlanet.com.
-
Ethics and Artificial Intelligence: Driving Greater Equality
FEATURE | By James Maguire,
December 16, 2020
-
AI vs. Machine Learning vs. Deep Learning
FEATURE | By Cynthia Harvey,
December 11, 2020
-
Huawei’s AI Update: Things Are Moving Faster Than We Think
FEATURE | By Rob Enderle,
December 04, 2020
-
Keeping Machine Learning Algorithms Honest in the ‘Ethics-First’ Era
ARTIFICIAL INTELLIGENCE | By Guest Author,
November 18, 2020
-
Key Trends in Chatbots and RPA
FEATURE | By Guest Author,
November 10, 2020
-
Top 10 AIOps Companies
FEATURE | By Samuel Greengard,
November 05, 2020
-
What is Text Analysis?
ARTIFICIAL INTELLIGENCE | By Guest Author,
November 02, 2020
-
How Intel’s Work With Autonomous Cars Could Redefine General Purpose AI
ARTIFICIAL INTELLIGENCE | By Rob Enderle,
October 29, 2020
-
Dell Technologies World: Weaving Together Human And Machine Interaction For AI And Robotics
ARTIFICIAL INTELLIGENCE | By Rob Enderle,
October 23, 2020
-
The Super Moderator, or How IBM Project Debater Could Save Social Media
FEATURE | By Rob Enderle,
October 16, 2020
-
Top 10 Chatbot Platforms
FEATURE | By Cynthia Harvey,
October 07, 2020
-
Finding a Career Path in AI
ARTIFICIAL INTELLIGENCE | By Guest Author,
October 05, 2020
-
CIOs Discuss the Promise of AI and Data Science
FEATURE | By Guest Author,
September 25, 2020
-
Microsoft Is Building An AI Product That Could Predict The Future
FEATURE | By Rob Enderle,
September 25, 2020
-
Top 10 Machine Learning Companies 2021
FEATURE | By Cynthia Harvey,
September 22, 2020
-
NVIDIA and ARM: Massively Changing The AI Landscape
ARTIFICIAL INTELLIGENCE | By Rob Enderle,
September 18, 2020
-
Continuous Intelligence: Expert Discussion [Video and Podcast]
ARTIFICIAL INTELLIGENCE | By James Maguire,
September 14, 2020
-
Artificial Intelligence: Governance and Ethics [Video]
ARTIFICIAL INTELLIGENCE | By James Maguire,
September 13, 2020
-
IBM Watson At The US Open: Showcasing The Power Of A Mature Enterprise-Class AI
FEATURE | By Rob Enderle,
September 11, 2020
-
Artificial Intelligence: Perception vs. Reality
FEATURE | By James Maguire,
September 09, 2020
SEE ALL
ARTICLES