Mounting an USB flask stick by-label
Alexander Griesser
alexander.griesser at lkh-vil.or.at
Mon Feb 16 12:26:23 UTC 2009
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Pedro Aguilar wrote:
> Hi,
>
> I have an embbeded device with an initramfs with busybox inside it. We
> want to use this initramfs basically for updating the real filesystem that
> resides in an USB flash stick.
>
> There could be several USB flash sticks connected to the target and we
> need to mount the one with our filesystem.
> We could differentiate our USB stick from the others by its label (mount
> -L), so I would like to know if there is a way with mdev to recognize an
> USB stick by-label or any other way (the serial id is not useful because
> each target has a different USB stick).
I'm using code like this for this purpose:
i=0
while [ "$i" != "10" ]; do
LXTC_BOOT=$(blkid | awk -F: '/LABEL="LXTC_BOOT"/ { print $1 }')
if [ "$LXTC_BOOT" = "" ]; then
sleep 1
i=$((i + 1))
echo -n "."
continue
else
echo "found ($LXTC_BOOT)".
break
fi
done
The label of my filesystem is "LXTC_BOOT", so by simply replacing this
label you will have the name of the blockdevice in the variable
"LXTC_BOOT" then.
The reason why I'm running through a 10 second time loop here is because
USB devices take some time to settle down and if the filesystem you're
looking for is on a USB drive (CD, stick, floppy, ...) the first
invocation will probably not find it immediately.
ciao,
- --
Alexander Griesser (Netzwerkadministration)
E-Mail: alexander.griesser at lkh-vil.or.at | Web: http://www.lkh-vil.or.at
KABEG LKH Villach | Nikolaigasse 43 | 9500 Villach
Tel.: +43 4242 208 3061 | Fax.: +43 4242 208 971 2061
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAkmZW28ACgkQ66HVD6KUm1pa2QCgjheNhOXgNdJl6I18uufsMzg5
mkkAniQpm5nfvAZH2+fcivctT9B540Gq
=JzI/
-----END PGP SIGNATURE-----
More information about the busybox
mailing list