Find the answer to your Linux question:
Results 1 to 9 of 9
I am mounting a USB flash drive to my FreeBSD 6.2 box in order for it to be used to boot FreeBSD from it. When trying to set the filesystem ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux User
    Join Date
    Dec 2004
    Posts
    323

    failed to open disk for writing


    I am mounting a USB flash drive to my FreeBSD 6.2 box in order for it to be used to boot FreeBSD from it. When trying to set the filesystem I get the following error:
    Code:
    [root@athens /dev]# newfs -U -L FreeBSDonUSB /dev/da0
    newfs: /dev/da0: failed to open disk for writing
    I have not found a way to get around this problem. How do I open a disk for writing?

    Thanks in advance

  2. #2
    Linux Guru anomie's Avatar
    Join Date
    Mar 2005
    Location
    Texas
    Posts
    1,692
    Check
    Code:
    $ dmesg | grep da
    to be sure we're really talking about /dev/da0.

    If so, I think you want /dev/da0s1 (which is slice 1).

  3. #3
    Linux User
    Join Date
    Dec 2004
    Posts
    323
    Thanks for the response, and for your information, here is some more output:
    Code:
    [root@athens /dev]# dmesg | grep da
    da0 at umass-sim0 bus 0 target 0 lun 0
    da0: < USB Flash Memory 5.00> Removable Direct Access SCSI-0 device
    da0: 40.000MB/s transfers
    da0: 983MB (2013184 512 byte sectors: 64H 32S/T 983C)
    [root@athens /dev]# newfs -U -L FreeBSDonUSB /dev/da0s1
    newfs: /dev/da0s1: failed to open disk for writing
    I am still not sure what needs to be done to make this work. Thanks in advance.

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Guru anomie's Avatar
    Join Date
    Mar 2005
    Location
    Texas
    Posts
    1,692
    From here we'll create a new slice and disk label, and then your newfs command should work.

    • First, use sysinstall to create the new slice on da0. If you're not familiar with it, its usage is here: Adding Disks - Section 18.3.1, steps 1 and 2. Only create the slice and then write the changes (say 'yes' when it asks you if you're sure). Don't worry about creating a label until the next step.
    • Next, write a standard label with the command:
      Code:
      # bsdlabel -w /dev/da0s1
    • Last, run the newfs command you specified.

  6. #5
    Linux User
    Join Date
    Dec 2004
    Posts
    323
    Thanks again for the response. I have done as outlined in the freebsd webpage on sysinstall. And when pressing 'W' to write the changes it says:
    ERROR: unable to write data to disk: da0!
    Disk partition write returned an error status!

    Not sure where it is going wrong.

  7. #6
    Linux Guru anomie's Avatar
    Join Date
    Mar 2005
    Location
    Texas
    Posts
    1,692
    You don't have da0 mounted already, do you? And you didn't boot from it?

    I made a couple assumptions in this -- that you're running FBSD 6.2. on a box (w/ separate drive) and that you're trying to do this operation on a new usb drive that does not contain partitions already. (Is that all true?)

    If da0 is mounted, unmount it first. If FBSD is actually running from da0 now, you're going to need to do this a different way. If da0 already contains partitions, delete them before creating new.

  8. #7
    Linux User
    Join Date
    Dec 2004
    Posts
    323
    Thanks again for your suggestions. By way of overview, some output of the commands I have tried. This is in /etc/fstab:
    Code:
    # Device                Mountpoint      FStype  Options         Dump    Pass#
    /dev/ad0s1b             none            swap    sw              0       0
    /dev/ad0s1a             /               ufs     rw              1       1
    /dev/ad0s1e             /tmp            ufs     rw              2       2
    /dev/ad0s1f             /usr            ufs     rw              2       2
    /dev/ad0s1d             /var            ufs     rw              2       2
    /dev/acd0               /cdrom          cd9660  ro,noauto       0       0
    These are the commands I executed to arrive at the error message:
    Code:
    # mount the USB flash drive
    sysctl vfs.usermount=1
    mount_msdosfs /dev/da0s1 /mnt
    
    # mount the iso on /dist
    mkdir -p /dist
    mdconfig -a -f /usr/FreeBSD/6.2-RC1-i386-disc1.iso
    # output at this point is: md0
    mount -t cd9660 /dev/md0 /dist
    
    # create BSD slice and apply disklabel
    fdisk -BI /dev/da0
    bsdlabel -B -w da0s1
    
    # create a filesystem
    newfs -U -L FreeBSDonUSB /dev/da0s1a
    # error output lead me to initiate this thread
    By the way, the USB drive is new and empty.

    For unmounting da0, I have the following output:
    Code:
    [root@athens /dev]# umount /dev/da0
    umount: /dev/da0: unknown file system
    Not sure where it is going wrong or how it should be corrected. Thanks again in advance
    Last edited by technossomy; 05-20-2007 at 09:43 AM. Reason: Added last line

  9. #8
    Linux Guru anomie's Avatar
    Join Date
    Mar 2005
    Location
    Texas
    Posts
    1,692
    You'll need to unmount the slice (just as you mounted it). So it would be:
    Code:
    # umount /dev/da0s1
    or
    Code:
    # umount /mnt
    After that is done, try following the steps in post #4 of this thread again.

  10. #9
    Linux User
    Join Date
    Dec 2004
    Posts
    323
    I am on my way, thanks for the guidance. Very helpful.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •