Gnu parted

2.1 Partitioning Concepts

Unfortunately, partitioning your disk is rather complicated. This is
because there are interactions between many different systems that need
to be taken into consideration:

  • The BIOS or firmware — the program that is built into a ROM chip inside
    your computer, that does memory checks, etc. You can not (easily)
    change programs in this system. Examples of BIOS or firmware programs:
    AmiBIOS, Award, Phoenix, OpenFirmware. You will only have one of these
    programs.

  • The boot loader — the program that allows you to select which operating
    system you want to use, and loads that operating system. Examples:
    LILO, GRUB, Yaboot, Quik. You may have more than one boot loader
    installed, especially if you have more than one type of operating system
    installed.

  • The operating system (at the moment, this must be GNU/Linux) that runs
    Parted, and the other operating systems that you use.

  • The file system types — the way the data stored on partitions. Examples
    of these are: ext2, fat32, hfs, reiserfs. You will often have
    partitions of of different file system types.

Parted suppports many combinations of BIOS, boot loader, operating
system, and file systems, and will support more in the future. To
further understand the roles of each, please see section , section , section , and section .

This chapter describes how to use Parted, which is largely the same, no
matter what systems you are using. You should read this chapter, then
each of chapters on BIOSes, boot loaders, operating systems, and file
systems. However, you only need to read the sections that are relevant
to you. For example, if you are only using LILO as your boot loader,
then you only need to read the introduction, and section .

Commands

[device] The block device to be used. When none is given, parted will use the first block device it finds.
[command [options]] Specifies the command to be executed. If no command is given, parted will present a command prompt. Possible commands are:

check partition Do a simple check on partition.
cp [source-device] source destination Copy the source partition’s filesystem on source-device (or the current device if no other device was specified) to the destination partition on the current device.
help [command] Print general help, or help on command if specified.
mkfs partition fs-type Make a filesystem fs-type on partition. fs-type can be one of «fat16«, «fat32«, «ext2«, «linux-swap«, or «reiserfs«.
mklabel label-type Create a new disklabel (partition table) of label-type. label-type should be one of «bsd«, «dvh«, «gpt«, «loop«, «mac«, «msdos«, «pc98«, or «sun«.
mkpart part-type [fs-type] start end Make a part-type partition with filesystem fs-type (if specified), beginning at start and ending at end (by default in megabytes). fs-type can be one of «fat16«, «fat32«, «ext2«, «HFS«, «linux-swap«, «NTFS«, «reiserfs«, or «ufs«. part-type should be one of «primary«, «logical«, or «extended«.
mkpartfs part-type fs-type start end Make a part-type partition with filesystem fs-type beginning at start and ending at end (by default in megabytes). Using this command is discouraged. Instead, use mkpart to create an empty partition, and then use external tools like mke2fs to create the filesystem.
move partition start end Move partition so that it begins at start and ends at end. Note: move never changes the minor number.
name partition name Set the name of partition to name. This option works only on Mac, PC98, and GPT disklabels. The name can be placed in quotes, if necessary.
print Display the partition table.
quit Exit from parted.
rescue start end Rescue a lost partition that was located somewhere between start and end. If a partition is found, parted will ask if you want to create an entry for it in the partition table.
resize partition start end Resize the filesystem on partition so that it begins at start and ends at end (by default in megabytes).
rm partition Delete partition.
select device Choose device as the current device to edit. The device should usually be a Linux hard disk device, but it can be a partition, software raid device, or an LVM logical volume if necessary.
set partition flag state Change the state of the flag on partition to state. Supported flags are: «boot«, «root«, «swap«, «hidden«, «raid«, «lvm«, «lba«, «legacy_boot» and «palo«. The state should be either «on» or «off«.
unit unit Set unit as the unit to use when displaying locations and sizes, and for interpreting those given by the user when not suffixed with an explicit unit. The unit can be one of «s» (sectors), «B» (bytes), «kB«, «MB«, «GB«, «TB«, «%» (percentage of device size), «cyl» (cylinders), «chs» (cylinders, heads, sectors), or «compact» (megabytes for input, and a human-friendly form for output).
version Display version information and a Copyright message.

