Virtual Disk Image

Single Line Parted Partition

Posted by

This guide will help us do a single line parted partition for the full volume. I was running into difficulties when adding a new hard drive for glusterfs volumes on some k8s vm nodes and I noticed that there were no good search results for a single line fdisk or parted partition and had to consult the man pages for parted. From there I was able to create this.:

sudo parted -s /dev/sdb mklabel msdos mkpart primary 0% 100%

** This assumes that your disk is /dev/sdb please modify as needed
** You will get no prompts to fix the partition

For Extras read below:

After using this single line to use 100% of the new volume in parted, we want to make a quick ext4 format:

sudo mkfs.ext4 /dev/sdb1

After this is completed you are good to mount the partition of our new disk.

We would be lacking in fstab if we do not use a label, so we will add the label. We will also create the directory and add in a line for fstab:

sudo e2label /dev/sdb1 glusterfs
sudo mkdir /glusterfs
sudo echo 'LABEL=glusterfs /glusterfs ext4 defaults 0 0' >> /etc/fstab

With this guide you will promptly get a fully working new disk in your vm or physical machine. This makes it much easier than having to follow the prompts and scripting this also becomes much easier. I have provided a full dump of all the commands below in order to help put this in a simple script. You can also download my script from here: script_on_git

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.