Issue when shutting down computer: internal hard drive is not shut down properly

Bug #2053041 reported by angros47
36
This bug affects 6 people
Affects Status Importance Assigned to Milestone
linux (Ubuntu)
Fix Released
Undecided
Unassigned
Mantic
Fix Released
High
Unassigned

Bug Description

After the last kernel upgrade, I noticed that, in the S.M.A.R.T. monitor, parameter ID 192 "Power Off Retract Count" increased every time I turned off the system. I also noticed the "click" of the head parking when shutting down the computer. By restarting the computer with previous kernel version (6.5.0-15.15~22.04.1) the issue didn't happen, so I assume it's a kernel bug, that causes it to shut down the computer before hard drive is deactivated

ProblemType: Bug
DistroRelease: Ubuntu 22.04
Package: linux-image-6.5.0-17-generic 6.5.0-17.17~22.04.1
ProcVersionSignature: Ubuntu 6.5.0-17.17~22.04.1-generic 6.5.8
Uname: Linux 6.5.0-17-generic x86_64
ApportVersion: 2.20.11-0ubuntu82.5
Architecture: amd64
CasperMD5CheckResult: unknown
CurrentDesktop: XFCE
Date: Tue Feb 13 16:35:55 2024
InstallationDate: Installed on 2020-10-02 (1228 days ago)
InstallationMedia: Ubuntu 20.04.1 LTS "Focal Fossa" - Release amd64 (20200731)
SourcePackage: linux-signed-hwe-6.5
UpgradeStatus: Upgraded to jammy on 2022-08-11 (550 days ago)

Revision history for this message
angros47 (angros47) wrote :
Revision history for this message
RJ (rvr6) wrote (last edit ):

I just bought new drives for 2k dollars because of this.
Then I realised it was this kernel update.

Can confirm, retracts (192) and hdd's gets hard shutdowns.

(Power cycle) also increases as if the PC had power loss.

This will break many old drives!

Backing to previous kernel solves it.

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in linux-signed-hwe-6.5 (Ubuntu):
status: New → Confirmed
no longer affects: linux-signed-hwe-6.5 (Ubuntu)
Changed in linux (Ubuntu Mantic):
importance: Undecided → High
Revision history for this message
Matthew Ruffell (mruffell) wrote :

Hi everyone,

Would it be possible if you could try 6.8-rc4 mainline to see if the issue is fixed there?

https://kernel.ubuntu.com/mainline/v6.8-rc4/

$ wget https://kernel.ubuntu.com/mainline/v6.8-rc4/amd64/linux-headers-6.8.0-060800rc4-generic_6.8.0-060800rc4.202402112032_amd64.deb
$ wget https://kernel.ubuntu.com/mainline/v6.8-rc4/amd64/linux-headers-6.8.0-060800rc4_6.8.0-060800rc4.202402112032_all.deb
$ wget https://kernel.ubuntu.com/mainline/v6.8-rc4/amd64/linux-image-unsigned-6.8.0-060800rc4-generic_6.8.0-060800rc4.202402112032_amd64.deb
$ wget https://kernel.ubuntu.com/mainline/v6.8-rc4/amd64/linux-modules-6.8.0-060800rc4-generic_6.8.0-060800rc4.202402112032_amd64.deb
$ sudo dpkg -i ./linux-*
$ sudo reboot

I had a look at the differences between 6.5.0-15-generic and 6.5.0-17-generic, and the number of ata, sata, scsi changes is huge. There seems to have been a real refactor of scsi in 6.6, and they all got marked for 6.5 stable, so they got pulled in.

https://paste.ubuntu.com/p/8VCbhBmDjj/

I will try reproduce in the lab tomorrow. None of my systems at home have spinning disks, you see.

If I can't see it in the lab, would anyone be interested in helping me git bisect? I will build the kernels, you just need to test them and say if they are good or bad.

Please try 6.8-rc4 mainline and see if its still an issue. If it is, we will talk to the ata and scsi subsystem maintainers.

Thanks,
Matthew

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in linux (Ubuntu Mantic):
status: New → Confirmed
Changed in linux (Ubuntu):
status: New → Confirmed
Revision history for this message
angros47 (angros47) wrote (last edit ):

Meanwhile, on Ubuntu 22.04, what should I do to work around the issue?

Is version 6.5.0-18.18~22.04.1 unaffected by it? Or is it affected as well?

Revision history for this message
Alex Desh (tutralex) wrote :

Kernel 6.5.0-18.18 - the problem is not solved, the HDD heads park loudly in an emergency.

Revision history for this message
Matthew Ruffell (mruffell) wrote :

I tried on a random lab machine with 2x HP MM0500GBKAK disks.

With 6.5.0-18-generic:

Before:

SMART Attributes Data Structure revision number: 10
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE
...
  4 Start_Stop_Count 0x0032 100 100 020 Old_age Always - 293
...
 12 Power_Cycle_Count 0x0032 100 100 020 Old_age Always - 293
...
192 Power-Off_Retract_Count 0x0032 100 100 000 Old_age Always - 292
...

and after:

SMART Attributes Data Structure revision number: 10
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE
...
  4 Start_Stop_Count 0x0032 100 100 020 Old_age Always - 294
...
 12 Power_Cycle_Count 0x0032 100 100 020 Old_age Always - 294
