Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

[Solved] What is the function of cp debian.iso /dev/sdX?

New to Debian (Or Linux in general)? Ask your questions here!
Post Reply
Message
Author
Free_Alan
Posts: 17
Joined: 2023-05-05 07:49
Has thanked: 15 times

[Solved] What is the function of cp debian.iso /dev/sdX?

#1 Post by Free_Alan »

Hi:

Since I used Rufus or balenaEtcher to create USBMedia before, I recently saw the official Debian document(https://wiki.debian.org/DebianInstaller/CreateUSBMedia) , which uses Linux commands to create USBMedia.

The Linux commands used in this document are as follows:

Code: Select all

# cp debian.iso /dev/sdX
# sync
A warning statement is included below the Linux instruction as follows:
The image must be written to the whole-disk device and not a partition, e.g. /dev/sdb and not /dev/sdb1.

I would like to ask why the copy operation is performed on the entire hard disk space. Will the file system be changed and all data originally on the hard disk deleted after this operation?

Thanks for any help.
Last edited by Free_Alan on 2024-03-20 05:45, edited 1 time in total.

steve_v
df -h | grep > 20TiB
df -h | grep > 20TiB
Posts: 1418
Joined: 2012-10-06 05:31
Location: /dev/chair
Has thanked: 80 times
Been thanked: 191 times

Re: [Software] What is the function of cp debian.iso /dev/sdX?

#2 Post by steve_v »

Free_Alan wrote: 2024-03-19 09:27 I would like to ask why the copy operation is performed on the entire hard disk space.
Because it's a hybrid bootable disk image, so it includes partition table, boot sector(s), and filesystems. That's how disk images generally work.
A cp to a block device node is roughly equivalent to a dd to the same, and writes directly to the raw disk or partition.
Free_Alan wrote: 2024-03-19 09:27Will the file system be changed and all data originally on the hard disk deleted after this operation?
Of course. As the wiki states:
Be aware, that the methods described here will destroy anything already on the device!
Once is happenstance. Twice is coincidence. Three times is enemy action. Four times is Official GNOME Policy.

User avatar
kent_dorfman766
Posts: 540
Joined: 2022-12-16 06:34
Location: socialist states of america
Has thanked: 59 times
Been thanked: 70 times

Re: [Software] What is the function of cp debian.iso /dev/sdX?

#3 Post by kent_dorfman766 »

FWIW, I would not use the cp command, but would instead do "dd if=debian.iso of=/dev/sdx bs=512" since cp is meant for filesystem operations, not raw devices.

User avatar
sunrat
Administrator
Administrator
Posts: 6511
Joined: 2006-08-29 09:12
Location: Melbourne, Australia
Has thanked: 119 times
Been thanked: 489 times

Re: [Software] What is the function of cp debian.iso /dev/sdX?

#4 Post by sunrat »

kent_dorfman766 wrote: 2024-03-19 11:35 FWIW, I would not use the cp command, but would instead do "dd if=debian.iso of=/dev/sdx bs=512" since cp is meant for filesystem operations, not raw devices.
Poppycock. It's less characters to type than dd! :mrgreen: But you are free to use whatever you wish.
As OP stated, it is also what is advised to use in the Debian wiki - https://wiki.debian.org/DebianInstaller/CreateUSBMedia
“ computer users can be divided into 2 categories:
Those who have lost data
...and those who have not lost data YET ”
Remember to BACKUP!

Post Reply