You are not logged in.

#1 2021-07-26 16:58:07

Delupara
Member
Registered: 2020-02-03
Posts: 17

DD does not work [Invalid argument] (Or perhaps it does)

According to the wiki
# dd bs=4M if=path/to/archlinux-version-x86_64.iso of=/dev/sdx conv=fsync oflag=direct status=progress

Is supposed to install arch to my usb but it 100% does not work (actually, it does if I remove the oflag=direct part but then it just Destroys my usb Drive, so I guess it works as advertised)

[jeff@Crude ~]$ sudo dd bs=4M if=Downloads/archlinux-2021.07.01-x86_64\ \(1\).iso of=/dev/sdb conv=fsync oflag=direct status=progress
[sudo] password for jeff:
dd: failed to open '/dev/sdb': Invalid argument
[jeff@Crude ~]$
[jeff@Crude ~]$ lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 465.8G  0 disk
├─sda1   8:1    0   100G  0 part /
└─sda2   8:2    0 365.8G  0 part /home
sdb      8:16   1  57.8G  0 disk
└─sdb1   8:17   1  57.8G  0 part

I would really appreciate if someone could respond to me in less than a week, preferably today (although I never come on here for help because sending my help by snail mail would probably get me faster results) but I wont keep my hopes up.

Have a nice day gents, I am not having a good one unfortunately

Offline

#2 2021-07-26 21:09:46

mpan
Member
Registered: 2012-08-01
Posts: 1,630
Website

Re: DD does not work [Invalid argument] (Or perhaps it does)

There is no reason to use dd. Neither in this case, nor in 99% cases you think you need it.

What you trying to use is cp:

sudo cp Downloads/archlinux-2021.07.01-x86_64\ \(1\).iso /dev/sdb

If you need progress, you may use pv:

pv -ctrab Downloads/archlinux-2021.07.01-x86_64\ \(1\).iso | sudo tee /dev/sdb >/dev/null

But be aware that with slow media — like USB sticks — progress is a bit misleading due to caching.

Keep in mind that in any case use eject to properly flush data, including device’s internal buffers, and power it down before removing⁽¹⁾:

sudo eject /dev/sdb

The error you are getting is likely because you have passed oflag=direct.
____
⁽¹⁾ That applies to removable media, like USB sticks.

Last edited by mpan (2021-07-26 21:17:51)

Offline

#3 2022-05-27 19:42:32

lachesis
Member
Registered: 2012-07-17
Posts: 9

Re: DD does not work [Invalid argument] (Or perhaps it does)

I had this problem. It was because I had accidentally created a 0-byte file called "/dev/sda" when trying to write to a USB stick with `dd oflag=direct` before I plugged it in. Oops! You can tell if you are having the same problem by running `ls -l /dev/sda`, which _should_ start with "c" to indicate that it is a character device. If it starts with a "-" it's a normal file, and you cannot open those with oflag=direct. Just remove the broken device and let devtmpfs create it again. @mpan: the reason to prefer `dd oflag=direct` is that it does not suffer from the misleading progress due to caching as `pv | tee` does.

Offline

#4 2022-05-27 20:34:59

Maniaxx
Member
Registered: 2014-05-14
Posts: 761

Re: DD does not work [Invalid argument] (Or perhaps it does)

Make sure you do not have it mounted in any way and try one of these commands:

Precise progress bar:

dd bs=4M if=path/to/archlinux-version-x86_64.iso of=/dev/sdx oflag=sync status=progress

Slightly faster. Only 'fsync' at the end via fdatasync() system-call. Progress bar might not be direct.

dd bs=4M if=path/to/archlinux-version-x86_64.iso of=/dev/sdx conv=fdatasync status=progress

Last edited by Maniaxx (2022-05-27 20:45:28)


sys2064

Offline

#5 2022-05-27 22:08:03

mpan
Member
Registered: 2012-08-01
Posts: 1,630
Website

Re: DD does not work [Invalid argument] (Or perhaps it does)

That’s a year old thread…

lachesis wrote:

the reason to prefer `dd oflag=direct` is that it does not suffer from the misleading progress due to caching as `pv | tee` does.

One more example of why the use of dd should not be encouraged, unless truly needed.

The direct flag has nothing to do with caching. The implementation has an unintended effect of skipping system file cache.⁽¹⁾ The intended function of this flag is different and it would be best if it was named “aligned” or “offloaded” instead of “direct”,⁽²⁾ and predates file caches by far. It’s used as a hint for reducing load on CPU, if the platform supports the feature. If it does work, the `bs` parameter must also be given and chosen to make a read/write buffer appropriately aligned. Fail to do so and the invocation will not work.⁽³⁾

What you actually wanted has been given by Maniaxx: forcing flushes after each data block. It gives the exact transfer speed to the device, but not without costs. You pay with increased number of operations on the storage medium and, for flash-based storage, considerable wear amplification if either the block size is not set right or you are not using GNU version of dd with the fullblock flag.

____
⁽¹⁾ But not other caches, so one can’t be assured of data actually be ing stored on the medium.
⁽²⁾ “Direct” comes from the name of the underlying technology used (DMA), with the naming rooted deep in history.
⁽³⁾ The reason it “worked” for you so far is luck: the buffer happened to be aligned to page size. O_DIRECT restrictions and issues are discussed in the manual.

Offline

#6 2022-05-27 22:15:40

2ManyDogs
Forum Fellow
Registered: 2012-01-15
Posts: 4,648

Re: DD does not work [Invalid argument] (Or perhaps it does)

The OP has not been back since last July. Closing this old thread.

Offline

Board footer

Powered by FluxBB