Guides & Tips

  • Pick up a Right Seagate External Hard Drive for You

    In this post, you can learn about Seagate external hard drives with different sizes, ranging from 1TB to 8TB. Read the post now to buy a right Seagate drive.

  • A Complete Guide to Fix Forza Horizon 4 Crashing PC

    Have you encountered Forza Horizon 4 crashing PC issue when you are trying to launch or play the game? In this post, you will get some methods to fix the issue.

  • How to Install Kali Linux on Virtual Machine, USB, and Hard Drive

    This post shows you how to install Kali Linux on VirtualBox, VMware, USB, and Windows 10.

  • How to Use WinToFlash to Make a Bootable USB Flash Drive

    Are you looking for a way to make a bootable USB for Windows? Actually, there are many available tools which might be helpful. WinToFlash is one of them.

  • The Best 1TB SSD External Drives and How to Use Them Effectively

    Are you looking for 1TB SSD external drives? Do you know how to choose one that suits you? You can refer to this post which provides some suggestions.

  • A Complete Guide to Fix GTA 5 Stuttering Issue

    It would be rather frustrating if GTA 5 gets stuttering during the gameplay. How to get rid of this issue? You can get several solutions to it in this article.

2.2 Using GNU Parted

Parted has two modes: command line and interactive. Parted should
always be started with:

# parted device

where device is the hard disk device to edit. (If you’re
lazy, Parted will attempt to guess which device you want.)

In command line mode, this is followed by one or more commands. For
example:

# parted /dev/sda resize 1 52 104 mkfs 2 fat16

Options (like --help) can only be specified on the
command line.

In interactive mode, commands are entered one at a time at a prompt, and
modify the disk immediately. For example:

(parted) resize 1 52.0005 104.5
(parted) mkfs 2 fat16

Unambiguous abbreviations are allowed. For example, you can
type «p» instead of «print», and «re» instead of «resize».
Commands can be typed in, either in English, or your native language (if
your language has been translated). This may create ambiguities.

Also note that you can specify decimal places in the numbers
corresponding to partition locations (in megabytes). Negative
numbers count from the end of the disk, with «-0» being the end
of the disk.

If you don’t give a parameter to a command, Parted will ask you for it.
For example:

(parted) resize 1
Start? 
End? 400

Parted will always warn you before doing something that is potentially
dangerous, unless it’s something that’s obviosuly dangerous (i.e. rm,
mklabel, mkfs) For example, if you attempt to shrink a partition «too
much» (i.e. by more than the free space available), Parted will
automatically resize to the minimum it can without losing data. If this
minimum is significantly different, it will warn you that it’s doing
something significanlty different to what you asked. Since many
partitioning systems have complicated constraints, Parted will usually
do something slightly different to what you asked. (For example, create
a partitiong starting at 10.352, not 10.4)

IM-Magic Partition Resizer

What We Like

  • Quick install

  • Lots of options

  • Accessing all the options from anywhere is easy

  • Shows a preview of what will happen after you save the changes

What We Don’t Like

  • Some features only work if you upgrade to the paid version

  • Free for home/personal use only

IM-Magic Partition Resizer works very much like the tools mentioned above. It installs quickly and is super simple to use.

With this tool, you can move partitions, resize partitions (even the active one), copy partitions, as well as change the drive letter and label, check the partition for errors, delete and format partitions (even with a custom cluster size), convert NTFS to FAT32, hide partitions, and wipe all that data off of partitions.

All of those actions are extremely easy to find because you just have to right-click the device you want to manipulate. As you perform these actions, you’ll see the program update in real time to reflect them so that you can see how it will look when everything has been applied.

Then, when you’re happy with the results, just hit the big Apply Changes button to put everything into action. If you have to reboot for anything to take effect, IM-Magic Partition Resizer will tell you so.

You can also view the properties of any drive, to see its NT object name, GUID, file system, sector size, cluster size, partition number, physical sector number, total number of hidden sectors, and more.

The only downfall I can see with this program is that a few of the features require that you upgrade to a paid edition. For example, you can’t make the bootable media program that they support unless you pay for it.

Paragon Partition Manager Free

What We Like

  • Supports plenty of basic features

  • Walks you through a step-by-step wizard

  • Previews changes before committing to them

  • Supports common file systems

What We Don’t Like

  • Missing features found in most disk partitioning tools

  • Not every feature is free to use; some require you to upgrade to the pro version

  • Not free for business usage; just personal

If walking through wizards helps you feel more comfortable making changes to partitions, then you’ll like Paragon Partition Manager Free.

Whether you’re creating a new partition or resizing, deleting, or formatting an existing one, this program has you move through a step by step process to do it.

Paragon Partition Manager Free supports common file systems like NTFS, FAT32, and HFS.

Unfortunately, a number of additional features are disabled in Paragon Partition Manager, available only in the pro version.

Options

-h, —help Display a help message, and exit.
-l, —list Lists partition layout on all block devices.
-m, —machine Displays machine-parseable output
-s, —script Never prompts for user input.
-v, —version Displays version information, and exits.
-a alignment-type, —align alignment-type Set alignment for newly created partitions, valid alignment types are:

none Use the minimum alignment allowed by the disk type.
cylinder Align partitions to cylinders.
minimal Use minimum alignment as given by the disk topology information. This and the optimal value will use layout information provided by the disk to align the logical partition table addresses to actual physical blocks on the disks. The minimal value is the minimum alignment needed to align the partition properly to physical blocks, which avoids performance degradation.
optimal Use optimum alignment as given by the disk topology information. This aligns to a multiple of the physical block size in a way that guarantees optimal performance.

7.1 Logical Volume Manager and Redundant Arrays of Inexpensive Disks

LVM (Logical Volume Manager) is an alternative system to partitioning.
It allows logical volumes (i.e. «virtual partitions») to be spread
over many physical volumes (i.e. hard disks and/or partitions). LVM
is supported on Linux version 2.4, and later.

RAID (Redundant Array of Inexpensive Disks) is a system for using many
disks and/or partitions together, as a «virtual partition». There are a
few different modes of utilising software RAID, that are essentially:

  • using multiple (small) disks for a single file system, to improve

    performance and to make the entire space available available on a single
    file system.

  • using multiple disks to store redundant copies of information, to

    improve reliability and performance.

Software RAID is supported on Linux version 2.0, and later.

Hardware RAID is supported normally by Parted — so you need not read
this section if you are using hardware RAID (as opposed to software
RAID).

LVM, software RAID and partitions are often used simultaneously, but
they can all be used independently. LVM and software RAID are often
composed of partitions, rather than raw hard disks.

GNU Parted does not support LVM and software RAID in full, but it is
still useful when used in combination with their respective tools.
Parted is useful for these tasks:

  • creating a software RAID or LVM partition

  • creating, resizing or copying a file system on a logical volume

    (or «virtual partition»)

Warnings

Parted will always warn you before doing something that is potentially dangerous, unless the command is one of those that is inherently dangerous (viz., rm, mklabel and mkpart).

Alignment

When creating a partition, parted might warn about improper partition alignment but does not hint about proper alignment. For example:

(parted) mkpart primary fat16 0 32M
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel?                                                     

The warning means the partition start is not aligned. Enter «Ignore» to go ahead anyway, print the partition table in sectors to see where it starts, and remove/recreate the partition with the start sector rounded up to increasing powers of 2 until the warning stops. As one example, on a flash drive with 512B sectors, Parted wanted partitions to start on sectors that were a multiple of 2048, which is 1 MiB alignment.

If you want parted to attempt to calculate the correct alignment for you, specify the start position as 0% instead of some concrete value. To make one large ext4 partition, your command would look like this:

(parted) mkpart primary ext4 0% 100%

Active@ Partition Manager

What We Like

  • It’s really easy to use and understand

  • Some changes you make can be restored from a backup

  • Many common disk partitioning tasks are supported

What We Don’t Like

  • Can’t copy partitions

  • Extending the system partition might not work for you

  • Won’t downsize locked volumes

Active@ Partition Manager can create new partitions out of unallocated space as well as manage existing partitions, like resizing and formatting them. Simple wizards make it easy to walk through some of these tasks.

No matter what kind of file system you’re using, the free Active@ Partition Manager tool should be able to handle it, with support for all the common ones, like FAT, NTFS, HFS+, and EXT2/3/4.

Active@ Partition Manager includes other features, too, like imaging a whole drive for backup purposes, converting between MBR and GPT, creating FAT32 partitions as large as 1 TB, editing boot records, and rolling back changes by auto-backing up partition layouts.

When Active@ Partition Manager resizes a partition, you can define the custom size in either megabytes or sectors.

Unfortunately, Active@ Partition Manager can’t resize locked volumes, which means it won’t let you change the size of the system volume.

Active@ Partition Manager should work just fine with Windows 10, 8, 7, Vista, and XP, as well as Windows Server 2012, 2008, and 2003. 

7.3 Manipulating a File System on a RAID or LVM volume

Parted can manipulate RAID and LVM logical volumes, even though it does
not understand RAID or LVM. It utilises Linux’s support for RAID and
LVM. Therefore, you can only use these methods if your Linux kernel
supports RAID and/or LVM.

To manipulate a file system on a RAID or LVM logical volume (or, a raw
partition, for that matter), you can start parted by selecting the
logical volume (partition) device. For example:

# parted /dev/md0

For the rest of this chapter, «virtual device» will refer to the
device Parted is editting (in our example cases, `/dev/md0').

To create a file system on an LVM volume, use the following steps:

  1. Create a loop disk label. This is a fake disk label, that tells

    Parted to treat the virtual device as a single file system. With this
    fake disk label, there is either zero or one partition.

    (parted) mklabel loop
    
  2. Create the file system, by using Parted’s mkpartfs command. You

    should make the start of the file system 0. The partition can end
    anywhere inside the virtual device. You can find out the size of the
    virtual device with the print command. For example:

    (parted) print
    Disk geometry for /dev/md0: 0.000-47.065 megabytes
    Disk label type: loop
    Minor    Start       End     Filesystem  Flags
    (parted) mkpartfs primary ext2 0 47.065
    (parted) print
    Disk geometry for /dev/md0: 0.000-47.065 megabytes
    Disk label type: loop
    Minor    Start       End     Filesystem  Flags
    1          0.000     47.065  ext2
    

You usually resize the file system at the same times as you resize your
virtual device. If you are growing the file system and virtual device,
you should grow the device first (with the RAID or LVM tools), and then
grow the file system. If you are shrinking the file system and virtual
device, you should shrink the file system first, and then the virtual
device afterwards.

To resize the file system in Parted, use the resize command. For example:

(parted) select /dev/md0
(parted) resize 1 0 20

To copy a filesystem from an LVM or RAID virtual device, just use the cp
command. For example:

(parted) select /dev/hda
(parted) cp /dev/md0 1 3

To copy a file system from an LVM or RAID virtual device, use the
following recipe:

  1. Create the loop disk label on the virtual device. For example:

    (parted) select /dev/md0
    (parted) mklabel loop
    
  2. Create a file system on the virtual device, with the mkpartfs

    command. For example:

    (parted) mkpartfs primary ext2 0 47.065
    
  3. Copy the partition with the cp command:

    (parted) select /dev/hda
    (parted) cp /dev/md0 3 1
    

Go to the first, previous, next, last section, table of contents.

EaseUS Partition Master Free Edition

What We Like

  • Easy to understand with lots of useful options

  • Lets you protect the program with a password

  • Makes it easy to upgrade the system drive to a larger HDD

  • Several helpful options and functions

  • Changes are previewed before they’re applied

  • The program updates often with improvements and new features

What We Don’t Like

  • Doesn’t work for commercial use; only personal

  • No support for managing dynamic volumes

  • You have to restart the computer to extend the system partition

  • Can’t convert between MBR and GPT

  • Setup tries to install another program

Managing the size of a partition in EaseUS Partition Master is dead simple thanks to their easy to use slider that lets you drag left and right to shrink or expand a partition.

Changes you apply to a partition in EaseUS Partition Master aren’t actually applied in real time. Modifications exist only virtually, which means you’re only seeing a preview of what will happen if you save the changes, but nothing is actually set in stone yet. Changes don’t take effect until you click the Execute button.

I particularly like this feature so things like expanding and copying partitions can be done in one swipe instead of having to reboot between each operation, thus saving tons of time. The list of pending operations is even shown on the side of the program so you can clearly see what will happen when you apply them.

You can also password protect EaseUS Partition Master, hide partitions, upgrade the system drive to a larger bootable drive, merge partitions, defragment a drive, and copy Windows to a different hard drive.

One thing I don’t like about this program is that several features are only available in the full, paid version, but are still clickable. This means you might sometimes try to open something in the free version only to be prompted to buy the professional one.

EaseUS Partition Master works with Windows 10, back through Windows XP.

По умолчанию: Использование parted для создания разделов диска

В этой главе, пример разметки разделов, упомянутый ранее в инструкции, будет использоваться такой:

Раздел Описание
/dev/sda1 BIOS boot раздел
/dev/sda2 Boot раздел
/dev/sda3 Swap раздел
/dev/sda4 Root раздел

Измените структуру разделов в соответствии с личными предпочтениями.

Просмотр текущей разметки разделов с помощью parted

Приложение parted предлагает простой интерфейс для разбития дисков и поддерживает очень большие разделы (более 2 ТБ). Указывайте для parted диск (например, в нашем примере мы используем /dev/sda). Рекомендуется также для parted указывать оптимальное выравнивание разделов:

GNU Parted 2.3
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.

Выравнивание разделов означает, что разделы будут начинаться с известных границ, в пределах диска, гарантируя, что операции на диске от уровня операционной системы (извлечения страниц с диска) будут использовать наименьшее количество внутренних операций диска. Невыровненные разделы могут потребовать извлечения двух страниц, даже если операционная система запросила только одну.

Чтобы узнать обо всех опциях, поддерживаемых parted введите help.

Установка метки GPT

Большинство дисков в архитектурах x86 или amd64 создаются с меткой msdos. Используйте parted для размещения метки GPT на диске используйте команду mklabel gpt:

ПредупреждениеИзменение типа разделов удалит все разделы на диске. Вся информация на диске будет потеряна.

Чтобы сделать структуру разделов MBR используйте команду mklabel msdos.

Удаление всех разделов с помощью parted

Если это не было сделано ранее (например через операцию mklabel, или если диск был недавно отформатирован), сначала удалите все существующие разделы на диске. Введите print, чтобы посмотреть текущие разделы и rm <N>, где — номер раздела для удаления.

Сделайте то же для всех других разделов, в которых нет необходимости. Однако, убедитесь, чтобы не сделали ошибок — parted применяет изменения немедленно (в отличии от fdisk, где пользователю дается возможность «отменить» изменения перед сохранением или выходом).

Создание разделов

Теперь, с помощью parted, создадим разделы со следующими параметрами:

  • Используемый тип раздела. Обычно это основной раздел. Если используется для разделов метка msdos, то учтите, что основных разделов может быть только 4. Если необходимо больше чем 4 раздела, то необходимо сначала создать расширенный раздел, а затем создать внутри него логические.
  • Начальная позиция раздела (которая может быть выражена в MB, GB, …)
  • Конечная позиция раздела (которая может быть выражена в MB, GB, …)

Во-первых, необходимо сказать parted, что единицы, с которыми мы работаем мегабайты (на самом деле мебибайты, сокращенно MiB, являющиеся «стандартом» обозначения, но мы будем использовать MB в тексте, поскольку это намного более распространено):

Теперь создайте 2МБ раздел, который будет использоваться загрузчиком GRUB2 позже. Используйте команду mkpart и сообщите parted, что раздел начинается с 1 МБ от начала диска и заканчивается на 3 МБ (для создания раздела размером 2 МБ).

Model: Virtio Block Device (virtblk)
Disk /dev/sda: 20480MiB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
  
Number   Start      End      Size     File system  Name   Flags
 1       1.00MiB    3.00MiB  2.00MiB               grub   bios_grub

При использовании интерфейса UEFI для загрузки системы (вместо BIOS), пометьте загрузочный раздел как системный раздел EFI. делает это автоматически, когда устанавливается опция boot у раздела:

Конечный результат выглядит так:

Model: Virtio Block Device (virtblk)
Disk /dev/sda: 20480MiB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
  
Number   Start      End      Size     File system  Name   Flags
 1       1.00MiB    3.00MiB  2.00MiB               grub   bios_grub
 2       3.00MiB    131MiB   128MiB                boot   boot
 3       131MiB     643MiB   512MiB                swap
 4       643MiB     20479MiB 19836MiB              rootfs

ЗаметкаПри установке на UEFI, на разделе boot будут отображаться флаги boot и esp (efi system partition).

Используйте команду quit для выхода из parted.

Usage

Parted has two modes: command line and interactive. Parted should always be started with:

# parted device

where is the hard disk device to edit (for example ). If you omit the argument, parted will attempt to guess which device you want.

Command line mode

In command line mode, this is followed by one or more commands. For example:

# parted /dev/sda mklabel gpt mkpart P1 ext3 1MiB 8MiB 

Note: Options (like ) can only be specified on the command line.

Interactive mode

Interactive mode simplifies the partitioning process and reduces unnecessary repetition by automatically applying all partitioning commands to the specified device.

In order to start operating on a device, execute:

# parted /dev/sdx

You will notice that the command-line prompt changes from a hash () to : this also means that the new prompt is not a command to be manually entered when running the commands in the examples.

To see a list of the available commands, enter:

(parted) help

When finished, or if wishing to implement a partition table or scheme for another device, exit from parted with:

(parted) quit

After exiting, the command-line prompt will change back to .

If you do not give a parameter to a command, Parted will prompt you for it. For example:

(parted) mklabel
New disk label type? gpt
Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *

Adblock
detector