- fdisk /dev/xvda ...(n > p = 2 > t = 8e)
- reboot
- pvcreate /dev/xvda2
- vgcreate centos /dev/xvda2
- lvcreate -n home -L 200G centos
- lvcreate -n root -L 100G centos
- lvcreate -n swap -L 4G cent
- mkfs.ext4 /dev/centos/root
- mkfs.ext4 /dev/centos/home
- mkswap /dev/centos/swap
- mount /dev/xvda1 /boot
- ...This is what i want to do but was not permitted.
- So instead, i updated
/etc/fstaband changed mount point for/dev/xvda1from/to/boot. But this also does not work.
- In the results provided below,
df -hshows the correct mount points for both/dev/xvda1 i.e. /bootand/dev/mapper/centos-root i.e. /but the disk space shown for/dev/mapper/centos-root = 7.8Gis incorrect. I was expecting~100G.- Also, the results for
lsblkshows empty mount point forcentos-root (dm-1). Forcentos-root, i expected mount point/and for/dev/xvda1expected mount point/boot.- mount /dev/centos/root /
- mount /dev/centos/home /home
- make corresponding entries into /etc/fstab (refer
cat /etc/fstabbelow)- shutdown -r now
- mkhomedir_helper centos
- On reboot, home dir for centos became inaccessible and so i got error "Could not chdir to home directory /home/centos: No such file or directory". To resolve, I had to run the above command to recreate home directory for user centos
- fdisk /dev/xvda ...(n > p = 2 > t = 8e)
- reboot
- pvcreate /dev/xvda2
- vgcreate centos /dev/xvda2
- lvcreate -n home -L 200G centos
- lvcreate -n root -L 100G centos
- lvcreate -n swap -L 4G cent
- mkfs.ext4 /dev/centos/root
- mkfs.ext4 /dev/centos/home
- mkswap /dev/centos/swap
- mount /dev/xvda1 /boot
- ...This is what i want to do but was not permitted.
- So instead, i updated
/etc/fstaband changed mount point for/dev/xvda1from/to/boot. But this also does not work.
- In the results provided below,
df -hshows the correct mount points for both/dev/xvda1 i.e. /bootand/dev/mapper/centos-root i.e. /but the disk space shown for/dev/mapper/centos-root = 7.8Gis incorrect. I was expecting~100G.- Also, the results for
lsblkshows empty mount point forcentos-root (dm-1). Forcentos-root, i expected mount point/and for/dev/xvda1expected mount point/boot.- mount /dev/centos/root /
- mount /dev/centos/home /home
- make corresponding entries into /etc/fstab (refer
cat /etc/fstabbelow)- shutdown -r now
- fdisk /dev/xvda ...(n > p = 2 > t = 8e)
- reboot
- pvcreate /dev/xvda2
- vgcreate centos /dev/xvda2
- lvcreate -n home -L 200G centos
- lvcreate -n root -L 100G centos
- lvcreate -n swap -L 4G cent
- mkfs.ext4 /dev/centos/root
- mkfs.ext4 /dev/centos/home
- mkswap /dev/centos/swap
- mount /dev/xvda1 /boot
- ...This is what i want to do but was not permitted.
- So instead, i updated
/etc/fstaband changed mount point for/dev/xvda1from/to/boot. But this also does not work.
- In the results provided below,
df -hshows the correct mount points for both/dev/xvda1 i.e. /bootand/dev/mapper/centos-root i.e. /but the disk space shown for/dev/mapper/centos-root = 7.8Gis incorrect. I was expecting~100G.- Also, the results for
lsblkshows empty mount point forcentos-root (dm-1). Forcentos-root, i expected mount point/and for/dev/xvda1expected mount point/boot.- mount /dev/centos/root /
- mount /dev/centos/home /home
- make corresponding entries into /etc/fstab (refer
cat /etc/fstabbelow)- shutdown -r now
- mkhomedir_helper centos
- On reboot, home dir for centos became inaccessible and so i got error "Could not chdir to home directory /home/centos: No such file or directory". To resolve, I had to run the above command to recreate home directory for user centos
Initial State of System:
# fdisk -l
Disk /dev/xvda: 536.9 GB, 536870912000 bytes 255 heads, 63 sectors/track, 65270 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x000611ee
Device Boot Start End Blocks Id System
/dev/xvda1 * 1 1045 8387584 83 Linux
Disk /dev/xvdb: 32.2 GB, 32204390400 bytes 255 heads, 63 sectors/track, 3915 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000
# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 500G 0 disk
└─xvda1 202:1 0 8G 0 part /
xvdb 202:16 0 30G 0 disk /mnt
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 7.8G 897M 6.5G 12% /
tmpfs 3.6G 0 3.6G 0% /dev/shm
/dev/xvdb 30G 173M 28G 1% /mnt
# cat /etc/fstab
UUID=2d0f2d55-672b-4c05-8eba-9421dd808ad7 / ext4 defaults 1 1
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
/dev/xvdb /mnt auto defaults,nofail,comment=cloudconfig 0 2
Steps i performed:
- fdisk /dev/xvda ...(n > p = 2 > t = 8e)
- reboot
- pvcreate /dev/xvda2
- vgcreate centos /dev/xvda2
- lvcreate -n home -L 200G centos
- lvcreate -n root -L 100G centos
- lvcreate -n swap -L 4G cent
- mkfs.ext4 /dev/centos/root
- mkfs.ext4 /dev/centos/home
- mkswap /dev/centos/swap
- mount /dev/xvda1 /boot
- ...This is what i want to do but was not permitted.
- So instead, i updated
/etc/fstaband changed mount point for/dev/xvda1from/to/boot. But this also does not work.
- In the results provided below,
df -hshows the correct mount points for both/dev/xvda1 i.e. /bootand/dev/mapper/centos-root i.e. /but the disk space shown for/dev/mapper/centos-root = 7.8Gis incorrect. I was expecting~100G.- Also, the results for
lsblkshows empty mount point forcentos-root (dm-1). Forcentos-root, i expected mount point/and for/dev/xvda1expected mount point/boot.- mount /dev/centos/root /
- mount /dev/centos/home /home
- make corresponding entries into /etc/fstab (refer
cat /etc/fstabbelow)- shutdown -r now
Initial State of System:
# fdisk -l
Disk /dev/xvda: 536.9 GB, 536870912000 bytes 255 heads, 63 sectors/track, 65270 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x000611ee
Device Boot Start End Blocks Id System
/dev/xvda1 * 1 1045 8387584 83 Linux
Disk /dev/xvdb: 32.2 GB, 32204390400 bytes 255 heads, 63 sectors/track, 3915 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000
# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 500G 0 disk
└─xvda1 202:1 0 8G 0 part /
xvdb 202:16 0 30G 0 disk /mnt
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 7.8G 897M 6.5G 12% /
tmpfs 3.6G 0 3.6G 0% /dev/shm
/dev/xvdb 30G 173M 28G 1% /mnt
# cat /etc/fstab
UUID=2d0f2d55-672b-4c05-8eba-9421dd808ad7 / ext4 defaults 1 1
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
/dev/xvdb /mnt auto defaults,nofail,comment=cloudconfig 0 2
Steps i performed:
- fdisk /dev/xvda ...(n > p = 2 > t = 8e)
- reboot
- pvcreate /dev/xvda2
- vgcreate centos /dev/xvda2
- lvcreate -n home -L 200G centos
- lvcreate -n root -L 100G centos
- lvcreate -n swap -L 4G cent
- mkfs.ext4 /dev/centos/root
- mkfs.ext4 /dev/centos/home
- mkswap /dev/centos/swap
- mount /dev/xvda1 /boot
- ...This is what i want to do but was not permitted.
- So instead, i updated
/etc/fstaband changed mount point for/dev/xvda1from/to/boot. But this also does not work.
- In the results provided below,
df -hshows the correct mount points for both/dev/xvda1 i.e. /bootand/dev/mapper/centos-root i.e. /but the disk space shown for/dev/mapper/centos-root = 7.8Gis incorrect. I was expecting~100G.- Also, the results for
lsblkshows empty mount point forcentos-root (dm-1). Forcentos-root, i expected mount point/and for/dev/xvda1expected mount point/boot.- mount /dev/centos/root /
- mount /dev/centos/home /home
- make corresponding entries into /etc/fstab (refer
cat /etc/fstabbelow)- shutdown -r now
Problem resizing ext4 root partition on Centos6x64
My Centos6x64 VM came has a ~500G disk xvda. Initially, 8G was allocated to xvda1 and mounted on /. The remainder of the 500G disk space in xvda was not yet allocated. So i decided to make this remainder disk space usable and created a partition xvda2 with logical volumes using fdisk, pvcreate, vgcreate, lvcreate, formatting and finally updating fstab to mounted them automatically.
The relationships to the corresponding folders (mount point) is:
- /dev/centos/home ..../home [200G]
- /dev/centos/root ..../ [100G]
Problem is:
- The /home seem to have mounted correctly as size shown upon
df -his 197G. - But the mounting on root is not correct. In the results for
df -hbelow, the size of/dev/xvda1mounted on/bootis 7.8G which is correct. But, the size of/dev/mapper/centos-rootmounted on/incorrectly shows 7.8G. It should show approximately 100G. It is incorrectly showing the same disk space as that of/dev/xvda1.
Questions:
- I have tried to collate some results below for your reference. Kindly help resolve this problem. What can i do to correct the problem?
- Also, if i just wanted to increase the disk space allocated to xvda1 from 8G to say 200G, is there a simpler more direct way? on googling, i found this post that very much matched the objective. But i could not get it to reboot successfully as it lay stuck on the grub screen. I don't have much info on this failure details. Could i have missed out some setup pre-requisites when using fdisk to allocate additional disk space eg: formatting?
I pretty much new on this and stuck. Please Kindly help.
cat /etc/fstab
UUID=3a75c67b-5053-4863-963e-c6a572f13972 / ext4 defaults 1 1
UUID=2d0f2d55-672b-4c05-8eba-9421dd808ad7 /boot ext4 defaults 1 2
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
/dev/xvdb /mnt auto defaults,nofail,comment=cloudconfig 0 2
/dev/mapper/centos-home /home ext4 defaults 0 0
fdisk -l
Device Boot Start End Blocks Id System
/dev/xvda1 * 1 1045 8387584 83 Linux
/dev/xvda2 1045 65270 515892667 8e Linux LVM
df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 7.8G 898M 6.5G 12% /
tmpfs 3.6G 0 3.6G 0% /dev/shm
/dev/xvda1 7.8G 898M 6.5G 12% /boot
/dev/xvdb 30G 173M 28G 1% /mnt
/dev/mapper/centos-home 197G 60M 187G 1% /home
lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 500G 0 disk
├─xvda1 202:1 0 8G 0 part /
└─xvda2 202:2 0 492G 0 part
├─centos-home (dm-0) 253:0 0 200G 0 lvm /home
├─centos-root (dm-1) 253:1 0 100G 0 lvm
└─centos-swap (dm-2) 253:2 0 4G 0 lvm
xvdb 202:16 0 30G 0 disk /mnt
blkid
/dev/xvda1: UUID="2d0f2d55-672b-4c05-8eba-9421dd808ad7" TYPE="ext4"
/dev/xvdb: UUID="3656cb72-7e94-4e63-81ea-66397ad45d13" SEC_TYPE="ext2" TYPE="ext3"
/dev/xvda2: UUID="ASXeKh-x8xL-nDVF-afzq-zU8a-sCbd-qGM6pS" TYPE="LVM2_member"
/dev/mapper/centos-home: UUID="4510891a-354d-4486-bd47-95d474f197bb" TYPE="ext4"
/dev/mapper/centos-root: UUID="3a75c67b-5053-4863-963e-c6a572f13972" TYPE="ext4"
/dev/mapper/centos-swap: UUID="5dff9552-3d36-4cfa-936c-28e02c1ae108" TYPE="swap"
lvdisplay
--- Logical volume ---
LV Path /dev/centos/home
LV Name home
VG Name centos
LV UUID lFWQxa-mqgc-Ur8t-npDc-O2NU-r6J4-UhC2j2
LV Write Access read/write
LV Creation host, time ip-xx-xx-xx-xx.ec2.internal, 2018-06-16 07:18:22 +0000
LV Status available
# open 1
LV Size 200.00 GiB
Current LE 51200
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
--- Logical volume ---
LV Path /dev/centos/root
LV Name root
VG Name centos
LV UUID UQ6oAD-JyRa-cb8l-VmgW-aZh9-qbof-Z1Z9af
LV Write Access read/write
LV Creation host, time ip-xx-xx-xx-xx.ec2.internal, 2018-06-16 07:18:22 +0000
LV Status available
# open 0
LV Size 100.00 GiB
Current LE 25600
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
--- Logical volume ---
LV Path /dev/centos/swap
LV Name swap
VG Name centos
LV UUID QyY2z9-5EpX-D8dY-DORZ-9BbY-TqgA-07fc3X
LV Write Access read/write
LV Creation host, time ip-xx-xx-xx-xx.ec2.internal, 2018-06-16 07:18:24 +0000
LV Status available
# open 0
LV Size 4.00 GiB
Current LE 1024
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:2