USB will not spin down when mounted

Hi all,

I’ve installed version 13.04 (timestamp 2013-05-29).
Configured the whole the system, gave it a static IP, etc.

I want to use the BBB as a rsync backup server.
I’m testing the USB drive (3TB, USB3) right now and running into a small issue.

I created a partition and filesystem (ext4) on the disk. In fstab I added this line:

/dev/sda1 /mnt/data ext4 defaults,noatime 0 0

When mounted is says:

/dev/sda1 2884024544 74736 2737443056 1% /mnt/data

So all looks good.

But when the drive is mounted, it refuses to spin down. Which ever tool I use (hdparm, sdparm and even hd-idle), all don’t work.

It looks like when the drive is mounted it has a hold on the drive and will not let go.
As soon as the drive is unmounted again it spin down almost instantly.

Is there a way to spin down the drive even if it is mounted?

For now I can adjust my script to unmount drive after backup and mount it when starting the backup, but I rather not.

Any help would be welcome!

Further investigation:

For testing I’ve changed the spindown idle time to 5 seconds.

hdparm -S 1 /dev/sda1

/dev/sda1:
setting standby to 1 (5 seconds)

And yes, the drive spins down. But unfortunately it starts to spin up right after the spindown. And 5 seconds later it does the same thing all over again.

Setting the spindown idle time back to 15 minutes:

hdparm -S 180 /dev/sda1

/dev/sda1:
setting standby to 180 (15 minutes)

And the drive keeps spinning.

lsof says that there are no processes running on the mountpoint (/mnt/data) or the disk (/dev/sda1).

I also followed these steps to ensure that nothing is running, that could access the drive.
http://info4admins.com/tips-to-spindown-your-hard-disk-in-debian-or-ubuntu/

I’m getting more and more the idea that there is some kernel process interfering or running a heartbeat on the mountpoint, because the access led on the USB HDD case is blinking every 5 seconds.

Is anybody else experiencing the same issue?

Any help is welcome!

Thx.

But when the drive is mounted, it refuses to spin down.

...

It looks like when the drive is mounted it has a hold on the drive and
will not let go. As soon as the drive is unmounted again it spin down
almost instantly.

perhaps some usb debugging will generate a clue? there are debug
switches in the kernel and i believe there is monitoring software that
can show every packet. perhaps seeing what data is sent to the drive
keeping it spun up will indicate who is sending it.

First, i’m pretty newbie at kernels and debugging.
Secondly, when I looked this morning the drive had spun down. It was in Standy mode.
Looks like the process who was polling the drive stopped.

It only takes a little longer then expected.

Well, I’m not sure how long it took. Went to bed :).
But I’m now working on second BBB setup with USB disk. And the following process is I think responsible.

17459 be/3 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [jbd2/sda1-8]

It keeps popping up every 5 seconds in iotop.

Google says it is a journaling agent for the harddrive. I think it was building a new journal or something like that. It would explain the refusal of going te sleep manually. It’s a 3TB disk, so it can take a while.

The initial setup I based the question on the disk was just formatted in Ext4. Now when I do a hdparm -S 1 /dev/sda it spins down in 5 seconds as expected.

I’m sure others with more embedded experience can say more about this.
Ext4 may not be your best choice but it really depends on your
requirements. I think ubifs may be targeted at embedded devices
but it’s fairly new. There have been some fairly visibile issues with
ext4 lately and I’m sure it gets used in production but I wouldn’t
use it. My long winded point is that any journaling fs will kick off
journaling and write to the device.

I don’t think UBIFS is the best solution for a traditional HDD. When I read the articles on UBIFS, it is more targeted for flash memory. For now I will stay on ext4.