0

I am making my own script for partitioning disks and I am unable to mount the partitions which were just created using parted CLI tool.

I am doing this on a virtual machine with virtual disks, but this should not matter as far as I know.

I execute:

parted -s ${device} mklabel gpt
parted -s ${device} mkpart primary ${fileSystem} ${start} ${end}

Variables in my testing scenario were

device=/dev/sdb
fileSystem=ext4
start=1
end=5000

Virtual disk is 10gb in size, so my scenario should create a 5gb partition, and it does if I use fdisk -l to list disks, but when I try to mount the newly created partition I get this:

wrong fs type, bad option, bad superblock on /dev/sdb1, missing codepage or helper program, or other error

Edit: I was not using mkfs the right way, I got it working now.

  • 2
    parted only sets partition type, but does not mkfs – frostschutz Apr 18 at 17:27
  • I tried executing mkfs after parted, but this only works for the first time. I do execute the wipefs command before doing parted and mkfs stuff to ensure there is no partition table or partitions on the disk, but mkfs for some reason detects the previous filesystem and asks for a user input, which I cannot have in a script – fingust Apr 18 at 17:42
  • maybe this? unix.stackexchange.com/a/394999/30851 – frostschutz Apr 18 at 18:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.