how to mount sdcard device when its path changes
I have a MIPS VENUS linux box. I can insert hdd, usb and sdcard in it. Because of insufficient space in its root (I think it's on flash), I use a sdcard and installed optware (only opt, ssh and nano) on it and set up links from /bin and /sbin to the sdcard. Without hdd and usb, the sdcard is always auto-mounted as sda1 so it works and survive reboot. But if hdd and/or usb is inserted before boot, the sdcard is no longer sda1 and of course ssh won't work. Is there any method I can auto-mount the sdcard to a fixed point when it boots? (I can modify the init script of the firmware).
|
I would say you need to use uuids for mount and set it in /etc/fstab
|
Quote:
/dev/disk contains persistent device files, but they aren't that easy to use. You can use mount UUID=reallylongstring; to find the UUID use a tool like tune2fs for ext filesystems or perhaps blkid (?) or lsblk (?). Another way is setting a label, which some filesystems support, ext included. Use e2label to create the label, then mount LABEL=thelabelyoucreated to mount the filesystem. UUID and LABEL mount options also work in fstab. |
Thank you for all the replies. My box is very limited. Most of the commands are from busybox and the version is 1.1.3, though the kernel is 2.6.12.6. It does not have mount -L or mount -U. It does not have e2label. I managed to "tune2fs -L venus_opt ..." to add label to my sdcard and added "LABEL=venus_opt .... defaults 0 0" to fstab, but it did not boot correctly (lan connected failed hence not able to telnet to find out what's wrong). Haven't try UUID but I think the result will be the same. Am I right that even if fstab is correctly set, the system still rely on mount command to do the actual mounting?
mount command showed that, after boot, if only the sdard is plugged (i.e. no hdd no usb) the device name is /dev/scsi/host2/bus0/target0/lun0/part1 and mount point /tmp/usbmounts/sda1. If hdd and sdcard is plugged, the hdd is host2 and sda, and the sdcard becomes host3 and sdb. My optware rely on a link from /opt to sda1 to work. So with a hdd plugged, my optware can't be located. Is there any method I can use to make it always put host2 and sda to sdcard? |
Quote:
Quote:
|
probably works, but you need to try:
mount will use fstab if there was a related entry (that means you can add mount points to non-existent devices in fstab, you just need to disable auto mount - see noauto flag). |
All times are GMT -5. The time now is 04:34 AM. |