From owner-freebsd-questions@freebsd.org Mon Mar 16 08:05:51 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 BB2AC25E1E4 for ; Mon, 16 Mar 2020 08:05:51 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.126.135]) (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 48gplL3RbZz3GkH for ; Mon, 16 Mar 2020 08:05:50 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from r56.edvax.de ([94.222.11.49]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPA (Nemesis) id 1MyK9U-1jWecB3XEC-00ylWo; Mon, 16 Mar 2020 09:05:40 +0100 Date: Mon, 16 Mar 2020 09:05:38 +0100 From: Polytropon To: freebsd@dreamchaser.org Cc: FreeBSD Mailing List Subject: Re: SD card formatting Message-Id: <20200316090538.27b1ecb1.freebsd@edvax.de> In-Reply-To: <90f83226-b557-98c4-749b-81d9dbd795c3@dreamchaser.org> References: <20200316000029.a6ba47c9.freebsd@edvax.de> <90f83226-b557-98c4-749b-81d9dbd795c3@dreamchaser.org> 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:HidlQnqprqogSZO3Laz2kgmMpV82/uH2+HTZl7X0jd2oRoO+nz7 jTHUdkZ9thxuDwffTWo6Q3h/BzqBnEytMOA9+ABhFQ9Kcepc59B1JrYllrUjhpoKQHjHN3G bQdjTHD4HJ01rNEZbVQ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plL3RbZz3GkH 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.135) smtp.mailfrom=freebsd@edvax.de X-Spamd-Result: default: False [4.70 / 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]; RECEIVED_SPAMHAUS_PBL(0.00)[49.11.222.94.khpj7ygk5idzvmvt5x4ziurxhy.zen.dq.spamhaus.net : 127.0.0.11]; FROM_EQ_ENVFROM(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:+]; ARC_NA(0.00)[]; REPLYTO_EQ_FROM(0.00)[]; FROM_HAS_DN(0.00)[]; MIME_GOOD(-0.10)[text/plain]; RCVD_TLS_LAST(0.00)[]; DMARC_NA(0.00)[edvax.de]; AUTH_NA(1.00)[]; NEURAL_SPAM_MEDIUM(0.98)[0.978,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)[135.126.227.212.list.dnswl.org : 127.0.5.0]; R_SPF_NA(0.00)[]; RWL_MAILSPIKE_POSSIBLE(0.00)[135.126.227.212.rep.mailspike.net : 127.0.0.17]; RCVD_COUNT_TWO(0.00)[2]; IP_SCORE(0.32)[ip: (0.57), 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: Mon, 16 Mar 2020 08:05:51 -0000 On Sun, 15 Mar 2020 19:06:22 -0600, Gary Aitken wrote: > On 3/15/20 5:00 PM, Polytropon wrote: > > 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. > > As stated above, this is a card formatted _in the camera_. So the > camera can read it fine. The problem is fbsd can't mount it. >From the program output presented, it seems that you're trying to mount a NTFS partition using the FAT mount option, which will not work. Try ntfs-3g (needs to be installed; mount_ntfs is no longer part of the OS). > > 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. > > :-) > > In this case, the camera is not the problem; cards formatted in the camera > are usable by the camera. But they aren't mountable on fbsd. So I can't > transfer the files to fbsd, either from the camera or by inserting the > card in an fbsd usb adapter. Depending on the camera, a USB connection can show up as a mass storage device (leads to /dev/da) or a MTP interface (leads to /dev/ugen). In many cases, the "personality" can be seleted by the menu in the camera. > Since cards formatted by the camera are not mountable on fbsd, I was > hoping to find a way to format the card on fbsd that would be > readable both by the camera and by fbsd. The camera seems to prefer NTFS, so when you (correctly) format a card as FAT, the camera refuses to read it. However, that's the first occassion I hear about a camera that seems to use NTFS natively... not that this is impossible, it's just something I never heared about it. :-) > > 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. > > For a card formatted in the camera, which the camera can read but fbsd > cannot mount: > > # file -r - < /dev/da0 > /dev/stdin: DOS/MBR boot sector; partition 1 : ID=0x7, active, > start-CHS (0x2,10,9), end-CHS (0x3ff,254,63), startsector 32768, > 120911872 sectors > # file -r - < /dev/da0s1 > /dev/stdin: DOS/MBR boot sector > # mount_msdosfs /dev/da0s1 /mnt/memstick > mount_msdosfs: /dev/da0s1: Invalid argument According to the gpart output, it's not FAT (msdosfs), but NTFS. > For a card never reformatted (i.e. formatted by the manufacturer, and > used in the camera); this card is usable by the camera and mountable > by fbsd: > > # file -r - < /dev/da0 > /dev/stdin: DOS/MBR boot sector; partition 1 : ID=0xc, active, > start-CHS (0x0,130,3), end-CHS (0x3ff,254,63), startsector 8192, > 31496192 sectors > # file -r - < /dev/da0s1 > /dev/stdin: , code offset 0x0+3, OEM-ID " ", sectors/cluster 64, > reserved sectors 504, Media descriptor 0xf8, sectors/track 63, > heads 255, hidden sectors 8192, sectors 31496192 (volumes > 32 MB), > FAT (32 bit), sectors/FAT 3844, serial number 0x0, unlabeled > # mount_msdosfs /dev/da0s1 /mnt/memstick > # ls /mnt/memstick > DCIM System Volume Information This doesn't actually look like a "mint condition" card. A directory named "DCIM" is typically created by a camera. However, _this_ card is FAT-formatted, and therefore can be mounted with msdosfs as correctly shown above. The directory name "System Volume Information" suggests it has been in a "Windows" PC before. COnclusion: Card works both in camera an in "Windows" PC. So the camera seems (!) to initialize cards as NTFS (strange, but surely possible), but also understands FAT. All you need to do now is to replicate _that_ formatting. The output shows "FAT (32 bit)", and the partitioning also looks reasonable. You should be able to create this either with gpart + newfs_msdosfs (should be quite standard today), or the traditional way with fdisk + newfs_msdosfs (archaic, but should also still work). Sidenote: I use my camera to initialize cards, and it creates a MS-DOS (FAT) filesystem on a "s1" partition. With mount_msdosfs, I can then access it. No NTFS. > >> 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). > > The problem is, on fbsd I _can't_ mount it. > > # dd if=/dev/zero of=/dev/da0 bs=1K count=1K > 1024+0 records in > 1024+0 records out > 1048576 bytes transferred in 0.507045 secs (2068012 bytes/sec) > > put card in camera and format it > > # gpart show -r /dev/da0 > => 63 120944577 da0 MBR (58G) > 63 32705 - free - (16M) > 32768 120911872 1 7 [active] (58G) > # mount -t msdosfs /dev/da0s1 /mnt/memstick > mount_msdosfs: /dev/da0s1: Invalid argument > > The card is readable by windows, however. It would be nice to see if _this_ card now is FAT or NTFS. If it's NTFS, "Windows" will of course be able to use it. On FreeBSD; you need to use nrfs_3g to mount it, though. :-) -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...