Disk Management With Parted Command In Linux | Manage Partitions on MBR & GPT Disks Using Parted

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
for more videos press the subscribe button and  also turn on the bell notifications to receive   the updates directly in your device hello friends  i vikas nara welcome you all to our nhira classes   youtube channel in today's tutorial we will learn  the disk management with parted command in linux   the parted command is one of the important  commands that we use for the disk management   in linux because it can handle the mbr partition  scheme as well as the gpt partition scheme so in   today's tutorial we will learn how can  we create or manage the mbr partitions   by using the parted command as well as we  will learn how can we create or manage the   gpt partitions so without  wasting time let's get started [Music] mbr partition scheme and gpt partition scheme  both use different methods to store the partition   information in the disk we cannot use both schemes  in a single disk since in this tutorial we will   create both types of partitions so we would  require two separate disks and we have already   added two virtual disks in our machine which i  can show you with the help of the lsblk command   so here in the output of lsblk you can see that  sdb is there as well as sdc is present both are of   5 gb in capacity or if you want to see the details  you can also execute the fdisk hyphen l command   there also you can see the details of these  disks so you can see that sdc of 5gb is present   and as well as sdb of 5gb is there since we want  to use the parted command so in this tutorial we   will only focus only on the parted command so  first i will show you how can you create or   manage the mbr partitions with the parted command  and then i will show you how can you create or   manage the gpt partitions with the same command  so first we are going to create the mbr partitions   so if you will simply execute the parted  command it will automatically select   the first available disk so every time when you  want to use the parted command make sure that you   mention the disk name as the argument after the  parted command so let me quit the parted utility   and here to create the mbr partitions we are going  to use the sdb disk so for that we will execute   the parted command with the disk name so  after the parted command we will simply   mention slash dev slash sdb so it will select  the sdb disk after that to see the information   you can simply execute the print command  inside the parted utility so it will show you   all the information regarding this disk the print  command provides important information about   the disk this information includes manufacturer  information disk model disk size partition table   and disk flag if this is a new disk we will get  unrecognized disk label error so this is the   error so since we are using the new disk that  is why this error is present here disk level   is the information which is used to determine  the type of the disk the parted command   needs a valid disk label before it can do  anything with the disk so see it practically   run mk part command for that the mk part  command is used to create the new partition   so if i will execute the mk part command here it  will give an error and the error is unrecognized   disk label so the disk level must be present if  you want to create the partitions as the above   output confirms that we are not allowed to create  the new partition unless it has a valid disk level   so in order to create the mbr partitions the disk  label must be ms dos and for the gpt partitions   the disk level would be gpt only to assign the  disk level mk label command is used inside the   parted utility so before creating the partitions  we will create the label on the disk so simply   we have to execute the mk label command here  inside the parted utility then it will prompt   you here you have to mention the label which  you want to set so as i mentioned earlier   for the mbr disk we will mention here ms dos  after that we will again execute the print command   and this time it will not show us that error here  it will show us the label and the level is ms dos do not use this command if disk contains data this  command is very risky this command will convert   disk in on partitioned blank disk  silently now the disk has level   we can create partitions in it and to  create the partitions we have to follow   these steps as i am going to show you so  we have to execute the mk part command here   mk part and we will have to press enter then  it will prompt us for the partition type here   either we can create the primary partition  or we can create the extended partition so i   am going to create the primary partition first  so i will mention here primary and press enter   then it will prompt us for the system type so  there we will use the default one that is ext2   after that it will ask us for the size from  where we want to start the sectors so here we   can simply mention 1 mb after that it will prompt  us for the ending sector here we can mention the   number as per the size i want to create a  partition of 600 mb so i will mention here   600 m and again i will execute the print command  to see the partition now you can see that   a partition of 600 mb is created there on this  disk always start first partition with 1 mb only   first 512 bytes are used to store the mbr data  this way we can avoid several entry point errors   again to create the more partitions you  have to execute the mk part command again   there it will prompt you for the primary or  secondary partition type so i want to create one   more primary partition here so i will write their  primary after that the file system type would be   xt2 so simply press enter here now to create the  second partition we have to mention this size   after the primary partition so i will write  here 601 as the starting sector and after that   i will mention 800 here because i want to create  a partition of 200 mb only and press enter again   to see the details i can execute the print command  so you can see that now this disk has two primary   partitions one of 600 mb and another one of 200  mb again we can follow the same process to create   more partitions so let me execute mk part  command again again i want to create one   more primary partition here so i will write  here primary file system type would be exe2   and this time we have to start the sector with 801  you can simply mention 801 it will automatically   take the size in mbs and after that you  have to mention the and sector so i want to   have the size of 200 mbs here so i will write  there 1000 and i can execute the print command   to see the details of these partitions so we have  created three primary partitions on this disk   now as you know that on mbr disks we can only  create up to four primary partitions or three   primary one extended now the next partition i  am going to create as the extended partition   on this disk so for that we have to again execute  the mk part command so let me execute mk part   this time we will not mention primary here we  will simply write here extended and press enter   and after that we will mention the starting  sector as 1001 and the ending sector as 2100   after that i will execute the print command so  i can show you the details of these partitions   so three primary partitions are there and one  extended now inside this extended partition   we can further create the logical partitions all  logical partitions will be created in the extended   partition the sum of all logical partitions cannot  go beyond the extended partition in this example   we created an extended partition of about  900 mbs so we can create logical partitions   up to 900 mb only we are allowed to  create up to 15 logical partitions   in this extended partition we can create any  number of partitions from range 1 to 15. the only   limit is that the sum of all partitions must be  below the size of the extended partition so let's   create a single logical partition of all available  space so again execute the mk part command here   after that we will write here logical after that  we will go with the default system type that is   2 and here we can mention the size as one zero  zero two and the ending size as two zero four five   after that we can execute the print command so  there you can see that three primary partitions   are there and one extended and inside this  extended partition we have one logical partition we have used all space of the extended partition  in one logical partition so even we are allowed   to create up to 15 logical partitions and free  space is available outside the extended partition   but we cannot create another logical partition  to create another logical partition we need free   space inside the extended partition note outside  the partition so you have to keep it in your   mind that we cannot create the partitions if we  don't have the sufficient space available in the   extended partition now in order to quit the  parted utility you can mention quit there   and press enter now if you want to see the details  of these partitions on the disk you can simply   execute the lsblk command so there you can see the  details of the partitions partitions that you have   created by using the parted command or you can  also execute the fdisk hyphen l command there it   will also show you the details of these partitions  have a look at this now since the parted command   cannot update in memory kernel partition table  so we have to execute the part probe command here   part probe slash dev slash sdb now the kernel  knows the changes which we have made on the disk   so we are done with the mbr partitions now i  will show you how can you create or manage the   gpt partitions with the parted command gpt is the  new partition scheme it allows us to create up to   128 partitions as i have shown you in the previous  tutorial as well it does not divide partitions   in primary extended and logical we will create  gpt partitions in slash dev slash sdc disk and   let's initiate the parted command again with  slash dev slash sdc so let me show you this   time we are going to use this disk that is less  devs less sdc so let's execute the parted command   parted slash steps less sdc press enter after  that we have to follow the same procedure that   we have followed while creating the partitions  under mbr scheme so here we will execute the mk   part command so here it is saying unrecognized  disk so first of all we will create the label so   let's execute the mk label command and we have  to mention here gpt for the guid partition table   after that we can execute the print command so  there you can see the details of the labels and   the label is gpt now and now in order to create  the partitions we can execute the mk part command after that it will prompt us for the partition  name here you can give any name let me write   here linux then the file system type would  be xc2 so we will simply press enter here   after that we will mention this  starting size so we will write here 1   m for 1 mb and the ending size would  be 600 mb so i will write here 600 m   so the partition is created we can execute the  print command they are inside the parted utility   it will show us the partition there similarly we  can create more partitions so let's execute the   mk part command so again it is asking us for the  partition name let me write the name as document   file system type is ext2 starting size  would be 601 ending size would be 1000   and let me confirm the changes by running  the print command so we have created two   partitions on this disk and similarly we  can create up to 128 primary partitions   on the gpt disk now i will simply quit the  parted utility by running the quit command   now we will execute the part probe command  so that the kernel can read these changes   and let me execute the lsblk command as well so it  will show us the details of the partitions that we   have created on different disks so so far we have  created mbr and gpt partitions in flash dev slash   sdb and slash dev slash sdc disks respectively  these partitions are useless unless we put a file   system in there file system is a logical container  which allows us to store files and directories   to create a file system in partition we  format it with supported file system type   to format a partition we can execute the mkfs  command so let me execute mkfs dot ext3 and after   that i will mention the partition name so i will  format slash dab slash sd b1 partition as ext3 same i'll do with other partition so   let me create the ext4 file system there so i  will execute mkfs dot ext4 slash dev slash sdb2   after that in order to store the data we have  to mount some directories on these partitions   so let me create two different directories  under slash srv so on srv directory i'll create   test one and test two directories now i  am going to mount these directories there   on these partitions so on slash devs less  sdv1 i will mount slash srv slash test one   and on sdb2 i will mount slash srv slash test2 to  see the details of the mounted file systems we can   execute the df hyphen h command and here you can  see that both the directories are successfully   mounted if you want to make it permanent you  can make an entry in the fstab file as well   for that you would require the uuid that you can  see with the help of lsblk hyphen f command or   the blk id command so this uuid you can mention  there in the fstrap file for all the partitions   which you want to make permanently mounted now  we can store the data so we can go to slash   srv slash test one and there we can create  the data so let me create some files there   i'm going to create nine files in one go  so the data is created there now let me go   to slash service less test to directory  and there also i will create some data touch a to m so we have created some  files on both the directories   now if you want to use these partitions as  lvm so you have to create the physical volumes   first so let me execute the pv create  command pv create slash step slash sdc1   so this will create the physical volume  on slash dev slash sdc1 partition and   we can see the details by running the previous  command so the physical volume is created on   this partition now we have to create the volume  group so we can execute the vg create command   vgcreate and after that we have to mention  the name of the vg so let me mention the name   as linux vg and after that we have to mention the  physical volume name that is slash dev slash sdc1   and to see the details we can execute the vgs  command so the volume group is successfully   created now we have to create the logical volume  so we can execute the lv create command lv create   hyphen capital l after that we can specify  the size so let me mention the size as 500 mb   hyphen n for the new and after that we can  mention the name of the logical volume so let   me mention the name as linux lv and after that we  can mention the volume group name that is linux pg   and we can see the details by running the lvs  command so the logical volume is also created   now we can format it so we can execute the  mkfs command and let me format it as xfs so i   will write there mkfs.xfs and after that we can  mention the lvm name so this is formatted and   we can execute the blk id command  for that as well to see the uuid linux vg slash linux lv so this is the uuid  with this we can permanently mount this as   well on any directory with the help  of the fstep file now i will show you   how to delete the mbr partitions to delete the  mbr partitions you have to unmount them first so   let's check the mounted file systems so these two  are mounted currently so let's unmount them so let   me execute the unmount command amount slash srv  slash test s trick so it will unmount both of them   again we will verify them by running the df hyphen  h command so both the file systems are unmounted   now we can again execute the parted command  parted slash dev slash sdb so we are inside   the parted utility to remove the partitions  we can execute the rm command but before that   let me execute the print command it will show  us the partitions available inside this disk   so there are five partitions let us remove  each one of them so i will execute rm1 rm two   rm three so first three primary partitions  are gone now we have to remove the logical   volume first so we have to execute rm5 first and  after that we can execute rm4 because the fourth   partition is the extended partition so before  deleting the extended partition we have to remove   the logical partition first now we can again  execute the print command so all the partitions   are successfully removed we can simply quit the  parted utility you have to execute the part probe   command so that the kernel can read these changes  so you have to mention slash dev slash sdb there   so we have successfully removed the partitions  from the mbr disk now in case if you want to   remove the gpt partitions the procedure is  the exactly same you have to execute the   parted command with the disk name and after  that you can execute the rm command there   so guys that's it from my side for today's  session i hope you would have enjoyed the session   if you like it then do share it with your friends  and colleagues and give a like to this video   and if you are new on this channel then please  subscribe us and turn on the bell notification   i'll see you in the next one till then bye  bye jai hind vande mataram take care [Music] [Music] [Applause] [Music]
Info
Channel: Nehra Classes
Views: 10,560
Rating: undefined out of 5
Keywords: Nehra Classes, Vikas Nehra, Linux Training, Ansible Training, RHCSA 8, RHCSA (EX 200), RHCE 8, RHCE (EX 300), Ansible, GPT Disk Linux, GPT Vs MBR, Linux GPT Disk Tutorial, mdsos partition linux, parted command linux, gpt partition linux, GUID partition table in linux, Disk management using parted command in linux, manage disk partitions with parted command, linux parted command use, parted command ubuntu, parted command in RHEL, mbr partition scheme, GPT partition scheme
Id: Lpc1Ech2KWE
Channel Id: undefined
Length: 23min 18sec (1398 seconds)
Published: Sun Sep 12 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.