0

I have a new hdd powered with external power plug It is attached to the usb 3.0 (new Pi from shop also)

hdd is ext4

problem:

I mount the hdd on the pi, fine. then I write some files, fine. then I reboot the pi. then ls -l to look at the pi, oh no it has zero files!

ls -l /disk/
ls: reading directory '/disk/': Input/output error
total 0

(reboot again, zero files) then I put the hdd into my laptop and I see all files are ok. then I put it back into the pi, and wow my files are back! but look:

ls: cannot access '/disk/Project': Input/output error
ls: cannot access '/disk/node_modules': Input/output error
d????????? ? ?    ?        ?            ? Project
drwxr-xr-x 3 me me  4096 Jan 31 17:23 SETTINGS
drwxr-xr-x 6 me me  4096 Jan 31 12:33 database_js
-rw-r--r-- 1 root root    21 Feb  4 21:40 ip.txt
drwx------ 2 root root 16384 Dec 17 15:06 lost+found
d????????? ? ?    ?        ?            ? node_modules
drwxr-xr-x 2 me me  4096 Feb  2 14:22 not_modules

so then I change permissions and ownership back to what it is suppose to be and everything is cool again.

ls -l /disk/
total 40
drwxr-xr-x   7 me me  4096 Feb  2 14:24 Project
drwxr-xr-x   3 me me  4096 Jan 31 17:23 SETTINGS
drwxr-xr-x   6 me me  4096 Jan 31 12:33 database_js
-rw-r--r--   1 root root    21 Feb  4 21:40 ip.txt
drwx------   2 root root 16384 Dec 17 15:06 lost+found
drwxr-xr-x 122 me me  4096 Oct 18 22:02 node_modules
drwxr-xr-x   2 me me  4096 Feb  2 14:22 not_modules

until I write to files, then the problem starts over again.

I see others have this problem with pi and ext4: https://superuser.com/questions/706186/format-an-external-drive-with-ext4

like I said all equipment is new.

sudo blkid
/dev/mmcblk0: PTUUID="579dffc1" PTTYPE="dos"
/dev/mmcblk0p1: LABEL_FATBOOT="boot" LABEL="boot" UUID="DC3E-E470" TYPE="vfat" PARTUUID="579dffc1-01"
/dev/mmcblk0p2: LABEL="rootfs" UUID="a7adb26a-8b87-4729-99c8-9f5ac069d51e" TYPE="ext4" PARTUUID="579dffc1-02"
/dev/sda1: LABEL="4" UUID="101a689d-3060-4c02-bbbe-886d96990686" TYPE="ext4" PARTUUID="0593da0a-01"

sudo fdisk -l
Disk /dev/sda: 931.5 GiB, 1000204883968 bytes, 1953525164 sectors
Disk model: super high speed
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x0593da0a

Device     Boot Start        End    Sectors   Size Id Type
/dev/sda1        2048 1953523711 1953521664 931.5G 83 Linux


sudo nano /etc/fstab
#UUID=101a689d-3060-4c02-bbbe-886d96990686 /disk ext4 defaults,auto,users,noatime,rw,exec,nofail 0 0
PARTUUID=0593da0a-01  /disk ext4 defaults,auto,users,noatime,rw,exec,nofail 0 0

does pi need extra software besides this installed to handle ext4?

sudo apt update
sudo apt install exfat-fuse

problem still happens

1
  • You should look at/edit in some of the output from dmesg right after you get one of those Input/output errors from ls (or anything). It implies a hardware issue, this will confirm (or at least rule out) that.
    – goldilocks
    Feb 7, 2021 at 16:41

1 Answer 1

1

The Pi handles ext4 perfectly. I would think your files are all owned by root with that arrangement of mounting it to some strange disk directory in the / of the file system. Installing a program designed to mount a different file system will not correct this problem. My external connected to my Pi.

root@buster-raspi:~# cat /etc/fstab 
# The root file system has fs_passno=1 as per fstab(5) for automatic fsck.
#LABEL=RASPIROOT / ext4 rw 0 1
PARTUUID=59097f66-f9fb-4a50-a491-8a71becaa2bd / ext4 rw 0 1
# All other file systems have fs_passno=2 as per fstab(5) for automatic fsck.
#LABEL=RASPIFIRM /boot/firmware vfat rw 0 2
PARTUUID=9fad4e77-177d-4a3c-929a-3897e6bc1810 /boot/firmware vfat rw 0 2

# Added for rtorrent files.
/dev/sdb1 /home/seeder1/rtorrent    ext4    defaults        0       2

# the /proc filesytem
proc /proc proc defaults 0 0

And the permissions on the mounted directory.

root@buster-raspi:~# ls -l /home/seeder1/
total 8
drwxr-xr-x  2 zeus zeus 4096 Jan 30 18:45 bin
drwxr-xr-x 13 zeus zeus 4096 Jan 30 19:58 rtorrent

This way every file newly created or moved/copied gets owned by my normal user. As well you have way to many options after the default mount option. The line in my fstab automatically mounts because it is in the fstab. That means no auto is needed for yours. The rw all mounts are read/write unless you tell it not to when mounted. The no atime is to prevent the access time from being written, a feature used with SSD drive to prevent excess wear. The users useless on a system like ours where we have single users of the machine, this is not in a data centre where multiple users will be accessing and possibly mounting the drive, the purpose of that setting. The exec included in the defaults too if wanting to prevent it then the noexec is used. The nofail the only useful option chosen by that line as it will allow the boot to continue if the drive is unavailable for mounting at boot. Oh the pass number is wrong it will never check the file system at boot, the second 0 should be 2. If the files created that have got the ?? to them when it happens, were they created by some process not owned by the user or root?

My recommendation to you would be to clean up the line make a directory as your /home/user_name/mount_point put it in the fstab and see if the problems persists. If necessary when it mounts the first time after the changes and it is owned by root, then.

sudo chown -R user_name:user_name /home/user_name/mount_point
3
  • this is a massive improvement! further tests indicate that the hdd is not receiving enough electricity. I will keep this updated as I get the situation figured out. Feb 8, 2021 at 18:59
  • I brought a portable hdd that connect to usb 3.0 with no power plug needed Feb 13, 2021 at 18:14
  • Depends on the power it needs from the Pi if it will work well, there is only 1.2A of power to be had from all those ports combined. That means 6W (1.2A * 5V) total power for all the ports, go over this and you are likely to have problems. Personally I use a lay down flat connector the hard drive goes into with its own power supply, I have had zero problems with it, connect my Mac keyboard and it all goes to hell during a boot, nothing but problems. These are lovely little machines but they definitely have their limitations.
    – user130167
    Feb 14, 2021 at 1:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.