Operational steps for VBox disk space expansion

Source: Internet
Author: User
Tags uuid hex code

My VBox's root directory is running short of disk space.

[Root@testdb2 ~]# Df-k
FileSystem 1k-blocks Used Available use% mounted on
/dev/mapper/vg_testdb2-lv_root
27431124 21329720 4707948 82%/
Tmpfs 3481600 3481512 1%/DEV/SHM
/DEV/SDA1 495844 56258 413986 12%/boot
[Root@testdb2 ~]#

My original Oracle software and data were placed under the/u01 of the root directory, and now the root directory is 82%.

I decided to add a disk to the VBox to enlarge the root directory space.

First, add a hard disk to the VBox graphical interface.
Add-vdisk
Of course, if the graphical interface is not used, the command line below is also possible.


Vboxmanage Createhd--filename "Z:\Oralce_Virtual_Box\Test db\testdb2 (11g 12c) \test_db (one 12c) _attachstorage.vdi"- Size 8192--format VDI--variant Standard

Vboxmanage Storageattach "TestDB2 (11g 12c)"--storagectl "SATA"--port 2--device 0--type hdd--medium "Z:\Oralce_Virtual _box\test db\testdb2 (11g 12c) \test_db (one 12c) _attachstorage.vdi "

When finished, turn on Linux for expansion.




# # Initial State


[Root@testdb2 ~]# Df-h


FileSystem Size Used Avail use% mounted on


/dev/mapper/vg_testdb2-lv_root


27G 21G 4.5G 82%/


Tmpfs 3.4G 88K 3.4G 1%/DEV/SHM


/DEV/SDA1 485M 55M 405M 12%/boot


[Root@testdb2 ~]#


[Root@testdb2 ~]#


[Root@testdb2 ~]#


[Root@testdb2 ~]# Cd/dev


[Root@testdb2 dev]# ls-l sd*


BRW-RW----. 1 root disk 8, 0 Nov 3 09:29 SDA


BRW-RW----. 1 root disk 8, 1 Nov 3 09:30 sda1


BRW-RW----. 1 root disk 8, 2 Nov 3 09:29 sda2


BRW-RW----. 1 root disk 8, Nov 3 09:29 SDB


As you can see, I added a new dish called SDB.

Create partitions, pay attention to type 8e, that is, LVM management.


[Root@testdb2 dev]# Fdisk/dev/sdb

Warning:dos-compatible mode is deprecated. It ' s strongly recommended to
Switch off "mode" (Command ' C ') and change display units to
Sectors (Command ' u ').

Command (M for help): n <<< input N
Command Action
E Extended
P primary partition (1-4)
P <<< Input P
Partition number (1-4): 1 <<< input 1
Cylinder (1-1044, default 1): <<< Enter
Using Default value 1
Last cylinder, +cylinders or +size{k,m,g} (1-1044, default 1044): <<< Enter
Using Default Value 1044

Command (M for help): T <<< input T
Selected partition 1
Hex code (Type L to list codes): L <<< input L

0 Empty NEC DOS bayi minix/old Lin BF Solaris


