• Post Reply Bookmark Topic Watch Topic
  • New Topic

Confusion about dd command in Ubuntu14.04  RSS feed

 
Mandar Khire
Ranch Hand
Posts: 582
Android Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I use Ubuntu 14.04 & 10 in different pc.
I have 16GB Micro SD card.
I follow some steps.
1. In Ubuntu 10, i attach SD card by card-reader & format it to Master Boot Record by Disk Utility.
2. I cross verify with Ubuntu 14.04 by following details i got:-
fdisk -l


gdisk -l /dev/sdb


in dmessages:-


Now i run dd command in Ubuntu 14.04 terminal as follows:-
sudo dd if=/dev/zero of=/dev/sdb bs=1M count=1

Then i cross verify again by fdisk -l, i got as bellow:-

&
gdisk -l /dev/sdb


dmesg |grep sdb

My question is where i do wrong thing so i got Disk /dev/sdb doesn't contain a valid partition table?
 
Ron McLeod
Bartender
Posts: 1603
232
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is your understanding of what the sudo dd if=/dev/zero of=/dev/sdb bs=1M count=1 command line does?
 
Mandar Khire
Ranch Hand
Posts: 582
Android Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I found some important information regarding dd command as below:-
--------------------------------------------------------------------------------
dd if=/dev/zero of=/dev/sdb bs=1M count=1

dd command use for Copy a file, converting and formatting according to the operands.

To wipe a disk by writing zeros to it, dd can be used this way:
dd if=/dev/zero of=/dev/sda bs=4k

/dev/zero is a special file in Unix-like operating systems that provides as many null characters (ASCII NUL, 0x00) as are read from it.One of the typical uses is to provide a character stream for initializing data storage.

The dd Unix utility program reads octet streams from a source to a destination, possibly performing data conversions in the process. Destroying existing data on a file system partition (low-level formatting):
dd if=/dev/zero of=/dev/<destination partition>

In computing (specifically data transmission and data storage), a block, sometimes called a physical record, is a sequence of bytes or bits, usually containing some whole number of records, having a maximum length, a block size.

bs=BYTES read and write up to BYTES bytes at a time
count=N copy only N input blocks
-------------------------------------------------------------------------------------------------

but i do one thing before using dd command as follows(Image is just example, not my SD cards info in it.)


Both way i wipe data, but by Disk utility, i do something different & by dd command i wipe everything( in this partition table also gone i think so) so even in fdisk -l i find that error message.
But why that so, is confusion.
 
Ron McLeod
Bartender
Posts: 1603
232
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My question was more about why you ran the command, and what you expected it do to, not how the dd utility works.

Your dd command line copied zeros in to the first 1MB of your disk. The MBR (first 446 bytes) and the partition table (next 64 bytes) for the disk are located in this space, and by running that command line, you zero-ed out that information. If you want the partition table (and MBR?) to remain intact, why are you running a command line that wipes them clean?

Sorry for the delay - I have been travelling.
 
Mandar Khire
Ranch Hand
Posts: 582
Android Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ron McLeod,
Sorry for reply.
I am studying how things works.
Currently i am running one script to wipe out SD card & make partitioning in it.
It contain first line as dd command which i mention previously.
But after completing script, i not got the result as i want...means partitioning complete but in Gparted tool or gdisk command i saw an error related to SD card.
So i thought something wrong due to dd command.
But when i read script properly, i understand that calculation of size of partitions is wrong.
When i try to modified calculation i got proper results.
I cross verfy with lots of commands in ubuntu 14.04 like
01. gdisk -l /dev/sdb
02. fdisk -l
03. df -l
04. df -h
05. sudo parted /dev/sdb unit s print
06. mount
07. sfdisk -l -uM
08. lsblk
09. blkid
10. dmesg |grep sdb
11.cfdisk /dev/sdb

Apps:-
1. Disk utility
2. Gparted

Now question related to dd command is over. I understand what exactly dd command do & how.
I know that asking questions under question is wrong way to ask...
but now question is after running partitioning script as follows:-

1. When Partitioning complete by shell script, partitions not mount automatically till we remove & reattach sd card to computer. & its info also differe in few commands & in Disk utility also. Why that so?
2. When successful partitioning done, in GParted warning shows for sd4 & sd8. Why that so?

Here i asked it.

If any one know its answer/clue etc...
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!