Format /dev/sda as unallocated

8,903

A hard disk usually has a partion table. If you use mkfs.ext4 /dev/sda you'll create a filesystem over the whole disk. Better create a partition table with fdisk or parted or similar. /dev/sda may not be mounted for that. If you created the filesystem the partition programs might complain about it. To clear the data from the mkfs you can use dd if=/dev/zero of=/dev/sda bs=512 count=1.

I'm not quite sure if cPanel wants free unformatted space or if it needs unused space inside a mounted filesystem. If it wants free unformatted space just create an empty partition table and you're done. It might need a reboot if /dev/sda was somehow in use.

If cPanel wants unused space inside a mounted filesystem, create a partition spanning the whole disk. This partition is then /dev/sda1. Use mkfs.ext4 /dev/sda1 to format it and mount /dev/sda1 /mountpoint to mount it (You'll have to create an entry in /etc/fstab to mount it at boot time). After that you'll have to tell cPanel to use /mountpoint.

Share:
8,903
htorbov
Author by

htorbov

Showtime!

Updated on September 18, 2022

Comments

  • htorbov
    htorbov over 1 year

    I want to format my hard disk (/dev/sda) to be unallocated (free space).

    The reason I want this is because I'm installing cPanel CentOS disk and it shows me that there's not free space on my system.

    This is the format command that I know, but the hard drive isn't becoming "free" when I format it that way: mkfs.ext4 /dev/sda

  • htorbov
    htorbov over 10 years
    Thanks for your reply! Well, I did "mkfs.ext4 /dev/sda" then "dd if=/dev/zero of=/dev/sda bs=512 count=1" and now I got a message that 512 bytes are copied. Then CentOS cPanel installation gives me "Not enough free space on disks" again. Weird... BTW, I see my hard drive (4TB) with fdisk -l
  • Michael Suelmann
    Michael Suelmann over 10 years
    You now have an empty drive. You'll need to add a partition and format that as described above. With 4TB you can't use fdisk anymore because it can use MBR only and that is limited to 2TB. You can use gdisk or parted to create a GPT partition.
  • htorbov
    htorbov over 10 years
    Can you help me with a sample command to create the partition, please?
  • Michael Suelmann
    Michael Suelmann over 10 years
    start gdisk with gdisk /dev/sda. You get a prompt where you can enter single character commands. With p you get a list of current partitions. Check that you have the right disk. With n you can add a new partition. You are asked for the parameters. The defaults should be okay (partition number: 1, first sector: 2048, last sector: maximum). After that you can write the partition table with w.
  • htorbov
    htorbov over 10 years
    Wow, it worked! Much gratitude!