Linux parted boot flag

Linux parted boot flag

Changes a flag on the partition with number number . A flag can be either “on” or “off”. Some or all of these flags will be available, depending on what disk label you are using:

(GPT) — Enable this to record that the selected partition is a GRUB BIOS partition.

(GPT) — this flag is used to tell special purpose software that the GPT partition may be bootable.

(MS-DOS, GPT) — Enable this to indicate that the selected partition is a Linux Boot Loader Specification compatible /boot partition.

(Mac, MS-DOS, PC98) — should be enabled if you want to boot off the partition. The semantics vary between disk labels. For MS-DOS disk labels, only one partition can be bootable. If you are installing LILO on a partition that partition must be bootable. For PC98 disk labels, all ext2 partitions must be bootable (this is enforced by Parted).

(GPT) — This flag identifies partitions that contain Microsoft filesystems (NTFS or FAT). It may optionally be set on Linux filesystems to mimic the type of configuration created by parted 3.0 and earlier, in which a separate Linux filesystem type code was not available on GPT disks. This flag can only be removed within parted by replacing it with a competing flag, such as boot or msftres.

(MS-DOS,GPT) — This flag identifies a «Microsoft Reserved» partition, which is used by Windows. Note that this flag should not normally be set on Windows filesystem partitions (those that contain NTFS or FAT filesystems).

(MS-DOS, GPT) — this flag identifies an Intel Rapid Start Technology partition.

(MS-DOS, GPT) — this flag identifies a UEFI System Partition. On GPT it is an alias for boot.

(GPT) — this flag indicates a partition that can be used with the Chrome OS bootloader and verified boot implementation.

(MS-DOS) — this flag can be enabled to tell MS DOS, MS Windows 9x and MS Windows ME based operating systems to use Linear (LBA) mode.

(Mac) — this flag should be enabled if the partition is the root device to be used by Linux.

(Mac) — this flag should be enabled if the partition is the swap device to be used by Linux.

(MS-DOS, PC98) — this flag can be enabled to hide partitions from Microsoft operating systems.

(MS-DOS) — this flag can be enabled to tell linux the partition is a software RAID partition.

(MS-DOS) — this flag can be enabled to tell linux the partition is a physical volume.

(MS-DOS) — this flag can be enabled so that the partition can be used by the Linux/PA-RISC boot loader, palo.

(MS-DOS, GPT) — this flag can be enabled so that the partition can be used as a PReP boot partition on PowerPC PReP or IBM RS6K/CHRP hardware.

(MS-DOS) — Enable this to indicate that a partition can be used as a diagnostics / recovery partition.

The print command displays all enabled flags for each partition.

Источник

Parted

GNU Parted is a program for creating and manipulating partition tables. GParted is a GUI frontend.

Contents

Installation

Install the parted package. For a graphical interface, install the gparted package, the graphical frontend to parted.

Usage

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

where device is the hard disk device to edit (for example /dev/sda ). If you omit the device 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:

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:

