Gparted: Difference between revisions
From charlesreid1
| Line 144: | Line 144: | ||
mkpart makes a partition without creating a new file system on | mkpart makes a partition without creating a new file system on | ||
the partition. FS-TYPE may be specified to set an appropriate partition ID. | the partition. FS-TYPE may be specified to set an appropriate | ||
partition ID. | |||
</pre> | </pre> | ||
Revision as of 08:31, 8 December 2010
Gparted is a unix utility that can be used to deal with partitions and disks.
Most gparted commands require superuser permissions, so it can be started using the sudo parted command, which will run gparted and provide a (parted) prompt:
$ sudo gparted
(parted)Command line usage
Showing disk information
The list of devices can be shown using the print command:
(parted) print all
Disk /dev/sda: 250GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number Start End Size Type File system Flags
1 32.3kB 839MB 839MB primary linux-swap
4 839MB 199GB 198GB primary ext3
3 199GB 225GB 26.2GB primary ext3
2 225GB 250GB 25.0GB primary ext3 boot
Disk /dev/sdb: 1000GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number Start End Size Type File system Flags
1 32.3kB 1000GB 1000GB primary fat32This scenario has two disks in the system:
- A 250 GB ext3 hard drive (this is the main hard drive, and has four partitions, with one main partition - the 839MB-199GB partition)
- A 1 TB fat32 hard drive (this is an external drive, since there is no boot or swap partition)
The main hard drive is the device /dev/sda, and the external hard drive is /dev/sdb. Further external hard drives would be labeled /dev/sdc, /dev/sdd, etc.
The device location is important, since it can be used to mount disks like this:
# For fat32 drives, specify uid and gid to allow read/write permission
mount /dev/sdb1 /path/to/mount/point -o user,rw,uid=userid,gid=groupid
# For ext3 drives, use chown and chgrp to add read/write permission
mount /dev/sdc1 /path/to/mount/point -o user,rw
chown userid /path/to/mount/point
chgrp groupid /path/to/mount/pointThe number in the list of each device, and in the name of each device in /dev, corresponds to the partition number.
Creating a new partition
There are a couple of commands that can be used to create partitions. A brief explanation of each is given here:
- mkpart - creates a partition
- mkpartfs - creates a partition, and a filesystem for each partition
- mkfs - creates a filesystem for a partition
There are a couple ways to do this. The first is to create a partition using mkpartition, and then create a filesystem for that partition using mkfs or some other method.
The other (preferred) option is to use mkpartfs, which does both.
If you don't have any partitions available on the device, you will see something like this:
(parted) print free
Disk /dev/sdd1: 500GB
Sector size (logical/physical): 512B/512B
Partition Table: loop
Number Start End Size File system Flags
0.00kB 500GB 500GB Free SpaceCommand mkpartfs
To begin, the help for this command is:
(parted) help mkpartfs
mkpartfs PART-TYPE FS-TYPE START END make a partition with a file system
PART-TYPE is one of: primary, logical, extended
START and END are disk locations, such as 4GB or 10%.
Negative values count from the end of the disk. For
example, -1s specifies exactly the last sector.Let's say I'm formatting an external hard drive: partitioning an external hard drive to use for storing files and such. I can choose several different formats, depending on what my needs are.
- FAT - this format is readable by
- Ext2 - this is a format used by Linux
- See wikipedia:Ext2
- Linux-swap - this is used as swap space on Linux
Other non-supported filesystems include:
- Ext3 - this is another format used by Linux (NOTE: this format is NOT compatible with parted! See below for use.)
- See wikipedia:Ext3
To create a partition with one of the filesystems supported by parted (e.g. ext2):
(parted) mkpartfs
File system type? [ext2]? ext2
Start? 0GB
End? 500GBThis creates a 500GB ext2 partition. The start can also be specified using megabytes, or sectors.
Command mkpart
The help for this command is:
(parted) help mkpart
mkpart PART-TYPE [FS-TYPE] START END make a partition
PART-TYPE is one of: primary, logical, extended
FS-TYPE is one of: ext3, ext2, fat32, fat16, hfsx, hfs+,
hfs, jfs, linux-swap, ntfs, reiserfs, hp-ufs, sun-ufs, xfs,
apfs2, apfs1, asfs, amufs5, amufs4, amufs3, amufs2, amufs1,
amufs0, amufs, affs7, affs6, affs5, affs4, affs3, affs2, affs1,
affs0
START and END are disk locations, such as 4GB or 10%. Negative
values count from the end of the disk. For example, -1s specifies
exactly the last sector.
mkpart makes a partition without creating a new file system on
the partition. FS-TYPE may be specified to set an appropriate
partition ID.
To create a partition using a filesystem not supported by parted, the mkpart command must be used to create the partition, while another command must be used to create the filesystem in the created partition.
To avoid specifying a filesystem type, the partition type, which may be one of "primary, extended, logical", must be "extended".
In order to create a 500GB partition, mkpart is used as follows:
(parted)Command: mkfs.ext3
This command creates an ext3 filesystem in an existing partition. This requires that a partition is already created using mkpart.