BLKID not giving output in linux when run in file - linux

I've written following script in linux to get USB detail: this script is executed from udev when usb is attached.
fgrep -A 15 'New USB device found' /var/log/messages | tail -n 16 > usb_detail
SERIAL=$(sed -n '5s/A.*: //p' usb_detail)
SIZE=$(sed -n '10s/A.*: //p' usb_detail)
MOUNT=$(sed -n '14s/A.*: //p' usb_detail)
blkid > Label
LABEL=$(grep $MOUNT Label | awk '{print $2}')
Now problem is that I'm getting all values (Serial No, Size, Mount on) but when it goes to check lable of usb from BLKID then i get nothing. this command gives me nothing in output:
blkid > Label
this command is working properly in command prompt. but when i run it in this script (which is called from UDEV when usb is attached) then it doesn't give any output.
So how can i figure out that what is main problem and why I'm not getting anything in LABEL file?
Here is my /var/log/messages:
Apr 28 08:25:58 box2 kernel: usb 1-3: New USB device found, idVendor=0411, idProduct=0105
Apr 28 08:25:58 box2 kernel: usb 1-3: New USB device strings: Mfr=1, Product=2, SerialNumber=5
Apr 28 08:25:58 box2 kernel: usb 1-3: Product: USB-SATA Bridge
Apr 28 08:25:58 box2 kernel: usb 1-3: Manufacturer: BUFFALO
Apr 28 08:25:58 box2 kernel: usb 1-3: SerialNumber: 00001412AA38
Apr 28 08:25:58 box2 kernel: usb 1-3: configuration #1 chosen from 1 choice
Apr 28 08:25:58 box2 kernel: scsi25 : SCSI emulation for USB Mass Storage devices
Apr 28 08:26:05 box2 kernel: scsi 25:0:0:0: Direct-Access BUFFALO External HDD PQ: 0 ANSI: 2 CCS
Apr 28 08:26:05 box2 kernel: sd 25:0:0:0: Attached scsi generic sg0 type 0
Apr 28 08:26:05 box2 kernel: sd 25:0:0:0: [sda] 976773168 512-byte logical blocks: (500 GB/465 GiB)
Apr 28 08:26:05 box2 kernel: sd 25:0:0:0: [sda] Write Protect is off
Apr 28 08:26:05 box2 kernel: sd 25:0:0:0: [sda] Assuming drive cache: write through
Apr 28 08:26:05 box2 kernel: sd 25:0:0:0: [sda] Assuming drive cache: write through
Apr 28 08:26:05 box2 kernel: sda: sda1
Apr 28 08:26:05 box2 kernel: sd 25:0:0:0: [sda] Assuming drive cache: write through
Apr 28 08:26:05 box2 kernel: sd 25:0:0:0: [sda] Attached SCSI disk
and here is blkid output from command prompt:
[root#box2 usbmon]# blkid
/dev/sdf1: UUID="2d1bd58e-86ea-4ab2-99e3-ec2d1fb24021" TYPE="ext4"
/dev/sdf2: UUID="Je95wE-NW7f-Mqlv-UBgi-qNOL-8i35-8cUUTj" TYPE="LVM2_member"
/dev/mapper/vg_box2-lv_root: UUID="27cf24f7-4e7d-42bd-97be-09ddc6eb614b" TYPE="ext4"
/dev/mapper/vg_box2-lv_swap: UUID="36c54ea3-f9f3-455a-9c84-58e7317d1e60" TYPE="swap"
/dev/mapper/vg_box2-lv_home: UUID="5cac0192-2757-4cf6-b70f-d9ff8fbe6f36" TYPE="ext4"
/dev/sda1: LABEL="BU5" UUID="242DB177461FD69A" TYPE="ntfs"

Running with sudo will give you proper out.
sudo blkid

i fixed the issue by changing syntax
blkid > Label
to
/sbin/blkid > Label
dont know why but sometimes it works.

Related

Why is my emmc card recognized as /dev/sdd instead of /dev/mmcblk0?

My desktop has a built-in SD/mini/MMC/RS card slot and I can use my eMMC card as storage device without problems. But under /dev directory it is recognized as /dev/sdd, which I think should be /dev/mmcblk0 or something. Here's the output of dmesg -T concerning sd part:
[Thu Nov 5 10:57:14 2015] sd 5:0:0:2: [sdd] 15269888 512-byte logical blocks: (7.81 GB/7.28 GiB)
[Thu Nov 5 10:57:14 2015] sd 5:0:0:2: [sdd] Write Protect is off
[Thu Nov 5 10:57:14 2015] sd 5:0:0:2: [sdd] Mode Sense: 03 00 00 00
[Thu Nov 5 10:57:14 2015] sd 5:0:0:2: [sdd] No Caching mode page found
[Thu Nov 5 10:57:14 2015] sd 5:0:0:2: [sdd] Assuming drive cache: write through
[Thu Nov 5 10:57:14 2015] sd 5:0:0:0: [sdb] Attached SCSI removable disk
[Thu Nov 5 10:57:14 2015] sd 5:0:0:1: [sdc] Attached SCSI removable disk
[Thu Nov 5 10:57:14 2015] sdd: sdd1
[Thu Nov 5 10:57:14 2015] sd 5:0:0:3: [sde] Attached SCSI removable disk
[Thu Nov 5 10:57:14 2015] sd 5:0:0:2: [sdd] Attached SCSI removable disk
The problem is that I want to use ioctl with MMC_IOC_CMD request to test its functionality, so I can compare the result/response with another FPGA-simulated eMMC controller. On an embedded arm board with Linux (3.0.1) installed this same eMMC card is recognized correctly as /dev/mmcblk0, and I can successfully send some commands to it. But on the Desktop, open("/dev/sdd", O_RDWR), then ioctl(fd, IOC_MMC_CMD, args) returns EINVAL.
Maybe the problem is the card isn't correctly recognized as sd/mmc card? How could I make it realized as mmcblkX so that I can interact with it on my PC (Arch Linux)?

mkfs ext4 failing on Azure VM

I have a VM running CenOS 6.3 on Azure. I'm following the steps in the Microsoft article to attach a disk (article).
When I run: sudo mkfs -t ext4 /dev/sdc1
the process hangs indefinitely at "Writing superblocks and filesystem accounting information"
If I start a new session and try mounting the partition it says:
"mount: you must specify the filesystem type"
I've upgraded and downgraded my VM in order to force a hardware switch. I've detached and re-attached new disks of various sizes. Same result each time.
I'm guessing it must be either an error or setting on my OS that is causing the problem. Below is a full bash session. Any help would be very much appreciated!
[apper#apper ~]$ sudo grep SCSI /var/log/messages
Apr 19 14:08:47 apper kernel: sd 3:0:0:0: [sdc] Attached SCSI disk
Apr 19 14:19:38 apper kernel: sd 3:0:0:0: [sdc] Synchronizing SCSI cache
Apr 19 14:22:58 apper kernel: SCSI subsystem initialized
Apr 19 14:22:58 apper kernel: Block layer SCSI generic (bsg) driver version 0.4 loaded (major 252)
Apr 19 14:22:58 apper kernel: sd 1:0:1:0: [sdb] Attached SCSI disk
Apr 19 14:22:58 apper kernel: sd 0:0:0:0: [sda] Attached SCSI disk
Apr 19 14:33:08 apper kernel: sd 3:0:0:0: [sdc] Attached SCSI disk
Apr 19 14:40:16 apper kernel: sd 3:0:0:0: [sdc] Synchronizing SCSI cache
Apr 19 14:47:11 apper kernel: SCSI subsystem initialized
Apr 19 14:47:11 apper kernel: Block layer SCSI generic (bsg) driver version 0.4 loaded (major 252)
Apr 19 14:47:11 apper kernel: sd 1:0:1:0: [sdb] Attached SCSI disk
Apr 19 14:47:11 apper kernel: sd 0:0:0:0: [sda] Attached SCSI disk
Apr 19 14:48:40 apper kernel: sd 3:0:0:0: [sdc] Attached SCSI disk
[apper#apper ~]$ sudo fdisk /dev/sdc
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-32635, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-32635, default 32635):
Using default value 32635
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[apper#apper ~]$ sudo mkfs -t ext4 /dev/sdc1
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
16384000 inodes, 65535151 blocks
3276757 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
2000 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information:
Try passing –E lazy_itable_init=1,lazy_journal_init=1 to mkfs.

USB drive stop working while is in use

First of all i'm sorry for my english.
I post here because i've searched a long time in google and i've not found anything useful.
Well my problem is with an external USB drive: I've a Debian wheezy Server full updated with kernel 3.2.0-4-686-pae, and i've bought an USB drive to extend it storage.
The problem is when i start to copy a lot of files to external storage, then the drive stop working. I've seen that drive continues mounted but it becomes unresponsive and the only way to get it working is disconnecting the USB and then reconnecting again.
The USB drive is a Seagate Expansion Desktop 2TB 3.5" USB3.0 with external power supply.
The syslog shows this:
Jul 18 10:57:38 SomeServer kernel: [163444.176034] usb 1-2: reset high-speed USB device number 12 using ehci_hcd
Jul 18 10:57:38 SomeServer kernel: [163444.300025] usb 1-2: device descriptor read/64, error -71
Jul 18 10:57:38 SomeServer kernel: [163444.528031] usb 1-2: device descriptor read/64, error -71
Jul 18 10:57:39 SomeServer kernel: [163444.744043] usb 1-2: reset high-speed USB device number 12 using ehci_hcd
Jul 18 10:57:39 SomeServer kernel: [163444.868054] usb 1-2: device descriptor read/64, error -71
Jul 18 10:57:39 SomeServer kernel: [163445.096045] usb 1-2: device descriptor read/64, error -71
Jul 18 10:57:39 SomeServer kernel: [163445.312044] usb 1-2: reset high-speed USB device number 12 using ehci_hcd
Jul 18 10:57:40 SomeServer kernel: [163445.724044] usb 1-2: device not accepting address 12, error -71
Jul 18 10:57:40 SomeServer kernel: [163445.836063] usb 1-2: reset high-speed USB device number 12 using ehci_hcd
Jul 18 10:57:40 SomeServer kernel: [163446.248060] usb 1-2: device not accepting address 12, error -71
Jul 18 10:57:40 SomeServer kernel: [163446.248133] usb 1-2: USB disconnect, device number 12
Jul 18 10:57:40 SomeServer kernel: [163446.248152] sd 6:0:0:0: Device offlined - not ready after error recovery
Jul 18 10:57:40 SomeServer kernel: [163446.248179] sd 6:0:0:0: [sdc] Unhandled error code
Jul 18 10:57:40 SomeServer kernel: [163446.248184] sd 6:0:0:0: [sdc] Result: hostbyte=DID_ABORT driverbyte=DRIVER_OK
Jul 18 10:57:40 SomeServer kernel: [163446.248192] sd 6:0:0:0: [sdc] CDB: Write(10): 2a 00 16 c3 7a 2a 00 00 1e 00
Jul 18 10:57:40 SomeServer kernel: [163446.248211] end_request: I/O error, dev sdc, sector 3055276368
Jul 18 10:57:40 SomeServer kernel: [163446.248244] Buffer I/O error on device sdc1, logical block 381909290
Jul 18 10:57:40 SomeServer kernel: [163446.248278] lost page write due to I/O error on sdc1
Jul 18 10:57:40 SomeServer kernel: [163446.248286] Buffer I/O error on device sdc1, logical block 381909291
Jul 18 10:57:40 SomeServer kernel: [163446.248320] lost page write due to I/O error on sdc1
Jul 18 10:57:40 SomeServer kernel: [163446.248328] Buffer I/O error on device sdc1, logical block 381909292
Jul 18 10:57:40 SomeServer kernel: [163446.248359] lost page write due to I/O error on sdc1
Jul 18 10:57:40 SomeServer kernel: [163446.248366] Buffer I/O error on device sdc1, logical block 381909293
Jul 18 10:57:40 SomeServer kernel: [163446.248402] lost page write due to I/O error on sdc1
Jul 18 10:57:40 SomeServer kernel: [163446.248408] Buffer I/O error on device sdc1, logical block 381909294
Jul 18 10:57:40 SomeServer kernel: [163446.248437] lost page write due to I/O error on sdc1
Jul 18 10:57:40 SomeServer kernel: [163446.248443] Buffer I/O error on device sdc1, logical block 381909295
Jul 18 10:57:40 SomeServer kernel: [163446.249782] lost page write due to I/O error on sdc1
Jul 18 10:57:40 SomeServer kernel: [163446.249790] Buffer I/O error on device sdc1, logical block 381909296
Jul 18 10:57:40 SomeServer kernel: [163446.249820] lost page write due to I/O error on sdc1
Jul 18 10:57:40 SomeServer kernel: [163446.249826] Buffer I/O error on device sdc1, logical block 381909297
Jul 18 10:57:40 SomeServer kernel: [163446.249855] lost page write due to I/O error on sdc1
Jul 18 10:57:40 SomeServer kernel: [163446.249861] Buffer I/O error on device sdc1, logical block 381909298
Jul 18 10:57:40 SomeServer kernel: [163446.249889] lost page write due to I/O error on sdc1
Jul 18 10:57:40 SomeServer kernel: [163446.249895] Buffer I/O error on device sdc1, logical block 381909299
Jul 18 10:57:40 SomeServer kernel: [163446.249923] lost page write due to I/O error on sdc1
Jul 18 10:57:40 SomeServer kernel: [163446.249997] sd 6:0:0:0: [sdc] Unhandled error code
Jul 18 10:57:40 SomeServer kernel: [163446.250002] sd 6:0:0:0: [sdc] Result: hostbyte=DID_NO_CONNECT driverbyte=DRIVER_OK
Jul 18 10:57:40 SomeServer kernel: [163446.250010] sd 6:0:0:0: [sdc] CDB: Write(10): 2a 00 16 c3 7a 48 00 00 1e 00
Jul 18 10:57:40 SomeServer kernel: [163446.250028] end_request: I/O error, dev sdc, sector 3055276608
Jul 18 10:57:40 SomeServer kernel: [163446.346073] JBD: Detected IO errors while flushing file data on sdc1
Jul 18 10:57:40 SomeServer kernel: [163446.346259] journal_bmap: journal block not found at offset 16396 on sdc1
Jul 18 10:57:40 SomeServer kernel: [163446.346302] Aborting journal on device sdc1.
Jul 18 10:57:40 SomeServer kernel: [163446.346375] JBD: I/O error detected when updating journal superblock for sdc1.
Jul 18 10:57:40 SomeServer kernel: [163446.346433] __journal_remove_journal_head: freeing b_committed_data
Jul 18 10:57:40 SomeServer kernel: [163446.346579] __journal_remove_journal_head: freeing b_committed_data
Jul 18 10:57:40 SomeServer kernel: [163446.374086] JBD: Detected IO errors while flushing file data on sdc1
Jul 18 10:57:40 SomeServer kernel: [163446.374142] __journal_remove_journal_head: freeing b_frozen_data
Jul 18 10:57:40 SomeServer kernel: [163446.374147] __journal_remove_journal_head: freeing b_frozen_data
Jul 18 10:57:40 SomeServer kernel: [163446.374151] __journal_remove_journal_head: freeing b_frozen_data
Jul 18 10:57:40 SomeServer kernel: [163446.374154] __journal_remove_journal_head: freeing b_committed_data
Jul 18 10:57:40 SomeServer kernel: [163446.374158] __journal_remove_journal_head: freeing b_frozen_data
Jul 18 10:57:40 SomeServer kernel: [163446.374190] journal commit I/O error
Jul 18 10:57:40 SomeServer kernel: [163446.394650] EXT3-fs (sdc1): error: ext3_journal_start_sb: Detected aborted journal
Jul 18 10:57:40 SomeServer kernel: [163446.394724] EXT3-fs (sdc1): error: remounting filesystem read-only
Jul 18 10:57:41 SomeServer kernel: [163446.820598] EXT3-fs error (device sdc1): ext3_find_entry: reading directory #93773868 offset 0
Jul 18 10:57:41 SomeServer kernel: [163446.820722] EXT3-fs error (device sdc1): ext3_find_entry: reading directory #93773868 offset 0
Jul 18 10:57:41 SomeServer kernel: [163446.820817] EXT3-fs error (device sdc1): ext3_find_entry: reading directory #93773868 offset 0
Jul 18 10:57:41 SomeServer kernel: [163446.820910] EXT3-fs error (device sdc1): ext3_find_entry: reading directory #93773868 offset 0
Jul 18 10:57:41 SomeServer kernel: [163446.821006] EXT3-fs error (device sdc1): ext3_find_entry: reading directory #93773868 offset 0
Jul 18 10:57:41 SomeServer kernel: [163446.821101] EXT3-fs error (device sdc1): ext3_find_entry: reading directory #93773868 offset 0
Jul 18 10:57:41 SomeServer kernel: [163446.821194] EXT3-fs error (device sdc1): ext3_find_entry: reading directory #93773868 offset 0
Jul 18 10:57:41 SomeServer kernel: [163446.821290] EXT3-fs error (device sdc1): ext3_find_entry: reading directory #93773868 offset 0
Jul 18 10:57:41 SomeServer kernel: [163446.821386] EXT3-fs error (device sdc1): ext3_find_entry: reading directory #93773868 offset 0
Jul 18 10:57:41 SomeServer kernel: [163446.821480] EXT3-fs error (device sdc1): ext3_find_entry: reading directory #93773868 offset 0
Jul 18 10:57:41 SomeServer kernel: [163446.821578] EXT3-fs error (device sdc1): ext3_find_entry: reading directory #93773868 offset 0
Jul 18 10:57:41 SomeServer kernel: [163446.821669] EXT3-fs error (device sdc1): ext3_find_entry: reading directory #93773868 offset 0
Jul 18 10:57:41 SomeServer kernel: [163446.821765] EXT3-fs error (device sdc1): ext3_find_entry: reading directory #93773868 offset 0
Jul 18 10:57:41 SomeServer kernel: [163446.821864] EXT3-fs error (device sdc1): ext3_find_entry: reading directory #93773868 offset 0
Jul 18 10:57:41 SomeServer kernel: [163446.821962] EXT3-fs error (device sdc1): ext3_find_entry: reading directory #93773868 offset 0
Jul 18 10:57:41 SomeServer kernel: [163446.822059] EXT3-fs error (device sdc1): ext3_find_entry: reading directory #93773868 offset 0
Jul 18 10:57:41 SomeServer kernel: [163446.822157] EXT3-fs error (device sdc1): ext3_find_entry: reading directory #93773868 offset 0
Jul 18 10:57:41 SomeServer kernel: [163446.822254] EXT3-fs error (device sdc1): ext3_find_entry: reading directory #93773868 offset 0
Jul 18 10:57:41 SomeServer kernel: [163446.822351] EXT3-fs error (device sdc1): ext3_find_entry: reading directory #93773868 offset 0
Jul 18 10:57:41 SomeServer kernel: [163446.822454] EXT3-fs error (device sdc1): ext3_find_entry: reading directory #93773868 offset 0
Jul 18 10:57:41 SomeServer kernel: [163446.822556] EXT3-fs error (device sdc1): ext3_find_entry: reading directory #93773868 offset 0
Jul 18 10:57:41 SomeServer kernel: [163446.822648] EXT3-fs error (device sdc1): ext3_find_entry: reading directory #93773868 offset 0
Jul 18 10:57:41 SomeServer kernel: [163446.822740] EXT3-fs error (device sdc1): ext3_find_entry: reading directory #93773868 offset 0
Jul 18 10:57:41 SomeServer kernel: [163446.822847] EXT3-fs error (device sdc1): ext3_find_entry: reading directory #93773868 offset 0
Jul 18 10:57:41 SomeServer kernel: [163446.822950] EXT3-fs error (device sdc1): ext3_find_entry: reading directory #93773868 offset 0
Jul 18 10:57:41 SomeServer kernel: [163446.823041] EXT3-fs error (device sdc1): ext3_find_entry: reading directory #93773868 offset 0
Jul 18 10:57:41 SomeServer kernel: [163446.823144] EXT3-fs error (device sdc1): ext3_find_entry: reading directory #93773868 offset 0
Jul 18 10:57:41 SomeServer kernel: [163446.823632] EXT3-fs error (device sdc1): ext3_find_entry: reading directory #92577799 offset 0
Jul 18 10:57:41 SomeServer kernel: [163446.831563] __journal_remove_journal_head: freeing b_frozen_data
Jul 18 10:57:41 SomeServer kernel: [163446.840980] sd 6:0:0:0: [sdc] Synchronizing SCSI cache
Jul 18 10:57:41 SomeServer kernel: [163446.841033] sd 6:0:0:0: [sdc] Result: hostbyte=DID_NO_CONNECT driverbyte=DRIVER_OK
Jul 18 10:57:41 SomeServer kernel: [163446.863650] EXT3-fs error (device sdc1): ext3_find_entry: reading directory #92561409 offset 0
Jul 18 10:57:41 SomeServer kernel: [163446.865293] EXT3-fs error (device sdc1): ext3_find_entry: reading directory #92561409 offset 0
Jul 18 10:57:41 SomeServer kernel: [163446.865900] EXT3-fs error (device sdc1): ext3_find_entry: reading directory #92561409 offset 0
Jul 18 10:57:41 SomeServer kernel: [163446.903243] EXT3-fs error (device sdc1): ext3_find_entry: reading directory #92561409 offset 0
Jul 18 10:57:41 SomeServer kernel: [163446.912264] EXT3-fs error (device sdc1): ext3_find_entry: reading directory #92561409 offset 0
Jul 18 10:57:41 SomeServer kernel: [163446.927942] EXT3-fs error (device sdc1): ext3_find_entry: reading directory #92561409 offset 0
Jul 18 10:57:41 SomeServer kernel: [163446.928606] EXT3-fs error (device sdc1): ext3_find_entry: reading directory #92561409 offset 0
Jul 18 10:57:41 SomeServer kernel: [163446.929807] EXT3-fs error (device sdc1): ext3_find_entry: reading directory #92561409 offset 0
Jul 18 10:57:41 SomeServer kernel: [163446.933678] EXT3-fs error (device sdc1): ext3_find_entry: reading directory #92561409 offset 0
Jul 18 10:57:41 SomeServer kernel: [163446.935572] EXT3-fs error (device sdc1): ext3_find_entry: reading directory #92561409 offset 0
Jul 18 10:57:41 SomeServer kernel: [163446.936040] EXT3-fs error (device sdc1): ext3_find_entry: reading directory #92561409 offset 0
Jul 18 10:57:41 SomeServer kernel: [163446.936901] EXT3-fs error (device sdc1): ext3_find_entry: reading directory #92561409 offset 0
Jul 18 10:57:41 SomeServer kernel: [163446.937351] EXT3-fs error (device sdc1): ext3_find_entry: reading directory #92561409 offset 0
Jul 18 10:57:41 SomeServer kernel: [163446.939195] EXT3-fs error (device sdc1): ext3_find_entry: reading directory #92561409 offset 0
Jul 18 10:57:41 SomeServer kernel: [163446.939678] EXT3-fs error (device sdc1): ext3_find_entry: reading directory #92561409 offset 0
Jul 18 10:57:41 SomeServer kernel: [163446.940349] EXT3-fs error (device sdc1): ext3_find_entry: reading directory #92561409 offset 0
Jul 18 10:57:41 SomeServer kernel: [163446.940860] EXT3-fs error (device sdc1): ext3_find_entry: reading directory #92561409 offset 0
Jul 18 10:57:41 SomeServer kernel: [163446.941317] EXT3-fs error (device sdc1): ext3_find_entry: reading directory #92561409 offset 0
Jul 18 10:57:41 SomeServer kernel: [163446.941758] EXT3-fs error (device sdc1): ext3_find_entry: reading directory #92561409 offset 0
Jul 18 10:57:41 SomeServer kernel: [163446.942208] EXT3-fs error (device sdc1): ext3_find_entry: reading directory #92561409 offset 0
Jul 18 10:57:41 SomeServer kernel: [163446.942617] EXT3-fs error (device sdc1): ext3_find_entry: reading directory #92561409 offset 0
Jul 18 10:57:41 SomeServer kernel: [163446.943089] EXT3-fs error (device sdc1): ext3_find_entry: reading directory #92561409 offset 0
Jul 18 10:57:41 SomeServer kernel: [163446.943557] EXT3-fs error (device sdc1): ext3_find_entry: reading directory #92561409 offset 0
Jul 18 10:57:41 SomeServer kernel: [163446.944000] EXT3-fs error (device sdc1): ext3_find_entry: reading directory #92561409 offset 0
Jul 18 10:57:41 SomeServer kernel: [163446.944757] EXT3-fs error (device sdc1): ext3_find_entry: reading directory #92561409 offset 0
Jul 18 10:57:41 SomeServer kernel: [163446.945234] EXT3-fs error (device sdc1): ext3_find_entry: reading directory #92561409 offset 0
Jul 18 10:57:41 SomeServer kernel: [163446.945651] EXT3-fs error (device sdc1): ext3_find_entry: reading directory #92561409 offset 0
Jul 18 10:57:41 SomeServer kernel: [163446.946142] EXT3-fs error (device sdc1): ext3_find_entry: reading directory #92561409 offset 0
Jul 18 10:57:41 SomeServer kernel: [163446.952110] usb 1-2: new high-speed USB device number 13 using ehci_hcd
I've tried to change the USB port, delete the partition and repartitioning with fdisk again, EXT3 and EXT4 format... and i don't know if is a Linux problem or maybe the USB drive is defective.
Yesterday i was able to copy about 170GB without problem, then i tried to copy a file of about 68GB and it started to fail.
Someone knows what can be failing?. I want to know it before replacing the unit with a new unit and continue having problems.
Thanks!!

Is this Possible to know device Mounting and Unmounting Time in Ubuntu?

from dmesg we can know that particular device has been mounted or unmounted.
But I want to know on which time the device has been mounted or unmounted.
Solution 1:
dmesg output isn't having human readable date-time information
Instead using dmesg you can use kernel log available, and filter it according to your need.
for e.g. Ubuntu, Debian stores kernel log at /var/log/kern.log
cat /var/log/kern.log | grep "usb"
It will give output like,
Apr 30 11:42:23 debian kernel: [ 1537.984584] usb 1-1.1: USB disconnect, device number 3
Apr 30 11:42:23 debian kernel: [ 1538.207012] usb 1-1.1: new low-speed USB device number 5 using ehci_hcd
Apr 30 11:42:29 debian kernel: [ 1543.409629] usb 1-1.1: new low-speed USB device number 6 using ehci_hcd
Apr 30 11:42:29 debian kernel: [ 1543.504880] usb 1-1.1: New USB device found, idVendor=04f3, idProduct=0235
Apr 30 11:42:29 debian kernel: [ 1543.504885] usb 1-1.1: New USB device strings: Mfr=0, Product=2, SerialNumber=0
Apr 30 11:42:29 debian kernel: [ 1543.504888] usb 1-1.1: Product: OM
Solution 2:
I've found one perl script to convert dmesg date-time to human readable.
Try it,
#!/usr/bin/perl
use strict;
use warnings;
my #dmesg_new = ();
my $dmesg = "/bin/dmesg";
my #dmesg_old = `$dmesg`;
my $now = time();
my $uptime = `cat /proc/uptime | cut -d"." -f1`;
my $t_now = $now - $uptime;
sub format_time {
my #time = localtime $_[0];
$time[4]+=1; # Adjust Month
$time[5]+=1900; # Adjust Year
return sprintf '%4i-%02i-%02i %02i:%02i:%02i', #time[reverse 0..5];
}
foreach my $line ( #dmesg_old )
{
chomp( $line );
if( $line =~ m/\[\s*(\d+)\.(\d+)\](.*)/i )
{
# now - uptime + sekunden
my $t_time = format_time( $t_now + $1 );
push( #dmesg_new , "[$t_time] $3" );
}
}
print join( "\n", #dmesg_new );
print "\n";
Save and apply execute permission.
$chmod a+x script.pl
$./script.pl
[Sample output:]
[2014-04-30 11:17:27] eth0: no IPv6 routers present
[2014-04-30 11:42:18] hub 1-1:1.0: port 1 disabled by hub (EMI?), re-enabling...
[2014-04-30 11:42:18] usb 1-1.1: USB disconnect, device number 3
[2014-04-30 11:42:19] usb 1-1.1: new low-speed USB device number 5 using ehci_hcd
[2014-04-30 11:42:24] hub 1-1:1.0: unable to enumerate USB device on port 1
[2014-04-30 11:42:24] usb 1-1.1: new low-speed USB device number 6 using ehci_hcd
[2014-04-30 11:42:24] usb 1-1.1: New USB device found, idVendor=04f3, idProduct=0235
[2014-04-30 11:42:24] usb 1-1.1: New USB device strings: Mfr=0, Product=2, SerialNumber=0
[2014-04-30 11:42:24] usb 1-1.1: Product: OM
[2014-04-30 11:42:24] input: OM as /devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.1/1-1.1:1.0/input/input11
[2014-04-30 11:42:24] generic-usb 0003:04F3:0235.0004: input,hidraw0: USB HID v1.11 Mouse [OM] on usb-0000:00:1a.0-1.1/input0
Solution 3:
If your distro supports -T option for dmesg
Try dmesg -T. For me it worked on Debian, It should work for you too on Ubuntu. It enables time-stamp for output.
[From man page]
-T, --ctime
Print human readable timestamps. The timestamp could be inaccurate!
The time source used for the logs is not updated after system SUSPEND/RESUME.
In linux /var/log directory contains various log details. We can also get history of previous logs from this directory. Kernel zips the previous log details. In case of yours you have to open kern.log. But If you are looking for details which is not in kern.log, you can see kern.log.1 or in case you are interested in very old details, you have to unzip kern.log.2.gz

Very low performance of g_mass_storage virtual usb device

Hello I am using Linux usb gadget facility to emulate a USB flash drive. It is working fine except for very low performance.
I use a 4Gb file, created by dd and created a ext2 or vfat (tried both) partition on it. Than I mount it using the following command sequence:
# modprobe dummy_hcd is_super_speed=1 # I tried is_high_speed=1, and no parameter too
# modprobe g_mass_storage file=/home/del/img/flash stall=0 # tried w/o stall=0 too
# mount /dev/sdc1 /mnt/tmp
After that I get /dev/sdc and /dev/sdc1 devices created without any errors in dmesg:
[1256700.986581] usb 3-1: reset high-speed USB device number 5 using dummy_hcd
[1256701.022551] gadget: high-speed config #1: Linux File-Backed Storage
[1256701.242481] usb 3-1: reset high-speed USB device number 5 using dummy_hcd
[1256701.278422] gadget: high-speed config #1: Linux File-Backed Storage
[1256701.422339] gadget: high-speed config #1: Linux File-Backed Storage
[1256934.915697] usb 3-1: reset high-speed USB device number 5 using dummy_hcd
[1256934.951628] gadget: high-speed config #1: Linux File-Backed Storage
[1256935.915155] usb 3-1: reset high-speed USB device number 5 using dummy_hcd
[1256935.951090] gadget: high-speed config #1: Linux File-Backed Storage
[1256936.095018] gadget: high-speed config #1: Linux File-Backed Storage
[1317073.396892] usb-storage 3-1:1.0: Quirks match for vid 0525 pid a4a5: 10000
[1317073.396995] scsi53 : usb-storage 3-1:1.0
[1317074.411883] scsi 53:0:0:0: Direct-Access Linux File-CD Gadget 0302 PQ: 0 ANSI: 2
[1317074.412669] sd 53:0:0:0: Attached scsi generic sg3 type 0
[1317074.431910] sd 53:0:0:0: [sdc] 8388608 512-byte logical blocks: (4.29 GB/4.00 GiB)
[1317074.443816] sd 53:0:0:0: [sdc] Write Protect is off
[1317074.443821] sd 53:0:0:0: [sdc] Mode Sense: 0f 00 00 00
[1317074.455839] sd 53:0:0:0: [sdc] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[1317074.551757] sdc: sdc1
[1317074.683704] sd 53:0:0:0: [sdc] Attached SCSI removable disk
The problem is that IO performance is very poor. Writing 200Mb file takes quite a while:
$ ls -lh file
-rw-rw-r-- 1 root del 206M Sep 4 09:34 file
$ time sudo cp file /mnt/tmp/
real 11m59.618s
user 0m0.000s
sys 0m0.260s
Which is about 300K/sec. However the same file on the same system is copied to a real USB flash in less than a minute.
Iotop shows something like this:
TID PRIO USER DISK READ DISK WRITE SWAPIN IO> COMMAND
9986 be/4 root 0.00 B/s 262.05 K/s 0.00 % 99.86 % cp file /mnt/tmp/
20651 be/4 root 51.77 K/s 238.95 K/s 0.00 % 93.23 % [file-storage]
Can anything be done to improve the performance of g_mass_storage-emulated USB drive?
PS: I am using kernel
$ uname -rm
3.2.0-4-686-pae i686
Same here.
After one night at 6:00 i had a solution for me.
modprobe g_mass_storage file=/home/del/img/flash stall=0 buflen=65536
This made up to 5MByte/sec
modprobe g_mass_storage file=/home/del/img/flash stall=0 nofua=1
This made up to 11MByte/sec
A combination of "buflen" and "nofua" did not really helped.
About "nufua" read here: http://lxr.free-electrons.com/source/drivers/usb/gadget/file_storage.c?v=3.5
Ultrasoft /

Resources