[Wylug-help] USB Flash: device numbers, filenames and grub
Dave Fisher
wylug-help at davefisher.co.uk
Fri Jan 26 16:58:43 GMT 2007
Hi,
Could someone explain, or point me to some reasonable quality
documentation that would give me a chance of figuring it out, the
following:
1. I get inconsistent behaviour when I unmount/eject different usb
sticks on the same PC (running Ubuntu 6.10 Edgy, with a 2.6.17-10-386
kernel).
When I unmount the single partition on one stick, the partition
device file (/dev/sda1 on this occasion) disappears, but the device
file for the whole device (/dev/sda) remains.
If I then insert a different stick, it gets the device file /dev/sdb
(presumably because /dev/sda remains in the file system) and its
partitions get /dev/sdb1, /dev/sdb2 and /dev/sdb3.
But if I unmount/eject any one of those partitions:
a) They are all unmounted.
b) All of their device files remain on the file system.
2. I presume that there is a clean way of removing device files from the
system, (e.g. to ensure that if I only have one stick inserted, it
always gets /dev/sda ... assuming no other scsi devices).
Or is that wishful thinking?
3. I've been experimenting with booting and running entire systems from
USB sticks. However, I suspect that my success so far is partly down
to luck, e.g. using similar PCs, none of which had other usb or scsi
devices attached.
I'd like to make my current stick-hosted system more robustly
portable, but the device file naming issue is a bit of an obstacle.
I am booting from grub, which provides command line completion for
finding discs, partitions and even ordinary files on unmounted
systems (cool).
Unfortunately, grub doesn't seem to be able to do this for device
file names, so I have to predict (i.e. guess) which device file the
USB-based root filesystem is going to appear on, in order pass the
kernel the correct vaue for its "root=" parameter.
In simple cases (e.g. one HDD, one USB stick) this needn't be a
problem, because I can accurately predict the device file name for
the root partition of the USB-based system.
Unfortunately, there are many common, non-simple, cases.
For example, If the host PC contains multiple partitioned hard
drives, grub can number them like so:
(Hd0) = /dev/hda
(Hd0,0) = /dev/hda1
(Hd0,1) = /dev/hda2
(Hd1) = /dev/sda
(Hd1,0) = /dev/sda1
(Hd2) = /dev/hdd
(Hd2,0) = /dev/hdd1
I expected that grub would name these in device type order, e.g.
all the IDE drives in channel-disc-partition order, then all the
usb/scsi drives in channel-disc-partition order.
Since I know that IDE and USB devices use scsi addressing, I'm not
really surprised by the fact that grub naming doesn't follow that
pattern, i.e, interleaving sd* devices with hd* devices.
What concerns me is that I don't know how the order is determined,
e.g. why an attached USB stick has a lower number than an on-board
IDE disc.
This is not an absolute obstacle, because one can always use the
grub command line to figure out and set these names interactively.
It would, however, be nicer to predict them, and hence offer
end-users simple and reliable options on a menu.
So in effect, I have two naming predicton problems:
a) How to predict the grub name for the device.
b) How to predict the device file name for the root file system.
Are the two in any way related, e.g. to scsi device orders?
Dave
More information about the Wylug-help
mailing list