You will notice that the command-line prompt changes from a hash ( # ) to (parted) : 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:

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

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:

Rounding

Since many partitioning systems have complicated constraints, Parted will usually do something slightly different to what you asked. (For example, create a partition starting at 10.352Mb, not 10.4Mb) If the calculated values differ too much, Parted will ask you for confirmation. If you know exactly what you want, or to see exactly what Parted is doing, it helps to specify partition endpoints in sectors (with the «s» suffix) and give the «unit s» command so that the partition endpoints are displayed in sectors.

As of parted-2.4, when you specify start and/or end values using IEC binary units like “MiB”, “GiB”, “TiB”, etc., parted treats those values as exact, and equivalent to the same number specified in bytes (i.e., with the “B” suffix), in that it provides no “helpful” range of sloppiness. Contrast that with a partition start request of “4GB”, which may actually resolve to some sector up to 500MB before or after that point. Thus, when creating a partition, you should prefer to specify units of bytes (“B”), sectors (“s”), or IEC binary units like “MiB”, but not “MB”, “GB”, etc.

Partitioning

Create new partition table

You need to (re)create the partition table of a device when it has never been partitioned before, or when you want to change the type of its partition table. Recreating the partition table of a device is also useful when the partition scheme needs to be restructured from scratch.

Open each device whose partition table must be (re)created with:

To then create a new GUID Partition Table, use the following command:

To create a new Master Boot Record/MS-DOS partition table instead, use:

Partition schemes

You can decide the number and size of the partitions the devices should be split into, and which directories will be used to mount the partitions in the installed system (also known as mount points). See Partitioning#Partition scheme for the required partitions.

The following command will be used to create partitions:

  • part-type-or-part-label is interpreted differently based on the partition table:
    • MBR: the parameter is interpreted as part-type , which can be one of primary , extended or logical .
    • GPT: the parameter is interpreted as part-label , which sets the PARTLABEL attribute of the partition. The partition label always has to be set, since mkpart does not allow to create partitions with empty label.
    • start is the beginning of the partition from the start of the device. It consists of a number followed by a unit, for example 1MiB means start at 1 MiB.
    • end is the end of the partition from the start of the device (not from the start value). It has the same syntax as start , for example 100% means end at the end of the device (use all the remaining space).

    The following command will be used to flag the partition that contains the /boot directory as bootable:

    • partition is the number of the partition to be flagged (see the output of the print command).
    • esp is an alias for boot on GPT. [1]

    This article or section needs expansion.

    UEFI/GPT examples

    In every instance, a special bootable EFI system partition is required.

    If creating a new EFI system partition, use the following commands (the recommended size is at least 260 MiB):

    The remaining partition scheme is entirely up to you. For one other partition using 100% of remaining space:

    For separate / (20 GiB) and /home (all remaining space) partitions:

    And for separate / (20 GiB), swap (4 GiB), and /home (all remaining space) partitions:

    BIOS/MBR examples

    For a minimum single primary partition using all available disk space, the following command would be used:

    In the following instance, a 20 GiB / partition will be created, followed by a /home partition using all the remaining space:

    In the final example below, separate /boot (100 MiB), / (20 GiB), swap (4 GiB), and /home (all remaining space) partitions will be created:

    Resizing partitions

    If you are growing a partition, you have to first resize the partition and then resize the filesystem on it, while for shrinking the filesystem must be resized before the partition to avoid data loss.

    Growing partitions

    To grow a partition (in parted interactive mode):

    Where number is the number of the partition you are growing, and end is the new end of the partition (which needs to be larger than the old end).

    Then, to grow the (ext2/3/4) filesystem on the partition:

    Or to grow a Btrfs filesystem:

    Where sdaX stands for the partition you are growing, and [size] is the new size of the partition. Note that [size] is optional, leave it off to fill the remaining space on the partition.

    Shrinking partitions

    To shrink an ext2/3/4 filesystem on the partition:

    To shrink a Btrfs filesystem:

    Where sdaX stands for the partition you are shrinking, and size is the new size of the partition.

    Then shrink the partition (in parted interactive mode):

    Where number is the number of the partition you are shrinking, and end is the new end of the partition (which needs to be smaller than the old end).

    When done, use the resizepart command from util-linux to tell the kernel about the new size:

    Where device is the device that holds the partition, number is the number of the partition and size is the new size of the partition, in 512-byte sectors.

    Warnings

    Parted will always warn you before doing something that is potentially dangerous, unless the command is one of those that is inherently dangerous (e.g. 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:

    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:

    Tips and tricks

    Dual booting with Windows XP

    If you have a Windows XP partition that you would like to move from drive-to-drive that also happens to be your boot partition, you can do so easily with GParted and keep Windows happy simply by deleting the following registry key PRIOR to the partition move:

    Reference to this little gem here.

    Check alignment

    On an already partitioned disk, you can use parted to verify the alignment of a partition on a device. For instance, to verify alignment of partition 1 on /dev/sda :

    Troubleshooting

    Resized FAT32 partition then unrecognized on Windows

    As of December 2018, there was a bug in parted which had been patched in git on 2016-04-15, but was still present in Arch Linux (and a number of other distros) due to there not having been an official release of parted since 2014-07-28.[3] This was resolved upstream once a new parted release was pushed out on 2019-08-12, and resolved in Arch with the 3.3-1 release of parted on 2019-10-11.[4]

    For older builds, a one-liner workaround was mentioned in the bug report, but the report also indicated that it did not seem to work properly for everyone.[5][6]

    It should be noted that this issue largely did not affect gparted, as the project included the patch in their build as of gparted version 0.26.0-1 (released 2016-04-29).[7]

    gparted on Wayland fails with «cannot open display: :0»

    This issue is caused by xwayland refusing access to gparted running as root . gparted developers implemented [8] a small workaround which temporarily adds root to the list of users allowed to connect to xwayland while the application is running.

    Источник

    Linux parted boot flag

    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 3. BIOSes and Firmware, section 4. Boot Loaders, section 5. Operating Systems, and section 6. File Systems supported by Parted.

    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 4.1 LILO: a bootloader for the Linux kernel.

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

    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:

    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:

    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 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)

    When invoked from the command line, parted supports the following syntax:

    Available options and commands follow. For detailed explanations of the use of parted commands, see section 2.4 Parted Session Commands. Options begin with a hyphen, commands do not:

    Options: `-h’ `—help’ display a help message `-i’ `—interactive’ where necessary, prompt for user intervention `-s’ `—script’ never prompt for user intervention `-v’ `—version’ display the version

    GNU Parted provides the following commands:

    Command: check minor

    Checks if the file system on partition minor has any errors.

    Check the file system on partition 1.

    Command: cp [ from-device ] from-minor to-minor

    Copies the file system on the partition from-minor to partition to-minor , deleting the original contents of the destination partition.

    An optional device parameter, from-device can be given, which specifies which device the source partition is on.

    Supported file systems:

    • ext2, ext3 (provided the destination partition is larger than the source partition)
    • fat16, fat32
    • linux-swap (equivalent to mkswap on destination partition)
    • reiserfs (if libreiserfs is installed)

    Copy partition 2 of `/dev/hdb’ (i.e. `/dev/hdb2′ ) to partition on 3, on the device Parted was loaded with, destroying the original contents of partition 3.

    Command: help [ command ]

    Prints general help, or help on command .

    Print help for the resize command.

    Command: mklabel label-type

    Creates a new disk label, of type label-type . The new disk label will have no partitions. This command (normally) won’t technically destroy your data, but it will make it will make it basically unusable, and you will need to use the rescue command (see section 9. Related Software and Info) to recover any partitions. Gpart only works for msdos disk labels (AFAIK), but is much better than parted at recovering partitions. Parted works on all partition tables. (1)

    label-type must be one of these supported disk labels:

    • bsd
    • loop (raw disk access)
    • gpt
    • mac
    • msdos
    • pc98
    • sun

    Create an msdos style disklabel.

    Command: mkfs minor fs-type

    Makes a file system fs-type on partition minor , destroying all data that resides on that partition.

    Supported file systems:

    • ext2
    • mips
    • fat16
    • fat32
    • linux-swap
    • reiserfs (if libreiserfs is installed)

    Make a fat32 file system on partition 2.

    Command: mkpart part-type [ fs-type ] start end

    Creates a new partition, without creating a new file system on that partition. This is useful for creating partitions for file systems (or LVM, etc.) that Parted doesn’t support. You may specify a file system type, to set the appropriate partition code in the partition table for the new partition. fs-type is required for data partitions (i.e., non-extended partitions). start and end are the offset from the beginning of the disk, that is, the «distance» from the start of the disk.

    part-type is one of: primary, extended, logical. Extended and logical are only used for msdos and mips disk labels.

    fs-type must be on of these supported file systems:

    • ext2
    • fat32
    • fat16
    • HFS
    • linux-swap
    • NTFS
    • reiserfs
    • ufs

    Create a logical partition that will contain an ext2 filesystem. The partition will start at the beginning of the disk, and end 692.1 megabytes into the disk.

    Command: mkpartfs part-type fs-type start end

    Creates a new partition of type part-type with a new file system of type fs-type on it. The new partition will start start megabytes, and end end megabytes from the beginning of the disk. Do not use this command to recover a deleted partition (use mkpart instead).

    part-type is one of: primary, extended, logical. Extended and logical are only used for msdos and mips disk labels.

    fs-type must be one of these supported file systems:

    • ext2
    • fat32
    • fat16
    • linux-swap
    • reiserfs (if libreiserfs is installed)

    Make a logical partition and write an ext2 file system, starting 440 megabytes and ending 670 megabytes from the beginning of the disk.

    Command: move minor start [ end ]

    Moves partition on the disk, by moving its beginning to start . Note: move never changes the minor number.

    If no end is given, the partition’s size remains the same.

    Supported file systems:

    • ext2, ext3 (provided the destination partition is larger than the source partition)
    • fat32
    • fat16
    • linux-swap
    • reiserfs (if libreiserfs is installed)

    Move partition with minor number 2 so that it begins 150 megabytes from the start of the disk.

    Command: name minor name

    Sets the name for the partition minor (Mac and PC98 only). The name can be placed in quotes.

    Set the name of partition 2 to `Secret Documents’.

    Displays the partition table on the device parted is editing.

    It is only after Parted exits that the Linux kernel knows about the changes Parted has made to the disks. However, the changes caused by typing your commands will probably be made to the disk immediately after typing a command. However, Linux’s cache, and the disk’s hardware cache may delay this.

    Command: rescue start end rescue a lost partition that used to be about start and end

    Looks for file system signatures around start and end . If one is found, it will ask you if you want to create a partition for it. This is useful if you accidently deleted a partition with parted’s rm command, for example.

    OUCH! We deleted our ext3 partition. Parted comes to the rescue.

    Command: resize minor start end

    Resizes the partition with number minor . The partition will start start from the beginning of the disk, and end end from the beginning of the disk. resize never changes the minor number. Extended partitions can be resized, so long as the new extended partition completely contains all logical partitions.

    Note that Parted does not require a file system to be «defragged» (Parted can safely move data around if necessary). It’s a waste of time defragging. Don’t bother!

    Supported file systems:

    • ext2, ext3 — restriction: the new start must be the same as the old start .
    • fat16, fat32
    • linux-swap
    • reiserfs (if libreiserfs is installed)

    Resize partition 3, so that it begins 200 megabytes and ends 850 megabytes from the beginning of the disk.

    Command: rm minor

    Removes the partition with number minor . If you accidently delete a partition with this command, use mkpart ( not mkpartfs) to recover it. Also, you can use the gpart program (see section 9. Related Software and Info) to recover damaged disk labels.

    Note for msdos disk labels: if you delete a logical partition, all logical partitions with a larger minor number will be renumbered. For example, if you delete a logical partition with a minor number of 6, then logical partitions that were number 7, 8 and 9 would be renumbered to 6, 7 and 8 respectively. This means, for example, that you have to update `/etc/fstab’ on GNU/Linux systems.

    Remove partition 3.

    Command: select device

    Selects the device, device , for Parted to edit. The device will usually be a Linux hard disk device, or, if direct access to a file system is required — a partition, software RAID device, or LVM logical volume.

    Select `/dev/hdb’ (the slave device on the first ide controller on Linux) as the device to edit.

    Command: set minor flag state

    Changes a flag on the partition with number minor . A flag can be either «on» or «off». Some or all of these flags will be available, depending on what disk label you are using: `boot’ (Mac, MSDOS, PC98) — should be enabled if you want to boot off the partition. The semantics vary between disk labels. For MSDOS disk labels, only one partition can be bootable. If you are installing LILO on a partition (see section 4.1 LILO: a bootloader for the Linux kernel), then that partition must be bootable. For PC98 disk labels, all ext2 partitions must be bootable (this is enforced by Parted). `lba’ (MSDOS) — this flag can be enabled, to tell MS DOS, MS Windows 9x and MS Windows ME based operating systems to use Linear (LBA) mode. `root’ (Mac) — this flag should be enabled if the partition is the root device to be used by Linux. `swap’ (Mac) — this flag should be enabled if the partition is the swap device to be used by Linux. `hidden’ (MSDOS, PC98) — this flag can be enabled to hide partitions from Microsoft operating systems. `raid’ (MSDOS) — this flag can be enabled to tell linux the partition is a software RAID partition See section 7. LVM and RAID. `LVM’ (MSDOS) — this flag can be enabled to tell linux the partition is a physical volume.

    The print command displays all enabled flags for each partition.

    Set the `boot’ flag on partition 1.

    These examples attempt to cover the most common circumstances, with the exception of disk imaging, which is covered in section 8. Disk Imaging.

    Suppose your disk layout looks like this:

    There is 375 Mb of free space at the end of the disk (after partition 2). Partition 1 has an ext2 file system, which is the root device. Partition 2 is a swap device.

    Suppose you wanted to use the free space at the end of the disk for the file system on partition 1. You could do the following:

    1. These steps will modify both the root file system on partition 1, and the swap device on partition 2. Therefore, you shouldn’t be using either partitions. You should probably use a Parted boot disk. See section 1.6 Using a Parted Boot Disk. From the boot disk, run Parted:
    2. Remove partition 2 (the swap partition). Normally, you wouldn’t want to delete a partition with data on it. However, a swap partition doesn’t contain data when it isn’t «swapped on» (mounted), so you can remove it, and create a replacement swap partition later.
    3. Create the new swap partition at the end of the disk:
    4. Grow partition 1, into the adjacent free space: All done!

    Suppose your disk layout looks like this:

    Suppose you wanted to increase the `/var’ partition ( `/dev/hda7′ ) to 1GB, using some space from `/home’ ( `/dev/hda6′ ).

    To resize a partition with Parted, you use the resize command:

    new start must be the same as the old start for ext2 partitions (unfortunately). So this process is going to be rather complicated. It is possible, though. (2)

    1. Shrink the `/home’ partition ( `/dev/hda6′ ) by 500MB:
    2. Make a new partition in its place. This is where `/var’ will be, eventually. This new partition will be numbered 10.
    3. Copy the old `/var’ partition ( `/dev/hda7′ ) to the new one ( `/dev/hda10′ ).
    4. Delete the old `/var’ . At this point: all logical partitions greater than 7 just changed number. So 8, 9 and 10 become 7, 8 and 9 respectively. This renumbering won’t take place while any partitions are mounted on that disk (this will happen when you reboot). That’s what that warning message is talking about. So you should never attempt to mount a file system touched by Parted (resized or created by Parted), before rebooting, if you get this message.
    5. Resize the new `/var’ partition (now numbered 9), adding the space from the old `/var’ partition:
    6. Since the partition numbers have changed, `/etc/fstab’ must be updated. This can be done before rebooting, because the root device wasn’t touched by Parted. (If you want to use Parted to do something to the root device, you need to use the boot disk). If the old `/etc/fstab’ looks like this: A few lines need to be changed:
      • `/var’ is now /dev/hda9 (because we copied it to a new partition)
      • `/dev/hda8′ (the root device) has been renumbered to `/dev/hda7′
      • `/dev/hda9′ (the swap device) has been renumbered to `/dev/hda8′

      The new `/etc/fstab’ looks like this:
    7. Reboot. That’s it!

    Источник

    Читайте также:  Кали линукс приложение для виндовс
Оцените статью