...
192 Power-Off_Retract_Count 0x0032 100 100 000 Old_age Always - 293
...

Seems Power-Off_Retract_Count increments regardless.

I rolled back to 6.5.0-15-generic, and saw the same behaviour.

I think I need to try a different lab machine with different disks.

Thanks,
Matthew

Revision history for this message
wuguangkai (wuguangkai211) wrote :

I can confirm this issue on Ubuntu 23.10 x86_64 6.5.0-17-generic, with Seagate Mobile HDD ST1000LM035-1RK172 (LCM2).

When I switched back to kernel 6.5.0-15, that strange "click" noise disappeared.

To set the older kernel as default, please refer to this link below:

https://askubuntu.com/questions/216398/set-older-kernel-as-default-grub-entry/1000735#1000735

Revision history for this message
angros47 (angros47) wrote :

Is there any relation with this one?

https://bugs.archlinux.org/task/80064

Revision history for this message
Alex Desh (tutralex) wrote :

Kernel 6.5.0-21 - the problem is not solved, the HDD heads park loudly in an emergency. Why is it that after 2 releases of the kernel the problem is still not fixed and you continue to break users’ hard drives?

Revision history for this message
Matthew Ruffell (mruffell) wrote :

Hi everyone,

@angros47, yes, this issue looks to be what you are experiencing here.

https://bugs.archlinux.org/task/80064 mentions that the issue was introduced in:

commit aa3998dbeb3abce63653b7f6d4542e7dcd022590
Author: Damien Le Moal <email address hidden>
Date: Sat Aug 26 09:43:39 2023 +0900
Subject: ata: libata-scsi: Disable scsi device manage_system_start_stop
Link: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=aa3998dbeb3abce63653b7f6d4542e7dcd022590

This was first included in... 6.5.0-17-generic.

The bug mentions the fix is:

commit 24eca2dce0f8d19db808c972b0281298d0bafe99
Author: Damien Le Moal <email address hidden>
Date: Wed Oct 25 15:46:12 2023 +0900
Subject: scsi: sd: Introduce manage_shutdown device flag
Link: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=24eca2dce0f8d19db808c972b0281298d0bafe99

This is currently queued up for 6.5.0-25-generic, which is currently in -proposed for mantic, and is currently being built for jammy.

If you are on mantic / 23.10, please try the -proposed kernel:

Instructions to Install (On a mantic system):
1) cat << EOF | sudo tee /etc/apt/sources.list.d/ubuntu-$(lsb_release -cs)-proposed.list
# Enable Ubuntu proposed archive
deb http://archive.ubuntu.com/ubuntu/ $(lsb_release -cs)-proposed main universe
EOF
2) sudo apt update
3) sudo apt install linux-image-6.5.0-25-generic linux-modules-6.5.0-25-generic linux-modules-extra-6.5.0-25-generic linux-headers-6.5.0-25-generic
4) sudo rm /etc/apt/sources.list.d/ubuntu-$(lsb_release -cs)-proposed.list
5) sudo apt update
6) sudo reboot
7) uname -rv
6.5.0-25-generic #25-Ubuntu SMP PREEMPT_DYNAMIC Wed Feb 7 14:58:39 UTC 2024

For jammy / 22.04 users, I have built 6.5.0-21-generic with the fix ontop of it, for anyone who wants to try it and report back that it actually fixes the issue.

Please note this package is NOT SUPPORTED by Canonical, and is for TESTING
PURPOSES ONLY. ONLY Install in a dedicated test environment.

Instructions to Install (On a jammy system):
1) sudo add-apt-repository ppa:mruffell/lp2053041-test
2) sudo apt update
3) sudo apt install linux-image-unsigned-6.5.0-21-generic linux-modules-6.5.0-21-generic linux-modules-extra-6.5.0-21-generic linux-headers-6.5.0-21-generic
4) sudo reboot
5) uname -rv
6.5.0-21-generic #21~22.04.1+TEST2053041v20240226b1-Ubuntu SMP PREEMPT_DYNAMIC Mo

If asked to abort removing the running kernel, say no.

You can also wait, and I'll write back when 6.5.0-25-generic enters -proposed for Jammy, will be a day or two.

If the patch works, then the kernel SRU cycle will complete in the first week of March, as per https://kernel.ubuntu.com/, so you don't have too much longer to wait until 6.5.0-25-generic becomes available.

Thanks,
Matthew

Changed in linux (Ubuntu):
status: Confirmed → Fix Released
Changed in linux (Ubuntu Mantic):
status: Confirmed → Fix Committed
Revision history for this message
angros47 (angros47) wrote :

Has the new version been released?

Revision history for this message
Matthew Ruffell (mruffell) wrote :

Yes, 6.5.0-25-generic is available for both jammy and mantic systems. It was released earlier this week.

Is anyone able to try it out and let me know if it fixes the issue? Thanks.

Changed in linux (Ubuntu Mantic):
status: Fix Committed → Fix Released
Revision history for this message
Norbert (norbert-r78) wrote :

In my case, the problem is solved.

Revision history for this message
Alireza Jafari (mr-jef) wrote :

@mruffell, I tried it on Kubuntu 23.10, seems that the bug has been fixed.

Revision history for this message
angros47 (angros47) wrote :

Yes, it seems so!

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.