Arch Linux

Please read this before reporting a bug:
https://wiki.archlinux.org/index.php/Reporting_Bug_Guidelines

Do NOT report bugs when a package is just outdated, or it is in Unsupported. Use the 'flag out of date' link on the package page, or the Mailing List.

REPEAT: Do NOT report bugs for outdated packages!
Tasklist

FS#12334 - [initscripts] ext3 partitions on external USB harddisks aren't autochecked (correctly) at boot time

Attached to Project: Arch Linux
Opened by Heiko Baums (cyberpatrol) - Wednesday, 03 December 2008, 23:06 GMT
Last edited by Roman Kyrylych (Romashka) - Monday, 06 September 2010, 16:44 GMT
Task Type Bug Report
Category Packages: Core
Status Closed
Assigned To Tobias Powalowski (tpowa)
Thomas Bächler (brain0)
Architecture All
Severity Medium
Priority Normal
Reported Version None
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 3
Private No

Details

Description:
ext3 partitions on external USB harddisks aren't (correctly) autochecked by fsck at boot time.

These are my fstab entries for my USB harddisk:
UUID=38db5cc2-8e5c-40dc-8498-be4450691ffe /mnt/hdd1 ext3 noatime,noauto 0 4
UUID=f872467d-a0a0-47aa-a604-922790674f23 /mnt/hdd2 ext3 noauto,noatime,users,exec 0 5

This is the message I get during boot:
:: Checking Filesystems [BUSY]
/dev/hda4: clean: 270211/550528 files, 1727108/2200905 blocks
/dev/hda2: clean: 504024/3662848 files, 2249754/7325640 blocks
/dev/hda3: clean: 51823/14663680 files, 7355952/29298543 blcks


***************** FILESYSTEM CHECK FAILED ****************
* *
* Please repair manually and reboot. Note that the root *
* file system is currently mounted read-only. To remount *
* it read-write type: mount -n -o remount,rw / *
* When you exit the maintenance shell the system will *
* reboot automatically. *
************************************************************

Give root password for maintenance
(or type Control-D to continue):


After typing Ctrl-D the system reboots.

The partitions on my external harddisk are in fact clean, because I've checked them manually before I changed the passno values > 0 in /etc/fstab, and on Gentoo they are also autochecked at boot time.

If I change pass to 0 for both partitions the system boots without any problems, and these partitions can be mounted without a hitch.
This task depends upon

Closed by  Roman Kyrylych (Romashka)
Monday, 06 September 2010, 16:44 GMT
Reason for closing:  No response
Additional comments about closing:  No response in 6 months. There is a "sleep" hook in mkinitcpio now, and there are hooks support on [initscripts], workarounds can be used. Please reopen if necessary.
Comment by Thomas Bächler (brain0) - Thursday, 04 December 2008, 09:55 GMT
This looks like a timing issue again. After the USB device has been recognized and the module has been loaded, it takes almost 10 seconds until the hard drive shows up in /dev, which causes all kinds of annoying problems.
Comment by Heiko Baums (cyberpatrol) - Thursday, 04 December 2008, 11:59 GMT
Don't tell me Archlinux is too fast. :-D
Comment by Thomas Bächler (brain0) - Thursday, 04 December 2008, 12:15 GMT
Edit your rc.sysinit, insert a "sleep 5" or "sleep 10" before the fsck section and I bet it'll work.

I have no idea why this delay exists for USB storage, but it is annoying in many places, especially because the only workaround I know is inserting arbitrary sleep calls.
Comment by Heiko Baums (cyberpatrol) - Thursday, 04 December 2008, 16:49 GMT
You're right, but "sleep 4" is sufficient for my computer. ;-)
Comment by Glenn Matthys (RedShift) - Friday, 05 December 2008, 14:01 GMT
Another option would be to move the USB controller and mass storage modules to MODULES in mkinitcpio.conf and regenerate your initcpio. That'll load the modules even before rc.sysinit gets executed, there may be just enough time between the initial ramdisk and rc.sysinit to have your USB harddrives ready for access at fsck time.

Relying on this behaviour is not a proper solution by any means.
Comment by Heiko Baums (cyberpatrol) - Friday, 05 December 2008, 20:30 GMT
This option does also work. But somehow I find the sleep option a bit easier. On the other hand the mkinitcpio option is not overwritten when initscripts is updated.
Comment by Heiko Baums (cyberpatrol) - Friday, 05 December 2008, 20:31 GMT
Oh, should be the same since both mkinitcpio.conf and rc.sysinit are protected since they are in /etc.
Comment by Thomas Bächler (brain0) - Friday, 05 December 2008, 20:36 GMT
Both sound a bit hackish. I'd love to see a better solution for these USB things.
Comment by Heiko Baums (cyberpatrol) - Saturday, 06 December 2008, 00:00 GMT
I found the problem. It was my or the wiki's fault.

I hadn't had usb in the hooks.

This is what http://wiki.archlinux.org/index.php/Configuring_mkinitcpio says about the usb hook:

Hook: USB
Installation: Adds USB modules to the image. Use this if your root device is on a USB mass storage device.
Runtime: Loads USB modules. You will need the udev or modload hook unless you specify the needed modules manually (see MODULES section below).

