From owner-freebsd-questions@freebsd.org Sun Mar 15 23:00:43 2020 Return-Path: Delivered-To: freebsd-questions@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 1459A27B1D6 for ; Sun, 15 Mar 2020 23:00:43 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.126.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "mout.kundenserver.de", Issuer "TeleSec ServerPass Class 2 CA" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48gZfK3Mfjz4Tg4 for ; Sun, 15 Mar 2020 23:00:41 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from r56.edvax.de ([178.12.43.36]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPA (Nemesis) id 1Mk0FM-1jbeOk10mG-00kLPp; Mon, 16 Mar 2020 00:00:30 +0100 Date: Mon, 16 Mar 2020 00:00:29 +0100 From: Polytropon To: freebsd@dreamchaser.org Cc: FreeBSD Mailing List Subject: Re: SD card formatting Message-Id: <20200316000029.a6ba47c9.freebsd@edvax.de> In-Reply-To: References: Reply-To: Polytropon Organization: EDVAX X-Mailer: Sylpheed 3.1.1 (GTK+ 2.24.5; i386-portbld-freebsd8.2) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K1:9SImF/WCPyTtUkISby8JR9U8Ssy4OQDfNrEPwfcLcG4fmttSIVb NFS9vUtR6DnNFah0XEsAOEYo0Fyg+MOw8KUkY71C46r108l4/vvx//Cj8jo0F7XCgBkZ6Jc SNw4rbbMVlQH6+BnV31zv+R3x79snaJ7zzQ2l+nlva2gt90byOt2I0tBp69qXjBeROGYvH/ UuUlEaEUWCcc4+9dD6iEw== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:EI90ftinseg=:rvbvGczj1KFv3Fhqom+L9V 0/jE9GVoE1+veoxarfc+YHBQw9nQgTwbbqYnf6mfcoXQlj4UslChDUEngC7wtU+penU1iB5EX hWo7H7q7D0NEgicrhG+7jPWHdHBP23TcLJCP+5B2ahqY2JZr1gXYgP0qdLYW2Ccpwo85WVXH9 wFZGIbpmaXzDxAc/Kxs+LDUpFmiD32Mj5NG7SzbUqjBM3crGKQ5fGOroBX31M9NoMZMMU/yIQ MKCdcz+1CGg52fC0Jmsr+Fm9ZO9v7zXuIzohm52W9NZkjDjulEfX+tZa9sWUhwvvUTvhNZKAf oUaMoKMouGTxf5mkKJx45XmVPlTO/zBWt9jnoVant8PF214+xcsZZ8TCI5jwW0DpC10ZRQGip FXSlKf+l72nvt2LmwaMM0L7SZdWD3LOg/2z50LxcT0jogggUfC7fj43n0YXY/d2srJ8Y54+42 adFTArYH79CC0KTv/xENacHZq2mes/IXWSh3crf7z/LYcB3SosKh6zQKS2t4uqcNWajNIm13/ 6U+i1DwiJ0YlHaCpgfYaYBzgJK+yh1AVTKS2luTl688yAaoTZBGvcLFi/M4regreff6ouLSb7 xPak1TnDTlx0b+atOeToMf26BcZ56kWZbqDNX6c1DQP7BihrKEI+WQOQb+Nzwb8v2QozRwj48 uet07ydjIkefo51S8M5cmoTD/7iocTBXP9kVUx4E9qnI67kqiwwWtNDvd3iltsA8t2ZMYG6da KC3p80d3O5dEj0SMtU8GRN2aNLZPq/0bOrRftBBdNDONkPGw/Ox/ywCxI60V4Bd488g8B4TPk nLthGC64qp5M2vdNfn38SXxcsCcqadLYK4JpNOfBIMYGajotyizG9wdHP2H6inQrWieK7i9 X-Rspamd-Queue-Id: 48gZfK3Mfjz4Tg4 X-Spamd-Bar: ++++ Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=none (mx1.freebsd.org: domain of freebsd@edvax.de has no SPF policy when checking 212.227.126.131) smtp.mailfrom=freebsd@edvax.de X-Spamd-Result: default: False [4.85 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; HAS_REPLYTO(0.00)[freebsd@edvax.de]; TO_DN_SOME(0.00)[]; MV_CASE(0.50)[]; HAS_ORG_HEADER(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; R_DKIM_NA(0.00)[]; ASN(0.00)[asn:8560, ipnet:212.227.0.0/16, country:DE]; MIME_TRACE(0.00)[0:+]; RECEIVED_SPAMHAUS_PBL(0.00)[36.43.12.178.khpj7ygk5idzvmvt5x4ziurxhy.zen.dq.spamhaus.net : 127.0.0.11]; ARC_NA(0.00)[]; REPLYTO_EQ_FROM(0.00)[]; FROM_HAS_DN(0.00)[]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[edvax.de]; AUTH_NA(1.00)[]; NEURAL_SPAM_MEDIUM(0.99)[0.986,0]; TO_MATCH_ENVRCPT_SOME(0.00)[]; NEURAL_SPAM_LONG(1.00)[1.000,0]; MID_CONTAINS_FROM(1.00)[]; RCVD_IN_DNSWL_NONE(0.00)[131.126.227.212.list.dnswl.org : 127.0.5.0]; R_SPF_NA(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; IP_SCORE(0.46)[ip: (1.29), ipnet: 212.227.0.0/16(-1.13), asn: 8560(2.18), country: DE(-0.02)] X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Mar 2020 23:00:43 -0000 On Sun, 15 Mar 2020 15:39:33 -0600, Gary Aitken wrote: > 11.3-RELEASE-p6 GENERIC amd64 > > I'm having trouble reading SD cards formatted in my camera (Olympus EM1-MkII) > or on a Win 7 system. What filesystem is in use? For cards, it's typically FAT. > When attempting to mount, I get the following: > > $ mount -t msdosfs /dev/da0s1 /mnt/memstick > mount_msdosfs: /dev/da0s1: Invalid argument > $ mount -t ntfs /dev/da0s1 /mnt/memstick > mount: /dev/da0s1: Operation not supported by device > > Cards used without formatting *usually* seem to work. So those are preformatted (sometimes sold this way, sometimes initialized when first used in a camera). > If I look at the cards which don't mount using gpart, I see: > > Card formatted in camera: > $ gpart show -p /dev/da0 > => 63 120944577 da0 MBR (58G) > 63 32705 - free - (16M) > 32768 120911872 da0s1 ntfs [active] (58G) ^^^^ It seems that the card has been accidentally formatted with NTFS. In most cases, cameras cannot use that. If you want to mount it on FreeBSD, use ntfs-3g. > $ gpart show -r /dev/da0 > => 63 120944577 da0 MBR (58G) > 63 32705 - free - (16M) > 32768 120911872 1 7 [active] (58G) > > If I look at cards that I know I can mount I see the following: > > $ gpart show -p da0 > => 63 30375873 da0 MBR (14G) > 63 8129 - free - (4.0M) > 8192 15118336 da0s1 fat32lba (7.2G) ^^^^^^^^ Correct. > 15126528 15249408 - free - (7.3G) > $ gpart show -r /dev/da0 > => 63 30375873 da0 MBR (14G) > 63 8129 - free - (4.0M) > 8192 15118336 1 12 (7.2G) > 15126528 15249408 - free - (7.3G) > > or: > > $ gpart show -p /dev/da0 > => 1 15633407 da0 MBR (7.5G) > 1 31 - free - (16K) > 32 15633376 da0s1 fat32 (7.5G) ^^^^^ Correct as well. > $ gpart show -r /dev/da0 > => 1 15633407 da0 MBR (7.5G) > 1 31 - free - (16K) > 32 15633376 1 11 (7.5G) > > I tried reformatting as follows: > > # gpart delete -i 1 da0 > da0s1 deleted > # gpart add -i 1 -a 4M -t "\!11" da0 > da0s1 added > # gpart show -r da0 > => 63 120944577 da0 MBR (58G) > 63 8129 - free - (4.0M) > 8192 120930304 1 11 (58G) > 120938496 6144 - free - (3.0M) > # newfs_msdos -F 32 /dev/da0s1 > /dev/da0s1: 120900736 sectors in 1889074 FAT32 clusters (32768 bytes/cluster) > BytesPerSec=512 SecPerClust=64 ResSectors=32 FATs=2 Media=0xf0 > SecPerTrack=63 Heads=255 HiddenSecs=0 HugeSectors=120930304 > FATsecs=14759 RootCluster=2 FSInfo=1 Backup=2 > > If I put this card in the camera, I get an error ("Card Error") Personally, I tend to leave the formatting to the camera which I want to use the card in; the camera "knows best" what it can uderstand. :-) There is a simple reason: Several variants of FAT exist, and some cameras often only support one out of that bag. If you guess (and use) the wrong one, the camera will report an error. So, as I suggested, let the camera do the right thing. > If I again format the card in the camera, I can't mount it. Have you checked _how_ the camera formats it? Check with gpart (or fdisk, it still works!). There's also the following totally unelegant way: # file -r - < /dev/da0 and / or # file -r - < /dev/da0s1 You should see a FAT summary. > I need to reformat these cards so I can use them in the camera and on > freebsd, and apparently neither the camera nor win7 does that, so... > What's the right way to lay out, format, and create a file system on an > SD card so it is usable by cameras and windoze? Typically using the _camera_ to do this job is the right thing. It's often nice to have the card in "mint condition" (i. e., nothing on it, no partitions, no filesystems). Using dd to overwrite the first MB should be enough. On a "Windows" PC, the card should then correctly be recognized as FAT. And on FreeBSD, you can easily mount it with the -t msdos type. Just make sure that you use /dev/da0 or /dev/da0s1 (some cameras are tricky and initialize the card as /dev/da0 instead of /dev/da0s1, I never understood why). In my /etc/fstab, I have the following entry for SD cards: /dev/da0s1 /media/sd msdosfs rw,noauto,noatime,-m=644,-M=755 0 0 So "mount /media/sd" does what you'd expect. :-) -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...