From owner-freebsd-current@freebsd.org Wed Jan 13 19:31:18 2021 Return-Path: Delivered-To: freebsd-current@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5C93D4E62CA for ; Wed, 13 Jan 2021 19:31:18 +0000 (UTC) (envelope-from grahamperrin@gmail.com) Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DGHcP1RWDz3NrK for ; Wed, 13 Jan 2021 19:31:16 +0000 (UTC) (envelope-from grahamperrin@gmail.com) Received: by mail-wr1-x435.google.com with SMTP id w5so3339474wrm.11 for ; Wed, 13 Jan 2021 11:31:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=pb8J2QRak9iMVaU5WbkedfwR5VWdCG75nsM8lBgyTMQ=; b=BrpONkl2mmCLQM7ZKq019AA4kLXFXTk9gwUpLBs0S4ROxpf0hJF1Q6MwzpgE8w1Xje 8hPeVad4e7mDyUJb/l4ckL8bse3Ssn1zwc8yEaYqOK2H95bk/Cx7UD0syc3zYo6iQ+0u rUYe29iWSpdqAjDfSzCBdrl2JaBM4dk/kiVxtJnsryreifCQ5OWDTJUyIEfzh99l2s5v ycVNljmL7hZx58ZZ7agp3pFds6ZztArvfxkJL+6JI/gDZckdfBFuEg7DtRbdiyorxD4N IQp/952Qz34LWjybvoOseXotORZeUYmahCmgtbUh+H+2SWjNGgPSZwbIGqMjdfVs4saP jsCQ== X-Gm-Message-State: AOAM530m+W/Kg7u2UzjHdCq4u5nsa0h2hvXnUXvYC2DMjD4AKQ250+Bs Ka7Gzt6VRXcboAatohJzSPSiZRGbob8bKA== X-Google-Smtp-Source: ABdhPJxMrJoySbN/v/nxb1w95irWEWiN1Xj8+gPTYel0VTR6V/3cqQN7K6vaP4SpiFBF7zDvCxCn8w== X-Received: by 2002:adf:9cca:: with SMTP id h10mr4169426wre.77.1610566274335; Wed, 13 Jan 2021 11:31:14 -0800 (PST) Received: from [192.168.1.11] (88-105-96-80.dynamic.dsl.as9105.com. [88.105.96.80]) by smtp.gmail.com with ESMTPSA id u10sm4134675wmd.43.2021.01.13.11.31.13 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 13 Jan 2021 11:31:13 -0800 (PST) Subject: USB flash drive sometimes inexplicably read-only To: freebsd-current@freebsd.org References: From: Graham Perrin Message-ID: Date: Wed, 13 Jan 2021 19:31:12 +0000 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB X-Rspamd-Queue-Id: 4DGHcP1RWDz3NrK X-Spamd-Bar: -- X-Spamd-Result: default: False [-2.11 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; RBL_SENDERSCORE_FAIL(0.00)[2a00:1450:4864:20::435:server fail]; FREEMAIL_FROM(0.00)[gmail.com]; R_SPF_ALLOW(-0.20)[+ip6:2a00:1450:4000::/36]; TO_DN_NONE(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; DKIM_TRACE(0.00)[gmail.com:+]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RBL_DBL_DONT_QUERY_IPS(0.00)[2a00:1450:4864:20::435:from]; FREEMAIL_ENVFROM(0.00)[gmail.com]; MID_RHS_MATCH_FROM(0.00)[]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20161025]; RECEIVED_SPAMHAUS_PBL(0.00)[88.105.96.80:received]; FROM_HAS_DN(0.00)[]; DWL_DNSWL_NONE(0.00)[gmail.com:dkim]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-current@freebsd.org]; RCPT_COUNT_ONE(0.00)[1]; SPAMHAUS_ZRD(0.00)[2a00:1450:4864:20::435:from:127.0.2.255]; NEURAL_SPAM_SHORT(0.89)[0.888]; RCVD_IN_DNSWL_NONE(0.00)[2a00:1450:4864:20::435:from]; RCVD_TLS_ALL(0.00)[]; MAILMAN_DEST(0.00)[freebsd-current] X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jan 2021 19:31:18 -0000 On 12/01/2021 09:45, Johan Hendriks wrote: > Re: zpool can not create a pool after using gdisk to prepare the device > On 12/01/2021 07:50, Graham Perrin wrote: >> I used gdisk(8) with a USB flash drive to: >> >> 1. zap (destroy) GPT data structures >> 2. blank out the MBR >> 3. (below) write a new GPT with a FreeBSD ZFS (A504) partition at >> /dev/da1p1 >> >> ---- >> >> root@mowa219-gjp4-8570p:~ # gdisk /dev/da1 >> GPT fdisk (gdisk) version 1.0.5 >> >> Partition table scan: >>   MBR: not present >>   BSD: not present >>   APM: not present >>   GPT: not present >> >> Creating new GPT entries in memory. >> >> Command (? for help): n >> Partition number (1-128, default 1): >> First sector (34-7827358, default = 2048) or {+-}size{KMGTP}: >> Last sector (2048-7827358, default = 7827358) or {+-}size{KMGTP}: >> Current type is A503 (FreeBSD UFS) >> Hex code or GUID (L to show codes, Enter = A503): A504 >> Changed type of partition to 'FreeBSD ZFS' >> >> Command (? for help): w >> >> Final checks complete. About to write GPT data. THIS WILL OVERWRITE >> EXISTING >> PARTITIONS!! >> >> Do you want to proceed? (Y/N): y >> OK; writing new GUID partition table (GPT) to /dev/da1. >> Warning: The kernel may continue to use old or deleted partitions. >> You should reboot or remove the drive. >> The operation has completed successfully. >> root@mowa219-gjp4-8570p:~ # >> >> ---- >> >> I exported the pool that used the device at /dev/da0 (preparing for a >> disruptive test), removed both devices then reconnected the USB flash >> drive. >> >> zpool can not create a pool, the file system is reportedly read-only. >> Please, why is this? >> >> ---- >> >> root@mowa219-gjp4-8570p:~ # tail -n 0 -f /var/log/messages >> Jan 12 06:44:44 mowa219-gjp4-8570p kernel: ugen0.6: > DataTraveler G2> at usbus0 (disconnected) >> Jan 12 06:44:44 mowa219-gjp4-8570p kernel: umass0: at uhub1, port 3, >> addr 14 (disconnected) >> Jan 12 06:44:44 mowa219-gjp4-8570p kernel: da0 at umass-sim0 bus 0 >> scbus6 target 0 lun 0 >> Jan 12 06:44:44 mowa219-gjp4-8570p kernel: da0: > DataTraveler G2 1.00>  s/n 001D0F0CAABFF97115A00A15 detached >> Jan 12 06:44:44 mowa219-gjp4-8570p kernel: (da0:umass-sim0:0:0:0): >> Periph destroyed >> Jan 12 06:44:44 mowa219-gjp4-8570p kernel: umass0: detached >> Jan 12 06:44:48 mowa219-gjp4-8570p kernel: ugen0.6: > DataTraveler G2> at usbus0 >> Jan 12 06:44:48 mowa219-gjp4-8570p kernel: umass0 on uhub1 >> Jan 12 06:44:48 mowa219-gjp4-8570p kernel: umass0: > DataTraveler G2, class 0/0, rev 2.00/1.00, addr 15> on usbus0 >> Jan 12 06:44:48 mowa219-gjp4-8570p kernel: umass0:  SCSI over >> Bulk-Only; quirks = 0xc100 >> Jan 12 06:44:48 mowa219-gjp4-8570p kernel: umass0:6:0: Attached to >> scbus6 >> Jan 12 06:44:48 mowa219-gjp4-8570p kernel: da0 at umass-sim0 bus 0 >> scbus6 target 0 lun 0 >> Jan 12 06:44:48 mowa219-gjp4-8570p kernel: da0: > DataTraveler G2 1.00> Removable Direct Access SCSI-2 device >> Jan 12 06:44:48 mowa219-gjp4-8570p kernel: da0: Serial Number >> 001D0F0CAABFF97115A00A15 >> Jan 12 06:44:48 mowa219-gjp4-8570p kernel: da0: 40.000MB/s transfers >> Jan 12 06:44:48 mowa219-gjp4-8570p kernel: da0: 3821MB (7827392 512 >> byte sectors) >> Jan 12 06:44:48 mowa219-gjp4-8570p kernel: da0: quirks=0x2 >> ^C >> root@mowa219-gjp4-8570p:~ # lsblk da0 >> DEVICE         MAJ:MIN SIZE TYPE LABEL MOUNT >> da0              1:247 3.7G GPT - - >>            -:-   1.0M -                                     - - >>   da0p1          1:248 3.7G freebsd-zfs gpt/efiboot0 >> root@mowa219-gjp4-8570p:~ # zpool create -m /media/sorry sorry >> /dev/da0p1 >> cannot open '/dev/da0p1': Read-only file system >> root@mowa219-gjp4-8570p:~ # >> >> > It looks like it is mounted or something like that. > So see with mount if it is mounted somewhere. > > I alway use gpart to partition disk and i never have problems. > gpart destroy -F /dev/da0 > gpart create -s GPT /dev/da0 > gpart create -a 1M -t freebsd-zfs -l LABELNAME /dev/da0 > > Now you can create your pool using zpool create sorry gpt/LABELNAME > > This way you create your pool using the GPT labelname that never > changes, and you can use it everywhere Thank you. With the device this evening at da1, it was again reportedly read-only; gpart destroy failed. After disconnecting then reconnecting, gpart destroy succeeded and an iso9660 'heritage' was observed. I'm now stress-testing the writeable space; ---- root@mowa219-gjp4-8570p:~ # gpart destroy -F /dev/da1 gpart: geom 'da1': Read-only file system root@mowa219-gjp4-8570p:~ # mount | grep /dev/da root@mowa219-gjp4-8570p:~ # lsblk da1 DEVICE         MAJ:MIN SIZE TYPE LABEL MOUNT da1              0:162 3.7G GPT - -            -:-   1.0M -                                     - -   da1p1          0:163 3.7G freebsd-zfs gpt/FreeBSD root@mowa219-gjp4-8570p:~ # gpart show /dev/da1 =>     34  7827325  da1  GPT  (3.7G)        34     2014       - free -  (1.0M)      2048  7825311    1  freebsd-zfs  (3.7G) root@mowa219-gjp4-8570p:~ # gpart destroy -F /dev/da1 da1 destroyed root@mowa219-gjp4-8570p:~ # lsblk da1 DEVICE         MAJ:MIN SIZE TYPE LABEL MOUNT da1              0:162 3.7G cd9660 iso9660/Kubuntu%2020.04.1%20LTS%20amd64 - root@mowa219-gjp4-8570p:~ # gpart show /dev/da1 gpart: No such geom: /dev/da1. root@mowa219-gjp4-8570p:~ # gpart create -s GPT /dev/da1 da1 created root@mowa219-gjp4-8570p:~ # lsblk da1 DEVICE         MAJ:MIN SIZE TYPE LABEL MOUNT da1              0:162 3.7G GPT - -            -:-   3.7G -                                     - - root@mowa219-gjp4-8570p:~ # gpart show /dev/da1 =>     40  7827312  da1  GPT  (3.7G)        40  7827312       - free -  (3.7G) root@mowa219-gjp4-8570p:~ # gpart create -a 1M -t freebsd-zfs -l iffy /dev/da1 gpart: illegal option -- a … ---- root@mowa219-gjp4-8570p:~ # lsblk da1 DEVICE         MAJ:MIN SIZE TYPE LABEL MOUNT da1              0:162 3.7G GPT - -            -:-   3.7G -                                     - - root@mowa219-gjp4-8570p:~ # gpart add -a 1M -t freebsd-zfs -l iffy /dev/da1 da1p1 added root@mowa219-gjp4-8570p:~ # zpool create sorry gpt/iffy root@mowa219-gjp4-8570p:~ # zpool status sorry   pool: sorry  state: ONLINE config:         NAME        STATE     READ WRITE CKSUM         sorry       ONLINE       0     0     0           gpt/iffy  ONLINE       0     0     0 errors: No known data errors root@mowa219-gjp4-8570p:~ # zfs unmount sorry root@mowa219-gjp4-8570p:~ # zfs set mountpoint=/media/sorry sorry root@mowa219-gjp4-8570p:~ # zfs mount sorry root@mowa219-gjp4-8570p:~ # ls -dhl /media/sorry drwxr-xr-x  2 root  wheel     2B Jan 13 19:20 /media/sorry root@mowa219-gjp4-8570p:~ # chown grahamperrin:grahamperrin /media/sorry root@mowa219-gjp4-8570p:~ # exit logout % whoami grahamperrin % stressdisk cycle /media/sorry 2021/01/13 19:24:45 loaded statsfile "stressdisk_stats.json" 2021/01/13 19:24:45 Bytes read:         24704 MByte (  20.46 MByte/s) Bytes written:      10454 MByte (   8.60 MByte/s) Errors:                 0 Elapsed time:  24.417097ms 2021/01/13 19:24:45 Removing 0 check files 2021/01/13 19:24:45 Starting round 1 2021/01/13 19:24:45 No check files - generating 2021/01/13 19:24:45 Writing file "/media/sorry/TST_0000" size 1000000000 2021/01/13 19:25:45 Bytes read:         24704 MByte (  20.46 MByte/s) Bytes written:      10864 MByte (   8.52 MByte/s) Errors:                 0 Elapsed time:  1m0.065825136s 2021/01/13 19:26:45 Bytes read:         24704 MByte (  20.46 MByte/s) Bytes written:      11112 MByte (   8.32 MByte/s) Errors:                 0 Elapsed time:  2m0.028319049s 2021/01/13 19:27:31 Writing file "/media/sorry/TST_0001" size 1000000000 2021/01/13 19:27:45 Bytes read:         24704 MByte (  20.46 MByte/s) Bytes written:      11444 MByte (   8.20 MByte/s) Errors:                 0 Elapsed time:  3m0.025935623s …