Questions tagged [fdisk]

fdisk is a utility present in many operating systems that perform partitioning on hard drives. There are versions of fdisk for Linux, DOS, Windows, FreeDOS and OS / 2. It handles DOS FAT partitions only.

196 questions
102
votes
12 answers

How to create and format a partition using a Bash script?

Is there any way to create and format a partition using a Bash script? I think it can be done with fdisk but I don't know how to feed commands from the Bash script into the fdisk shell and then exit the fdisk shell. I'd like to create a partition…
GlassGhost
  • 1,279
71
votes
6 answers

Why does the partition start on sector 2048 instead of 63?

I had two drives partitioned the same and running two RAID partitions on each. One died and I replaced it under warranty for the same model. While trying to partition it, the first partition can only start on sector 2048, instead of 63 that was…
gcb
  • 5,442
  • 13
  • 62
  • 86
63
votes
3 answers

What is the equivalent of the Linux command "sudo fdisk -l" in MacOS?

In Linux, the command sudo fdisk -l produces an output that lists all the disks and partitions in the computer. Here is an example: If I try to use sudo fdisk -l in MacOS X 10.7.5, the output is the following one: fdisk: illegal option -- l usage:…
27
votes
3 answers

What does sfdisk do, and how does it compare to fdisk or parted?

I was looking over documentation for ZFS for Linux and I came accross a command that the instructions tell me to run to prepare a disk for use. The command was; sfdisk -q /dev/zvol/tank/fish << EOF 0, EOF The line breaks are included the command…
18
votes
5 answers

Partition Not Showing up in /dev

I recently unmounted a 4TB hard drive from one computer in order to access the files directly from another computer. It seemed like there were no problems with the unmounting process. When connecting the hard drive to the other computer, the hard…
13
votes
2 answers

How to force partition to value out of range

I have an ubuntu desktop system (VM guest), whose partitions were created by the install media. I wanted to expand the disk, so I shutdown the guest, and increased the disk size of the guest in the host. Now I need to expand the partitions in the…
13
votes
5 answers

Recover harddrive data

I have a dell laptop that recently "died" (It would get the blue screen of death upon starting) and the hard drive would make a weird cyclic clicking noises. I wanted to see if I could use some tools on my linux machine to recover the data, so I…
Erik W
  • 348
13
votes
2 answers

What does the output of fdisk mean?

I've got a flash drive and I want to understand the properties of it as is outputted from fdisk. I inserted it and check the dmesg and I could see that it was mounted as /dev/sdb1 so I ran fdisk to see what is reported for…
Mike
  • 1,069
12
votes
1 answer

How to set a partition type to ef02 with fdisk?

Setting a partition's type to ef02 is easy in gdisk. You just type it. However, I could not find a similar type code in fdisk. I don't want to use gdisk, because it force convert my drive to GPT which I do not want. FYI, fdisk’s (util-linux 2.20.1)…
David S.
  • 1,036
  • 3
  • 19
  • 39
11
votes
2 answers

How do you create and partition a raw disk image?

I need to create a raw disk image for use in a virtual machine, but I need to create the partitions before creating the file system or installing the operating system. Can anyone describe a process to do this?
Aethylred
  • 485
10
votes
3 answers

Truncate empy space from a raw dd image

I have a raw disk image I took using dd of a Ubuntu instance. The total disk size is 300 GB, but only 5.5 GB used. Is there a way to resize the raw dd image down to 20 GB, keeping all of the 5.5 GB of data, and just truncating empty blocks?
Justin
  • 571
8
votes
1 answer

No "fdisk" command in Debian wheezy

I need to see how my disk is partitioned and I remeber that I have to use the command fdisk -l but in Debian wheezy is not installed. I installed gnu-fdisk but nothing change. How can I resolve? Are there other programs could help me in the…
Kyrol
  • 1,247
7
votes
1 answer

How to force a USB disk to format?

I can't seem to get my USB drive to format anymore or be recognized by the file system (including gparted). How do I just wipe the whole thing and start over!? dmesg [ 5036.408102] usb 2-3: new high-speed USB device number 10 using ehci-pci […
Eric Fossum
  • 571
  • 1
  • 6
  • 16
7
votes
2 answers

What is the "the dos compatibility flag" in fdisk?

I fired up fdisk and got this warning: WARNING: DOS-compatible mode is deprecated. It's strongly recommended to switch off the mode (command 'c') and change display units to sectors (command 'u'). I didn't even know that my…
SamK
  • 524
6
votes
1 answer

Partition table independent of sector size

The plot I have a WD10JPVT 1Tb disk inside an IcyBox IB-290StUS-B USB/esata enclosure. When I connect the disk via USB, I get a 512 logical / 512 physical sector size. When I connect the disk via the computer's native esata port, I get a 512…
1
2 3
13 14