External USB hard drive doesn't unmount cleanly at shutdown
SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
External USB hard drive doesn't unmount cleanly at shutdown
I have a USB external hard drive. I'm not hot plugging or unplugging it.
My computer has two kinds of USB ports. The built in USB ports are USB1.1. Also, I've added a PCMCIA/Cardbus card (or whatever it's called now) that gives me some USB2.0 ports.
The problem is what occurs when I do shutdown -h now or ctl-alt-del. When the external drive is plugged into a built-in USB port, the drive is unmounted cleanly with no problems. If it's plugged into my USB2.0 PCMCIA adapter, the drive does not unmount cleanly -- it always fscks at the next boot.
I think the problem is that when I do a shutdown or ctl-alt-delete, my USB2.0 adapter gets shut down before the external hard drive gets unmounted. I can see this easily by watching the console in real time. The time stamps in the log files don't have enough resolution to show the exact sequence of events, but you can see what's happening more or less.
Question: In Slackware 12.2, how can I get my external hard drive unmounted before the system shutdown takes down the PCMCIA/Cardbus USB interface that's talking to the external drive? (One way is to do it manually -- I'm looking for something more automatic.)
From /var/log/messages:
Code:
Feb 18 15:29:20 barsoom shutdown[2878]: shutting down for system halt
Feb 18 15:29:20 barsoom init: Switching to runlevel: 0
Feb 18 15:29:27 barsoom sshd[2639]: Received signal 15; terminating.
Feb 18 15:29:27 barsoom logger: /etc/rc.d/rc.inet1: /sbin/route del default
Feb 18 15:29:27 barsoom logger: /etc/rc.d/rc.inet1: /sbin/ifconfig eth0 down
Feb 18 15:29:27 barsoom logger: /etc/rc.d/rc.inet1: /sbin/ifconfig lo down
Feb 18 15:29:27 barsoom kernel: pccard: card ejected from slot 0
Feb 18 15:29:27 barsoom kernel: ohci_hcd 0000:03:00.0: remove, state 1
Feb 18 15:29:27 barsoom kernel: usb usb3: USB disconnect, address 1
Feb 18 15:29:27 barsoom kernel: ohci_hcd 0000:03:00.0: USB bus 3 deregistered
Feb 18 15:29:27 barsoom kernel: ohci_hcd 0000:03:00.0: PCI INT A disabled
Feb 18 15:29:27 barsoom kernel: ohci_hcd 0000:03:00.1: remove, state 1
Feb 18 15:29:27 barsoom kernel: usb usb4: USB disconnect, address 1
Feb 18 15:29:27 barsoom kernel: ohci_hcd 0000:03:00.1: USB bus 4 deregistered
Feb 18 15:29:27 barsoom kernel: ohci_hcd 0000:03:00.1: PCI INT B disabled
Feb 18 15:29:27 barsoom kernel: ehci_hcd 0000:03:00.2: remove, state 1
Feb 18 15:29:27 barsoom kernel: usb usb5: USB disconnect, address 1
Feb 18 15:29:27 barsoom kernel: usb 5-2: USB disconnect, address 2
Feb 18 15:29:27 barsoom kernel: ehci_hcd 0000:03:00.2: USB bus 5 deregistered
Feb 18 15:29:27 barsoom kernel: ehci_hcd 0000:03:00.2: PCI INT C disabled
From /var/log/syslog:
Code:
Feb 18 15:29:27 barsoom kernel: Buffer I/O error on device sda1, logical block 7355
Feb 18 15:29:27 barsoom kernel: lost page write due to I/O error on sda1
Feb 18 15:29:27 barsoom kernel: Buffer I/O error on device sda1, logical block 7356
Feb 18 15:29:27 barsoom kernel: lost page write due to I/O error on sda1
Feb 18 15:29:27 barsoom kernel: REISERFS: abort (device sda1): Journal write error in flush_commit_list
Feb 18 15:29:27 barsoom kernel: REISERFS: Aborting journal for filesystem on sda1
I only discarded that idea when i read last block:
Quote:
Question: In Slackware 12.2, ... and so...
If it was about any major distro from nowadays, it'll must be reported, but treating as we must, slack, like it is....
I suggest you to look at rc.scripts(/etc/init.d ??), mainly rc4, 5, 6.., maybe opposite of rc.local (or it's been linked in reboot/shutdown levels???).. There you'll find scripts for this tweaking... Do you have hal or what managing automounts?? are you in stick group??.. so many to watch out!
Unfortunately, i had to leave slack when i move to amd64 machines, i find none of slack alternatives good enough and changed, so .. think cannot help you more than that, but don't forget it: "when in slack, you must manage it on your nail edge.."
I'm not sure what mounts my external hard drive at boot time. I don't hotplug it, it's always connected to the computer. The drive has one partition, the system's /home. It's reiserfs. I labelled it "colossus-home". I added the following line to /etc/fstab:
Code:
LABEL=colossus-home /home reiserfs defaults 1 2
The label feature allows Linux to recognize the partition and mount it as /home. It doesn't care if the partition is actually /dev/sda1 or /dev/sdb1 or whatever else.
Quote:
Originally Posted by armandrix
I suggest you to look at rc.scripts(/etc/init.d ??), mainly rc4, 5, 6..,\
Hmm, /etc/rc.d/rc.6 looks like the script that handles shutdowns. Looks promising. Thanks.
Last edited by DavidHindman; 02-18-2009 at 08:14 PM.
Nothing came flying out of my computer! My USB2.0 adapter is a PCMCIA/Cardbus/PCCARD card or whatever they're calling it this year. It's removeable and maybe theoretically ejectable. I'm guessing that it means the adapter card has been logically removed from the system.
Quote:
Originally Posted by bgeddy
.This script calls /etc/rc.d/rc.local_shutdown if it's there and executable which is where to put local shutdown code.
Thanks, that might be helpful. There are a few more steps that take place after rc.local_shutdown is called. I don't think any of those things require access to /home, so it might work.
I did something else as an experiment. I commented out the following code in /etc/rc.d/rc6:
Code:
# Shut down PCMCIA devices:
# DLH - commented out
#if [ -x /etc/rc.d/rc.pcmcia ]; then
# . /etc/rc.d/rc.pcmcia stop
# The cards might need a little extra time here to deactivate:
# /bin/sleep 5
#fi
I think commenting out this block might leave the PCMCIA/Cardbus/PCCARD USB2.0 interface up long enough for the external drive to get unmounted. Yes, two tests seem to show that the external drive now gets unmounted. There are no error messages in the system log files and the drive doesn't need an fsck at the next boot.
The problem is that I don't know what might be the unintended side effects of commenting out that block of code.
I'd read your answwers but cannot think much about it... sorry
Even for the first information that is very relevant...
I can see you mount your usb drive in the home diretory.,. very bad.. I.E. if you use kde desktop environment, it always have a process of konqueror sitting at your home directory...
Slackware needs a must muscle job to take rid of it cause none automounts can easily unmount a busy device..
After what you'd posted before, i can tell you to try to make it mounts it in a specific folder, like /home/fulano/ext-drive/ ... did you got it?? a folder that will be not busy at the "unmount time".. post here if it works,
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.