Tiny Core Linux
Tiny Core Base => TCB Q&A Forum => Topic started by: bbenson on February 26, 2015, 08:18:43 PM
-
Hi folks, this is my first post here and I am a first time user running Tiny Core installed to a VirtualBox VM.
I ran into a problem while writing a script that will format a USB mounted SD card with four partitions, and then copy files over to each of the partitions.
I'm doing the following in a sh script:
dd if=/dev/zero of=$DEVICE bs=1024 count=1024
{
echo ,9,0x0c,*
echo ,$(expr $CYLINDERS / 4),,-
echo ,$(expr $CYLINDERS / 4),,-
echo ,,0x0c,-
} | sfdisk -D -H 255 -S 63 -C $CYLINDERS $DEVICE
# creates four partitions
mkfs.vfat -F 32 -n boot ${DEVICE}1
mkfs.ext4 -L rootfs ${DEVICE}2
mkfs.ext4 -L userdata ${DEVICE}3
mkfs.vfat -F 32 -n other ${DEVICE}4
mount ${DEVICE}1
cp ~/files/* /mnt/$MOUNT
umount ${DEVICE}1
This gives the error
mount: can't find /dev/sdb1 in /etc/fstab
cp also says that there's no space left on the device.
I know this approach works on other distros, and I'm thinking maybe in this case fstab isn't being updated before I try to mount the new partitions. I searched for hours and can't really find what I'm looking for.
So I guess my question is, how can I refresh or regenerate fstab so that I can mount newly created partitions?
Many thanks in advance,
Bruce
-
Hi bbenson
So I guess my question is, how can I refresh or regenerate fstab so that I can mount newly created partitions?
You could try:
sudo rebuildfstab
-
You could try:
sudo rebuildfstab
Thank you for the reply, Rich. I did try that after finding rebuildfstab listed in the udev rules for USB devices. It doesn't seem to be picking up the changes to the device. When I run the script, the USB device (/dev/sdb) disappears completely from fstab. rebuildfstab doesn't seem to do anything to bring it back.
-
I'm finding this is happening when I just plug a USB device in normally as well. dmesg will say that there is a SCSI removable disk attached to /dev/sdc, but then it doesn't show up in fstab. Where is the disconnect here?
-
fstab will not show sdb or sdc.
It only shows partitions that have filesystems on them, not the raw devices.
-
fstab will not show sdb or sdc.
It only shows partitions that have filesystems on them, not the raw devices.
Isn't mkfs building the file systems?
-
Filesystems will be on /dev/sdb1 or /dev/sdc1..... ;)
-
Filesystems will be on /dev/sdb1 or /dev/sdc1..... ;)
I agree. They should show up as enumerations on the base name, sdb or sdc. But they don't. Not unless I disconnect the device and connect it again. How can I manually jog the device bus so that TinyCore will pick up the newly written file systems on the device?
-
The util-linux partx tool is for this purpose, though at least fdisk also does it by itself. Curious that sfdisk does not.
-
Hi bbenson
Are you saying rebuildfstab works after unplugging/replugging your device?
-
Hi bbenson
Are you saying rebuildfstab works after unplugging/replugging your device?
rebuildfstab seems to be unnecessary after I detach/reattach the device. The file systems will show up with no added effort on my part.
-
Hi bbenson
From what I understand, rebuildfstab also creates the mount points in /mnt.
-
partprobe is part of the parted.tcz package.
-
I tried partprobe and did not have any luck, but that might be a different issue.
I disconnected the device and reconnected it, and the file systems did not show up this time (sdb was not listed in blkid, mount, or sfdisk -l).
dmesg reports:
usb 1-1: new high-speed USB device number 12 using ehci-pci
usb 1-1: device descriptor read/all, error -110
usb 1-1: new high-speed USB device number 13 using ehci-pci
usb 1-1: device descriptor read/all, error -110
usb 1-1: new high-speed USB device number 14 using ehci-pci
usb 1-1: unable to read config index 0 descriptor/start: -110
usb 1-1: can't read configurations, error -110
usb 1-1: new high-speed USB device number 15 using ehci-pci
usb 1-1: unable to read config index 0 descriptor/start: -110
usb 1-1: can't read configurations, error -110
usb usb1-port1: unable to enumerate USB device
I have an Ubuntu VM running side-by-side with TinyCore, and Ubuntu can find the four filesystems and read and write to them every time, so it doesn't seem to be the card.
The fact that the file systems were showing up before and not now makes me think the problem is with TinyCore, or possibly with my expectations of how a removable media device should behave on an OS that isn't Ubuntu.
Edit: When I reboot the machine the file systems show up like normal: sdb1, sdb2, sdb3, sdb4
-
Oh, and... a big thanks for everyone taking the time to respond and lend a hand.
-
Looks like a failed USB drive.
-
Hi gerald_clark
Actually he's using an SD card. Is there anything special or different maybe driver wise verses a thumb drive?
-
Yes, but connected via USB.
It could be the card reader or the card, or the card being improperly removed and inserted in a connected card reader.
-
I do not believe the USB device has failed, for the following reasons:
- The device is attached and removed properly each time (all file systems are unmounted prior to disconnecting)
- Ubuntu can read the device each time, without having to disconnect the device or restart the VM.
- When TinyCore is restarted, the device shows up normally
And yes, this is an SD card which is connected through a USB card reader. No special drivers are being used on either VM.
-
Hi bbenson
What happens if you try it on bare metal, take the VM out of the equation?