1 FAT12 9 swap/so Linux C1 drdos/sec (fat-


2 Xenix root 3c partitionmagic c4 drdos/sec (fat-


3 Xenix usr Venix 80286 os/2 hidden c:c6 drdos/sec (fat-


4 FAT16 &lt;32m PPC PReP Boot Linux Extended C7 Syrinx


5 Extended SFS NTFS volume set da non-fs data


6 FAT16 4d qnx4.x NTFS Volume set db cp/m/CTOs/.


7 Hpfs/ntfs 4e qnx4.x 2nd part Linux plaintext de Dell Utility


8 AIX 4f qnx4.x 3rd part 8e Linux LVM DF bootit


9 AIX bootable Ontrack DM Amoeba E1 DOS Access


A os/2 Boot manag wuyi ontrack DM6 Aux Amoeba BBT e3 DOS r/o


b W95 FAT32 cp/m 9f bsd/os e4 speedstor


C W95 FAT32 (LBA) Ontrack DM6 Aux A0 IBM Thinkpad hi EB BeOS FS


E W95 FAT16 (LBA) OnTrackDM6 a5 FreeBSD ee GPT


F W95 Ext ' d (LBA) ez-drive a6 OpenBSD ef EFI (fat-12/16/


OPUS Golden Bow A7 NeXTSTEP f0 linux/pa-risc b


One Hidden FAT12 5c Priam edisk A8 Darwin UFS F1 SpeedStor


Compaq diagnost speedstor A9 NetBSD f4 SpeedStor


Hidden FAT16 &lt;3 The GNU HURD or Sys ab Darwin boot F2 DOS Secondary


Hidden FAT16 Novell Netware af hfs/hfs+ fb VMware VMFS


Hidden hpfs/ntf Novell Netware b7 BSDI FS FC VMware Vmkcore


The AST smartsleep disksecure mult b8 bsdi swap fd Linux RAID auto


1b Hidden W95 FAT3 pc/ix bb Boot Wizard hid Fe lanstep


1c Hidden W95 FAT3 Minix be Solaris boot ff BBT


1e Hidden W95 FAT1


Hex code (type L to list codes): 8e &lt;&lt;&lt; input 8e


Changed system type of partition 1 to 8e (Linux LVM)

Command (M for help):
Command (M for help): P <<< enter p, check to make sure there is no problem

disk/dev/sdb:8589 MB, 8589934592 bytes
255 heads, Sectors/track, 1044 cylinders
Units = Cylinders of 16065 * 8225280 bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk identifier:0x039b1264

Device Boot Start End Blocks Id System
/DEV/SDB1 1 1044 8385898+ 8e Linux LVM

Command (M for help): W <<< Enter W, write to partition table.
The partition table has been altered!

Calling IOCTL () to re-read partition table.
Syncing disks.
[Root@testdb2 dev]#

[Root@testdb2 dev]# ls-l sd*
BRW-RW----. 1 root disk 8, 0 Nov 3 09:29 SDA
BRW-RW----. 1 root disk 8, 1 Nov 3 09:30 sda1
BRW-RW----. 1 root disk 8, 2 Nov 3 09:29 sda2
BRW-RW----. 1 root disk 8, Nov 3 09:29 SDB
BRW-RW----. 1 root disk 8, Nov 3 09:30 sdb1

You can check with Fdisk-l, the new SDB1 partition, is LVM management:


[Root@testdb2 dev]# Fdisk-l

disk/dev/sda:32.2 GB, 32212254720 bytes
255 heads, Sectors/track, 3916 cylinders
Units = Cylinders of 16065 * 8225280 bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk identifier:0x000b1d34

Device Boot Start End Blocks Id System
/DEV/SDA1 * 1 512000 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 3917 30944256 8e Linux LVM

disk/dev/sdb:8589 MB, 8589934592 bytes
255 heads, Sectors/track, 1044 cylinders
Units = Cylinders of 16065 * 8225280 bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk identifier:0x039b1264

Device Boot Start End Blocks Id System
/DEV/SDB1 1 1044 8385898+ 8e Linux LVM <<<< new partition, LVM management

disk/dev/mapper/vg_testdb2-lv_root:28.5 GB, 28538044416 bytes
255 heads, Sectors/track, 3469 cylinders
Units = Cylinders of 16065 * 8225280 bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk identifier:0x00000000


disk/dev/mapper/vg_testdb2-lv_swap:3145 MB, 3145728000 bytes
255 heads, Sectors/track, 382 cylinders
Units = Cylinders of 16065 * 8225280 bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk identifier:0x00000000

[Root@testdb2 dev]#


Then, first create PV:




[Root@testdb2 dev]# PVCREATE/DEV/SDB1


Physical volume "/DEV/SDB1" successfully created


[Root@testdb2 dev]#


[Root@testdb2 ~]# Pvdisplay


---physical volume---


PV Name/dev/sda2


VG name VG_TESTDB2 &lt;&lt;&lt; You can see a PV that already exists, note that this name will be used in a few minutes.


PV Size 29.51 gib/not usable 3.00 MiB


Allocatable Yes (but full)


PE Size 4.00 MiB


Total PE 7554


Free PE 0


Allocated PE 7554


PV UUID FM5QPS-QVVZ-HZAR-YDKY-XYP7-PNII-ZJEQSV





"/DEV/SDB1" is a new physical volume of "8.00 GiB"


---NEW physical volume---


PV NAME/DEV/SDB1


VG Name &lt;&lt;&lt; Newly created PV is not yet joined to VG, so the display is empty. Join in a while.


PV Size 8.00 GiB


Allocatable NO


PE Size 0


Total PE 0


Free PE 0


Allocated PE 0


PV UUID BVODFN-BEGG-FD3I-J12E-LZBE-Z9I7-PQHCFO





[Root@testdb2 ~]#


Let's take a look at the PV, VG situation:




[Root@testdb2 ~]# Vgdisplay


---Volume Group---


VG name VG_TESTDB2 &lt;&lt;&lt;&lt; Note that this name is to be used for a few minutes.


System ID


Format lvm2


Metadata Areas 1


Metadata Sequence No 3


VG Access Read/write


VG Status resizable


MAX LV 0


Cur LV 2


Open LV 2


Max PV 0


Cur PV 1


ACT PV 1


VG Size 29.51 GiB


PE Size 4.00 MiB


Total PE 7554


Alloc pe/size 7554/29.51 GiB


Free pe/size 0/0 &lt;&lt;&lt;&lt;&lt;&lt; Note the size of free, vgextend before free for 0


VG UUID VOCOIO-LDU1-RIYX-TKUC-FBVZ-AKYY-QOVSFE





[Root@testdb2 ~]#


We conduct vgextend:




[Root@testdb2 ~]# Vgextend VG_TESTDB2/DEV/SDB1


Volume Group "VG_TESTDB2" successfully extended


[Root@testdb2 ~]#


[Root@testdb2 ~]# Vgdisplay


---Volume Group---


VG Name VG_TESTDB2


System ID


Format lvm2


Metadata Areas 2


Metadata Sequence No 4


VG Access Read/write


VG Status resizable


MAX LV 0


Cur LV 2


Open LV 2


Max PV 0


Cur PV 2


ACT PV 2


VG Size 37.50 GiB


PE Size 4.00 MiB


Total PE 9601


Alloc pe/size 7554/29.51 GiB


Free pe/size 2047/8.00 GiB &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt; has changed, free has 8 g.


VG UUID VOCOIO-LDU1-RIYX-TKUC-FBVZ-AKYY-QOVSFE





[Root@testdb2 ~]#


Let's look at the LV situation again:

[Root@testdb2 ~]# Lvdisplay




---Logical volume---


LV Path/dev/vg_testdb2/lv_root


LV Name Lv_root


VG Name VG_TESTDB2


LV UUID Gvdftq-rlee-iuxw-szew-xzsh-mhv3-yxf5um


LV Write Access Read/write


LV creation host, Time Localhost.localdomain, 2013-12-09 10:46:23 +0800


LV Status Available


# open 1


LV Size 26.58 GiB


Current LE 6804


Segments 1


Allocation inherit


Read ahead Sectors Auto


-Currently set to 256


Block Device 252:0





---Logical volume---


LV Path/dev/vg_testdb2/lv_swap


LV Name Lv_swap


VG Name VG_TESTDB2


LV UUID AXCKEE-CZEX-PAPL-NDWN-H0VY-ERFC-KISGL7


LV Write Access Read/write


LV creation host, Time Localhost.localdomain, 2013-12-09 10:46:26 +0800


LV Status Available


# open 2


LV Size 2.93 GiB


Current LE 750


Segments 1


Allocation inherit


Read ahead Sectors Auto


-Currently set to 256


Block Device 252:1





[Root@testdb2 ~]#

For Lvextend, note that the size is slightly smaller than the original 8G:


[Root@testdb2 ~]# lvextend-l +7.9g/dev/vg_testdb2/lv_root
Rounding size to boundary between physical extents:7.90 GiB
Extending logical Volume Lv_root to 34.48 GiB
Logical Volume Lv_root successfully resized
[Root@testdb2 ~]#

Note that after lvextend, we look at the file system and there is no expansion, because the RESIZE2FS command is also required:


[root@testdb2 ~]# df-k
filesystem           1K-blocks       Used Available use% mounted on
/dev/mapper/vg_testdb2-lv_root
                        27431124  21329720   4707948  82%/
tmpfs                   3481600        88   3481512   1%/DEV/SHM
/dev/sda1                495844     56258    413986  12%/boot
[ ROOT@TESTDB2 ~]#
RESIZE2FS command:


[Root@testdb2 ~]# Resize2fs/dev/vg_testdb2/lv_root
RESIZE2FS 1.41.12 (17-may-2010)
FileSystem at/dev/vg_testdb2/lv_root is mounted on/; On-line resizing required
Old desc_blocks = 2, new_desc_blocks = 3
Performing a on-line resize of/dev/vg_testdb2/lv_root to 9038848 (4k) blocks.
The filesystem on/dev/vg_testdb2/lv_root is now 9038848 blocks long.

[root@testdb2 ~]# df-k
filesystem           1K-blocks       Used Available use% mounted on
/dev/mapper/vg_testdb2-lv_root
                        35587744  21333800  12448736  64%/
tmpfs                   3481600        88    3481512   1%/DEV/SHM
/dev/sda1                495844     56258    413986  12%/boot
[ ROOT@TESTDB2 ~]#

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.