Can I resize "/" partition?

General support questions
mashiro2004
Posts: 68
Joined: 2018/12/08 21:46:22
Location: Italy

Re: Can I resize "/" partition?

Post by mashiro2004 » 2019/01/08 12:52:47

yes if you use lvm you can add hd from hypervisor (vmware, kvm, virtual box etc....)
Then you must rescan the host scsi bus o reboot the system.

If you want to rescan WIHTOUT REBOOTING you can lanch:

lsscsi -k

and you see the ouptut of disks like this:

[0:0:0:0] disk ATA SanDisk SSD PLUS 00RL /dev/sda
[1:0:0:0] disk ATA SanDisk SD8SN8U2 0000 /dev/sdb

The first number is the host bus. Launch:

echo 1 > /sys/class/scsi_host/hostX/scan (X depending what's the host bus above).

Ok, now you must take this commands:

fdisk /dev/sdX (where x is the number of your new disk above)

n (new partitio)
p (primary)
1 (partition number)
enter (defautl value of first cilinder)
enter (default value of last cilinder) [If you want to partition all disk in 1 partition]
t (to select partition id)
8e (is the HEX code to identify LVM)
w (write changes)

if you get an error or warning reading partition table don't worry and lauch this command:

partprobe /dev/sdX

if now you launch fdisk -l you can see something like this:

# Start End Size Type Name
1 2048 411647 200M Linux LVM

Now you must increase the volume.

Create a phisical volume:

pvcreate /dev/sdX1


Get the Volume group name launching:

vgdisplay

Do you receive output like this:

--- Volume group ---
VG Name pizza
VG Size 60.0 GiB

Now you have the name of you Volume group: pizza, extend it on new disk like this:

vgextend pizza /dev/sdX1

Launch a phisical volume scan:

pvscan

do you see output like this:

PV /dev/sda1 VG pizza lvm2 [60.0 GiB / 0 free]
PV /dev/sdX1 VG pizza lvm2 [20.0 GiB / 20.0 GiB free]
Total: 2 [80.0 GiB] / in use: 2 [80.0 GiB] / in no VG: 0 [0 ]

Now you must get the Logical volume path:

lvdisplay

and you get more info, you must get the root volume, like this:

LV Path /dev/pizza/root
LV Name root
VG Name pizza

Now extend the logical volume like this:

lvextend /dev/pizza/root /dev/sdX1

Ok now you must extend filesystem and do you have finish:

If you have ext4 partition you can resize like this:

resize2fs /dev/pizza/root

If you have xfs partition (Centos 7.6 create xfs on default) you can resize like this:

xfs_growfs /dev/pizza/root

Launch df -h and you see the root enlarged.

It's also possible to enlarge lvm by enlarging existing disk from you hypervisor.

Bust question: 60gb for root partition is not little, why do you want extend it?

hack3rcon
Posts: 757
Joined: 2014/11/24 11:04:37

Re: Can I resize "/" partition?

Post by hack3rcon » 2019/01/18 06:19:09

Thank you.
I got below error:

Code: Select all

# lvextend /dev/centos/root /dev/sdb1
  Size of logical volume centos/root changed from 46.73 GiB (11964 extents) to 54.73 GiB (14011 extents).
  Logical volume root successfully resized.
# resize2fs /dev/centos/root
resize2fs 1.42.9 (28-Dec-2013)
resize2fs: Bad magic number in super-block while trying to open /dev/centos/root
Couldn't find valid filesystem superblock.

User avatar
TrevorH
Site Admin
Posts: 33215
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Can I resize "/" partition?

Post by TrevorH » 2019/01/18 07:58:02

If your filesystem is xfs then you need to use xfs_growfs not resize2fs which is for ext2/3/4 filesystems.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

hack3rcon
Posts: 757
Joined: 2014/11/24 11:04:37

Re: Can I resize "/" partition?

Post by hack3rcon » 2019/01/18 09:44:05

TrevorH wrote:
2019/01/18 07:58:02
If your filesystem is xfs then you need to use xfs_growfs not resize2fs which is for ext2/3/4 filesystems.
My partition is "Linux LVM":

Code: Select all

# fdisk -l

Disk /dev/sda: 77.4 GB, 77420888064 bytes, 151212672 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x0005a5dd

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     1026047      512000   83  Linux
/dev/sda2         1026048   151212031    75092992   8e  Linux LVM

Disk /dev/sdb: 8589 MB, 8589934592 bytes, 16777216 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1              63    16777215     8388576+  8e  Linux LVM

Disk /dev/mapper/centos-root: 58.8 GB, 58766393344 bytes, 114778112 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/mapper/centos-home: 24.5 GB, 24498929664 bytes, 47849472 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

hack3rcon
Posts: 757
Joined: 2014/11/24 11:04:37

Re: Can I resize "/" partition?

Post by hack3rcon » 2019/01/20 06:18:15

What is my problem?

hunter86_bg
Posts: 2019
Joined: 2015/02/17 15:14:33
Location: Bulgaria
Contact:

Re: Can I resize "/" partition?

Post by hunter86_bg » 2019/01/20 06:22:54

Run xfs_grow /dev/vg/extended-lv
I prefer to extend/shrink my LVs with the '-r' option which will resize the filesystem in 1 shot.
It even checks if you forgot to umount the LV - there is no need to mention how many times it saved my *** .
Last edited by hunter86_bg on 2019/01/20 17:25:20, edited 1 time in total.

hack3rcon
Posts: 757
Joined: 2014/11/24 11:04:37

Re: Can I resize "/" partition?

Post by hack3rcon » 2019/01/20 12:12:15

mashiro2004 wrote:
2019/01/08 12:52:47
yes if you use lvm you can add hd from hypervisor (vmware, kvm, virtual box etc....)
Then you must rescan the host scsi bus o reboot the system.

If you want to rescan WIHTOUT REBOOTING you can lanch:

lsscsi -k

and you see the ouptut of disks like this:

[0:0:0:0] disk ATA SanDisk SSD PLUS 00RL /dev/sda
[1:0:0:0] disk ATA SanDisk SD8SN8U2 0000 /dev/sdb

The first number is the host bus. Launch:

echo 1 > /sys/class/scsi_host/hostX/scan (X depending what's the host bus above).

Ok, now you must take this commands:

fdisk /dev/sdX (where x is the number of your new disk above)

n (new partitio)
p (primary)
1 (partition number)
enter (defautl value of first cilinder)
enter (default value of last cilinder) [If you want to partition all disk in 1 partition]
t (to select partition id)
8e (is the HEX code to identify LVM)
w (write changes)

if you get an error or warning reading partition table don't worry and lauch this command:

partprobe /dev/sdX

if now you launch fdisk -l you can see something like this:

# Start End Size Type Name
1 2048 411647 200M Linux LVM

Now you must increase the volume.

Create a phisical volume:

pvcreate /dev/sdX1


Get the Volume group name launching:

vgdisplay

Do you receive output like this:

--- Volume group ---
VG Name pizza
VG Size 60.0 GiB

Now you have the name of you Volume group: pizza, extend it on new disk like this:

vgextend pizza /dev/sdX1

Launch a phisical volume scan:

pvscan

do you see output like this:

PV /dev/sda1 VG pizza lvm2 [60.0 GiB / 0 free]
PV /dev/sdX1 VG pizza lvm2 [20.0 GiB / 20.0 GiB free]
Total: 2 [80.0 GiB] / in use: 2 [80.0 GiB] / in no VG: 0 [0 ]

Now you must get the Logical volume path:

lvdisplay

and you get more info, you must get the root volume, like this:

LV Path /dev/pizza/root
LV Name root
VG Name pizza

Now extend the logical volume like this:

lvextend /dev/pizza/root /dev/sdX1

Ok now you must extend filesystem and do you have finish:

If you have ext4 partition you can resize like this:

resize2fs /dev/pizza/root

If you have xfs partition (Centos 7.6 create xfs on default) you can resize like this:

xfs_growfs /dev/pizza/root

Launch df -h and you see the root enlarged.

It's also possible to enlarge lvm by enlarging existing disk from you hypervisor.

Bust question: 60gb for root partition is not little, why do you want extend it?
It show me:

Code: Select all

resize2fs: Bad magic number in super-block while trying to open /dev/centos/root
Couldn't find valid filesystem superblock.

User avatar
TrevorH
Site Admin
Posts: 33215
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Can I resize "/" partition?

Post by TrevorH » 2019/01/20 15:20:51

Two separate people have told you that resize2fs only works on ext2/3/4 filesystems. The default filesystem in CentOS 7 is xfs. Use df -Th to see what sort of filesystem is in use for you. Then use xfs_growfs like you've been told twice already.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

mashiro2004
Posts: 68
Joined: 2018/12/08 21:46:22
Location: Italy

Re: Can I resize "/" partition?

Post by mashiro2004 » 2019/01/20 21:06:10

hack3rcon wrote:
2019/01/20 12:12:15
mashiro2004 wrote:
2019/01/08 12:52:47
yes if you use lvm you can add hd from hypervisor (vmware, kvm, virtual box etc....)
Then you must rescan the host scsi bus o reboot the system.

If you want to rescan WIHTOUT REBOOTING you can lanch:

lsscsi -k

and you see the ouptut of disks like this:

[0:0:0:0] disk ATA SanDisk SSD PLUS 00RL /dev/sda
[1:0:0:0] disk ATA SanDisk SD8SN8U2 0000 /dev/sdb

The first number is the host bus. Launch:

echo 1 > /sys/class/scsi_host/hostX/scan (X depending what's the host bus above).

Ok, now you must take this commands:

fdisk /dev/sdX (where x is the number of your new disk above)

n (new partitio)
p (primary)
1 (partition number)
enter (defautl value of first cilinder)
enter (default value of last cilinder) [If you want to partition all disk in 1 partition]
t (to select partition id)
8e (is the HEX code to identify LVM)
w (write changes)

if you get an error or warning reading partition table don't worry and lauch this command:

partprobe /dev/sdX

if now you launch fdisk -l you can see something like this:

# Start End Size Type Name
1 2048 411647 200M Linux LVM

Now you must increase the volume.

Create a phisical volume:

pvcreate /dev/sdX1


Get the Volume group name launching:

vgdisplay

Do you receive output like this:

--- Volume group ---
VG Name pizza
VG Size 60.0 GiB

Now you have the name of you Volume group: pizza, extend it on new disk like this:

vgextend pizza /dev/sdX1

Launch a phisical volume scan:

pvscan

do you see output like this:

PV /dev/sda1 VG pizza lvm2 [60.0 GiB / 0 free]
PV /dev/sdX1 VG pizza lvm2 [20.0 GiB / 20.0 GiB free]
Total: 2 [80.0 GiB] / in use: 2 [80.0 GiB] / in no VG: 0 [0 ]

Now you must get the Logical volume path:

lvdisplay

and you get more info, you must get the root volume, like this:

LV Path /dev/pizza/root
LV Name root
VG Name pizza

Now extend the logical volume like this:

lvextend /dev/pizza/root /dev/sdX1

Ok now you must extend filesystem and do you have finish:

If you have ext4 partition you can resize like this:

resize2fs /dev/pizza/root

If you have xfs partition (Centos 7.6 create xfs on default) you can resize like this:

xfs_growfs /dev/pizza/root

Launch df -h and you see the root enlarged.

It's also possible to enlarge lvm by enlarging existing disk from you hypervisor.

Bust question: 60gb for root partition is not little, why do you want extend it?
It show me:

Code: Select all

resize2fs: Bad magic number in super-block while trying to open /dev/centos/root
Couldn't find valid filesystem superblock.
as mentioned by Trevor uses xfs_growfs and fix, your fs is xfs and not ext

hack3rcon
Posts: 757
Joined: 2014/11/24 11:04:37

Re: Can I resize "/" partition?

Post by hack3rcon » 2019/01/21 07:06:28

mashiro2004 wrote:
2019/01/20 21:06:10
hack3rcon wrote:
2019/01/20 12:12:15
mashiro2004 wrote:
2019/01/08 12:52:47
yes if you use lvm you can add hd from hypervisor (vmware, kvm, virtual box etc....)
Then you must rescan the host scsi bus o reboot the system.

If you want to rescan WIHTOUT REBOOTING you can lanch:

lsscsi -k

and you see the ouptut of disks like this:

[0:0:0:0] disk ATA SanDisk SSD PLUS 00RL /dev/sda
[1:0:0:0] disk ATA SanDisk SD8SN8U2 0000 /dev/sdb

The first number is the host bus. Launch:

echo 1 > /sys/class/scsi_host/hostX/scan (X depending what's the host bus above).

Ok, now you must take this commands:

fdisk /dev/sdX (where x is the number of your new disk above)

n (new partitio)
p (primary)
1 (partition number)
enter (defautl value of first cilinder)
enter (default value of last cilinder) [If you want to partition all disk in 1 partition]
t (to select partition id)
8e (is the HEX code to identify LVM)
w (write changes)

if you get an error or warning reading partition table don't worry and lauch this command:

partprobe /dev/sdX

if now you launch fdisk -l you can see something like this:

# Start End Size Type Name
1 2048 411647 200M Linux LVM

Now you must increase the volume.

Create a phisical volume:

pvcreate /dev/sdX1


Get the Volume group name launching:

vgdisplay

Do you receive output like this:

--- Volume group ---
VG Name pizza
VG Size 60.0 GiB

Now you have the name of you Volume group: pizza, extend it on new disk like this:

vgextend pizza /dev/sdX1

Launch a phisical volume scan:

pvscan

do you see output like this:

PV /dev/sda1 VG pizza lvm2 [60.0 GiB / 0 free]
PV /dev/sdX1 VG pizza lvm2 [20.0 GiB / 20.0 GiB free]
Total: 2 [80.0 GiB] / in use: 2 [80.0 GiB] / in no VG: 0 [0 ]

Now you must get the Logical volume path:

lvdisplay

and you get more info, you must get the root volume, like this:

LV Path /dev/pizza/root
LV Name root
VG Name pizza

Now extend the logical volume like this:

lvextend /dev/pizza/root /dev/sdX1

Ok now you must extend filesystem and do you have finish:

If you have ext4 partition you can resize like this:

resize2fs /dev/pizza/root

If you have xfs partition (Centos 7.6 create xfs on default) you can resize like this:

xfs_growfs /dev/pizza/root

Launch df -h and you see the root enlarged.

It's also possible to enlarge lvm by enlarging existing disk from you hypervisor.

Bust question: 60gb for root partition is not little, why do you want extend it?
It show me:

Code: Select all

resize2fs: Bad magic number in super-block while trying to open /dev/centos/root
Couldn't find valid filesystem superblock.
as mentioned by Trevor uses xfs_growfs and fix, your fs is xfs and not ext
I did below command:

Code: Select all

# xfs_growfs /dev/centos/root
meta-data=/dev/mapper/centos-root isize=256    agcount=5, agsize=3062784 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0        finobt=0
data     =                       bsize=4096   blocks=14347264, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =internal               bsize=4096   blocks=5982, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

Post Reply