How to resize OVH Public Cloud disk in CentOS 7 linux

I’m going to resize 100G SSD to 150GB SSD in Public Cloud

First I check the current mounted disk
[code lang=”shell”]
[[email protected] ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 40G 2.4G 36G 7% /
devtmpfs 3.8G 0 3.8G 0% /dev
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 3.9G 17M 3.8G 1% /run
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
tmpfs 780M 0 780M 0% /run/user/1000
/dev/vdb 99G 84G 9.7G 90% /mnt/data
[/code]

Then I’m going to umount it
[code lang=”shell”]
[[email protected] ~]# umount /dev/vdb
[[email protected] ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 40G 2.4G 36G 7% /
devtmpfs 3.8G 0 3.8G 0% /dev
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 3.9G 17M 3.8G 1% /run
[/code]

I use the OVH interface to Backup first, then Detach the disk, and resize it to 150GB then Save.
And now back to the shell.

[code lang=”shell”]
[[email protected] ~]# fdisk -l

Disk /dev/vda: 42.9 GB, 42949672960 bytes, 83886080 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: 0x000161a3

Device Boot Start End Blocks Id System
/dev/vda1 * 2048 83883491 41940722 83 Linux

Disk /dev/vdb: 161.1 GB, 161061273600 bytes, 314572800 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
[/code]
Use e2fsck to chekc the file systems.

[code lang=”shell”]
[[email protected] ~]# e2fsck /dev/vdb
e2fsck 1.42.9 (28-Dec-2013)
/dev/vdb: clean, 62/6553600 files, 22382398/26214144 blocks

[[email protected] ~]# resize2fs /dev/vdb
resize2fs 1.42.9 (28-Dec-2013)
Please run ‘e2fsck -f /dev/vdb’ first.

[[email protected] ~]# e2fsck -f /dev/vdb
e2fsck 1.42.9 (28-Dec-2013)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/vdb: 62/6553600 files (56.5% non-contiguous), 22382398/26214144 blocks
[/code]

Resize using resize2fs

[code lang=”shell”]
[[email protected] ~]# resize2fs /dev/vdb
resize2fs 1.42.9 (28-Dec-2013)
Resizing the filesystem on /dev/vdb to 39321600 (4k) blocks.
The filesystem on /dev/vdb is now 39321600 blocks long.
[/code]

Mount again to our system.

[code lang=”shell”]
[[email protected] ~]# mount /dev/vdb /mnt/data
[[email protected] ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 40G 2.4G 36G 7% /
devtmpfs 3.8G 0 3.8G 0% /dev
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 3.9G 17M 3.8G 1% /run
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
tmpfs 780M 0 780M 0% /run/user/1000
/dev/vdb 148G 84G 57G 60% /mnt/data
[/code]

You can see the Size increased.
Always backup before you do any change to disk.
Please take your own risk on these command in Linux.

How to Install MongoDB 3.2 on CentOS 7

[code lang=”shell”]
vim /etc/yum.repos.d/mongodb.repo
[/code]
Paste this to the file and save using :wq
[code lang=”shell”]

[MongoDB]
name=MongoDB Repository
baseurl=http://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.2/x86_64/
gpgcheck=0
enabled=1
[/code]
Download and install mongodb using yum
[code lang=”shell”]
yum install mongodb-org -y
[/code]
Start mongod and configure auto start while system boot
[code lang=”shell”]
/etc/init.d/mongod restart
chkconfig mongod on
[/code]
Check all the versions
[code lang=”shell”]
[[email protected] ~]# mongo –version
MongoDB shell version: 3.2.3
[[email protected] ~]# mongod –version
db version v3.2.3
git version: b326ba837cf6f49d65c2f85e1b70f6f31ece7937
OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 2013
allocator: tcmalloc
modules: none
build environment:
distmod: rhel70
distarch: x86_64
target_arch: x86_64
[/code]
Test the connection
[code lang=”shell”]
[[email protected] ~]# mongo
MongoDB shell version: 3.2.3
> use test
switched to db test
> db.test.save( { juzhax: 1 } )
WriteResult({ "nInserted" : 1 })
> db.test.find()
{ "_id" : ObjectId("56d4ac48b376b143e4749229"), "juzhax" : 1 }
[/code]