[9fans] Unmount a USB stick? - Plan9

This is a discussion on [9fans] Unmount a USB stick? - Plan9 ; I've got a USB stick that I've been using to shuttle a few docs around. I googled a bit and I've been using: % usb/disk -l % usbfat: to mount the stick. That works all well and good, but how ...

+ Reply to Thread
Results 1 to 9 of 9

Thread: [9fans] Unmount a USB stick?

  1. [9fans] Unmount a USB stick?

    I've got a USB stick that I've been using to shuttle a few docs
    around. I googled a bit and I've been using:

    % usb/disk -l
    % usbfat:

    to mount the stick. That works all well and good, but how do I go
    about ejecting it gracefully? I've tried:

    % unmount /n/usb
    % unmount /n/disk

    But have no idea if that's the right way to go about it. Additionally
    if I eject it in this manner the next time I try to mount it using the
    first two commands I get a bunch of usb errors.

    Also, why is the disk only available from the rc window that I used to
    mount it? In any other rc window I can't access the /n/usb mountpoint.
    I realize I'm probably missing something fundamental about plan 9
    (newbie here).

    - Devrin


  2. Re: [9fans] Unmount a USB stick?

    >
    > % unmount /n/usb
    > % unmount /n/disk
    >
    > But have no idea if that's the right way to go about it. Additionally
    > if I eject it in this manner the next time I try to mount it using the
    > first two commands I get a bunch of usb errors.


    you have to restart usbd. usbd doesn't handle device ejection as far
    as i can tell.

    > Also, why is the disk only available from the rc window that I used to
    > mount it? In any other rc window I can't access the /n/usb mountpoint.
    > I realize I'm probably missing something fundamental about plan 9
    > (newbie here).


    this is because rio puts each window in a sepeate namespace. there are
    two ways around this. first, start this before you start rio. (alternatively
    use the plumber to give all new windows access. plumb a string like
    Local 'cmd for everyone to see'
    ) alternatively, you can use /srv to post the fd.

    - erik


  3. Re: [9fans] Unmount a USB stick?

    // ...why is the disk only available from the rc window
    // that I used to mount it?

    Each rio window gets its own namespace from rio. Changes in
    one will not affect others; this is central to the Plan 9's per-
    process namespaces.

    srvfs(4) is often useful for getting portions of one namespace
    into another.
    Anthony



  4. Re: [9fans] Unmount a USB stick?

    I believe dossrv (which implements the fat filesystem) is synchronous,
    so you shouldn't have to do anything special before removing the
    stick. What are the errors you get the next time you try to mount the
    stick?

    > you have to restart usbd. usbd doesn't handle device ejection as
    > far as i can tell.


    I'm pretty sure that it's more nuanced than that. I've been able to
    eject and re-insert usb devices on uhci interfaces. I think the
    problems with usbd not noticing device additions and removals is
    limited to ohci interfaces, and I'm not sure why yet.


  5. Re: [9fans] Unmount a USB stick?

    > I'm pretty sure that it's more nuanced than that. I've been able to
    > eject and re-insert usb devices on uhci interfaces. I think the
    > problems with usbd not noticing device additions and removals is
    > limited to ohci interfaces, and I'm not sure why yet.


    this very well could be. i have not been able to do much testing
    with intel-style usb.

    - erik


  6. Re: [9fans] Unmount a USB stick?

    On Thu, Apr 3, 2008 at 6:28 PM, wrote:
    > I believe dossrv (which implements the fat filesystem) is synchronous,
    > so you shouldn't have to do anything special before removing the
    > stick. What are the errors you get the next time you try to mount the
    > stick?


    If I have mounted the stick, then try to exit the rc window with which
    I mounted it:

    % exit

    the window hangs indefinitely. If I delete the window, remove the
    stick, reinsert it, then in a new rc window type:

    % echo kill > /proc/86/notes # 86 is the pid of usbd
    % usb/usbd
    % usb/disk -l
    usb/disk: describedevice: error reading usb device descriptor, got 0 of 18:

    usb/disk: maxlun 0

    and a few black boxes in the upper left of my screen with messages such as:

    CleanTD 1/0: Error 00000001 ...

    Usually at this point I just end up restarting the box, and I'll be
    able to use the stick once again.

    - Devrin


  7. Re: [9fans] Unmount a USB stick?

    >
    > % echo kill > /proc/86/notes # 86 is the pid of usbd
    > % usb/usbd
    > % usb/disk -l
    > usb/disk: describedevice: error reading usb device descriptor, got 0 of 18:
    >
    > usb/disk: maxlun 0
    >
    > and a few black boxes in the upper left of my screen with messages such as:
    >
    > CleanTD 1/0: Error 00000001 ...
    >
    > Usually at this point I just end up restarting the box, and I'll be
    > able to use the stick once again.


    trick 'o the day: keep kernel messages from messing with rio:
    window -hide rc -c 'label kmesg ; tail -f /dev/kprint'
    as long as you have someone reading kernel messages, they won't
    be written directly to the screen.

    what happens when you do the following:

    slay usbd|rc
    slay disk|rc
    usb/usbd; usb/disk -l


    - erik


  8. Re: [9fans] Unmount a USB stick?

    On Thu, Apr 3, 2008 at 8:41 PM, erik quanstrom wrote:
    > trick 'o the day: keep kernel messages from messing with rio:
    > window -hide rc -c 'label kmesg ; tail -f /dev/kprint'
    > as long as you have someone reading kernel messages, they won't
    > be written directly to the screen.


    Thanks!

    > what happens when you do the following:
    >
    > slay usbd|rc
    > slay disk|rc
    > usb/usbd; usb/disk -l


    % usb/usbd; usb/disk -l
    usb/disk: maxlun 0

    But then I try

    % usbfat:
    mount: mount /n/usb: '/n/disk/0' i/o on hungup channel

    Is that an effect of me killing the window earlier?


  9. Re: [9fans] Unmount a USB stick?

    > Additionally
    > if I eject it in this manner the next time I try to mount it using the
    > first two commands I get a bunch of usb errors.


    There is a problem with usbd (and uhci?) on reinsertion of some
    but not all devices. Also the usbfat: script makes an entry in '#s'
    which needs to be cleaned up. You should find this works to undo
    everything so the usb disk can be removed and reinserted:

    unmount /n/usb
    unmount /n/disk
    rm /srv/usbfat.$user
    kill usbd | rc
    usb/usbd

    > Also, why is the disk only available from the rc window that I used to
    > mount it?


    To see the disk in another window, just type usbfat: there -- the
    script uses the /srv/usbfat.$user entry to check for an existing service.



+ Reply to Thread