Gentoo Archives: gentoo-user

From: Laurence Perkins <lperkins@×××××××.net>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Is there a way to misconfigure USB ports in the kernel?
Date: Tue, 30 Mar 2021 21:29:51
Message-Id: 9B5D4AD5-6647-4F2A-8F6B-C29CA7AC8DA9@openeye.net
In Reply to: Re: [gentoo-user] Is there a way to misconfigure USB ports in the kernel? by Dr Rainer Woitok
1 On March 30, 2021 10:11:56 AM PDT, Dr Rainer Woitok <rainer.woitok@×××××.com> wrote:
2 >On Saturday, 2020-12-05 19:07:51 +0100, I myself wrote:
3 >
4 >("> >" refers to Michael <confabulate@××××××××.com>)
5 >
6 >> Michael,
7 >>
8 >> On Friday, 2020-11-27 19:07:17 +0000, you wrote:
9 >>
10 >> > ...
11 >> > A 4k block size is recommended for ntfs-3g which is the default
12 >sector created
13 >> > by fdisk and friends on Linux these days. This will align your
14 >partition
15 >> > optimally. In addition, mkfs.ntfs will use 4096 bytes as the
16 >default cluster
17 >> > size, so you should be good in that respect.
18 >> >
19 >> > Another setting you may want to try is mounting the USB with
20 >'big_writes' -
21 >> > check the man page. This should help particularly with large
22 >files, which
23 >> > will use larger blocks up to 128KB when copying data to the NTFS.
24 >>
25 >> Both, the VeraCrypt command line (--fs-options=big_writes) and the
26 >Vera-
27 >> Crypt GUI (under "Settings --> Preferences") allow setting this
28 >mount
29 >> option. But
30 >>
31 >> $ mount | grep veracrypt
32 >>
33 >> never shows it, initially causing me to erroneously believe it
34 >wasn't
35 >> set and to try finding on the web another way of setting it. By
36 >pure
37 >> chance I finally found out that
38 >>
39 >> $ ps -ef | grep veracrypt
40 >>
41 >> lists a "/usr/sbin/mount.ntfs" task which shows the options really
42 >in
43 >> effect. However, I haven't yet had the time to test the effect of
44 >this
45 >> option when writing plenty of really big files. I will report on
46 >that
47 >> later.
48 >
49 >Well, it's been quite a while, due to my being almost permanently
50 >con-
51 >fronted with more pressing tasks ... :-(
52 >
53 >To sum up my experience with my new 128 GB Philips USB 3.0 sticks:
54 >while
55 >the Philips sticks are significantly faster for reading operations
56 >than
57 >my old 64 GB Verbatim ones (probably USB 2.0), writing operations to
58 >the
59 >Philips sticks are unbearably slow, regardless of whether I created
60 >a
61 >normal unencrypted NTFS filesystem on them or an encrypted NTFS
62 >filesys-
63 >tem using VeraCrypt. Writing to the USB stick while at the same
64 >time
65 >reading from it in a different terminal window caused commands like
66 >"cd"
67 >or "ls" to simply stall. Thus while running
68 >
69 > $ cp --preserve=timestamps -ru $source_dir .
70 >
71 >in one terminal window, I ran
72 >
73 > $ while true
74 > > do n=$(ps -ef|g 'cp --preserve'|g -v grep)
75 > > if [[ "$n" = "${o-}" ]]
76 > > then sleep 10
77 > > else o="$n"
78 > > echo "$n"
79 > > fi
80 > > done
81 >
82 >in another, to get the wall clock times when copying a new file
83 >began.
84 >That way I found that copying a 30 MB file took about 40 minutes.
85 >
86 >So what are my options?
87 >
88 > - Stay away from Philips USB 3.0 sticks?
89 >
90 > - Stay away from Philips USB sticks in general?
91 >
92 > - Stay away from USB 3.0 sticks in general?
93 >
94 > - Stay away from Filesystem in User Space using a non-stable 5.10 or
95 > 5.11 kernel (currently I'm using stable 5.4.97)?
96 >
97 > - Stay away from Gentoo?
98 >
99 > - Stay away from Linux in general and go back to OTOS (aka the Only
100 > True Operating System aka Windoze)?
101 >
102 > - ...?
103 >
104 >Any ideas and comments welcome ...
105 >
106 >Sincerely,
107 > Rainer
108
109 There are a number of things which might be going on here.
110 To start with, you can get the kernel, user, and wall clock run times for commands by prefixing it with "time". So:
111
112 time cp <large file> <USB mountpoint>
113
114 Will get you more precise answers with much less effort.
115
116 As for the performance of the USB drive in question, there are a few things that might be tripping it up.
117
118 Firstly, writing flash memory is significantly slower than reading it. Some drives deal with this by having some kind of internal cache mechanism. Many deal with it by using a pile of smaller chips instead of one big one and striping the writes. If the Phillips drive just used a few large chips instead, then it's just slow to write to and there isn't much you can do about it. I've seen a lot of cheaper drives that are that way.
119
120 Double check that the alignment and block size are correct for the drive's internal structure. That can cause some pretty massive performance hits if it's incorrect.
121
122 You can also check the output of the dmesg command for any errors the system is encountering with regard to the drive.
123
124 I don't know of any reason to stay away from usb 3.0 on Linux, but if you have USB 3 devices on both ends and try to hook them together with a USB 2.0 or 1.1 rated cable that could easily cause some problems... I assume you're plugging the drive straight into the machine's socket. If you're using the front panel though try one of the ones on the back. There may be something up with the case wiring.
125
126 I've never had a Phillips USB stick, so maybe do some tests with another brand of stick and see if it has the same problem. Kingston or SanDisk or something. One of the ones where memory is their primary focus.
127
128 You could definitely check performance on a different OS. There may be driver-related performance issues on this model of drive or even this specific drive.
129
130 Instead of NTFS you could also try UDF. It's supported on both Linux and Windows Vista and newer. (And even XP I think, but only an older revision of the filesystem.) Being an open standard it is quite a bit more stable on Linux than NTFS, doesn't need a userspace driver, and still supports larger drives and files. You can find Linux and Windows formatting instructions on the web pretty easily. Big thing is that on Windows it's available via the format command, but not in the GUI.
131
132 That's all I can think of at the moment. Hope it helps.
133
134 LMP