Because I don't have a root device on my external USB harddisk, I thought this isn't necessary. When I installed Archlinux I was new to Archlinux and mkinitcpio, so I had to rely on the wiki.

I changed the wiki to this:
Installation: Adds USB modules to the image. Use this if your root device is on a USB mass storage device or if your USB mass storage device needs to be accessed otherwise (checked, mounted, etc.) at boot time.

Please correct my English. I know it's not the best. ;-)
Comment by Heiko Baums (cyberpatrol) - Saturday, 06 December 2008, 00:08 GMT
This is the mkinitcpio output at boot time, after adding the usb hook to mkinitcpio.conf:

:: Running Hook [usb]
:: Running Hook [keymap]
:: Loading keymap...done.
:: Running Hook [filesystems]
:: Loading root filesystem module...ext3
Waiting for devices to settle...scsi 0:0:0:0: Direct-Access SAMSUNG HD501LJ PQ: 0 ANSI: 2
Driver 'sd' needs updating - please use bus_type methods
sd 0:0:0:0: [sda] 976773168 512-byte hardware sectors (500108 MB)
sd 0:0:0:0: [sda] Write Protect is off
sd 0:0:0:0: [sda] Assuming drive cache: write through
sd 0:0:0:0: [sda] 976773168 512-byte hardware sectors (500108 MB)
sd 0:0:0:0: [sda] Write Protect is off
sd 0:0:0:0: [sda] Assuming drive cache: write through
sda: sda1 sda2
sd 0:0:0:0: [sda] Attached SCSI disk
done.
:: Initramfs Completed - control passing to kinit

See especially this: "Waiting for devices to settle..."

But there's also this message: "Driver 'sd' needs updating - please use bus_type methods"
I don't know, what that means. Maybe it's a different issue in mkinitcpio.
Comment by Thomas Bächler (brain0) - Saturday, 06 December 2008, 08:24 GMT
That is still not the right solution. As you don't boot from the USB drive, it shouldn't be necessary to wait for it (or even have the driver in initramfs).
Comment by Heiko Baums (cyberpatrol) - Saturday, 06 December 2008, 12:37 GMT
It doesn't matter, if you boot from the USB drive or if you have to access it at boot time for other reasons. As soon as you need to access it anyway the drive needs to be ready and the appropriate modules need to be loaded. And if the initscripts are faster than the hardware or udev, the initscripts or the kernel just have to wait for the hardware or udev until they are ready. I don't see an alternative.

The question is, if this has to be done in the initramfs or if this could be done somehow else in the initscripts.

In my opinion the cleanest and probably fastest method is the usb hook. I haven't checked it yet, but I think the few modules don't make the initrd image so much bigger.

Another option would be to move the fsck part in rc.sysinit down. But this is not possible, because the partitions have to be checked before they are mounted rw.
Comment by Thomas Bächler (brain0) - Sunday, 25 January 2009, 10:42 GMT
I have a workaround for you: You can disable the 5 second wait between finding the usb-storage and enabling the hard drive. There must be a reason for this delay, but I tried it and it worked with 3 different devices - this was a nice new experience, I simply plugged it in and it showed up in hal INSTANTLY. This will (if it works) fix all your timing problems:

Add this line to /etc/modprobe.conf (if USB is enabled in initramfs, then this file also has to be added there):
options usb-storage delay_use=0
Comment by Heiko Baums (cyberpatrol) - Sunday, 25 January 2009, 14:06 GMT
Thanks for the info.

In the meantime I don't need my external harddisk for daily use anymore, because I needed to buy a new mainboard, CPU and therefore a new and of course bigger harddisk. So now I need my external harddisk only as a backup medium.

And the fs_passno field in fstab can be indeed set to 0 for ext3 partitions from what I read here: http://www.ibm.com/developerworks/linux/library/l-fs7.html
It's because ext3 seems to check and fix the consistency of the filesystem by itself, and therefore doesn't need an explicit fsck anymore.

It can be read in forums and wikis once in a while, that fs_passno can be 0, but usually it's not explained why. So I wasn't sure about this and just tried to set fs_passno to >0. But now I think it's not necessary.

Nevertheless there are other filesystems, which need an explicit fsck and therefore need your workaround.
Comment by markus (markuman) - Tuesday, 22 September 2009, 14:31 GMT
this happen on an ext2 usb device too!
http://www.pastie.org/625895
Comment by markus (markuman) - Tuesday, 22 September 2009, 14:39 GMT
in additional: arch is installed of this ext2 usb device...
Comment by Thomas Bächler (brain0) - Tuesday, 22 September 2009, 16:56 GMT
With the next version of initscripts, you can hook up a small piece of code before the filesystem check that allows you to wait until the device shows up. I need to fix a few things before the release, but this can ultimately be a good solution.
Comment by Paul Mattal (paul) - Saturday, 06 March 2010, 03:19 GMT
Is this the hook system from this and subsequent commits?

http://projects.archlinux.org/initscripts.git/commit/?id=cfabb85924f35c636550609b332d088aaae9941f

If so, should this now be closed?

Loading...