0

What specific commands need to be entered into a CentOS 7 server in order to:
1.) Partition the hard drive into 8 partitions and then
2.) Attach the first two partitions to the operating system, so that the remaining 6 partitions remain detached?

Here is my first attempt, which as you can see is throwing an error indicating that the partition is currently in use:

[root@remote-host ~]# parted --script /dev/sda mklabel gpt mkpart primary 1MiB 250MiB mkpart primary 250MiB 500MiB mkpart primary 500MiB 750MiB mkpart primary 750MiB 1000MiB mkpart primary 1000MiB 1250MiB mkpart primary 1250MiB 1500MiB mkpart primary 1500MiB 1750MiB mkpart primary 1750MiB 2000MiB
Error: Partition(s) on /dev/sda are being used.

Note: I need to use commands that can be migrated into scripts later. Therefore, I cannot use interactive console tools in the solution to this problem.

Is the answer as simple as unmounting the disk before running the parted command, and then remounting two of the new partitions after running the parted command?

For background, I am providing information about the current disk contents as follows:

[root@remote-host ~]# parted -l
Model: ATA WDC WD20EZRX-00D (scsi)
Disk /dev/sda: 2000GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system  Name                  Flags
 1      1049kB  211MB   210MB   fat16        EFI System Partition  boot
 2      211MB   735MB   524MB   xfs
 3      735MB   2000GB  2000GB                                     lvm

Model: Linux device-mapper (linear) (dm)
Disk /dev/mapper/centos-home: 1938GB
Sector size (logical/physical): 512B/4096B
Partition Table: loop
Disk Flags:

Number  Start  End     Size    File system  Flags
 1      0.00B  1938GB  1938GB  xfs

Model: Linux device-mapper (linear) (dm)
Disk /dev/mapper/centos-swap: 8187MB
Sector size (logical/physical): 512B/4096B
Partition Table: loop
Disk Flags:

Number  Start  End     Size    File system     Flags
 1      0.00B  8187MB  8187MB  linux-swap(v1)

Model: Linux device-mapper (linear) (dm)
Disk /dev/mapper/centos-root: 53.7GB
Sector size (logical/physical): 512B/4096B
Partition Table: loop
Disk Flags:

Number  Start  End     Size    File system  Flags
 1      0.00B  53.7GB  53.7GB  xfs

[root@remote-host ~]#
  • You're right - if you've mounted the partition you can't change it. If you unmount it, you'll loose access to everything. Catch 22 really. The best option is to prepare the disks first, then install. Maybe have a look at Kickstart scripts which can create a custom install image for you. – garethTheRed Mar 11 '17 at 8:18
  • @garethTheRed I have been doing a lot of work to set up a kickstart installation, but I seem to have hit a dead end in that the installation process freezes and I am subsequently not able to get in to view the logs using virsh. I think this is in you area of expertise. Are you willing to help? Here is the link: unix.stackexchange.com/questions/352181/… – CodeMed Mar 17 '17 at 21:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.