disks and devices:
How we are going to do ,partitions with three different tools?
Actually creating filesystems from that partitions.
Each ten gigabytes in size.
We use each disk 10 for fdisk,gdisk and parted.
How we prepare the drive to be used?
- There are number of different types you will go through:
- The physical installation or in the case of virtual machine,the allocation of disk to the virtual machine.
- that is the partioning of the device,using one of several partioning tools.
- depending on the size,feature and what you want to do with it.
- Then you will be format the partition,which where your allocating particular type of filesystem.
- Then you will also create the system mountpoint directory that we mounted on.
- Then you will determine the access permissions.
- You will mount the device on the partition on the chosen directory mount point and if it
- intended to be a persistent device.will have to entry to the /etc/fstab file.
- Linux everything treated as a file.
- So even our disk or intended to be treated as a file,
- As a result we have entries to be in our dev directory: entries are
[ root@la ~]# cd /dev
[ root@la dev]#
entries are correspond to the drive name.that is been given.
Generally the name for the sdd drives is the sda1,sdb and partitions are numbered on top of it.
Each partition are numbered are associated with it
Now for standard device directory location,historically IDE are:
They are different kinds of partitions:
There is primary partition:this is independent of extended and logical partitions.
Typically they are four primary partitions:
Which is historically limited to MBR (Master boot record).we talked about this during the
bootloader.
Ofcourse,with some exceptions for the modern linux distributions.
As a result of limitation of only being to have four kinds of partitions,the extended partition was
developed.
Although it counts in the four primary partitions,you can only have one of this drive,but you can
think of the container for the logical partitions.
therefore the logical partitions in that extended
partitions,we can have multiple depending upon the disk space.that you have available.
It was the way working around,the four primary partitions limit,that was for MBR
devices,historicaly and it was for the devices under 2tb’s,as a result of modern linux
distributions,being able to support drives more than 2tb’s and their availablity.
Something,we have to support for the drives at that size and address some of the limitations,
Particularly on the primary partitions,enable to have four primary partitions.
So that is the development of the GUID,in the GPT partition.
Basically,it treats the partitions,exactly the same way,but it requires different partition
tool,gdisk come in to the evation and gpt based drive,will allow you upto 128 primary
partitions,eliminates the need entirely,extended in the logical partitions.that doesn’t mean
that,we cannot do logical volume management,but that is the separate topic about the logical
volume and logically partitions goes in hand-in-hand.
So,historically,primary partitions are the 134 and logically partitions are 53n(6.54),again when
we are talking about the MBR based drives,for gpt drives the primary partitions are 1-128.
We have three drives:
An easy way for me to find out,what is available is :by issuing the fdisk -l
Fdisk is the primary partitioning tool that is been installed with linux,pretty much since,it is
same for Dos and windows.
[ root@la dev]# fdisk -l
Disk /dev/xvde: 6442 MB, 6442450944 bytes
255 heads, 63 sectors/track, 783 cylinders
Units = cylinder of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/xvde1 1 766 6144000 83 Linux
Partition 1 does not end of cylinder boundary.
/dev/xvde2 766 784 146432 82 Linux swap/solaris
we got list of all drives in our system.
We have /dev/xvde1 and /dev/xvde2:which Is formatted and available as a linux
And another one is the linux swap.
We have this 3 ----20gb partitions.that as a not as partition disks,they do not have any
partitions.
We are going to order from /dev/xvdj:
Device Boot Start End Blocks Id System
/dev/xvde1 1 766 6144000 83 Linux
Partition 1 does not end of cylinder boundary.
/dev/xvde2 766 784 146432 82 Linux swap/solaris
Disk /dev/xvdj : 21.5 GB, 21474836480 bytes
255 heads,63 sectors/track, 2610 cylinders
units = cylinder of 16065 * 512 = 8225280 bytes
Sector size (logical/physical) : 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000000000
Disk /dev/xvdj : 21.5 GB, 21474836480 bytes
255 heads,63 sectors/track, 2610 cylinders
units = cylinder of 16065 * 512 = 8225280 bytes
Sector size (logical/physical) : 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000000000
[ root@la dev]#
so,we are doing fdisk on that selected portions:
On the second one,we are planning to use the gdisk:
and on
Device Boot Start End Blocks Id System
/dev/xvde1 1 766 6144000 83 Linux
Partition 1 does not end of cylinder boundary.
/dev/xvde2 766 784 146432 82 Linux swap/solaris
Disk /dev/xvdj : 21.5 GB, 21474836480 bytes
255 heads,63 sectors/track, 2610 cylinders
units = cylinder of 16065 * 512 = 8225280 bytes
Sector size (logical/physical) : 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000000000
Disk /de/xvdg: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes /512 bytes
Disk identifier: 0x000000000
Disk /dev/xvdj : 21.5 GB, 21474836480 bytes
255 heads,63 sectors/track, 2610 cylinders
units = cylinder of 16065 * 512 = 8225280 bytes
Sector size (logical/physical) : 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000000000
Disk /de/xvdg: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes /512 bytes
Disk identifier: 0x000000000
and on the third one we are using the parted:
Device Boot Start End Blocks Id System
/dev/xvde1 1 766 6144000 83 Linux
Partition 1 does not end of cylinder boundary.
/dev/xvde2 766 784 146432 82 Linux swap/solaris
Disk /dev/xvdj : 21.5 GB, 21474836480 bytes
255 heads,63 sectors/track, 2610 cylinders
units = cylinder of 16065 * 512 = 8225280 bytes
Sector size (logical/physical) : 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000000000
Disk /dev/xvdg: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes /512 bytes
Disk identifier: 0x000000000
Disk /dev/xvdf: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes /512 bytes
Disk identifier: 0x000000000
Disk /dev/xvdj : 21.5 GB, 21474836480 bytes
255 heads,63 sectors/track, 2610 cylinders
units = cylinder of 16065 * 512 = 8225280 bytes
Sector size (logical/physical) : 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000000000
Disk /dev/xvdg: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes /512 bytes
Disk identifier: 0x000000000
Disk /dev/xvdf: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes /512 bytes
Disk identifier: 0x000000000
Fdisk is an historical way of tool,because it will only support four partitions and it will only
support upto 2Tb’s.
We have don’t have partitions currently,so we no need to specify the partitions number:
[ root@la dev]# fdisk /dev/xvdj
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disk label
Building a new DOS disk label with disk identifier 0xe4ee34be
changes willl remain in memory only, until you decide to write them
After that of course, the previous content won't be recoverable
[ root@la dev]# fdisk /dev/xvdj
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disk label
Building a new DOS disk label with disk identifier 0xe4ee34be
changes willl remain in memory only, until you decide to write them
After that of course, the previous content won't be recoverable
Disk /dev/xvdj : 21.5 GB, 21474836480 bytes
255 heads,63 sectors/track, 2610 cylinders
units = cylinder of 16065 * 512 = 8225280 bytes
Sector size (logical/physical) : 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000000000
Command (m for help) : m
Command action
a toggle a bootable flag
b edit bad disk label
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
0 create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty sun disk label
t change a partitions system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
Command (m for help) : m
Command action
a toggle a bootable flag
b edit bad disk label
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
0 create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty sun disk label
t change a partitions system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
Command (m for help) : n
Command action
e extended
p primary partition (1-4)
Command (m for help) : n
Command action
e extended
p primary partition (1-4): 1
Command (m for help) : n
Command action
e extended
p primary partition (1-4): 1
Command (m for help) : n
Command action
e extended
p primary partition (1-4): 1
Disk /dev/xvdj : 21.5 GB, 21474836480 bytes
255 heads,63 sectors/track, 2610 cylinders
units = cylinder of 16065 * 512 = 8225280 bytes
Sector size (logical/physical) : 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000000000
Device Boot Start End Blocks ID system
/dev/xvdj1 1 262 2104483 83 Linux
Command ( m for help)
Command (m for help) : n
Command action
e extended
p primary partition (1-4): 2
That is the second partition:
it is smart enough that the cylinder allocated space between the 1-262 and start from the 263 to 2610
Command (m for help) : n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (263-2610, default 263):
Partition number (1-4): 2
First cylinder (263-2610, default 263):
Disk /dev/xvdj : 21.5 GB, 21474836480 bytes
255 heads,63 sectors/track, 2610 cylinders
units = cylinder of 16065 * 512 = 8225280 bytes
Sector size (logical/physical) : 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000000000
Device Boot Start End Blocks ID system
/dev/xvdj1 1 262 2104483 83 Linux
/dev/xvdj2 263 524 2104515 83 Lines
Command (m for help):
Disk /dev/xvdj : 21.5 GB, 21474836480 bytes
255 heads,63 sectors/track, 2610 cylinders
units = cylinder of 16065 * 512 = 8225280 bytes
Sector size (logical/physical) : 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000000000
Device Boot Start End Blocks ID system
/dev/xvdj1 1 262 2104483 83 Linux
/dev/xvdj2 263 524 2104515 83 Linux
Command (m for help): t
Partition number (1-4): 2
Hex code (type L to list codes) : l
and provide it,Which one you want to change.
Hex code (type L to list codes) : 82
Changed system type of partition 2 to 82 (linux swap / solaris)
Command (m for help) :
when you do the 'p'.
you can see the list of partitions with there filesystem types:
Disk /dev/xvdj : 21.5 GB, 21474836480 bytes
255 heads,63 sectors/track, 2610 cylinders
units = cylinder of 16065 * 512 = 8225280 bytes
Sector size (logical/physical) : 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000000000
Device Boot Start End Blocks ID system
/dev/xvdj1 1 262 2104483 83 Linux
/dev/xvdj2 263 524 2104515 83 Linux swap / solaris
Device Boot Start End Blocks ID system
/dev/xvdj1 1 262 2104483 83 Linux
/dev/xvdj2 263 524 2104515 83 Linux swap / solaris
255 heads,63 sectors/track, 2610 cylinders
units = cylinder of 16065 * 512 = 8225280 bytes
Sector size (logical/physical) : 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000000000
Device Boot Start End Blocks ID system
/dev/xvdj1 1 262 2104483 83 Linux
/dev/xvdj2 263 524 2104515 83 Linux swap / solaris
[ root@la dev]# gdisk /dev/xvdg
GPT fdisk (gdisk) version 0.8.10
Partition table scan:
MBR: not present
BSD: not present
APM: not present
GPT: not present
Creating new GPT entries
Command (? for help)
[ root@la dev]# gdisk -l /dev/xvdg
GPT fdisk (gdisk) version 0.8.10
Partition table scan:
MBR: not present
BSD: not present
APM: not present
GPT: not present
Creating new GPT entries
Command (? for help)
[ root@la dev]# which parted
/sbin/parted
[ root@la dev]#
Disk /dev/xvdf: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes /512 bytes
Disk identifier: 0x000000000
[ root@la dev]# parted /dev/xvdf
GNU Parted 2.1
Using /dev/xvdf
Welcome to GNU Parted! Type 'help' to view a list of commands
(parted).
We used parted here:to do this:
[ root@la dev]# parted /dev/xvdf
GNU Parted 2.1
Using /dev/xvdf
Welcome to GNU Parted!Type help to view a list of commands.
(parted) help
(parted) mislabel kudos
Warning: The existing disk label on /dev/xvdf will destroyed and all data on this disk will be lost,Do you want to continue?
Yes/No? yes
(parted)
[ root@la dev]# fdisk -l /dev/xvdf
Disk /dev/xvdf: 21.5 GB, 21474836480 bytes
89 heads, 62 sectors/track, 17346 cylinders
Units = cylinders of 2418 * 512 = 1238016 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disk label
Building a new DOS disk label with disk identifier 0xe4ee34be
changes willl remain in memory only, until you decide to write them
After that of course, the previous content won't be recoverable
we got an invalid point.because this drive is raw at this point.so at currently there are no
partition table
Fdisk is the part of the partitions process,when we write it,we create a partition table for us.
Just completely fine.exactly,what we wanted to do.
So this is the device,if anything have on it for example,it is formatted with a different type of
partition table.because there are number of them as we see.you wanted to be sure,that is
the device you want.
If you want to see ,any information ,before the device is formatted.
We press the ‘p’ key:
[ root@la dev]# fdisk /dev/xvdj
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disk label
Building a new DOS disk label with disk identifier 0xe4ee34be
changes willl remain in memory only, until you decide to write them
After that of course, the previous content won't be recoverable
Disk /dev/xvdj : 21.5 GB, 21474836480 bytes
255 heads,63 sectors/track, 2610 cylinders
units = cylinder of 16065 * 512 = 8225280 bytes
Sector size (logical/physical) : 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000000000
Command (m for help) : m
Command action
a toggle a bootable flag
b edit bad disk label
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
0 create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty sun disk label
t change a partitions system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
one letter can manage the partitions on our table.
Now we have a 20gb disk,now we have to partition:
We can partition,however we like:
Now we are keeping partitioning sizes relatively small,because later on when we create the
filesystem type,when we increase the partition size,it will take longer time it will take to
format,as well as to finish the partitioning scheme.
As we have 20gb,we can create multiple partitions to run.
We can add a new partition,by using the letter ‘n’
Command action
a toggle a bootable flag
b edit bad disk label
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
0 create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty sun disk label
t change a partitions system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
Command (m for help) : n
Command action
e extended
p primary partition (1-4)
there are two kinds of partition:extended and the primary partition.
as there are no partitions before,we are selecting the parimary partitions and the number of
the partitions is ‘1’
Command action
e extended
p primary partition (1-4): 1
first cylinder,start my first partitions at the beginning of my free space.
p
Partition number (1-4): 1
First cylinder (1-2610, default 1)
Using default value 1
Last cylinder, +cylinder or +size{K,M,G} (1-2610, default 2610):
and we can indicate number of cylinders,there are couple of ways to do this:
on partition one,we have the ability to create from 1-2610.(13.05 Is the ending cylinder,that I
am going to standby.).
I want to confirm,how much the size of the drive be.
Command action
e extended
p primary partition (1-4): 1
first cylinder,start my first partitions at the beginning of my free space.
p
Partition number (1-4): 1
First cylinder (1-2610, default 1)
Using default value 1
Last cylinder, +cylinder or +size{K,M,G} (1-2610, default 2610): +2G
this is where,your saying you want 2g of the cylinder.
Command action
e extended
p primary partition (1-4): 1
first cylinder,start my first partitions at the beginning of my free space.
p
Partition number (1-4): 1
First cylinder (1-2610, default 1)
Using default value 1
Last cylinder, +cylinder or +size{K,M,G} (1-2610, default 2610): +2G
Command (m for help):
this is where, you print the cylinder
Disk /dev/xvdj : 21.5 GB, 21474836480 bytes
255 heads,63 sectors/track, 2610 cylinders
units = cylinder of 16065 * 512 = 8225280 bytes
Sector size (logical/physical) : 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000000000
Device Boot Start End Blocks ID system
/dev/xvdj1 1 262 2104483 83 Linux
Command ( m for help)
if I want to add one more partition 2:
Command action
e extended
p primary partition (1-4): 2
That is the second partition:
it is smart enough that the cylinder allocated space between the 1-262 and start from the 263 to 2610
Command (m for help) : n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (263-2610, default 263):
Partition number (1-4): 2
First cylinder (263-2610, default 263):
Using default value 263
Last cylinder, +cylinder or +size{K,M,G} (263-2610, default 2610) : +2G
we are doing another 2gb partition:
when we print the values :
255 heads,63 sectors/track, 2610 cylinders
units = cylinder of 16065 * 512 = 8225280 bytes
Sector size (logical/physical) : 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000000000
Device Boot Start End Blocks ID system
/dev/xvdj1 1 262 2104483 83 Linux
/dev/xvdj2 263 524 2104515 83 Lines
Command (m for help):
the 1 and 2 have the same size.
We can see the ID’s and when we see the system type,it is automatically assigned when we
create in the fdisk.it will also automatically assigned ID:83 which is associated with the
filesystem:linux.
If want to display the complete filesystem:we have to press ‘l’ key
Command (m for help): l
0 Empty
1 FAT12
since,we are set for linux filesystem type.
If we want to change the type:click on ‘t’ key and change it.
Command (m for help): t
Partition number (1-4):
for which partition number you want to change the filesystem type:
255 heads,63 sectors/track, 2610 cylinders
units = cylinder of 16065 * 512 = 8225280 bytes
Sector size (logical/physical) : 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000000000
Device Boot Start End Blocks ID system
/dev/xvdj1 1 262 2104483 83 Linux
/dev/xvdj2 263 524 2104515 83 Linux
Command (m for help): t
Partition number (1-4): 2
Hex code (type L to list codes) : l
and provide it,Which one you want to change.
Hex code (type L to list codes) : 82
Changed system type of partition 2 to 82 (linux swap / solaris)
Command (m for help) :
when you do the 'p'.
you can see the list of partitions with there filesystem types:
Command (m for help): p (print the partition numbers).
for which partition number you want to change the filesystem type:
255 heads,63 sectors/track, 2610 cylinders
units = cylinder of 16065 * 512 = 8225280 bytes
Sector size (logical/physical) : 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000000000
Device Boot Start End Blocks ID system
/dev/xvdj1 1 262 2104483 83 Linux
/dev/xvdj2 263 524 2104515 83 Linux swap / solaris
successful it is changed to the linux swap.
The partition table will created,when Fdisk was started up.we need to specify the write
changes specified to the disk.
/dev/xvdj1 1 262 2104483 83 Linux
/dev/xvdj2 263 524 2104515 83 Linux swap / solaris
Command (m for help) : w
The partition table has been altered!
Calling ioctl() to re-read partition table
Syncing disks
[ root@la dev]#
We can see the changes:
Disk /dev/xvdj : 21.5 GB, 21474836480 bytesWe can see the changes:
255 heads,63 sectors/track, 2610 cylinders
units = cylinder of 16065 * 512 = 8225280 bytes
Sector size (logical/physical) : 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000000000
Device Boot Start End Blocks ID system
/dev/xvdj1 1 262 2104483 83 Linux
/dev/xvdj2 263 524 2104515 83 Linux swap / solaris
because the filesystem type has changed from linux to the linux swap/Solaris.
The gdisk tool is the tool similar to the fdisk.
[ root@la dev]# gdisk /dev/xvdg
Fdisk was installed with linux distribution
[ root@la dev]# yum install gdisk
xxxx
xxxxx
xxxxx
xxxx
xxxxx
Once you install that:
GPT fdisk (gdisk) version 0.8.10
Partition table scan:
MBR: not present
BSD: not present
APM: not present
GPT: not present
Creating new GPT entries
Command (? for help)
none of them are present,now it will help us to entries the GPT:
list of information on my disk using p:
Command (? for help): p
Disk /dev/xvdg: 41943040 sectors, 20.0 GiB
Logical sector size: 512 bytes
Disk identifier (GUID) : 5Dxxxxxxxxxxxxx
Partition table holds up to 128 entries
First usable sector is 34,last usable sector is 41943006
Partitions will be aligned on 2048-sector boundaries
Total free space is 41942973 sectors (20.0 GiB)
I can get list of commands by using the :?
Command (? for help): ?
b back up GPT data to a file
c change a partition's name
d delete a partition
i show detailed information on a partition
l list known partition types
n add a new partition
o create a new empty GUID partition table (GPT)
p print the partition table
q quit without saving changes
r recovery and transformation options
s sort partitions
t change a partition's type code
v verify disk
w write table to disk and exit
x extra functionality (experts only)
? print this menu
Command (? for help):
n is for creating the partition:
command (? for help): n
Partition number (1-128, default 1):
the partition is 1-128
Instead of creating the primary partition and extended partition
Gpt will allow mw, to create 128 different kind of partitions.
Disk /dev/xvdg: 41943040 sectors, 20.0 GiB
Logical sector size: 512 bytes
Disk identifier (GUID) : 5Dxxxxxxxxxxxxx
Partition table holds up to 128 entries
First usable sector is 34,last usable sector is 41943006
Partitions will be aligned on 2048-sector boundaries
Total free space is 41942973 sectors (20.0 GiB)
Number Start (sector) End (sector) Size code Name
Command (? for help): ?
b back up GPT data to a file
c change a partition's name
d delete a partition
i show detailed information on a partition
l list known partition types
n add a new partition
o create a new empty GUID partition table (GPT)
p print the partition table
q quit without saving changes
r recovery and transformation options
s sort partitions
t change a partition's type code
v verify disk
w write table to disk and exit
x extra functionality (experts only)
? print this menu
The first sector is the one, whatever indicated in the disk.
Command (? for help): n
Partition number (1-128, default 1):
First sector (34-41943006, default = 2048) or {+-size{KMGTP}
(KMGTP = KILOBYTES,MEGABYTES,GIGABYTES,TERABYTES AND PETABYTES.)
I want to create a disk size.
Gdisk supports upto 2terabytes.
Command (? for help): n
Partition number (1-128, default 1):
First sector (34-41943006, default = 2048) or {+-}size{KMGTP}: +2G
last sector (4196352-41943006, default = 41943006) or {+-}size{KMGTP}:
and the last sector is the +4G
start at +2gb to 4gb which still gives me the 2gigabytes of disk.
Command (? for help): n
Partition number (1-128, default 1):
First sector (34-41943006, default = 2048) or {+-}size{KMGTP}: +2G
last sector (4196352-41943006, default = 41943006) or {+-}size{KMGTP}: +4G
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, enter = 8300):
and the current filesystem type is linux file system.
We got many number of filesystems:
Hex code or GUID (L to show codes, enter = 8300): l
0700 Microsoft basic data
3000 ONIE boot
okay,now are creating the partition number 2:
Partition number (2-128, default 2): 2
First sector (34-41943006, default = 12584960) or {+-}size{KMGTP}
Partition table holds up to 128 entires
First usable sector is 34, let usable sector is 41943006
Partitions will be aligned on 2048-sector boundaries
Total free space 33554365 sectors (16.0 GiB)
Number Start (sector) End (sector) Size code Name
1 419635 12584959 4.0 GiB 8300 Linux filesystem
Command (? for help): n
Partition number (2-128, default 2): 2
First sector (34-41943006, default = 12584960) or {+-}size{KMGTP}
Last sector (12584960-41943006, default = 41943006) or {+-}size{KMGTP}: +2g
Current type is 'Linux filesystem'
hex code or GUID (L to show codes, Enter = 8300) : 8200
Changed type of partition to 'Linux swap'
Command (? for help): p
Disk /dev/xvdg: 41943040 sectors, 20.0 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 5Dxxxxxxxxxxxxx
Partition table holds up to 128 entries
First usable sector is 34, let usable sector is 41943006
Total free space is 29360061 sectors (14.0 GiB)
Number Start (sector) End (sector) Size code Name
1 419635 12584959 4.0 GiB 8300 Linux filesystem
2 12584960 16779263 2.0 GiB 8200 Linux swap
Disk /dev/xvdj : 21.5 GB, 21474836480 bytes
255 heads,63 sectors/track, 2610 cylinders
units = cylinder of 16065 * 512 = 8225280 bytes
Sector size (logical/physical) : 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000000000
Device Boot Start End Blocks ID system
/dev/xvdj1 1 262 2104483 83 Linux
/dev/xvdj2 263 524 2104515 83 Linux swap / solaris
once this is done,we have to write to the drive,we get this prompt:
Now it will create the partitions as indicated:
Command (? for help) : w
Final checks complete. About to write GPT data .This will overwrite existing partitions!!
Do you want to proceed? (Y/N): y
OK; writing new GUID partition table (GPT) to /dev/xvdg
The operation has completed successfully.
when you do the fdisk –l,it will show the following.
255 heads,63 sectors/track, 2610 cylinders
units = cylinder of 16065 * 512 = 8225280 bytes
Sector size (logical/physical) : 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000000000
Device Boot Start End Blocks ID system
/dev/xvdj1 1 262 2104483 83 Linux
/dev/xvdj2 263 524 2104515 83 Linux swap / solaris
Disk /dev/xvdg: 41943040 sectors, 20.0 GiB
Logical sector size: 512 bytes
Disk identifier (GUID) : 5Dxxxxxxxxxxxxx
Partition table holds up to 128 entries
First usable sector is 34,last usable sector is 41943006
Partitions will be aligned on 2048-sector boundaries
Total free space is 41942973 sectors (20.0 GiB)
Device Boot Start End Blocks ID system
/dev/xvdg1 1 2601 20971519+ ee GPT
it gives information about the xvdg,but it says the GPT system.
Fdisk –l cannot able to read the GPT device type,so it cannot provide information than
above,so we have to use the gdisk –l to view the partition details of the above.
[ root@la dev]# gdisk -l /dev/xvdg
GPT fdisk (gdisk) version 0.8.10
Partition table scan:
MBR: not present
BSD: not present
APM: not present
GPT: not present
Creating new GPT entries
Command (? for help)
none of them are present,now it will help us to entries the GPT:
list of information on my disk using p:
Command (? for help): p
Disk /dev/xvdg: 41943040 sectors, 20.0 GiB
Logical sector size: 512 bytes
Disk identifier (GUID) : 5Dxxxxxxxxxxxxx
Partition table holds up to 128 entries
First usable sector is 34,last usable sector is 41943006
Partitions will be aligned on 2048-sector boundaries
Total free space is 41942973 sectors (14.0 GiB)
Number Start (sector) End (sector) Size code Name
1 419635 12584959 4.0 GiB 8300 Linux filesystem
2 12584960 16779263 2.0 GiB 8200 Linux swap
Now,we are going to use the parted:this is little more advanced and little more limited.
Parted is the utility that can deal with the legacy MBR and the GPT drives.
It allows us to in to command prompt and do something.
However it helps to resize the partition.
It is little more advanced than expected and it is out of the LPIC exam.
We just require the general awareness of the parted is.
How to install our distribution?
[ root@la dev]# which parted
/sbin/parted
[ root@la dev]#
we do it ,exactly the same way,as we did for the:
Disk /dev/xvdj : 21.5 GB, 21474836480 bytes
255 heads,63 sectors/track, 2610 cylinders
units = cylinder of 16065 * 512 = 8225280 bytes
Sector size (logical/physical) : 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000000000
Device Boot Start End Blocks ID system
/dev/xvdj1 1 262 2104483 83 Linux
/dev/xvdj2 263 524 2104515 83 Linux swap / solaris
255 heads,63 sectors/track, 2610 cylinders
units = cylinder of 16065 * 512 = 8225280 bytes
Sector size (logical/physical) : 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000000000
Device Boot Start End Blocks ID system
/dev/xvdj1 1 262 2104483 83 Linux
/dev/xvdj2 263 524 2104515 83 Linux swap / solaris
Disk /dev/xvdg: 41943040 sectors, 20.0 GiB
Logical sector size: 512 bytes
Disk identifier (GUID) : 5Dxxxxxxxxxxxxx
Partition table holds up to 128 entries
First usable sector is 34,last usable sector is 41943006
Partitions will be aligned on 2048-sector boundaries
Total free space is 41942973 sectors (20.0 GiB)
Device Boot Start End Blocks ID system
/dev/xvdg1 1 2601 20971519+ ee GPTDisk /dev/xvdf: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes /512 bytes
Disk identifier: 0x000000000
as we are going to see the,last part that is the 20gb’s. that is the /dev/xvdf:
[ root@la dev]# parted /dev/xvdf
GNU Parted 2.1
Using /dev/xvdf
Welcome to GNU Parted! Type 'help' to view a list of commands
(parted).
We used parted here:to do this:
[ root@la dev]# parted /dev/xvdf
GNU Parted 2.1
Using /dev/xvdf
Welcome to GNU Parted!Type help to view a list of commands.
(parted) help
we are creating label here:
when we create label,we can make it Agpt drive or we can make a legacy drive.
The legacy drive ,weill be indicated with a msdos.
Warning: The existing disk label on /dev/xvdf will destroyed and all data on this disk will be lost,Do you want to continue?
Yes/No? yes
(parted)
we no need to make the w or write to quit the process.
We made a label code on code to msdos.
At this time,we need to make a partition and we need to indicate the partition type:
Because we are creating a legacy partition.
It is a primary partition -------à this is nothing but the partition type.
We need to set a first available sector:which is going to be zero and I want to create a 2G disk.
(parted) mkpart primary 0 2G
Warning: The resulting partition is not properly aligned for best performance
Ignore/Cancel
we indicate as a ignore.
You would think,we should assign a file system type:
(some versions of parted,do not assign the default filesystem type).
It will realy depend up on the distribution of parted.
Linux,does not care about the filesystem type.
There is some legacy applications,that may test the particular partition for the specific
filesystem type,but it is weared and it is paerfectly acceptable in most cases.
That a partition type for linux swap,formatted with a ext4 partition.
We may need to update the stuff in the /etc/fstab.
now if we do fdisk –l,now it will read and say we have single 2gb partition
Disk /dev/xvdf: 21.5 GB, 21474836480 bytes
89 heads, 62 sectors/track, 17346 cylinders
Units = cylinders of 2418 * 512 = 1238016 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
Device Boot Start End Blocks ID system
/dev/xvdf1 1 1616 20971519+ 83 linux
No comments:
Post a Comment