LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-05-2019, 10:52 AM   #1
centguy
Member
 
Registered: Feb 2008
Posts: 627
Blog Entries: 1

Rep: Reputation: 48
fdisk and parted give different output (which one should trust?)


I have a thumb drive

subjected to dd command:

Quote:
dd bs=4M if=firmware-9.9.0-amd64-netinst.iso of=/dev/sdd conv=fdatasync
It works as a bootable thumbdrive to install Debian 9.


Now, on a CentOS 7 terminal,

I found this:

Quote:
[root@centos73-asus ~]# fdisk /dev/sdc
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): print

Disk /dev/sdc: 15.7 GB, 15669919744 bytes, 30605312 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x13156673

Device Boot Start End Blocks Id System
/dev/sdc1 * 0 669695 334848 0 Empty
/dev/sdc2 3996 4827 416 ef EFI (FAT-12/16/32)

Command (m for help): quit

But

Quote:
[root@centos73-asus ~]# parted /dev/sdc print
Warning: The driver descriptor says the physical block size is 2048 bytes, but Linux says it is 512 bytes.
Ignore/Cancel?
Ignore/Cancel? i
Model: SanDisk Cruzer Blade (scsi)
Disk /dev/sdc: 62.7GB
Sector size (logical/physical): 2048B/512B
Partition Table: mac
Disk Flags:

Number Start End Size File system Name Flags
1 8192B 24.6kB 16.4kB Apple
2 8184kB 9888kB 1704kB EFI

parted seems to be completely confused by the content.

Is parted inferior to fdisk?
 
Old 07-05-2019, 11:22 AM   #2
dc.901
Senior Member
 
Registered: Aug 2018
Location: Atlanta, GA - USA
Distribution: CentOS/RHEL, openSuSE/SLES, Ubuntu
Posts: 1,005

Rep: Reputation: 370Reputation: 370Reputation: 370Reputation: 370
This has a good explanation:
https://superuser.com/questions/1194...k-gdisk-parted
 
Old 07-05-2019, 01:13 PM   #3
fatmac
LQ Guru
 
Registered: Sep 2011
Location: Upper Hale, Surrey/Hants Border, UK
Distribution: Mainly Devuan, antiX, & Void, with Tiny Core, Fatdog, & BSD thrown in.
Posts: 5,484

Rep: Reputation: Disabled
I prefer to use command line tools, most GUI tools use them underneath anyway, so I cut out the overhead.

I've found fdisk & cfdisk work well for me.
 
Old 07-05-2019, 06:33 PM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,125

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
That's probably a hybrid USB - open to interpretation.
For many years I avoided parted, but when gpt became the "go-to" structure for me, fdisk was useless, so I switched to parted, and got used to it eventually. With the re-write of fdisk 18 months or so ago, it now is usable again, but I tend not to use it a lot except for listing.

So, use what you're comfortable with - both are "right".
 
Old 07-06-2019, 03:16 AM   #5
centguy
Member
 
Registered: Feb 2008
Posts: 627

Original Poster
Blog Entries: 1

Rep: Reputation: 48
The discrepancy between fdisk and parted means that I am not ready to believe what they say about a disk
that has been subjected to a dd command. I know
the thumbdrive is 16 GB when I bought it. The deeper question is: what does dd do beyond copy blindly
from source A to destination B. How does it affect the partition table? That is the fundamental question.

I knew nothing the diff between GPT vs MBR (or msdos) until recently. Strange thing is that
I was able to manage a few laptops/desktops, each with a few OSes, some UEFI, some non-UEFI,
some grub1, and some grub2. Partitioning of the disks are always with gparted.

I guess I have always been lucky.

Anyway, I trusted gparted a lot (especially that comes with the LiveDVD of latest Linux Mint).
I hope gparted can do all what gdisk can do eventually.

Last edited by centguy; 07-06-2019 at 03:20 AM.
 
Old 07-06-2019, 03:35 AM   #6
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,125

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
"dd" does as it is requested by the user. Sometimes it is even what the user thinks they requested.

A USB thumb-drive is not a "real" disk. All of the tools work fine with "real" disks.
Be careful to define your requirements precisely - to yourself as well as to the rest of the world.
 
Old 07-06-2019, 08:50 AM   #7
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,699

Rep: Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895
I agree with syg00. Your correct dd just copies byte for byte the contents of the file to the USB drive. However, firmware-9.9.0-amd64-netinst.iso is a hybrid ISO which is basically a CD/DVD that contains a MBR.

I believe parted is examining the filesystem which is ISO9660 but fdisk just looks at the MBR therefore your seeing a perceived discrepancy.

https://wiki.syslinux.org/wiki/index...itle=Isohybrid

In another example if you use dd to create an image of a smaller drive and then copy it to a larger capacity drive, the larger drive will appear to be the same size as the smaller one because the MBR/UEFI is the same regardless of its actual "physical" size. You have to resize the partitions to use the empty space.

By deleting the MBR and recreating a new partition table and partitions you can "restore" the USB drive back to "normal".

Last edited by michaelk; 07-06-2019 at 08:52 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Question about fstab, fdisk, and parted? anon091 Linux - Newbie 8 01-08-2013 01:43 PM
Parted Magic vs. G-parted jk07 Linux - Software 6 09-23-2012 04:46 AM
fdisk, parted, and gparted lawrence_lee_lee Linux - Software 3 06-15-2008 08:26 AM
workaround for parted bug using fdisk and resize2fs carneros Linux - Newbie 2 10-05-2004 12:52 AM
working around PARTED bug 90894 using fdisk and resize2fs carneros Red Hat 0 07-29-2004 02:42 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:01 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration