5

I have a Raspberry PI to which an external 1T hard drive is attached by USB. The USB drive works fine if it is formatted in FAT but if I format the drive in ext4 the drive does not mount correctly and it gives me all sorts of error. This is what I do:

fdisk -l

and the result is

Device Boot      Start         End      Blocks   Id  System
/dev/sda1               2  1953525167   976762583   83  Linux

then I run

mkfs.ext4 /dev/sda1

and this runs and does what it does without any erros. then I mount the drive by

mount /dev/sda1 /mnt/external1

and this takes a little while but it returns with no error. Two things happen here. If I do a ls /mnt/external1 I get the following error:

ls: reading directory /mnt/external1: Input/output error

the other thing that happens in that if I do a fdisk -l I will get this now:

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               2  1953525167   976762583   83  Linux

my disk is now moved to sdb1 and if I try to mount sdb1 the same errors happen and the disk reappear under sda1.

What am I doing wrong?

Here is the output from dmesg

[98931.054218] usb 1-1.2: New USB device found, idVendor=13fd, idProduct=1340
[98931.054254] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[98931.054274] usb 1-1.2: Product: External        
[98931.054290] usb 1-1.2: Manufacturer: Generic 
[98931.054308] usb 1-1.2: SerialNumber: 533144464256454C20202020
[98931.055405] usb-storage 1-1.2:1.0: USB Mass Storage device detected
[98931.058815] scsi12 : usb-storage 1-1.2:1.0
[98932.054219] scsi 12:0:0:0: Direct-Access     Generic  External         2.10 PQ: 0 ANSI: 4
[98932.055913] smsc95xx 1-1.1:1.0 eth0: link up, 100Mbps, full-duplex, lpa 0x45E1
[98932.056737] sd 12:0:0:0: [sdb] 1953525168 512-byte logical blocks: (1.00 TB/931 GiB)
[98932.058233] sd 12:0:0:0: [sdb] Write Protect is off
[98932.058270] sd 12:0:0:0: [sdb] Mode Sense: 21 00 00 00
[98932.059724] sd 12:0:0:0: [sdb] No Caching mode page found
[98932.059763] sd 12:0:0:0: [sdb] Assuming drive cache: write through
[98932.066927] sd 12:0:0:0: [sdb] No Caching mode page found
[98932.066967] sd 12:0:0:0: [sdb] Assuming drive cache: write through
[98932.090896]  sdb: sdb1
[98932.096586] sd 12:0:0:0: [sdb] No Caching mode page found
[98932.096629] sd 12:0:0:0: [sdb] Assuming drive cache: write through
[98932.096654] sd 12:0:0:0: [sdb] Attached SCSI disk
[98935.392602] Buffer I/O error on device sda1, logical block 121667584
[98935.392632] lost page write due to I/O error on sda1
[98935.392651] JBD2: Error -5 detected when updating journal superblock for sda1-8.
[98935.392822] Aborting journal on device sda1-8.
[98935.392857] Buffer I/O error on device sda1, logical block 121667584
[98935.392872] lost page write due to I/O error on sda1
[98935.392887] JBD2: Error -5 detected when updating journal superblock for sda1-8.
[98970.278132] EXT4-fs warning (device sda1): __ext4_read_dirblock:908: error reading directory block (ino 2, block 0)
[98970.278186] EXT4-fs error (device sda1): __ext4_journal_start_sb:62: Detected aborted journal
[98970.300661] EXT4-fs (sda1): Remounting filesystem read-only
Farzad
  • 151
  • Please provide dmesg | tail output. – Sepahrad Salour Jan 24 '14 at 06:20
  • Smells damaged, run fsck on it. – Bobby Jan 24 '14 at 14:03
  • that's the thing. if I format the same disk as fat or ntfs everything works fine! – Farzad Jan 24 '14 at 15:25
  • I tried the same hard disk with fedora live cd on my computer and it mounted with no problem. This seems to be either a Raspberry Pi issue or Raspbian – Farzad Jan 25 '14 at 03:44
  • NTFS and FAT32 are the two most stupid filesystems out there...I would not trust it with my data and I would not trust it if it tells me "everything's cool dude". From here it looks like your harddisk is damaged. – Bobby Jan 25 '14 at 21:13
  • Bobby, thanks for the info. I had a hunch about the NTFS and FAT32. However, as I mentioned the same hard disk works fine with I attach it to my PC booted with a live Fedora disk. The disk is fine. I am 100% sure of that. – Farzad Jan 27 '14 at 01:01

4 Answers4

4

To create the partition I used fdisk by invoking sudo fdisk /dev/sda the interactive session is easy to follow :

Command (m for help): d 

Selected partition 1 Partition 1 has been deleted.

Command (m for help): n 

Partition number (1-128, default 1): First sector (34-1953525134, default 2048): 34 Last sector, +sectors or
+size{K,M,G,T,P} (34-1953525134, default 1953525134):


Command (m for help): w 

The partition table has been altered. Calling ioctl() to re-read partition table. Syncing disks.

Next, I formatted the partition:

pi@retina:~ $ sudo mkfs.ext4 /dev/sda1 

mke2fs 1.42.12 (29-Aug-2014) Creating filesystem with 244190637 4k blocks and 61054976 inodes Filesystem UUID: fe042d87-3266-44b5-beff-a98f70b783ed Superblock backups stored on blocks:    32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,     4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,     102400000, 214990848

Allocating group tables: done Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done

Created a new partition 1 of type 'Linux filesystem' and of size 931.5 GiB.

finally I ejected the drive:

sudo eject /dev/sda

to re-connect it, such that it appears now in the mount table.

nelson2tm
  • 956
meduz
  • 357
1

I also had problems with ext4 and the raspberry pi (3), when trying to format a usb stick with

sudo mkfs.ext4 /dev/sda1

(after creating a gpt table and a linux partition with fdisk)

This was my error message:

Warning, had trouble writing out superblocks.

FAT however worked.

So I tried to format the usb stick with gparted on another pc and when it worked I checked for the command gparted was using and tried to format the usb sick with this command on my raspberry pi. It still took some time (about a minute) but it worked.

sudo mkfs.ext4 -F -O ^64bit -L "YOUR_LABEL" /dev/sda1
0

You can also use parted for this purpose. I formatted two external disks with parted as ext4 and they work well.

Before you plug the device run ls -t /dev | grep sd and run it again after you plug and note the device letter (I'll use sdX). Unmount the drive if it is automatically mounted (it will have a partition number when mounted):

sudo umount /dev/sdX1

Run parted without the partition number an as root:

sudo parted /dev/sdX

mklabel gpt
mkpart primary
mkpart primary ext 0% 100%
quit

And format it (with partition number):

mkfs.ext4 /dev/sdX1

Now plug and unplug the device, if does not mount automatically, mount it as root. Note that, since Rpi is a low power consuming device, USB port does not feed an external HDD which does not have separate power supply.

S.C
  • 339
  • 1
  • 5
0

Use tune2fs command to adjust some parameters:

  1. tune2fs -m 0 /dev/sda1
  2. tune2fs -L bakap01 /dev/sda1

The -m option is for adjusting the percentage of reserved blocks. The reserved blocks are used by privileged processes which is by default 5% of the hard disk size. (I assume) Since you are using the external hard disk solely as a storage, I set this to 0 so I can also use those 5% for storage. The -L option is for labeling the file system.