https://wiki.archlinux.org/api.php?action=feedcontributions&user=Sloppy+joes&feedformat=atomArchWiki - User contributions [en]2024-03-28T09:53:28ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=Xrandr&diff=473821Xrandr2017-04-13T05:59:25Z<p>Sloppy joes: See https://bbs.archlinux.org/viewtopic.php?id=225134</p>
<hr />
<div>{{Lowercase title}}<br />
[[Category:X server]]<br />
[[ru:Xrandr]]<br />
[[ja:Xrandr]]<br />
[[zh-hans:Xrandr]]<br />
{{Related articles start}}<br />
{{Related|Xorg}}<br />
{{Related|Multihead}}<br />
{{Related articles end}}<br />
<br />
''xrandr'' is an official configuration utility to the [[Wikipedia:RandR|RandR]] [[Wikipedia:X Window System|X Window System]] extension. It can be used to set the size, orientation or reflection of the outputs for a screen. For configuring multiple monitors see the [[Multihead]] page.<br />
<br />
== Installation ==<br />
<br />
[[Install]] {{Pkg|xorg-xrandr}}. A graphical front end such as {{Pkg|arandr}} or {{Pkg|lxrandr}} is also available.<br />
<br />
== Testing configuration ==<br />
<br />
When run without any option, ''xrandr'' shows the names of different outputs available on the system ({{ic|LVDS}}, {{ic|VGA-0}}, etc.) and resolutions available on each, with a '''*''' after the current one and a '''+''' after the preferred one :<br />
<br />
{{hc|xrandr|<br />
Screen 0: minimum 320 x 200, current 1440 x 900, maximum 8192 x 8192<br />
VGA disconnected (normal left inverted right x axis y axis)<br />
LVDS connected (normal left inverted right x axis y axis)<br />
1440x900 59.9*+<br />
1280x854 59.9 <br />
1280x800 59.8 <br />
...<br />
}}<br />
<br />
You can use ''xrandr'' to set different resolution (must be present in the above list) on some output:<br />
<br />
$ xrandr --output LVDS --mode 1280x800<br />
<br />
When multiple refresh rates are present in the list ('''not''' in the example above), it may be changed by the {{ic|--rate}} option, either at the same time or independently. For example:<br />
<br />
$ xrandr --output LVDS --mode 1280x800 --rate 75<br />
<br />
The {{ic|--auto}} option will turn the specified output on if it is off and set the preferred (maximum) resolution:<br />
<br />
$ xrandr --output LVDS --auto<br />
<br />
It is possible to specify multiple outputs in one command, e.g. to turn off {{ic|LVDS}} and turn on {{ic|HDMI-0}} with preferred resolution:<br />
<br />
$ xrandr --output LVDS --off --output HDMI-0 --auto<br />
<br />
{{Note|<br />
* Changes you make using ''xrandr'' will only last through the current session.<br />
* ''xrandr'' has a lot more capabilities - see {{man|1|xrandr|url=https://www.x.org/archive/X11R7.5/doc/man/man1/xrandr.1.html}} for details.<br />
}}<br />
<br />
== Configuration ==<br />
<br />
''xrandr'' is just a simple interface to the RandR extension and has no configuration file. However, there are multiple ways of achieving persistent configuration:<br />
<br />
# The RandR extension can be configured via [[Xorg#Configuration|X configuration files]], see [[Multihead#RandR]] for details. This method provides only static configuration.<br />
# If you need dynamic configuration, you need to execute ''xrandr'' commands each time X server starts. See [[Autostarting#Graphical]] for details. This method has the disadvantage of occurring fairly late in the startup process, thus it will not alter the resolution of the [[display manager]] if you use one.<br />
# Custom scripts calling ''xrandr'' can be bound to events (for example when external monitor is plugged in), see [[acpid]] for details. The [[#Scripts]] section provides you with some example scripts that might be useful for this purpose.<br />
<br />
{{Tip|Both KDM and GDM have startup scripts that are executed when X is initiated. For GDM, these are in {{ic|/etc/gdm/}}, while for KDM this is done at {{ic|/usr/share/config/kdm/Xsetup}} and for SDDM at {{ic|/usr/share/sddm/scripts/Xsetup}}. This method requires root access and mucking around in system config files, but will take effect earlier in the startup process than using xprofile.}}<br />
<br />
=== Scripts ===<br />
<br />
==== Toggle external monitor ====<br />
<br />
This script toggles between an external monitor (specified by {{ic|$extern}}) and a default monitor (specified by {{ic|$intern}}), so that only one monitor is active at a time.<br />
<br />
The default monitor should be connected when running the script, which is always true for a laptop.<br />
<br />
{{bc|<nowiki><br />
#!/bin/bash<br />
intern=LVDS1<br />
extern=VGA1<br />
<br />
if xrandr | grep "$extern disconnected"; then<br />
xrandr --output "$extern" --off --output "$intern" --auto<br />
else<br />
xrandr --output "$intern" --off --output "$extern" --auto<br />
fi<br />
</nowiki>}}<br />
<br />
{{Note|To leave the external monitor enabled, replace the ''else'' clause with {{ic|xrandr --output "$intern" --primary --auto --output "$extern" --right-of "$intern" --auto}}.}}<br />
<br />
==== Manage 2-monitors ====<br />
<br />
{{AUR|mons}} is a POSIX-compliant shell script to quickly manage 2-monitors display.<br />
<br />
It provides well-known modes like computer, duplicate, extend and projector mode as well as selecting and positioning one or two monitors among those plugged in (for more details, see [https://github.com/Ventto/mons mons]).<br />
<br />
==== Example 3 ====<br />
<br />
{{Accuracy|1=Basic shell mistakes: relying on quoting errors to relay arguments (instead of using arrays), convoluted grep+sed pipes (instead of awk), echo -e (instead of printf), ancient backtick format (instead of {{ic|$()}})}}<br />
<br />
This script iterates through connected monitors, selects currently active monitor, turns next one on and the others off:<br />
<br />
{{bc|<nowiki><br />
# get info from xrandr<br />
connectedOutputs=$(xrandr | grep " connected" | sed -e "s/\([A-Z0-9]\+\) connected.*/\1/")<br />
activeOutput=$(xrandr | grep -E " connected (primary )?[1-9]+" | sed -e "s/\([A-Z0-9]\+\) connected.*/\1/")<br />
<br />
# initialize variables<br />
execute="xrandr "<br />
default="xrandr "<br />
i=1<br />
switch=0<br />
<br />
for display in $connectedOutputs<br />
do<br />
# build default configuration<br />
if [ $i -eq 1 ]<br />
then<br />
default=$default"--output $display --auto "<br />
else<br />
default=$default"--output $display --off "<br />
fi<br />
<br />
# build "switching" configuration<br />
if [ $switch -eq 1 ]<br />
then<br />
execute=$execute"--output $display --auto "<br />
switch=0<br />
else<br />
execute=$execute"--output $display --off "<br />
fi<br />
<br />
# check whether the next output should be switched on<br />
if [ $display = $activeOutput ]<br />
then<br />
switch=1<br />
fi<br />
<br />
i=$(( $i + 1 ))<br />
done<br />
<br />
# check if the default setup needs to be executed then run it<br />
echo "Resulting Configuration:"<br />
if [ -z "$(echo $execute | grep "auto")" ]<br />
then<br />
echo "Command: $default"<br />
`$default`<br />
else<br />
echo "Command: $execute"<br />
`$execute`<br />
fi<br />
echo -e "\n$(xrandr)"<br />
</nowiki>}}<br />
<br />
==== Avoid X crash with xrasengan ====<br />
<br />
Use this workaround to turn on connected outputs that may be in suspend mode and hence shown as disconnected, as is often the case of DisplayPort monitors:<br />
<br />
{{bc|<nowiki><br />
declare -i count=2<br />
declare -i seconds=1<br />
<br />
while ((count)); do<br />
xrandr >/dev/null<br />
sleep $seconds<br />
((count--))<br />
done<br />
</nowiki>}}<br />
<br />
[https://github.com/geyslan/xrasengan xrasengan] is an xrandr wrapper with this workaround built in.<br />
<br />
$ xrasengan --force -on DisplayPort-0 -off HDMI-0<br />
<br />
With the {{ic|--force}} option, ''xrasengan'' will update status of all outputs before HDMI-0 is turned off, avoiding an X crash if they were the only connected/active outputs.<br />
<br />
To force reload current settings, ''xrasengan'' provides a {{ic|--try-reload-active-layout}} option, which uses {{ic|--force}} and ''unxrandr'' from the {{Pkg|arandr}} package to assemble the command line:<br />
<br />
$ xrasengan --try-reload-active-layout<br />
<br />
This can be used in systemd unit or in a keyboard binding to avoid blank screen when resuming DisplayPort monitors from suspend.<br />
<br />
== Troubleshooting ==<br />
<br />
=== Adding undetected resolutions ===<br />
<br />
Due to buggy hardware or drivers, your monitor's correct resolutions may not always be detected by xrandr. For example, the EDID data block queried from the monitor may be incorrect. However, we can add the desired resolutions to xrandr.<br />
<br />
First we run {{ic|gtf}} or {{ic|cvt}} to get the '''Modeline''' for the resolution we want:<br />
<br />
For some LCD screens (samsung 2343NW), the command "cvt -r" (= with reduced blanking) is to be used.<br />
<br />
{{hc|$ cvt 1280 1024|<br />
# 1280x1024 59.89 Hz (CVT 1.31M4) hsync: 63.67 kHz; pclk: 109.00 MHz<br />
Modeline "1280x1024_60.00" 109.00 1280 1368 1496 1712 1024 1027 1034 1063 -hsync +vsync<br />
}}<br />
<br />
{{Note|If the Intel video driver {{pkg|xf86-video-intel}} is used, it may report the desired resolution along with its properties in {{ic|/var/log/Xorg.0.log}} — use that first if it is different from the output of {{ic|gtf}} or {{ic|cvt}}. For instance, the log and its use with xrandr:<br />
[ 45.063] (II) intel(0): clock: 241.5 MHz Image Size: 597 x 336 mm<br />
[ 45.063] (II) intel(0): h_active: 2560 h_sync: 2600 h_sync_end 2632 h_blank_end 2720 h_border: 0<br />
[ 45.063] (II) intel(0): v_active: 1440 v_sync: 1443 v_sync_end 1448 v_blanking: 1481 v_border: 0<br />
<br />
xrandr --newmode "2560x1440" 241.50 2560 2600 2632 2720 1440 1443 1448 1481 -hsync +vsync<br />
}}<br />
<br />
Then we create a new xrandr mode. Note that the Modeline keyword needs to be ommited.<br />
<br />
$ xrandr --newmode "1280x1024_60.00" 109.00 1280 1368 1496 1712 1024 1027 1034 1063 -hsync +vsync<br />
<br />
After creating it we need an extra step to add this new mode to our current output (VGA1). We use just the name of the mode, since the parameters have been set previously.<br />
<br />
$ xrandr --addmode VGA1 1280x1024_60.00<br />
<br />
Now we change the resolution of the screen to the one we just added:<br />
<br />
$ xrandr --output VGA1 --mode 1280x1024_60.00<br />
<br />
Note that these settings only take effect during this session. <br />
<br />
If you are not sure about the resolution you will test, you may add a {{ic|sleep 5}} and a safe resolution command line following, like this:<br />
<br />
$ xrandr --output VGA1 --mode 1280x1024_60.00 && sleep 5 && xrandr --newmode "1024x768-safe" 65.00 1024 1048 1184 1344 768 771 777 806 -HSync -VSync && xrandr --addmode VGA1 1024x768-safe && xrandr --output VGA1 --mode 1024x768-safe<br />
<br />
Also, change {{ic|VGA1}} to correct output name.<br />
<br />
==== EDID checksum is invalid ====<br />
<br />
If the previous method results in an {{ic|*ERROR* EDID checksum is invalid}} error during boot, see [[KMS#Forcing modes and EDID]] and [http://askubuntu.com/questions/201081/how-can-i-make-linux-behave-better-when-edid-is-unavailable].<br />
<br />
Or {{ic|xrandr --addmode}} might give you the error {{ic|X Error of failed request: BadMatch}}. NVIDIA users should read [[NVIDIA/Troubleshooting#xrandr BadMatch]]. {{ic|BadMatch}} could indicate an invalid EDID checksum. To verify that this is the case, run X in verbose mode (e.g. {{ic|startx -- -logverbose 6}}) and check your Xorg log for messages about a bad EDID.<br />
<br />
==== Screen resolution reverts back after a blink ====<br />
<br />
If you use [[GNOME]] and your monitor doesn't have an EDID, above [[#Adding undetected resolutions]] might not work, with your screen just blinking once, after {{ic|xrandr --output}}.<br />
<br />
Poke around with {{ic|~/.config/monitors.xml}}, or delete the file completely, and then reboot.<br />
<br />
It is better explained in [http://unix.stackexchange.com/questions/184941/gnome-prevents-high-resolution-vga-without-edid-info-over-vga this] article.<br />
<br />
=== Permanently adding undetected resolutions ===<br />
<br />
Once a suitable resolution is found using {{ic|xrandr}}, the mode can be permanently added by creating an entry in {{ic|/etc/X11/xorg.conf.d/}}:<br />
<br />
{{hc|/etc/X11/xorg.conf.d/10-monitor.conf|<br />
Section "Monitor"<br />
Identifier "VGA1"<br />
Modeline "1280x1024_60.00" 109.00 1280 1368 1496 1712 1024 1027 1034 1063 -hsync +vsync<br />
Option "PreferredMode" "1280x1024_60.00"<br />
EndSection<br />
<br />
Section "Screen"<br />
Identifier "Screen0"<br />
Monitor "VGA1"<br />
DefaultDepth 24<br />
SubSection "Display"<br />
Modes "1280x1024_60.00"<br />
EndSubSection<br />
EndSection<br />
<br />
Section "Device"<br />
Identifier "Device0"<br />
Driver "intel"<br />
EndSection}}<br />
<br />
Replace {{ic|intel}} with the right driver, e.g. {{ic|nvidia}}.<br />
<br />
If this doesn't work for you, try removing the Screen and Device sections and just leaving the Monitor section.<br />
<br />
=== Resolution lower than expected ===<br />
<br />
{{Tip|Try [[#Adding undetected resolutions]] first, if it doesn't work, you may try this method.}}<br />
<br />
If your video card is recognized but the resolution is lower than you expect, you may try this.<br />
<br />
Background: ATI X1550 based video card and two LCD monitors DELL 2408(up to 1920x1200) and Samsung 206BW(up to 1680x1050). Upon first login after installation, the resolution default to 1152x864. xrandr does not list any resolution higher than 1152x864. You may want to try editing /etc/X11/xorg.conf, add a section about virtual screen, logout, login and see if this helps. If not then read on.<br />
<br />
Change xorg.conf<br />
{{hc|/etc/X11/xorg.conf|<br />
Section "Screen"<br />
...<br />
SubSection "Display"<br />
Virtual 3600 1200<br />
EndSubSection<br />
EndSection<br />
}}<br />
<br />
About the numbers: DELL on the left and Samsung on the right. So the virtual width is of sum of both LCD width 3600=1920+1680; Height then is figured as the max of them, which is max(1200,1050)=1200. If you put one LCD above the other, use this calculation instead: (max(width1, width2), height1+height2).<br />
<br />
=== Correction of overscan tv resolutions ===<br />
<br />
With a flat panel TV, [[w:overscan]] looks like the picture is "zoomed in" so the edges are cut off.<br />
<br />
Check your TV if there is a parameter to change. If not, apply an {{ic|underscan}} and change border values. <br />
The required {{ic|underscan vborder}} and {{ic|underscan hborder}} values can be different for you, just check it and change it by more or less.<br />
<br />
{{ic|$ xrandr --output HDMI-0 --set underscan on --set "underscan vborder" 25 --set "underscan hborder" 40 }}<br />
<br />
=== Full RGB in HDMI ===<br />
<br />
It may occur that the [[Intel]] driver will not configure correctly the output of the HDMI monitor. It will set a limited color range (16-235) using the [https://patchwork.kernel.org/patch/1972181/ Broadcast RGB property], and the black will not look black, it will be grey.<br />
<br />
To see if it is your case:<br />
<br />
$ xrandr --output HDMI1 --set "Broadcast RGB" "Full"<br />
<br />
== See also ==<br />
* https://wiki.ubuntu.com/X/Config/Resolution<br />
* [http://wiki.debian.org/XStrikeForce/HowToRandR12 RandR 1.2 tutorial]<br />
* [http://www.thinkwiki.org/wiki/Xorg_RandR_1.2 Xorg RandR 1.2 on ThinkWiki]<br />
* [http://www.x.org/wiki/FAQVideoModes#ObtainingmodelinesfromWindowsprogramPowerStrip FAQVideoModes - more information about modelines]</div>Sloppy joeshttps://wiki.archlinux.org/index.php?title=Parted&diff=472211Parted2017-03-29T23:07:42Z<p>Sloppy joes: Added further specification to the BIOS/GPT example</p>
<hr />
<div>[[Category:File systems]]<br />
[[Category:System recovery]]<br />
[[ja:GNU Parted]]<br />
[[zh-hans:GNU Parted]]<br />
{{Related articles start}}<br />
{{Related|fdisk}}<br />
{{Related|Partitioning}}<br />
{{Related articles end}}<br />
<br />
GNU Parted is a program for creating and manipulating partition tables. [[GParted]] is a GUI frontend.<br />
<br />
== Installation ==<br />
<br />
[[Install]] the {{Pkg|parted}} package. For a graphical interface, [[install]] the {{pkg|gparted}} package, the graphical frontend to ''parted''.<br />
<br />
== Usage ==<br />
<br />
Parted has two modes: command line and interactive. Parted should always be started with:<br />
<br />
# parted device<br />
<br />
where {{ic|''device''}} is the hard disk device to edit (for example {{ic|/dev/sda}}). If you omit the {{ic|''device''}} argument, ''parted'' will attempt to guess which device you want.<br />
<br />
=== Command line mode ===<br />
<br />
In command line mode, this is followed by one or more commands. For example:<br />
<br />
# parted /dev/sda mklabel gpt mkpart P1 ext3 1MiB 8MiB <br />
<br />
{{Note|Options (like {{ic|--help}}) can only be specified on the command line.}}<br />
<br />
=== Interactive mode ===<br />
<br />
Interactive mode simplifies the partitioning process and reduces unnecessary repetition by automatically applying all partitioning commands to the specified device. <br />
<br />
In order to start operating on a device, execute:<br />
<br />
# parted /dev/sd''x''<br />
<br />
You will notice that the command-line prompt changes from a hash ({{ic|#}}) to {{ic|(parted)}}: this also means that the new prompt is not a command to be manually entered when running the commands in the examples.<br />
<br />
To see a list of the available commands, enter:<br />
<br />
(parted) help<br />
<br />
When finished, or if wishing to implement a partition table or scheme for another device, exit from parted with:<br />
<br />
(parted) quit<br />
<br />
After exiting, the command-line prompt will change back to {{ic|#}}.<br />
<br />
If you do not give a parameter to a command, Parted will prompt you for it. For example:<br />
<br />
(parted) mklabel<br />
New disk label type? gpt<br />
<br />
== Rounding ==<br />
<br />
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.<br />
<br />
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.<br />
<br />
== Partitioning ==<br />
<br />
=== Create new partition table ===<br />
<br />
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.<br />
<br />
Open each device whose partition table must be (re)created with:<br />
<br />
# parted /dev/sd''x''<br />
<br />
To then create a new MBR/msdos partition table for BIOS systems, use the following command:<br />
<br />
(parted) mklabel msdos<br />
<br />
To create a new GPT partition table for UEFI systems instead, use:<br />
<br />
(parted) mklabel gpt<br />
<br />
=== Partition schemes ===<br />
<br />
{{Merge|partitioning|duplicates much content}}<br />
<br />
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''). The mapping from partitions to directories is the [[partition scheme]], which must comply with the following requirements:<br />
<br />
* At least a partition for the {{ic|/}} (''root'') directory '''must''' be created.<br />
* When using a UEFI motherboard, one [[EFI System Partition]] '''must''' be created<br />
<br />
In the examples below it is assumed that a new and contiguous partitioning scheme is applied to a single device. Some optional partitions will also be created for the {{ic|/boot}} and {{ic|/home}} directories: see also [[Arch filesystem hierarchy]] for an explanation of the purpose of the various directories; if separate partitions for directories like {{ic|/boot}} or {{ic|/home}} are not created, these will simply be contained in the {{ic|/}} partition. Also the creation of an optional partiton for [[swap space]] will be illustrated.<br />
<br />
If not already open in a ''parted'' interactive session, open each device to be partitioned with:<br />
<br />
# parted /dev/sd''x''<br />
<br />
The following command will be used to create partitions:<br />
<br />
(parted) mkpart ''part-type'' ''fs-type'' ''start'' ''end''<br />
<br />
* {{ic|''part-type''}} is one of {{ic|primary}}, {{ic|extended}} or {{ic|logical}}, and is meaningful only for MBR partition tables.<br />
* {{ic|''fs-type''}} is an identifier chosen among those listed by entering {{ic|help mkpart}} as the closest match to the file system that you will use. The ''mkpart'' command does not actually create the file system: the {{ic|''fs-type''}} parameter will simply be used by ''parted'' to set a 1-byte code that is used by boot loaders to "preview" what kind of data is found in the partition, and act accordingly if necessary. See also [[Wikipedia:Disk partitioning#PC partition types]].<br />
: {{Tip|Most [[Wikipedia:File_system#Linux|Linux native file systems]] map to the same partition code ([[Wikipedia:Partition type#PID_83h|0x83]]), so it is perfectly safe to e.g. use {{ic|ext2}} for an ''ext4''-formatted partition.}}<br />
* {{ic|''start''}} is the beginning of the partition from the start of the device. It consists of a number followed by a [http://www.gnu.org/software/parted/manual/parted.html#unit unit], for example {{ic|1M}} means start at 1MiB.<br />
* {{ic|''end''}} is the end of the partition from the start of the device (''not'' from the {{ic|''start''}} value). It has the same syntax as {{ic|''start''}}, for example {{ic|100%}} means end at the end of the device (use all the remaining space).<br />
<br />
{{Warning|It is important that the partitions do not overlap each other: if you do not want to leave unused space in the device, make sure that each partition starts where the previous one ends.}}<br />
<br />
{{Note|''parted'' may issue a warning like:<br />
<br />
Warning: The resulting partition is not properly aligned for best performance.<br />
Ignore/Cancel?<br />
<br />
In this case, read [[Partitioning#Partition alignment]] and follow [[#Alignment]] to fix it.}}<br />
<br />
The following command will be used to flag the partition that contains the {{ic|/boot}} directory as bootable:<br />
<br />
(parted) set ''partition'' boot on<br />
<br />
* {{ic|''partition''}} is the number of the partition to be flagged (see the output of the {{ic|print}} command).<br />
<br />
==== UEFI/GPT examples ====<br />
<br />
In every instance, a special bootable [[EFI System Partition]] is required.<br />
<br />
If creating a new EFI System Partition, use the following commands (the recommended size is 512MiB):<br />
<br />
(parted) mkpart ESP fat32 1MiB 513MiB<br />
(parted) set 1 boot on<br />
<br />
The remaining partition scheme is entirely up to you. For one other partition using 100% of remaining space:<br />
<br />
(parted) mkpart primary ext4 513MiB 100%<br />
<br />
For separate {{ic|/}} (20GiB) and {{ic|/home}} (all remaining space) partitions:<br />
<br />
(parted) mkpart primary ext4 513MiB 20.5GiB<br />
(parted) mkpart primary ext4 20.5GiB 100%<br />
<br />
And for separate {{ic|/}} (20GiB), swap (4GiB), and {{ic|/home}} (all remaining space) partitions:<br />
<br />
(parted) mkpart primary ext4 513MiB 20.5GiB<br />
(parted) mkpart primary linux-swap 20.5GiB 24.5GiB<br />
(parted) mkpart primary ext4 24.5GiB 100%<br />
<br />
==== BIOS/MBR examples ====<br />
<br />
For a minimum single primary partition using all available disk space, the following command would be used:<br />
<br />
(parted) mkpart primary ext4 1MiB 100%<br />
(parted) set 1 boot on<br />
<br />
In the following instance, a 20GiB {{ic|/}} partition will be created, followed by a {{ic|/home}} partition using all the remaining space:<br />
<br />
(parted) mkpart primary ext4 1MiB 20GiB<br />
(parted) set 1 boot on<br />
(parted) mkpart primary ext4 20GiB 100%<br />
<br />
In the final example below, separate {{ic|/boot}} (100MiB), {{ic|/}} (20GiB), swap (4GiB), and {{ic|/home}} (all remaining space) partitions will be created:<br />
<br />
(parted) mkpart primary ext3 1MiB 100MiB<br />
(parted) set 1 boot on<br />
(parted) mkpart primary ext3 100MiB 20GiB<br />
(parted) mkpart primary linux-swap 20GiB 24GiB<br />
(parted) mkpart primary ext3 24GiB 100%<br />
<br />
==== BIOS/GPT example ====<br />
<br />
This example assumes you are using [[grub]] as your bootloader.<br />
<br />
Unlike in the BIOS/MBR case, a special 2 MiB partition [http://askubuntu.com/questions/500359/efi-boot-partition-and-biosgrub-partition is required for the extra grub code.] The third partition can be further divided to include a swap partition or a separate partition for {{ic|/home}}.<br />
<br />
(parted) mkpart primary 1MiB 3MiB<br />
(parted) set 1 bios_grub on<br />
(parted) mkpart primary ext2 3MiB 200MiB<br />
(parted) set 2 boot on<br />
(parted) mkpart primary ext4 200MiB 100%<br />
<br />
=== Resizing Partitions ===<br />
<br />
{{Warning|Partitions that are being resized must be unmounted and not in use. If it cannot be done (e.g. the partition that mounts to {{ic|/}}), use a live media/rescue system.}}<br />
{{Note|<br />
* You can only move the end of the partition with {{ic|parted}}.<br />
* As of parted v4.2 ''resizepart'' may need the use of [[#Interactive mode]].[https://bugs.launchpad.net/ubuntu/+source/parted/+bug/1270203]<br />
* These instructions apply to partitions that have ext2, ext3 or ext4 filesystems.<br />
}}<br />
<br />
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.<br />
<br />
==== Growing partitions ====<br />
<br />
To grow a partition (in parted interactive mode):<br />
<br />
(parted) resizepart ''number'' ''end''<br />
<br />
Where {{ic|''number''}} is the number of the partition you are growing, and {{ic|''end''}} is the new end of the partition (which needs to be larger than the old end).<br />
<br />
Then, to grow the filesystem on the partition:<br />
<br />
# resize2fs /dev/''sdaX'' ''size''<br />
<br />
Where {{ic|''sdaX''}} stands for the partition you are growing, and {{ic|''size''}} is the new size of the partition.<br />
<br />
==== Shrinking partitions ====<br />
<br />
To shrink the filesystem on the partition:<br />
<br />
# resize2fs /dev/''sdaX'' ''size''<br />
<br />
Where {{ic|''sdaX''}} stands for the partition you are shrinking, and {{ic|''size''}} is the new size of the partition.<br />
<br />
Then shrink the partition (in parted interactive mode):<br />
<br />
(parted) resizepart ''number'' ''end''<br />
<br />
Where {{ic|''number''}} is the number of the partition you are shrinking, and {{ic|''end''}} is the new end of the partition (which needs to be smaller than the old end).<br />
<br />
When done, use the ''resizepart'' command from {{Pkg|util-linux}} to tell the kernel about the new size:<br />
<br />
# resizepart ''device'' ''number'' ''size''<br />
<br />
Where {{ic|''device''}} is the device that holds the partition, {{ic|''number''}} is the number of the partition and {{ic|''size''}} is the new size of the partition.<br />
<br />
== Warnings ==<br />
<br />
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).<br />
<br />
=== Alignment ===<br />
<br />
When creating a partition, ''parted'' might warn about improper partition alignment but does not hint about proper alignment. For example:<br />
<br />
(parted) mkpart primary fat16 0 32M<br />
Warning: The resulting partition is not properly aligned for best performance.<br />
Ignore/Cancel? <br />
<br />
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.<br />
<br />
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:<br />
<br />
(parted) mkpart primary ext4 0% 100%<br />
<br />
== Tips and tricks ==<br />
<br />
=== Dual booting with Windows XP ===<br />
<br />
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:<br />
<br />
HKEY_LOCAL_MACHINE\SYSTEM\MountedDevices<br />
<br />
Reference to this little gem [http://gparted-forum.surf4.info/viewtopic.php?pid=8347#p8347 here].<br />
<br />
=== Fixing messed-up partition order ===<br />
<br />
{{Merge|fdisk|Merge note to [[fdisk]]? Cf. http://serverfault.com/questions/36038/reread-partition-table-without-rebooting}}<br />
<br />
See [[Fdisk#Sort_partitions]].<br />
<br />
{{Note|You must run '''partprobe''' as root or reboot the system in order for the kernel to read the new partition table!}}<br />
<br />
=== Check alignment ===<br />
<br />
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 {{ic|/dev/sda}}:<br />
<br />
# parted /dev/sda<br />
(parted) align-check optimal 1<br />
1 aligned<br />
<br />
== See also ==<br />
<br />
* [https://www.gnu.org/software/parted/manual/ GNU parted - Parted User's Manual]<br />
* [http://rainbow.chard.org/2013/01/30/how-to-align-partitions-for-best-performance-using-parted/ How to align partitions for best performance using parted]<br />
* [http://positon.org/resize-an-ext3-ext4-partition Resize an ext3/ext4 partition]<br />
* [http://gparted-forum.surf4.info/ Official GParted forums]</div>Sloppy joeshttps://wiki.archlinux.org/index.php?title=Parted&diff=472195Parted2017-03-29T21:03:45Z<p>Sloppy joes: GiB to MiB from my previous change</p>
<hr />
<div>[[Category:File systems]]<br />
[[Category:System recovery]]<br />
[[ja:GNU Parted]]<br />
[[zh-hans:GNU Parted]]<br />
{{Related articles start}}<br />
{{Related|fdisk}}<br />
{{Related|Partitioning}}<br />
{{Related articles end}}<br />
<br />
GNU Parted is a program for creating and manipulating partition tables. [[GParted]] is a GUI frontend.<br />
<br />
== Installation ==<br />
<br />
[[Install]] the {{Pkg|parted}} package. For a graphical interface, [[install]] the {{pkg|gparted}} package, the graphical frontend to ''parted''.<br />
<br />
== Usage ==<br />
<br />
Parted has two modes: command line and interactive. Parted should always be started with:<br />
<br />
# parted device<br />
<br />
where {{ic|''device''}} is the hard disk device to edit (for example {{ic|/dev/sda}}). If you omit the {{ic|''device''}} argument, ''parted'' will attempt to guess which device you want.<br />
<br />
=== Command line mode ===<br />
<br />
In command line mode, this is followed by one or more commands. For example:<br />
<br />
# parted /dev/sda mklabel gpt mkpart P1 ext3 1MiB 8MiB <br />
<br />
{{Note|Options (like {{ic|--help}}) can only be specified on the command line.}}<br />
<br />
=== Interactive mode ===<br />
<br />
Interactive mode simplifies the partitioning process and reduces unnecessary repetition by automatically applying all partitioning commands to the specified device. <br />
<br />
In order to start operating on a device, execute:<br />
<br />
# parted /dev/sd''x''<br />
<br />
You will notice that the command-line prompt changes from a hash ({{ic|#}}) to {{ic|(parted)}}: this also means that the new prompt is not a command to be manually entered when running the commands in the examples.<br />
<br />
To see a list of the available commands, enter:<br />
<br />
(parted) help<br />
<br />
When finished, or if wishing to implement a partition table or scheme for another device, exit from parted with:<br />
<br />
(parted) quit<br />
<br />
After exiting, the command-line prompt will change back to {{ic|#}}.<br />
<br />
If you do not give a parameter to a command, Parted will prompt you for it. For example:<br />
<br />
(parted) mklabel<br />
New disk label type? gpt<br />
<br />
== Rounding ==<br />
<br />
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.<br />
<br />
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.<br />
<br />
== Partitioning ==<br />
<br />
=== Create new partition table ===<br />
<br />
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.<br />
<br />
Open each device whose partition table must be (re)created with:<br />
<br />
# parted /dev/sd''x''<br />
<br />
To then create a new MBR/msdos partition table for BIOS systems, use the following command:<br />
<br />
(parted) mklabel msdos<br />
<br />
To create a new GPT partition table for UEFI systems instead, use:<br />
<br />
(parted) mklabel gpt<br />
<br />
=== Partition schemes ===<br />
<br />
{{Merge|partitioning|duplicates much content}}<br />
<br />
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''). The mapping from partitions to directories is the [[partition scheme]], which must comply with the following requirements:<br />
<br />
* At least a partition for the {{ic|/}} (''root'') directory '''must''' be created.<br />
* When using a UEFI motherboard, one [[EFI System Partition]] '''must''' be created<br />
<br />
In the examples below it is assumed that a new and contiguous partitioning scheme is applied to a single device. Some optional partitions will also be created for the {{ic|/boot}} and {{ic|/home}} directories: see also [[Arch filesystem hierarchy]] for an explanation of the purpose of the various directories; if separate partitions for directories like {{ic|/boot}} or {{ic|/home}} are not created, these will simply be contained in the {{ic|/}} partition. Also the creation of an optional partiton for [[swap space]] will be illustrated.<br />
<br />
If not already open in a ''parted'' interactive session, open each device to be partitioned with:<br />
<br />
# parted /dev/sd''x''<br />
<br />
The following command will be used to create partitions:<br />
<br />
(parted) mkpart ''part-type'' ''fs-type'' ''start'' ''end''<br />
<br />
* {{ic|''part-type''}} is one of {{ic|primary}}, {{ic|extended}} or {{ic|logical}}, and is meaningful only for MBR partition tables.<br />
* {{ic|''fs-type''}} is an identifier chosen among those listed by entering {{ic|help mkpart}} as the closest match to the file system that you will use. The ''mkpart'' command does not actually create the file system: the {{ic|''fs-type''}} parameter will simply be used by ''parted'' to set a 1-byte code that is used by boot loaders to "preview" what kind of data is found in the partition, and act accordingly if necessary. See also [[Wikipedia:Disk partitioning#PC partition types]].<br />
: {{Tip|Most [[Wikipedia:File_system#Linux|Linux native file systems]] map to the same partition code ([[Wikipedia:Partition type#PID_83h|0x83]]), so it is perfectly safe to e.g. use {{ic|ext2}} for an ''ext4''-formatted partition.}}<br />
* {{ic|''start''}} is the beginning of the partition from the start of the device. It consists of a number followed by a [http://www.gnu.org/software/parted/manual/parted.html#unit unit], for example {{ic|1M}} means start at 1MiB.<br />
* {{ic|''end''}} is the end of the partition from the start of the device (''not'' from the {{ic|''start''}} value). It has the same syntax as {{ic|''start''}}, for example {{ic|100%}} means end at the end of the device (use all the remaining space).<br />
<br />
{{Warning|It is important that the partitions do not overlap each other: if you do not want to leave unused space in the device, make sure that each partition starts where the previous one ends.}}<br />
<br />
{{Note|''parted'' may issue a warning like:<br />
<br />
Warning: The resulting partition is not properly aligned for best performance.<br />
Ignore/Cancel?<br />
<br />
In this case, read [[Partitioning#Partition alignment]] and follow [[#Alignment]] to fix it.}}<br />
<br />
The following command will be used to flag the partition that contains the {{ic|/boot}} directory as bootable:<br />
<br />
(parted) set ''partition'' boot on<br />
<br />
* {{ic|''partition''}} is the number of the partition to be flagged (see the output of the {{ic|print}} command).<br />
<br />
==== UEFI/GPT examples ====<br />
<br />
In every instance, a special bootable [[EFI System Partition]] is required.<br />
<br />
If creating a new EFI System Partition, use the following commands (the recommended size is 512MiB):<br />
<br />
(parted) mkpart ESP fat32 1MiB 513MiB<br />
(parted) set 1 boot on<br />
<br />
The remaining partition scheme is entirely up to you. For one other partition using 100% of remaining space:<br />
<br />
(parted) mkpart primary ext4 513MiB 100%<br />
<br />
For separate {{ic|/}} (20GiB) and {{ic|/home}} (all remaining space) partitions:<br />
<br />
(parted) mkpart primary ext4 513MiB 20.5GiB<br />
(parted) mkpart primary ext4 20.5GiB 100%<br />
<br />
And for separate {{ic|/}} (20GiB), swap (4GiB), and {{ic|/home}} (all remaining space) partitions:<br />
<br />
(parted) mkpart primary ext4 513MiB 20.5GiB<br />
(parted) mkpart primary linux-swap 20.5GiB 24.5GiB<br />
(parted) mkpart primary ext4 24.5GiB 100%<br />
<br />
==== BIOS/MBR examples ====<br />
<br />
For a minimum single primary partition using all available disk space, the following command would be used:<br />
<br />
(parted) mkpart primary ext4 1MiB 100%<br />
(parted) set 1 boot on<br />
<br />
In the following instance, a 20GiB {{ic|/}} partition will be created, followed by a {{ic|/home}} partition using all the remaining space:<br />
<br />
(parted) mkpart primary ext4 1MiB 20GiB<br />
(parted) set 1 boot on<br />
(parted) mkpart primary ext4 20GiB 100%<br />
<br />
In the final example below, separate {{ic|/boot}} (100MiB), {{ic|/}} (20GiB), swap (4GiB), and {{ic|/home}} (all remaining space) partitions will be created:<br />
<br />
(parted) mkpart primary ext3 1MiB 100MiB<br />
(parted) set 1 boot on<br />
(parted) mkpart primary ext3 100MiB 20GiB<br />
(parted) mkpart primary linux-swap 20GiB 24GiB<br />
(parted) mkpart primary ext3 24GiB 100%<br />
<br />
==== BIOS/GPT example ====<br />
<br />
Unlike in the BIOS/MBR case, a special 2 MiB partition [http://askubuntu.com/questions/500359/efi-boot-partition-and-biosgrub-partition is required for the extra grub code.] The third partition can be further divided to include a swap partition or a separate partition for {{ic|/home}}.<br />
<br />
(parted) mkpart primary 1MiB 3MiB<br />
(parted) set 1 bios_grub on<br />
(parted) mkpart primary ext2 3MiB 200MiB<br />
(parted) set 2 boot on<br />
(parted) mkpart primary ext4 200MiB 100%<br />
<br />
=== Resizing Partitions ===<br />
<br />
{{Warning|Partitions that are being resized must be unmounted and not in use. If it cannot be done (e.g. the partition that mounts to {{ic|/}}), use a live media/rescue system.}}<br />
{{Note|<br />
* You can only move the end of the partition with {{ic|parted}}.<br />
* As of parted v4.2 ''resizepart'' may need the use of [[#Interactive mode]].[https://bugs.launchpad.net/ubuntu/+source/parted/+bug/1270203]<br />
* These instructions apply to partitions that have ext2, ext3 or ext4 filesystems.<br />
}}<br />
<br />
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.<br />
<br />
==== Growing partitions ====<br />
<br />
To grow a partition (in parted interactive mode):<br />
<br />
(parted) resizepart ''number'' ''end''<br />
<br />
Where {{ic|''number''}} is the number of the partition you are growing, and {{ic|''end''}} is the new end of the partition (which needs to be larger than the old end).<br />
<br />
Then, to grow the filesystem on the partition:<br />
<br />
# resize2fs /dev/''sdaX'' ''size''<br />
<br />
Where {{ic|''sdaX''}} stands for the partition you are growing, and {{ic|''size''}} is the new size of the partition.<br />
<br />
==== Shrinking partitions ====<br />
<br />
To shrink the filesystem on the partition:<br />
<br />
# resize2fs /dev/''sdaX'' ''size''<br />
<br />
Where {{ic|''sdaX''}} stands for the partition you are shrinking, and {{ic|''size''}} is the new size of the partition.<br />
<br />
Then shrink the partition (in parted interactive mode):<br />
<br />
(parted) resizepart ''number'' ''end''<br />
<br />
Where {{ic|''number''}} is the number of the partition you are shrinking, and {{ic|''end''}} is the new end of the partition (which needs to be smaller than the old end).<br />
<br />
When done, use the ''resizepart'' command from {{Pkg|util-linux}} to tell the kernel about the new size:<br />
<br />
# resizepart ''device'' ''number'' ''size''<br />
<br />
Where {{ic|''device''}} is the device that holds the partition, {{ic|''number''}} is the number of the partition and {{ic|''size''}} is the new size of the partition.<br />
<br />
== Warnings ==<br />
<br />
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).<br />
<br />
=== Alignment ===<br />
<br />
When creating a partition, ''parted'' might warn about improper partition alignment but does not hint about proper alignment. For example:<br />
<br />
(parted) mkpart primary fat16 0 32M<br />
Warning: The resulting partition is not properly aligned for best performance.<br />
Ignore/Cancel? <br />
<br />
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.<br />
<br />
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:<br />
<br />
(parted) mkpart primary ext4 0% 100%<br />
<br />
== Tips and tricks ==<br />
<br />
=== Dual booting with Windows XP ===<br />
<br />
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:<br />
<br />
HKEY_LOCAL_MACHINE\SYSTEM\MountedDevices<br />
<br />
Reference to this little gem [http://gparted-forum.surf4.info/viewtopic.php?pid=8347#p8347 here].<br />
<br />
=== Fixing messed-up partition order ===<br />
<br />
{{Merge|fdisk|Merge note to [[fdisk]]? Cf. http://serverfault.com/questions/36038/reread-partition-table-without-rebooting}}<br />
<br />
See [[Fdisk#Sort_partitions]].<br />
<br />
{{Note|You must run '''partprobe''' as root or reboot the system in order for the kernel to read the new partition table!}}<br />
<br />
=== Check alignment ===<br />
<br />
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 {{ic|/dev/sda}}:<br />
<br />
# parted /dev/sda<br />
(parted) align-check optimal 1<br />
1 aligned<br />
<br />
== See also ==<br />
<br />
* [https://www.gnu.org/software/parted/manual/ GNU parted - Parted User's Manual]<br />
* [http://rainbow.chard.org/2013/01/30/how-to-align-partitions-for-best-performance-using-parted/ How to align partitions for best performance using parted]<br />
* [http://positon.org/resize-an-ext3-ext4-partition Resize an ext3/ext4 partition]<br />
* [http://gparted-forum.surf4.info/ Official GParted forums]</div>Sloppy joeshttps://wiki.archlinux.org/index.php?title=Parted&diff=472193Parted2017-03-29T21:00:28Z<p>Sloppy joes: formatting</p>
<hr />
<div>[[Category:File systems]]<br />
[[Category:System recovery]]<br />
[[ja:GNU Parted]]<br />
[[zh-hans:GNU Parted]]<br />
{{Related articles start}}<br />
{{Related|fdisk}}<br />
{{Related|Partitioning}}<br />
{{Related articles end}}<br />
<br />
GNU Parted is a program for creating and manipulating partition tables. [[GParted]] is a GUI frontend.<br />
<br />
== Installation ==<br />
<br />
[[Install]] the {{Pkg|parted}} package. For a graphical interface, [[install]] the {{pkg|gparted}} package, the graphical frontend to ''parted''.<br />
<br />
== Usage ==<br />
<br />
Parted has two modes: command line and interactive. Parted should always be started with:<br />
<br />
# parted device<br />
<br />
where {{ic|''device''}} is the hard disk device to edit (for example {{ic|/dev/sda}}). If you omit the {{ic|''device''}} argument, ''parted'' will attempt to guess which device you want.<br />
<br />
=== Command line mode ===<br />
<br />
In command line mode, this is followed by one or more commands. For example:<br />
<br />
# parted /dev/sda mklabel gpt mkpart P1 ext3 1MiB 8MiB <br />
<br />
{{Note|Options (like {{ic|--help}}) can only be specified on the command line.}}<br />
<br />
=== Interactive mode ===<br />
<br />
Interactive mode simplifies the partitioning process and reduces unnecessary repetition by automatically applying all partitioning commands to the specified device. <br />
<br />
In order to start operating on a device, execute:<br />
<br />
# parted /dev/sd''x''<br />
<br />
You will notice that the command-line prompt changes from a hash ({{ic|#}}) to {{ic|(parted)}}: this also means that the new prompt is not a command to be manually entered when running the commands in the examples.<br />
<br />
To see a list of the available commands, enter:<br />
<br />
(parted) help<br />
<br />
When finished, or if wishing to implement a partition table or scheme for another device, exit from parted with:<br />
<br />
(parted) quit<br />
<br />
After exiting, the command-line prompt will change back to {{ic|#}}.<br />
<br />
If you do not give a parameter to a command, Parted will prompt you for it. For example:<br />
<br />
(parted) mklabel<br />
New disk label type? gpt<br />
<br />
== Rounding ==<br />
<br />
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.<br />
<br />
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.<br />
<br />
== Partitioning ==<br />
<br />
=== Create new partition table ===<br />
<br />
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.<br />
<br />
Open each device whose partition table must be (re)created with:<br />
<br />
# parted /dev/sd''x''<br />
<br />
To then create a new MBR/msdos partition table for BIOS systems, use the following command:<br />
<br />
(parted) mklabel msdos<br />
<br />
To create a new GPT partition table for UEFI systems instead, use:<br />
<br />
(parted) mklabel gpt<br />
<br />
=== Partition schemes ===<br />
<br />
{{Merge|partitioning|duplicates much content}}<br />
<br />
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''). The mapping from partitions to directories is the [[partition scheme]], which must comply with the following requirements:<br />
<br />
* At least a partition for the {{ic|/}} (''root'') directory '''must''' be created.<br />
* When using a UEFI motherboard, one [[EFI System Partition]] '''must''' be created<br />
<br />
In the examples below it is assumed that a new and contiguous partitioning scheme is applied to a single device. Some optional partitions will also be created for the {{ic|/boot}} and {{ic|/home}} directories: see also [[Arch filesystem hierarchy]] for an explanation of the purpose of the various directories; if separate partitions for directories like {{ic|/boot}} or {{ic|/home}} are not created, these will simply be contained in the {{ic|/}} partition. Also the creation of an optional partiton for [[swap space]] will be illustrated.<br />
<br />
If not already open in a ''parted'' interactive session, open each device to be partitioned with:<br />
<br />
# parted /dev/sd''x''<br />
<br />
The following command will be used to create partitions:<br />
<br />
(parted) mkpart ''part-type'' ''fs-type'' ''start'' ''end''<br />
<br />
* {{ic|''part-type''}} is one of {{ic|primary}}, {{ic|extended}} or {{ic|logical}}, and is meaningful only for MBR partition tables.<br />
* {{ic|''fs-type''}} is an identifier chosen among those listed by entering {{ic|help mkpart}} as the closest match to the file system that you will use. The ''mkpart'' command does not actually create the file system: the {{ic|''fs-type''}} parameter will simply be used by ''parted'' to set a 1-byte code that is used by boot loaders to "preview" what kind of data is found in the partition, and act accordingly if necessary. See also [[Wikipedia:Disk partitioning#PC partition types]].<br />
: {{Tip|Most [[Wikipedia:File_system#Linux|Linux native file systems]] map to the same partition code ([[Wikipedia:Partition type#PID_83h|0x83]]), so it is perfectly safe to e.g. use {{ic|ext2}} for an ''ext4''-formatted partition.}}<br />
* {{ic|''start''}} is the beginning of the partition from the start of the device. It consists of a number followed by a [http://www.gnu.org/software/parted/manual/parted.html#unit unit], for example {{ic|1M}} means start at 1MiB.<br />
* {{ic|''end''}} is the end of the partition from the start of the device (''not'' from the {{ic|''start''}} value). It has the same syntax as {{ic|''start''}}, for example {{ic|100%}} means end at the end of the device (use all the remaining space).<br />
<br />
{{Warning|It is important that the partitions do not overlap each other: if you do not want to leave unused space in the device, make sure that each partition starts where the previous one ends.}}<br />
<br />
{{Note|''parted'' may issue a warning like:<br />
<br />
Warning: The resulting partition is not properly aligned for best performance.<br />
Ignore/Cancel?<br />
<br />
In this case, read [[Partitioning#Partition alignment]] and follow [[#Alignment]] to fix it.}}<br />
<br />
The following command will be used to flag the partition that contains the {{ic|/boot}} directory as bootable:<br />
<br />
(parted) set ''partition'' boot on<br />
<br />
* {{ic|''partition''}} is the number of the partition to be flagged (see the output of the {{ic|print}} command).<br />
<br />
==== UEFI/GPT examples ====<br />
<br />
In every instance, a special bootable [[EFI System Partition]] is required.<br />
<br />
If creating a new EFI System Partition, use the following commands (the recommended size is 512MiB):<br />
<br />
(parted) mkpart ESP fat32 1MiB 513MiB<br />
(parted) set 1 boot on<br />
<br />
The remaining partition scheme is entirely up to you. For one other partition using 100% of remaining space:<br />
<br />
(parted) mkpart primary ext4 513MiB 100%<br />
<br />
For separate {{ic|/}} (20GiB) and {{ic|/home}} (all remaining space) partitions:<br />
<br />
(parted) mkpart primary ext4 513MiB 20.5GiB<br />
(parted) mkpart primary ext4 20.5GiB 100%<br />
<br />
And for separate {{ic|/}} (20GiB), swap (4GiB), and {{ic|/home}} (all remaining space) partitions:<br />
<br />
(parted) mkpart primary ext4 513MiB 20.5GiB<br />
(parted) mkpart primary linux-swap 20.5GiB 24.5GiB<br />
(parted) mkpart primary ext4 24.5GiB 100%<br />
<br />
==== BIOS/MBR examples ====<br />
<br />
For a minimum single primary partition using all available disk space, the following command would be used:<br />
<br />
(parted) mkpart primary ext4 1MiB 100%<br />
(parted) set 1 boot on<br />
<br />
In the following instance, a 20GiB {{ic|/}} partition will be created, followed by a {{ic|/home}} partition using all the remaining space:<br />
<br />
(parted) mkpart primary ext4 1MiB 20GiB<br />
(parted) set 1 boot on<br />
(parted) mkpart primary ext4 20GiB 100%<br />
<br />
In the final example below, separate {{ic|/boot}} (100MiB), {{ic|/}} (20GiB), swap (4GiB), and {{ic|/home}} (all remaining space) partitions will be created:<br />
<br />
(parted) mkpart primary ext3 1MiB 100MiB<br />
(parted) set 1 boot on<br />
(parted) mkpart primary ext3 100MiB 20GiB<br />
(parted) mkpart primary linux-swap 20GiB 24GiB<br />
(parted) mkpart primary ext3 24GiB 100%<br />
<br />
==== BIOS/GPT example ====<br />
<br />
Unlike in the BIOS/MBR case, a special 2 MiB partition [http://askubuntu.com/questions/500359/efi-boot-partition-and-biosgrub-partition is required for the extra grub code.] The third partition can be further divided to include a swap partition or a separate partition for {{ic|/home}}.<br />
<br />
(parted) mkpart primary 1MiB 3MiB<br />
(parted) set 1 bios_grub on<br />
(parted) mkpart primary ext2 3MiB 200MiB<br />
(parted) set 2 boot on<br />
(parted) mkpart primary ext4 200GiB 100%<br />
<br />
=== Resizing Partitions ===<br />
<br />
{{Warning|Partitions that are being resized must be unmounted and not in use. If it cannot be done (e.g. the partition that mounts to {{ic|/}}), use a live media/rescue system.}}<br />
{{Note|<br />
* You can only move the end of the partition with {{ic|parted}}.<br />
* As of parted v4.2 ''resizepart'' may need the use of [[#Interactive mode]].[https://bugs.launchpad.net/ubuntu/+source/parted/+bug/1270203]<br />
* These instructions apply to partitions that have ext2, ext3 or ext4 filesystems.<br />
}}<br />
<br />
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.<br />
<br />
==== Growing partitions ====<br />
<br />
To grow a partition (in parted interactive mode):<br />
<br />
(parted) resizepart ''number'' ''end''<br />
<br />
Where {{ic|''number''}} is the number of the partition you are growing, and {{ic|''end''}} is the new end of the partition (which needs to be larger than the old end).<br />
<br />
Then, to grow the filesystem on the partition:<br />
<br />
# resize2fs /dev/''sdaX'' ''size''<br />
<br />
Where {{ic|''sdaX''}} stands for the partition you are growing, and {{ic|''size''}} is the new size of the partition.<br />
<br />
==== Shrinking partitions ====<br />
<br />
To shrink the filesystem on the partition:<br />
<br />
# resize2fs /dev/''sdaX'' ''size''<br />
<br />
Where {{ic|''sdaX''}} stands for the partition you are shrinking, and {{ic|''size''}} is the new size of the partition.<br />
<br />
Then shrink the partition (in parted interactive mode):<br />
<br />
(parted) resizepart ''number'' ''end''<br />
<br />
Where {{ic|''number''}} is the number of the partition you are shrinking, and {{ic|''end''}} is the new end of the partition (which needs to be smaller than the old end).<br />
<br />
When done, use the ''resizepart'' command from {{Pkg|util-linux}} to tell the kernel about the new size:<br />
<br />
# resizepart ''device'' ''number'' ''size''<br />
<br />
Where {{ic|''device''}} is the device that holds the partition, {{ic|''number''}} is the number of the partition and {{ic|''size''}} is the new size of the partition.<br />
<br />
== Warnings ==<br />
<br />
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).<br />
<br />
=== Alignment ===<br />
<br />
When creating a partition, ''parted'' might warn about improper partition alignment but does not hint about proper alignment. For example:<br />
<br />
(parted) mkpart primary fat16 0 32M<br />
Warning: The resulting partition is not properly aligned for best performance.<br />
Ignore/Cancel? <br />
<br />
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.<br />
<br />
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:<br />
<br />
(parted) mkpart primary ext4 0% 100%<br />
<br />
== Tips and tricks ==<br />
<br />
=== Dual booting with Windows XP ===<br />
<br />
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:<br />
<br />
HKEY_LOCAL_MACHINE\SYSTEM\MountedDevices<br />
<br />
Reference to this little gem [http://gparted-forum.surf4.info/viewtopic.php?pid=8347#p8347 here].<br />
<br />
=== Fixing messed-up partition order ===<br />
<br />
{{Merge|fdisk|Merge note to [[fdisk]]? Cf. http://serverfault.com/questions/36038/reread-partition-table-without-rebooting}}<br />
<br />
See [[Fdisk#Sort_partitions]].<br />
<br />
{{Note|You must run '''partprobe''' as root or reboot the system in order for the kernel to read the new partition table!}}<br />
<br />
=== Check alignment ===<br />
<br />
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 {{ic|/dev/sda}}:<br />
<br />
# parted /dev/sda<br />
(parted) align-check optimal 1<br />
1 aligned<br />
<br />
== See also ==<br />
<br />
* [https://www.gnu.org/software/parted/manual/ GNU parted - Parted User's Manual]<br />
* [http://rainbow.chard.org/2013/01/30/how-to-align-partitions-for-best-performance-using-parted/ How to align partitions for best performance using parted]<br />
* [http://positon.org/resize-an-ext3-ext4-partition Resize an ext3/ext4 partition]<br />
* [http://gparted-forum.surf4.info/ Official GParted forums]</div>Sloppy joeshttps://wiki.archlinux.org/index.php?title=Parted&diff=472184Parted2017-03-29T20:36:55Z<p>Sloppy joes: Fixed typo</p>
<hr />
<div>[[Category:File systems]]<br />
[[Category:System recovery]]<br />
[[ja:GNU Parted]]<br />
[[zh-hans:GNU Parted]]<br />
{{Related articles start}}<br />
{{Related|fdisk}}<br />
{{Related|Partitioning}}<br />
{{Related articles end}}<br />
<br />
GNU Parted is a program for creating and manipulating partition tables. [[GParted]] is a GUI frontend.<br />
<br />
== Installation ==<br />
<br />
[[Install]] the {{Pkg|parted}} package. For a graphical interface, [[install]] the {{pkg|gparted}} package, the graphical frontend to ''parted''.<br />
<br />
== Usage ==<br />
<br />
Parted has two modes: command line and interactive. Parted should always be started with:<br />
<br />
# parted device<br />
<br />
where {{ic|''device''}} is the hard disk device to edit (for example {{ic|/dev/sda}}). If you omit the {{ic|''device''}} argument, ''parted'' will attempt to guess which device you want.<br />
<br />
=== Command line mode ===<br />
<br />
In command line mode, this is followed by one or more commands. For example:<br />
<br />
# parted /dev/sda mklabel gpt mkpart P1 ext3 1MiB 8MiB <br />
<br />
{{Note|Options (like {{ic|--help}}) can only be specified on the command line.}}<br />
<br />
=== Interactive mode ===<br />
<br />
Interactive mode simplifies the partitioning process and reduces unnecessary repetition by automatically applying all partitioning commands to the specified device. <br />
<br />
In order to start operating on a device, execute:<br />
<br />
# parted /dev/sd''x''<br />
<br />
You will notice that the command-line prompt changes from a hash ({{ic|#}}) to {{ic|(parted)}}: this also means that the new prompt is not a command to be manually entered when running the commands in the examples.<br />
<br />
To see a list of the available commands, enter:<br />
<br />
(parted) help<br />
<br />
When finished, or if wishing to implement a partition table or scheme for another device, exit from parted with:<br />
<br />
(parted) quit<br />
<br />
After exiting, the command-line prompt will change back to {{ic|#}}.<br />
<br />
If you do not give a parameter to a command, Parted will prompt you for it. For example:<br />
<br />
(parted) mklabel<br />
New disk label type? gpt<br />
<br />
== Rounding ==<br />
<br />
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.<br />
<br />
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.<br />
<br />
== Partitioning ==<br />
<br />
=== Create new partition table ===<br />
<br />
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.<br />
<br />
Open each device whose partition table must be (re)created with:<br />
<br />
# parted /dev/sd''x''<br />
<br />
To then create a new MBR/msdos partition table for BIOS systems, use the following command:<br />
<br />
(parted) mklabel msdos<br />
<br />
To create a new GPT partition table for UEFI systems instead, use:<br />
<br />
(parted) mklabel gpt<br />
<br />
=== Partition schemes ===<br />
<br />
{{Merge|partitioning|duplicates much content}}<br />
<br />
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''). The mapping from partitions to directories is the [[partition scheme]], which must comply with the following requirements:<br />
<br />
* At least a partition for the {{ic|/}} (''root'') directory '''must''' be created.<br />
* When using a UEFI motherboard, one [[EFI System Partition]] '''must''' be created<br />
<br />
In the examples below it is assumed that a new and contiguous partitioning scheme is applied to a single device. Some optional partitions will also be created for the {{ic|/boot}} and {{ic|/home}} directories: see also [[Arch filesystem hierarchy]] for an explanation of the purpose of the various directories; if separate partitions for directories like {{ic|/boot}} or {{ic|/home}} are not created, these will simply be contained in the {{ic|/}} partition. Also the creation of an optional partiton for [[swap space]] will be illustrated.<br />
<br />
If not already open in a ''parted'' interactive session, open each device to be partitioned with:<br />
<br />
# parted /dev/sd''x''<br />
<br />
The following command will be used to create partitions:<br />
<br />
(parted) mkpart ''part-type'' ''fs-type'' ''start'' ''end''<br />
<br />
* {{ic|''part-type''}} is one of {{ic|primary}}, {{ic|extended}} or {{ic|logical}}, and is meaningful only for MBR partition tables.<br />
* {{ic|''fs-type''}} is an identifier chosen among those listed by entering {{ic|help mkpart}} as the closest match to the file system that you will use. The ''mkpart'' command does not actually create the file system: the {{ic|''fs-type''}} parameter will simply be used by ''parted'' to set a 1-byte code that is used by boot loaders to "preview" what kind of data is found in the partition, and act accordingly if necessary. See also [[Wikipedia:Disk partitioning#PC partition types]].<br />
: {{Tip|Most [[Wikipedia:File_system#Linux|Linux native file systems]] map to the same partition code ([[Wikipedia:Partition type#PID_83h|0x83]]), so it is perfectly safe to e.g. use {{ic|ext2}} for an ''ext4''-formatted partition.}}<br />
* {{ic|''start''}} is the beginning of the partition from the start of the device. It consists of a number followed by a [http://www.gnu.org/software/parted/manual/parted.html#unit unit], for example {{ic|1M}} means start at 1MiB.<br />
* {{ic|''end''}} is the end of the partition from the start of the device (''not'' from the {{ic|''start''}} value). It has the same syntax as {{ic|''start''}}, for example {{ic|100%}} means end at the end of the device (use all the remaining space).<br />
<br />
{{Warning|It is important that the partitions do not overlap each other: if you do not want to leave unused space in the device, make sure that each partition starts where the previous one ends.}}<br />
<br />
{{Note|''parted'' may issue a warning like:<br />
<br />
Warning: The resulting partition is not properly aligned for best performance.<br />
Ignore/Cancel?<br />
<br />
In this case, read [[Partitioning#Partition alignment]] and follow [[#Alignment]] to fix it.}}<br />
<br />
The following command will be used to flag the partition that contains the {{ic|/boot}} directory as bootable:<br />
<br />
(parted) set ''partition'' boot on<br />
<br />
* {{ic|''partition''}} is the number of the partition to be flagged (see the output of the {{ic|print}} command).<br />
<br />
==== UEFI/GPT examples ====<br />
<br />
In every instance, a special bootable [[EFI System Partition]] is required.<br />
<br />
If creating a new EFI System Partition, use the following commands (the recommended size is 512MiB):<br />
<br />
(parted) mkpart ESP fat32 1MiB 513MiB<br />
(parted) set 1 boot on<br />
<br />
The remaining partition scheme is entirely up to you. For one other partition using 100% of remaining space:<br />
<br />
(parted) mkpart primary ext4 513MiB 100%<br />
<br />
For separate {{ic|/}} (20GiB) and {{ic|/home}} (all remaining space) partitions:<br />
<br />
(parted) mkpart primary ext4 513MiB 20.5GiB<br />
(parted) mkpart primary ext4 20.5GiB 100%<br />
<br />
And for separate {{ic|/}} (20GiB), swap (4GiB), and {{ic|/home}} (all remaining space) partitions:<br />
<br />
(parted) mkpart primary ext4 513MiB 20.5GiB<br />
(parted) mkpart primary linux-swap 20.5GiB 24.5GiB<br />
(parted) mkpart primary ext4 24.5GiB 100%<br />
<br />
==== BIOS/MBR examples ====<br />
<br />
For a minimum single primary partition using all available disk space, the following command would be used:<br />
<br />
(parted) mkpart primary ext4 1MiB 100%<br />
(parted) set 1 boot on<br />
<br />
In the following instance, a 20GiB {{ic|/}} partition will be created, followed by a {{ic|/home}} partition using all the remaining space:<br />
<br />
(parted) mkpart primary ext4 1MiB 20GiB<br />
(parted) set 1 boot on<br />
(parted) mkpart primary ext4 20GiB 100%<br />
<br />
In the final example below, separate {{ic|/boot}} (100MiB), {{ic|/}} (20GiB), swap (4GiB), and {{ic|/home}} (all remaining space) partitions will be created:<br />
<br />
(parted) mkpart primary ext3 1MiB 100MiB<br />
(parted) set 1 boot on<br />
(parted) mkpart primary ext3 100MiB 20GiB<br />
(parted) mkpart primary linux-swap 20GiB 24GiB<br />
(parted) mkpart primary ext3 24GiB 100%<br />
<br />
==== BIOS/GPT example ====<br />
<br />
Unlike in the BIOS/MBR case, a special 2 MiB partition [http://askubuntu.com/questions/500359/efi-boot-partition-and-biosgrub-partition is required for the extra grub code.] The third partition can be further divided to include a swap partition or a separate partition for /home.<br />
<br />
(parted) mkpart primary 1MiB 3MiB<br />
(parted) set 1 bios_grub on<br />
(parted) mkpart primary ext2 3MiB 200MiB<br />
(parted) set 2 boot on<br />
(parted) mkpart primary ext4 200GiB 100%<br />
<br />
=== Resizing Partitions ===<br />
<br />
{{Warning|Partitions that are being resized must be unmounted and not in use. If it cannot be done (e.g. the partition that mounts to {{ic|/}}), use a live media/rescue system.}}<br />
{{Note|<br />
* You can only move the end of the partition with {{ic|parted}}.<br />
* As of parted v4.2 ''resizepart'' may need the use of [[#Interactive mode]].[https://bugs.launchpad.net/ubuntu/+source/parted/+bug/1270203]<br />
* These instructions apply to partitions that have ext2, ext3 or ext4 filesystems.<br />
}}<br />
<br />
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.<br />
<br />
==== Growing partitions ====<br />
<br />
To grow a partition (in parted interactive mode):<br />
<br />
(parted) resizepart ''number'' ''end''<br />
<br />
Where {{ic|''number''}} is the number of the partition you are growing, and {{ic|''end''}} is the new end of the partition (which needs to be larger than the old end).<br />
<br />
Then, to grow the filesystem on the partition:<br />
<br />
# resize2fs /dev/''sdaX'' ''size''<br />
<br />
Where {{ic|''sdaX''}} stands for the partition you are growing, and {{ic|''size''}} is the new size of the partition.<br />
<br />
==== Shrinking partitions ====<br />
<br />
To shrink the filesystem on the partition:<br />
<br />
# resize2fs /dev/''sdaX'' ''size''<br />
<br />
Where {{ic|''sdaX''}} stands for the partition you are shrinking, and {{ic|''size''}} is the new size of the partition.<br />
<br />
Then shrink the partition (in parted interactive mode):<br />
<br />
(parted) resizepart ''number'' ''end''<br />
<br />
Where {{ic|''number''}} is the number of the partition you are shrinking, and {{ic|''end''}} is the new end of the partition (which needs to be smaller than the old end).<br />
<br />
When done, use the ''resizepart'' command from {{Pkg|util-linux}} to tell the kernel about the new size:<br />
<br />
# resizepart ''device'' ''number'' ''size''<br />
<br />
Where {{ic|''device''}} is the device that holds the partition, {{ic|''number''}} is the number of the partition and {{ic|''size''}} is the new size of the partition.<br />
<br />
== Warnings ==<br />
<br />
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).<br />
<br />
=== Alignment ===<br />
<br />
When creating a partition, ''parted'' might warn about improper partition alignment but does not hint about proper alignment. For example:<br />
<br />
(parted) mkpart primary fat16 0 32M<br />
Warning: The resulting partition is not properly aligned for best performance.<br />
Ignore/Cancel? <br />
<br />
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.<br />
<br />
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:<br />
<br />
(parted) mkpart primary ext4 0% 100%<br />
<br />
== Tips and tricks ==<br />
<br />
=== Dual booting with Windows XP ===<br />
<br />
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:<br />
<br />
HKEY_LOCAL_MACHINE\SYSTEM\MountedDevices<br />
<br />
Reference to this little gem [http://gparted-forum.surf4.info/viewtopic.php?pid=8347#p8347 here].<br />
<br />
=== Fixing messed-up partition order ===<br />
<br />
{{Merge|fdisk|Merge note to [[fdisk]]? Cf. http://serverfault.com/questions/36038/reread-partition-table-without-rebooting}}<br />
<br />
See [[Fdisk#Sort_partitions]].<br />
<br />
{{Note|You must run '''partprobe''' as root or reboot the system in order for the kernel to read the new partition table!}}<br />
<br />
=== Check alignment ===<br />
<br />
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 {{ic|/dev/sda}}:<br />
<br />
# parted /dev/sda<br />
(parted) align-check optimal 1<br />
1 aligned<br />
<br />
== See also ==<br />
<br />
* [https://www.gnu.org/software/parted/manual/ GNU parted - Parted User's Manual]<br />
* [http://rainbow.chard.org/2013/01/30/how-to-align-partitions-for-best-performance-using-parted/ How to align partitions for best performance using parted]<br />
* [http://positon.org/resize-an-ext3-ext4-partition Resize an ext3/ext4 partition]<br />
* [http://gparted-forum.surf4.info/ Official GParted forums]</div>Sloppy joeshttps://wiki.archlinux.org/index.php?title=Parted&diff=472183Parted2017-03-29T20:36:13Z<p>Sloppy joes: Include an example on BIOS/GPT</p>
<hr />
<div>[[Category:File systems]]<br />
[[Category:System recovery]]<br />
[[ja:GNU Parted]]<br />
[[zh-hans:GNU Parted]]<br />
{{Related articles start}}<br />
{{Related|fdisk}}<br />
{{Related|Partitioning}}<br />
{{Related articles end}}<br />
<br />
GNU Parted is a program for creating and manipulating partition tables. [[GParted]] is a GUI frontend.<br />
<br />
== Installation ==<br />
<br />
[[Install]] the {{Pkg|parted}} package. For a graphical interface, [[install]] the {{pkg|gparted}} package, the graphical frontend to ''parted''.<br />
<br />
== Usage ==<br />
<br />
Parted has two modes: command line and interactive. Parted should always be started with:<br />
<br />
# parted device<br />
<br />
where {{ic|''device''}} is the hard disk device to edit (for example {{ic|/dev/sda}}). If you omit the {{ic|''device''}} argument, ''parted'' will attempt to guess which device you want.<br />
<br />
=== Command line mode ===<br />
<br />
In command line mode, this is followed by one or more commands. For example:<br />
<br />
# parted /dev/sda mklabel gpt mkpart P1 ext3 1MiB 8MiB <br />
<br />
{{Note|Options (like {{ic|--help}}) can only be specified on the command line.}}<br />
<br />
=== Interactive mode ===<br />
<br />
Interactive mode simplifies the partitioning process and reduces unnecessary repetition by automatically applying all partitioning commands to the specified device. <br />
<br />
In order to start operating on a device, execute:<br />
<br />
# parted /dev/sd''x''<br />
<br />
You will notice that the command-line prompt changes from a hash ({{ic|#}}) to {{ic|(parted)}}: this also means that the new prompt is not a command to be manually entered when running the commands in the examples.<br />
<br />
To see a list of the available commands, enter:<br />
<br />
(parted) help<br />
<br />
When finished, or if wishing to implement a partition table or scheme for another device, exit from parted with:<br />
<br />
(parted) quit<br />
<br />
After exiting, the command-line prompt will change back to {{ic|#}}.<br />
<br />
If you do not give a parameter to a command, Parted will prompt you for it. For example:<br />
<br />
(parted) mklabel<br />
New disk label type? gpt<br />
<br />
== Rounding ==<br />
<br />
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.<br />
<br />
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.<br />
<br />
== Partitioning ==<br />
<br />
=== Create new partition table ===<br />
<br />
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.<br />
<br />
Open each device whose partition table must be (re)created with:<br />
<br />
# parted /dev/sd''x''<br />
<br />
To then create a new MBR/msdos partition table for BIOS systems, use the following command:<br />
<br />
(parted) mklabel msdos<br />
<br />
To create a new GPT partition table for UEFI systems instead, use:<br />
<br />
(parted) mklabel gpt<br />
<br />
=== Partition schemes ===<br />
<br />
{{Merge|partitioning|duplicates much content}}<br />
<br />
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''). The mapping from partitions to directories is the [[partition scheme]], which must comply with the following requirements:<br />
<br />
* At least a partition for the {{ic|/}} (''root'') directory '''must''' be created.<br />
* When using a UEFI motherboard, one [[EFI System Partition]] '''must''' be created<br />
<br />
In the examples below it is assumed that a new and contiguous partitioning scheme is applied to a single device. Some optional partitions will also be created for the {{ic|/boot}} and {{ic|/home}} directories: see also [[Arch filesystem hierarchy]] for an explanation of the purpose of the various directories; if separate partitions for directories like {{ic|/boot}} or {{ic|/home}} are not created, these will simply be contained in the {{ic|/}} partition. Also the creation of an optional partiton for [[swap space]] will be illustrated.<br />
<br />
If not already open in a ''parted'' interactive session, open each device to be partitioned with:<br />
<br />
# parted /dev/sd''x''<br />
<br />
The following command will be used to create partitions:<br />
<br />
(parted) mkpart ''part-type'' ''fs-type'' ''start'' ''end''<br />
<br />
* {{ic|''part-type''}} is one of {{ic|primary}}, {{ic|extended}} or {{ic|logical}}, and is meaningful only for MBR partition tables.<br />
* {{ic|''fs-type''}} is an identifier chosen among those listed by entering {{ic|help mkpart}} as the closest match to the file system that you will use. The ''mkpart'' command does not actually create the file system: the {{ic|''fs-type''}} parameter will simply be used by ''parted'' to set a 1-byte code that is used by boot loaders to "preview" what kind of data is found in the partition, and act accordingly if necessary. See also [[Wikipedia:Disk partitioning#PC partition types]].<br />
: {{Tip|Most [[Wikipedia:File_system#Linux|Linux native file systems]] map to the same partition code ([[Wikipedia:Partition type#PID_83h|0x83]]), so it is perfectly safe to e.g. use {{ic|ext2}} for an ''ext4''-formatted partition.}}<br />
* {{ic|''start''}} is the beginning of the partition from the start of the device. It consists of a number followed by a [http://www.gnu.org/software/parted/manual/parted.html#unit unit], for example {{ic|1M}} means start at 1MiB.<br />
* {{ic|''end''}} is the end of the partition from the start of the device (''not'' from the {{ic|''start''}} value). It has the same syntax as {{ic|''start''}}, for example {{ic|100%}} means end at the end of the device (use all the remaining space).<br />
<br />
{{Warning|It is important that the partitions do not overlap each other: if you do not want to leave unused space in the device, make sure that each partition starts where the previous one ends.}}<br />
<br />
{{Note|''parted'' may issue a warning like:<br />
<br />
Warning: The resulting partition is not properly aligned for best performance.<br />
Ignore/Cancel?<br />
<br />
In this case, read [[Partitioning#Partition alignment]] and follow [[#Alignment]] to fix it.}}<br />
<br />
The following command will be used to flag the partition that contains the {{ic|/boot}} directory as bootable:<br />
<br />
(parted) set ''partition'' boot on<br />
<br />
* {{ic|''partition''}} is the number of the partition to be flagged (see the output of the {{ic|print}} command).<br />
<br />
==== UEFI/GPT examples ====<br />
<br />
In every instance, a special bootable [[EFI System Partition]] is required.<br />
<br />
If creating a new EFI System Partition, use the following commands (the recommended size is 512MiB):<br />
<br />
(parted) mkpart ESP fat32 1MiB 513MiB<br />
(parted) set 1 boot on<br />
<br />
The remaining partition scheme is entirely up to you. For one other partition using 100% of remaining space:<br />
<br />
(parted) mkpart primary ext4 513MiB 100%<br />
<br />
For separate {{ic|/}} (20GiB) and {{ic|/home}} (all remaining space) partitions:<br />
<br />
(parted) mkpart primary ext4 513MiB 20.5GiB<br />
(parted) mkpart primary ext4 20.5GiB 100%<br />
<br />
And for separate {{ic|/}} (20GiB), swap (4GiB), and {{ic|/home}} (all remaining space) partitions:<br />
<br />
(parted) mkpart primary ext4 513MiB 20.5GiB<br />
(parted) mkpart primary linux-swap 20.5GiB 24.5GiB<br />
(parted) mkpart primary ext4 24.5GiB 100%<br />
<br />
==== BIOS/MBR examples ====<br />
<br />
For a minimum single primary partition using all available disk space, the following command would be used:<br />
<br />
(parted) mkpart primary ext4 1MiB 100%<br />
(parted) set 1 boot on<br />
<br />
In the following instance, a 20GiB {{ic|/}} partition will be created, followed by a {{ic|/home}} partition using all the remaining space:<br />
<br />
(parted) mkpart primary ext4 1MiB 20GiB<br />
(parted) set 1 boot on<br />
(parted) mkpart primary ext4 20GiB 100%<br />
<br />
In the final example below, separate {{ic|/boot}} (100MiB), {{ic|/}} (20GiB), swap (4GiB), and {{ic|/home}} (all remaining space) partitions will be created:<br />
<br />
(parted) mkpart primary ext3 1MiB 100MiB<br />
(parted) set 1 boot on<br />
(parted) mkpart primary ext3 100MiB 20GiB<br />
(parted) mkpart primary linux-swap 20GiB 24GiB<br />
(parted) mkpart primary ext3 24GiB 100%<br />
<br />
==== BIOS/GPT example ====<br />
<br />
Unlike in the BIOS/MBR case, a special 2 MiB partition [http://askubuntu.com/questions/500359/efi-boot-partition-and-biosgrub-partition is required for the extra grub code.] The third partition can be further divided to include a swap partition or a separate partition for /home.<br />
<br />
(parted) mkpart primary 1MiB 3MiB<br />
(parted) set 1 bios_grub on<br />
(parted) mkpart primary ext2 100MiB 200MiB<br />
(parted) set 2 boot on<br />
(parted) mkpart primary ext4 200GiB 100%<br />
<br />
=== Resizing Partitions ===<br />
<br />
{{Warning|Partitions that are being resized must be unmounted and not in use. If it cannot be done (e.g. the partition that mounts to {{ic|/}}), use a live media/rescue system.}}<br />
{{Note|<br />
* You can only move the end of the partition with {{ic|parted}}.<br />
* As of parted v4.2 ''resizepart'' may need the use of [[#Interactive mode]].[https://bugs.launchpad.net/ubuntu/+source/parted/+bug/1270203]<br />
* These instructions apply to partitions that have ext2, ext3 or ext4 filesystems.<br />
}}<br />
<br />
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.<br />
<br />
==== Growing partitions ====<br />
<br />
To grow a partition (in parted interactive mode):<br />
<br />
(parted) resizepart ''number'' ''end''<br />
<br />
Where {{ic|''number''}} is the number of the partition you are growing, and {{ic|''end''}} is the new end of the partition (which needs to be larger than the old end).<br />
<br />
Then, to grow the filesystem on the partition:<br />
<br />
# resize2fs /dev/''sdaX'' ''size''<br />
<br />
Where {{ic|''sdaX''}} stands for the partition you are growing, and {{ic|''size''}} is the new size of the partition.<br />
<br />
==== Shrinking partitions ====<br />
<br />
To shrink the filesystem on the partition:<br />
<br />
# resize2fs /dev/''sdaX'' ''size''<br />
<br />
Where {{ic|''sdaX''}} stands for the partition you are shrinking, and {{ic|''size''}} is the new size of the partition.<br />
<br />
Then shrink the partition (in parted interactive mode):<br />
<br />
(parted) resizepart ''number'' ''end''<br />
<br />
Where {{ic|''number''}} is the number of the partition you are shrinking, and {{ic|''end''}} is the new end of the partition (which needs to be smaller than the old end).<br />
<br />
When done, use the ''resizepart'' command from {{Pkg|util-linux}} to tell the kernel about the new size:<br />
<br />
# resizepart ''device'' ''number'' ''size''<br />
<br />
Where {{ic|''device''}} is the device that holds the partition, {{ic|''number''}} is the number of the partition and {{ic|''size''}} is the new size of the partition.<br />
<br />
== Warnings ==<br />
<br />
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).<br />
<br />
=== Alignment ===<br />
<br />
When creating a partition, ''parted'' might warn about improper partition alignment but does not hint about proper alignment. For example:<br />
<br />
(parted) mkpart primary fat16 0 32M<br />
Warning: The resulting partition is not properly aligned for best performance.<br />
Ignore/Cancel? <br />
<br />
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.<br />
<br />
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:<br />
<br />
(parted) mkpart primary ext4 0% 100%<br />
<br />
== Tips and tricks ==<br />
<br />
=== Dual booting with Windows XP ===<br />
<br />
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:<br />
<br />
HKEY_LOCAL_MACHINE\SYSTEM\MountedDevices<br />
<br />
Reference to this little gem [http://gparted-forum.surf4.info/viewtopic.php?pid=8347#p8347 here].<br />
<br />
=== Fixing messed-up partition order ===<br />
<br />
{{Merge|fdisk|Merge note to [[fdisk]]? Cf. http://serverfault.com/questions/36038/reread-partition-table-without-rebooting}}<br />
<br />
See [[Fdisk#Sort_partitions]].<br />
<br />
{{Note|You must run '''partprobe''' as root or reboot the system in order for the kernel to read the new partition table!}}<br />
<br />
=== Check alignment ===<br />
<br />
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 {{ic|/dev/sda}}:<br />
<br />
# parted /dev/sda<br />
(parted) align-check optimal 1<br />
1 aligned<br />
<br />
== See also ==<br />
<br />
* [https://www.gnu.org/software/parted/manual/ GNU parted - Parted User's Manual]<br />
* [http://rainbow.chard.org/2013/01/30/how-to-align-partitions-for-best-performance-using-parted/ How to align partitions for best performance using parted]<br />
* [http://positon.org/resize-an-ext3-ext4-partition Resize an ext3/ext4 partition]<br />
* [http://gparted-forum.surf4.info/ Official GParted forums]</div>Sloppy joeshttps://wiki.archlinux.org/index.php?title=NVIDIA_Optimus&diff=465470NVIDIA Optimus2017-01-16T04:07:18Z<p>Sloppy joes: Vsync has been fixed, updated that section</p>
<hr />
<div>[[Category:Graphics]]<br />
[[ja:NVIDIA Optimus]]<br />
[[ru:NVIDIA Optimus]]<br />
[[zh-hans:NVIDIA Optimus]]<br />
{{Related articles start}}<br />
{{Related|Bumblebee}}<br />
{{Related|Nouveau}}<br />
{{Related|NVIDIA}}<br />
{{Related articles end}}<br />
<br />
NVIDIA Optimus is a technology that allows an Intel integrated GPU and discrete NVIDIA GPU to be built into and accessed by a laptop. Getting Optimus graphics to work on Arch Linux requires a few somewhat complicated steps, explained below. There are several methods available:<br />
<br />
* disabling one of the devices in BIOS, which may result in improved battery life if the NVIDIA device is disabled, but may not be available with all BIOSes and does not allow GPU switching<br />
<br />
* using the official Optimus support included with the proprietary NVIDIA driver, which offers the best NVIDIA performance but does not allow GPU switching and can be more buggy than the open-source driver<br />
<br />
* using the PRIME functionality of the open-source nouveau driver, which allows GPU switching but offers poor performance compared to the proprietary NVIDIA driver and does not currently implement any powersaving<br />
<br />
* using the third-party Bumblebee program to implement Optimus-like functionality, which offers GPU switching and powersaving but requires extra configuration<br />
<br />
These options are explained in detail below.<br />
<br />
== Disabling switchable graphics ==<br />
<br />
If you only care to use a certain GPU without switching, check the options in your system's BIOS. There should be an option to disable one of the cards. Some laptops only allow disabling of the discrete card, or vice-versa, but it is worth checking if you only plan to use one of the cards. If you want to use both cards, or cannot disable the card you do not want, see the options below.<br />
<br />
== Using nvidia ==<br />
<br />
The [[NVIDIA|proprietary NVIDIA driver]] does not support dynamic switching like the nouveau driver (meaning it can only use the NVIDIA device). It also has notable screen-tearing issues that NVIDIA recognizes but has not fixed. However, it does allow use of the discrete GPU and has (as of October 2013) a marked edge in performance over the nouveau driver.<br />
<br />
First, install {{Pkg|nvidia}}, {{Pkg|nvidia-libgl}} and {{Pkg|xorg-xrandr}} from the official repositories.<br />
<br />
Then, configure {{ic|xorg.conf}}. You will need to know the PCI address of the NVIDIA card, which you can find by issuing<br />
<br />
$ lspci | grep -E "VGA|3D"<br />
<br />
The PCI address is the first 7 characters of the line that mentions NVIDIA. It will look something like {{ic|01:00.0}}. In the {{ic|xorg.conf}}, you will need to format it as {{ic|#:#:#}}; e.g. {{ic|01:00.0}} would be formatted as {{ic|1:0:0}}.<br />
<br />
{{Note|Since Xorg-server 1.17-1 {{Bug|43830}} related to the {{ic|modesetting}} module persists for Optimus configurations. A work-around for some systems is to set the {{ic|Option "AccelMethod"}} to {{ic|"none"}}, as in the configuration below. Other systems require it set to {{ic|"sna"}}, see [[#Alternative configuration]].}}<br />
{{Note|On some setups this setup breaks automatic detection of the values of the display by the nvidia driver through the EDID file. As a work-around see [[#Resolution, screen scan wrong. EDID errors in Xorg.log]]. }}<br />
If X.Org X server version 1.17.2 or higher is installed ([http://us.download.nvidia.com/XFree86/Linux-x86/358.16/README/randr14.html])<br />
{{hc|/etc/X11/xorg.conf|<br />
Section "Module"<br />
Load "modesetting"<br />
EndSection<br />
<br />
Section "Device"<br />
Identifier "nvidia"<br />
Driver "nvidia"<br />
BusID "<BusID for NVIDIA device here>"<br />
Option "AllowEmptyInitialConfiguration"<br />
EndSection<br />
}}<br />
For older X servers<br />
{{hc|/etc/X11/xorg.conf|<br />
Section "ServerLayout"<br />
Identifier "layout"<br />
Screen 0 "nvidia"<br />
Inactive "intel"<br />
EndSection<br />
<br />
Section "Device"<br />
Identifier "nvidia"<br />
Driver "nvidia"<br />
'''# Change BusID if necessary. Tips: (lspci &#124; grep 3D) (Change 01:00.0 to 1:0:0)'''<br />
'''BusID "PCI:1:0:0"'''<br />
EndSection<br />
<br />
Section "Screen"<br />
Identifier "nvidia"<br />
Device "nvidia"<br />
Option "AllowEmptyInitialConfiguration" "Yes"<br />
EndSection<br />
<br />
Section "Device"<br />
Identifier "intel"<br />
Driver "modesetting"<br />
'''# Change BusID if necessary. Tips: (lspci &#124; grep VGA) (Change 00:02.0 to 0:2:0)'''<br />
'''BusID "PCI:0:2:0"'''<br />
Option "AccelMethod" "none"<br />
EndSection<br />
<br />
Section "Screen"<br />
Identifier "intel"<br />
Device "intel"<br />
EndSection<br />
<br />
}}<br />
<br />
Next, add the following two lines to the beginning of your {{ic|~/.xinitrc}}:<br />
<br />
{{hc|~/.xinitrc|<br />
xrandr --setprovideroutputsource modesetting NVIDIA-0<br />
xrandr --auto<br />
}}<br />
<br />
Now reboot to load the drivers, and X should start.<br />
<br />
If your display dpi is not correct add following line:<br />
<br />
xrandr --dpi 96<br />
<br />
If you get a black screen when starting X, make sure that there are no ampersands after the two {{ic|xrandr}} commands in {{ic|~/.xinitrc}}. If there are ampersands, it seems that the window manager can run before the {{ic|xrandr}} commands finish executing, leading to a black screen. <br />
<br />
If the black screen persists, see the [[#Alternative configuration]] below. <br />
<br />
=== Alternative configuration ===<br />
<br />
If you experience Xorg-server crashes since release 1.17.1 with above configuration, modify the section for the Intel device in {{ic|/etc/X11/xorg.conf}} as follows:<br />
<br />
{{hc|# nano /etc/X11/xorg.conf|<br />
Section "Device"<br />
Identifier "intel"<br />
Driver "modesetting"<br />
BusID "PCI:0:2:0"<br />
Option "AccelMethod" "sna"<br />
#Option "TearFree" "True"<br />
#Option "Tiling" "True"<br />
#Option "SwapbuffersWait" "True"<br />
EndSection}}<br />
<br />
As above, the {{ic|BusID}} must match for the output of the ''lspci'' command. Search for the line with "VGA compatible controller", that contains something Intel. For example: <br />
$ lspci |grep VGA<br />
00:02.0 VGA compatible controller: Intel Corporation Haswell-ULT Integrated Graphics Controller (rev 0b)<br />
<br />
{{Tip|The three last commented out options may (without #) result in positive effects on the tearing, but exchange for some performance cost. Note the {{ic|TearFree}} option may be used for {{ic|"sna"}} acceleration only, see [[Intel graphics]]. <br />
You can use either {{ic|"sna"}} or {{ic|"uxa"}} in {{ic|"AccelMethod"}} option. For further experimenting, a working {{ic|xorg.conf}} from a Lenovo Ideapad Z50-70 59-432128 is here: [http://pastebin.com/tMtPz381].}}<br />
<br />
If X starts but nothing appears on the screen, check if {{ic|/var/log/xorg.conf}} contains a following line or similar:<br />
<br />
{{hc|/var/log/xorg.conf|<br />
[ 16112.937] (EE) Screen 1 deleted because of no matching config section.<br />
}}<br />
<br />
If so, the problem may disappear when you change your ServerLayout section of {{ic|/etc/X11/xorg.conf}}:<br />
<br />
{{hc|/etc/X11/xorg.conf|<br />
Section "ServerLayout"<br />
Identifier "layout"<br />
Screen '''1''' "nvidia"<br />
Inactive "intel"<br />
EndSection<br />
}}<br />
<br />
=== Display Managers ===<br />
<br />
If you are using a display manager then you will need to create or edit a display setup script for your display manager instead of using {{ic|~/.xinitrc}}.<br />
<br />
==== LightDM ====<br />
<br />
For the [[LightDM]] display manager:<br />
<br />
{{hc|/etc/lightdm/display_setup.sh|<br />
#!/bin/sh<br />
xrandr --setprovideroutputsource modesetting NVIDIA-0<br />
xrandr --auto<br />
}}<br />
<br />
Make the script executable:<br />
<br />
# chmod +x /etc/lightdm/display_setup.sh<br />
<br />
Now configure lightdm to run the script by editing the {{ic|[Seat:*]}} section in {{ic|/etc/lightdm/lightdm.conf}}:<br />
<br />
{{hc|/etc/lightdm/lightdm.conf|output=<br />
[Seat:*]<br />
display-setup-script=/etc/lightdm/display_setup.sh<br />
}}<br />
<br />
Now reboot and your display manager should start.<br />
<br />
==== SDDM ====<br />
For the [[SDDM]] display manager:<br />
<br />
{{hc|/usr/share/sddm/scripts/Xsetup|<br />
xrandr --setprovideroutputsource modesetting NVIDIA-0<br />
xrandr --auto<br />
}}<br />
<br />
==== GDM ====<br />
<br />
For the [[GDM]] display manager create a new .desktop file:<br />
<br />
{{hc|/usr/share/gdm/greeter/autostart/optimus.desktop|<br />
<nowiki>[Desktop Entry]<br />
Type=Application<br />
Name=Optimus<br />
Exec=sh -c "xrandr --setprovideroutputsource modesetting NVIDIA-0; xrandr --auto"<br />
NoDisplay=true<br />
X-GNOME-Autostart-Phase=DisplayServer</nowiki><br />
}}<br />
<br />
Make sure that GDM use [[GDM#Use_Xorg_backend|X as default backend]].<br />
<br />
==== KDM ====<br />
<br />
For KDE's [[KDM]], add the xrandr lines into {{ic|/usr/share/config/kdm/Xsetup}}.<br />
<br />
=== Checking 3D ===<br />
<br />
You can check if the NVIDIA graphics are being used by installing {{Pkg|mesa-demos}} and running<br />
<br />
$ glxinfo | grep NVIDIA<br />
<br />
=== Further Information ===<br />
<br />
For more information, look at NVIDIA's official page on the topic [http://us.download.nvidia.com/XFree86/Linux-x86/370.28/README/randr14.html].<br />
<br />
== Troubleshooting ==<br />
<br />
=== Tearing/Broken VSync ===<br />
<br />
This requires {{pkg|xorg-server}} 1.19 or higher, {{pkg|linux}} kernel 4.5 or higher, and {{pkg|nvidia}} 370.23 or higher. You can read the official [https://devtalk.nvidia.com/default/topic/957814/linux/prime-and-prime-synchronization/ forum thread here]. <br />
<br />
=== Failed to initialize the NVIDIA GPU at PCI:1:0:0 (GPU fallen off the bus / RmInitAdapter failed!) ===<br />
<br />
Add {{ic|1=rcutree.rcu_idle_gp_delay=1}} to the kernel parameters. Original topic can be found [https://bbs.archlinux.org/viewtopic.php?id=169742 here].<br />
<br />
=== Resolution, screen scan wrong. EDID errors in Xorg.log ===<br />
<br />
This is due to the NVIDIA driver not detecting the EDID for the display. You need to manually specify the path to an EDID file or provide the same information in a similar way.<br />
<br />
To provide the path to the EDID file edit the Device Section for the NVIDIA card in Xorg.conf, adding these lines and changing parts to reflect your own system:<br />
<br />
{{hc|/etc/X11/xorg.conf|<br />
Section "Device"<br />
Option "ConnectedMonitor" "CRT-0"<br />
Option "CustomEDID" "CRT-0:/sys/class/drm/card0-LVDS-1/edid"<br />
Option "IgnoreEDID" "false"<br />
Option "UseEDID" "true"<br />
EndSection<br />
}}<br />
<br />
If Xorg wont start try swapping out all references of CRT to DFB.<br />
card0 is the identifier for the intel card to which the display is connected via LVDS. The edid binary is in this directory. If the hardware arrangement is different, the value for CustomEDID might vary but yet this has to be confirmed. The path will start in any case with /sys/class/drm.<br />
<br />
Alternatively you can generate your edid with tools like {{Pkg|read-edid}} and point the driver to this file. Even modelines can be used, but then be sure to change "UseEDID" and "IgnoreEDID".<br />
<br />
=== Lockup issue (lspci hangs) ===<br />
Symptoms: lspci hangs, system suspend fails, shutdown hangs, optirun hangs.<br />
<br />
Applies to: newer laptops with GTX 965M or alike when bbswitch (e.g. via Bumblebee) or nouveau is in use.<br />
<br />
When the dGPU power resource is turned on, it may fail to do so and hang in ACPI code ([https://bugzilla.kernel.org/show_bug.cgi?id=156341 kernel bug 156341]).<br />
<br />
For known model-specific workarounds, see [https://github.com/Bumblebee-Project/Bumblebee/issues/764#issuecomment-234494238 this issue].<br />
In other cases you can try to boot with {{ic|1=acpi_osi="!Windows 2015"}} or {{ic|1=acpi_osi=! acpi_osi="Windows 2009"}} added to your [[Kernel parameters]]. (Consider reporting your laptop to that issue.)<br />
<br />
== Using nouveau ==<br />
<br />
The open-source [[nouveau]] driver ({{Pkg|xf86-video-nouveau}}) can dynamically switch with the Intel driver ({{Pkg|xf86-video-intel}}) using a technology called PRIME. For more information, see the wiki article on [[PRIME]].<br />
<br />
== Using Bumblebee ==<br />
<br />
If you wish to use Bumblebee, which will implement powersaving and some other useful features, see the wiki article on [[Bumblebee]].</div>Sloppy joes