• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

parted Command Examples in Linux

by Deepika

The GNU parted utility is also used to view the existing partition table, change the size of existing partitions, or add partitions from free space or additional hard drives. This utility is more advanced than the fdisk utility. It supports more disk label types and offers additional commands. parted syntax is:

# parted [option] [device_name] [command [argument]]

Use parted interactively to enter commands one at a time. Include only the device as an argument to invoke interactive mode. Example:

# parted /dev/sda
GNU Parted 3.1
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted)

From the (parted) prompt, enter a command or type help to view the list of available commands. Get additional help on a specific command by typing help plus the command. Example:

parted command help linux

parted Command Examples

1. List partitions on all block devices:

# sudo parted --list

2. Start interactive mode with the specified disk selected:

# sudo parted /dev/sdX

3. Create a new partition table of the specified label-type:

# sudo parted --script /dev/sdX mklabel aix|amiga|bsd|dvh|gpt|loop|mac|msdos|pc98|sun

4. Show partition information in interactive mode:

# print

5. Select a disk in interactive mode:

# select /dev/sdX

6. Create a 16 GB partition with the specified filesystem in interactive mode:

# mkpart primary|logical|extended btrfs|ext2|ext3|ext4|fat16|fat32|hfs|hfs+|linux-swap|ntfs|reiserfs|udf|xfs 0% 16G

7. Resize a partition in interactive mode:

# resizepart /dev/sdXN end_position_of_partition

8. Remove a partition in interactive mode:

# rm /dev/sdXN

Filed Under: Linux

Some more articles you might also be interested in …

  1. mkfs.xfs: command not found
  2. sudo: command not found
  3. Linux OS Service ‘acpid’
  4. How to enable Debug Option For CIFS Module in CentOS/RHEL 7 and 8
  5. Honeypot Tutorials – Modes and Working of Honeypot
  6. playerctl Command Examples in Linux
  7. paste: command not found
  8. blkid Command Examples in Linux
  9. groupmems Command Examples in Linux
  10. How to restrict ssh logins by user and client address on CentOS/RHEL

You May Also Like

Primary Sidebar

Recent Posts

  • protonvpn-cli Command Examples in Linux
  • protonvpn-cli connect Command Examples
  • procs Command Examples in Linux
  • prlimit: command not found

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright