Eucalyptus FastStart: NC detects wrong disk size - diskspace

I installed the Eucalyptus FastStart Image to familiarize myself with Eucalyptus, but for some reason the NC doesn't detect the correct disk size:
from /var/log/eucalyptus/nc.log:
2015-04-03 17:49:56 INFO | disk space for instances: /var/lib/eucalyptus/instances/work
2015-04-03 17:49:56 INFO | 014328MB limit (0.3% of the file system) - 260MB overhead = 14068MB = 13GB
2015-04-03 17:49:56 INFO | 000000MB reserved for use (0.0% of limit)
2015-04-03 17:49:56 INFO | 000000MB allocated for use (0.0% of limit, 0.0% of the file system)
2015-04-03 17:49:56 INFO | disk space for cache: /var/lib/eucalyptus/instances/cache
2015-04-03 17:49:56 INFO | 029093MB limit (0.7% of the file system)
2015-04-03 17:49:56 INFO | 007168MB reserved for use (24.6% of limit)
2015-04-03 17:49:56 INFO | 002296MB allocated for use (7.9% of limit, 0.1% of the file system)
My root-disk was to small for the /var/lib/ so I mounted another 4TB device to /var/lib/eucalyptus
# cat /etc/fstab | grep euca
/dev/mapper/vg_euca-lv_euca_data /var/lib/eucalyptus xfs defaults 1 1
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_hsun1-lv_root
50G 5.8G 41G 13% /
tmpfs 64G 168K 64G 1% /dev/shm
/dev/sdb1 477M 47M 406M 11% /boot
/dev/mapper/vg_hsun1-lv_home
81G 56M 77G 1% /home
/dev/mapper/vg_euca-lv_euca_data
4.0T 4.2G 4.0T 1% /var/lib/eucalyptus
Is there something wrong with my /var/lib/eucalyptus mount? I unmounted this partition and checked the /var/lib/eucalyptus folder on / which is empty. So the NC can't work at the root partition.
In /etc/eucalyptus/eucalyptus.conf the INSTANCE_PATH is set to: "/var/lib/eucalyptus/instances"
Do you see whats wrong with my setup or do I deal with a bug here?
Thanks for your help in advance!

I think your /var/lib/eucalyptus mount of 4TB is fine.
Eucalyptus won't automatically grab the entire filesystem, at least beyond a certain size.
You may want to take a look at the NC's /etc/eucalyptus/eucalyptus.conf file. These sections should be present (unless you did a Faststart install):
https://github.com/eucalyptus/eucalyptus/blob/e363faae31a26fe630c353a88638db4bf51153a9/tools/eucalyptus.conf#L102-110
Check out the (commented-out) NC_WORK_SIZE and NC_CACHE_SIZE settings. Uncomment them, and set them as appropriate (per the comments noted within the baseline eucalyptus.conf file, linked-to above).

Related

No space left on device even after increasing the volume and partition size on EC2

I have an EC2 instance with 2 EBS volumes. On the root volume, I increased the volume size.
First I modified the volume size on console. Then followed this instruction to extended the partition following this instruction.
However, when running any command, I get No space left on device.
echo "Hello" > hello.txt
-bash: hello.txt: No space left on device
The df -h correctly shows, the total space correctly.
$ df -h
Filesystem Size Used Avail Use% Mounted on
udev 1.9G 0 1.9G 0% /dev
tmpfs 395M 596K 394M 1% /run
/dev/xvda1 30G 19G 9.6G 67% /
tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
/dev/xvdg 10G 6.2G 3.9G 62% /data2
tmpfs 395M 0 395M 0% /run/user/1001
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 30G 0 disk
└─xvda1 202:1 0 30G 0 part /
xvdg 202:96 0 31G 0 disk /data2
The bottom of the guide said,
If the increased available space on your volume remains invisible to
the system, try re-initializing the volume as described in
Initializing Amazon EBS Volumes.
So I followed the instruction to reinitialize the volume.
I used dd to reinitialize.
sudo dd if=/dev/xvda of=/dev/null bs=1M
30720+0 records in
30720+0 records out
32212254720 bytes (32 GB, 30 GiB) copied, 504.621 s, 63.8 MB/s
However, I still get "No space left on device" error. I have done multipe reboot of the instance, I still see the same error.
Update 1: I have a large number of small files 4-10KB. So, I am running out of inodes. Please let me know how to increase the inodes (on ext4 partition)? Thanks.
df -i
Filesystem Inodes IUsed IFree IUse% Mounted on
udev 497270 371 496899 1% /dev
tmpfs 504717 539 504178 1% /run
/dev/xvda1 1966080 1966080 0 100% /
tmpfs 504717 1 504716 1% /dev/shm
tmpfs 504717 4 504713 1% /run/lock
tmpfs 504717 18 504699 1% /sys/fs/cgroup
/dev/xvdg 5242880 39994 5202886 1% /data2
tmpfs 504717 10 504707 1% /run/user/1001
Please let me know how to resolve this error.
You don't need to reinitialise the volumes if you are using the new generations EC2 instance type like M4, M5, T2 and T3.
You have to also expand your volume on EC2 instance:
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/recognize-expanded-volume-linux.html
As I can see your Inode is full, try this command to find the directory:
for i in /*; do echo $i; find $i |wc -l; done
Then, after finding the directory, do:
for i in /path/to/directory/*; do echo $i; find $i |wc -l; done
After that remove those file using:
rm -rf /path/to/fileorfoldername
As you don't want to remove the files, you will have to create a new filesystem using mke2fs and -I parameter for inode size, or keep increasing your root volume more.
Here is a similar question for it:
https://unix.stackexchange.com/questions/26598/how-can-i-increase-the-number-of-inodes-in-an-ext4-filesystem
Also, you can move your files to secondary drive.
You are running out of inodes on your / (root) directory. so to debug it, you need:
Find what are the inodes pointing to or open files something like for i in /*; do echo $i; find $i |wc -l; done
Now look for directories which take more time and then delete that dir

Where is my shared memory object saved?

I'm new to programming and i have programmer some share memory on my beaglebone black which runs on Linux.
I need to make sure that the memory is saved on the Beaglebone blacks ram, and not flash.
The filepath is:
#define FILEPATH "/tmp/mmapped.bin"
fd = open(FILEPATH, O_RDWR | O_CREAT | O_TRUNC, (mode_t)0600);
if (fd == -1) {
perror("Error opening file for writing");
exit(EXIT_FAILURE);
}
coded in C++
Please let me know if any further questions are needed.
The file path /tmp/whatever does not guarantee anything. What you need to do is log into your Beaglebone and see what filesystems are mounted where.
In order to store files in RAM you need to store them on a tmpfs or ramfs filesystem.
On my Fedora Linux laptop if I type mount or cat /proc/mounts I see everything that is mounted. These are the kinds of lines you're looking for:
$ grep tmpfs /proc/mounts
tmpfs /dev/shm tmpfs rw,seclabel,nosuid,nodev 0 0
tmpfs /run tmpfs rw,seclabel,nosuid,nodev,mode=755 0 0
tmpfs /sys/fs/cgroup tmpfs ro,seclabel,nosuid,nodev,noexec,mode=755 0 0
tmpfs /tmp tmpfs rw,seclabel,nosuid,nodev 0 0
So you can see that on Fedora anyway, the /tmp/ directory is a tmpfs and the files in /tmp/ will be in RAM.
One thing to watch for with tmpfs is that the default maximum size is half of RAM. If a file in tmpfs, plus programs using RAM exceeds the RAM size the tmpfs data will go into swap, which will be on Flash, if a Beaglebone even has swap, which I don't remember at the moment.
If there's no swap or it is small then using a tmpfs for big files will cause OOM (out of memory) and break a lot of things so be careful how much you use.

Amazon EC2 resize root device

I have one amazonw ec2 instance and would like to extend root device device form 100G to 500G. After create a new 500G volume and reattached to instance.
I can see volume is there by command $lsblk. However, after I resize the disk. I cannot do it with error "The filesystem is already 26212055 blocks long. Nothing to do!
name#ip-172-1-1-3:~$ df -h
Filesystem Size Used Avail Use% Mounted on
udev 3.9G 8.0K 3.9G 1% /dev
tmpfs 799M 840K 798M 1% /run
/dev/xvda1 99G 92G 3.1G 97% /
name#ip-172-1-1-3:~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE
MOUNTPOINT
xvda 202:0 0 500G 0 disk
└─xvda1 202:1 0 100G 0 part /
name#ip-172-1-1-3:~$sudo resize2fs /dev/xvda1
resize2fs 1.42.9 (4-Feb-2014)
The filesystem is already 26212055 blocks long. Nothing to do!
here's exactly what to do:
df -h #print the name of your boot partition
lsblk #show info on all your block devices
You'll see from that output what the name of the disk is of your root partition. For example, you probably see something like this:
xvde 202:64 0 32G 0 disk
└─xvde1 202:65 0 8G 0 part /
Our goal is to make xvde1 use the whole available space from xvde.
Here's how to resize your partition:
fdisk /dev/xvda (the disk name, not your partition)
This enters into the fdisk utility.
u #Change the display to sectors
p #Print info
d #Delete the partition
n #New partition
p #Primary partition
1 #Partition number
2048 #First sector
Press Enter to accept the default
p #Print info
a #Toggle the bootable flag
1 #Select partition 1
w #Write table to disk and exit
Now, reboot your instance:
reboot
After it comes back do:
resize2fs /dev/xvde1 (the name of your partition, not the block device)
And finally verify the new disk size:
df -h
After I follow #error2007s step 12 with "a" a #Toggle the bootable flag stop and reboot. I can not bring up instance.
Disk /dev/xvda: 536.9 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders, total 1048576000 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 identifier: 0x00000000
Device Boot Start End Blocks Id System
/dev/xvda1 2048 1048575999 524286976 83 Linux
Command (m for help): a
Partition number (1-4): 1
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
name#ip-172-1-1-3:~$ reboot
reboot: Need to be root
name#ip-172-1-1-3:~$ sudo reboot
Broadcast message from name#ip-172-1-1-3
(/dev/pts/1) at 10:18 ...
The system is going down for reboot NOW!
$ ssh -i "a.pem" name#ec2-172.1.1.3.compute-1.amazonaws.com -p 22
ssh: connect to host ec2-172.1.1.3.compute-1.amazonaws.com port 22: Operation timed out
You need to extend the available space:
$ lsblk
xvda 202:0 0 500G 0 disk
└─xvda1 202:1 0 100G 0 part /
$ growpart /dev/xvda 1
$ resize2fs /dev/xvda1

EC2 Storage attached at sda is /dev/xvde1 cannot resize

I have cPanel & WHm installed on an EC2 instance.
The EC2 EBS volume is 100GB
CentOS 6 x86_64 (2014_09_29) EBS pv-1-adc4348e-1dc3-41df-b833-e86ba57a33d6-ami-809020e8.2 (ami-bc8131d4)
This is what df -h shows:
Filesystem Size Used Avail Use% Mounted on
/dev/xvde1 7.8G 6.6G 834M 89% /
tmpfs 3.7G 0 3.7G 0% /dev/shm
/usr/tmpDSK 485M 11M 449M 3% /tmp
The EBS is mounted at /dev/sda
I am trying to increase the size of the xvde1 to almost fill the 100GB
When I run resize2fs /dev/xvde1 i get this:
root#vs1 [~]# resize2fs /dev/xvde1
resize2fs 1.41.12 (17-May-2010)
The filesystem is already 2096896 blocks long. Nothing to do!
I have tried the solution stated here: EC2 Can't resize volume after increasing size
But when i reboot the instance it gets stuck on 1/2 Status Checks
I saw something that stated to start the partition on 16 and also to use the same start as it is in the original configuration. This did not work.
Here is some more information and other things that i have tried:
root#vs1 [~]# resize2fs /dev/xvde1
resize2fs 1.41.12 (17-May-2010)
The filesystem is already 2096896 blocks long. Nothing to do!
root#vs1 [~]# resize2fs /dev/xvde
resize2fs 1.41.12 (17-May-2010)
resize2fs: Device or resource busy while trying to open /dev/xvde
Couldn't find valid filesystem superblock.
root#vs1 [~]# resize2fs /dev/xvde1
resize2fs 1.41.12 (17-May-2010)
The filesystem is already 2096896 blocks long. Nothing to do!
root#vs1 [~]# resize2fs /dev/xvde1 +25G
resize2fs 1.41.12 (17-May-2010)
The containing partition (or device) is only 2096896 (4k) blocks.
You requested a new size of 6553600 blocks.
root#vs1 [~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/xvde1 7.8G 6.6G 834M 89% /
tmpfs 3.7G 0 3.7G 0% /dev/shm
/usr/tmpDSK 485M 11M 449M 3% /tmp
root#vs1 [~]# resize2fs /dev/xvde1 +15g
resize2fs 1.41.12 (17-May-2010)
The containing partition (or device) is only 2096896 (4k) blocks.
You requested a new size of 3932160 blocks.
root#vs1 [~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/xvde1 7.8G 6.6G 834M 89% /
tmpfs 3.7G 0 3.7G 0% /dev/shm
/usr/tmpDSK 485M 11M 449M 3% /tmp
root#vs1 [~]# resize2fs /dev/xvde1
resize2fs 1.41.12 (17-May-2010)
The filesystem is already 2096896 blocks long. Nothing to do!
root#vs1 [~]# fdisk -l
Disk /dev/xvde: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 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: 0x00098461
Device Boot Start End Blocks Id System
/dev/xvde1 * 1 1045 8387584 83 Linux
root#vs1 [~]# Write failed: Broken pipe
This is the last step in a complete build that has taken over 18 hours.
I may just be delirious. Any and all help will be greatly appreciated!
EDIT:
The system log on the server shows this, not sure if it is any help:
Thread "main": pointer: 0x21e0003760, stack: 0x3740000
"main" "root=/dev/sda" "ro" "4"
vbd 2048 is hd0
******************* BLKFRONT for device/vbd/2048 **********
backend at /local/domain/0/backend/vbd/60/2048
209715200 sectors of 512 bytes
**************************
[H[J
GNU GRUB version 0.97 (7864320K lower / 0K upper memory)
[m[4;2H+-------------------------------------------------------------------------+[5;2H|[5;76H|[6;2H|[6;76H|[7;2H|[7;76H|[8;2H|[8;76H|[9;2H|[9;76H|[10;2H|[10;76H|[11;2H|[11;76H|[12;2H|[12;76H|[13;2H|[13;76H|[14;2H|[14;76H|[15;2H|[15;76H|[16;2H|[16;76H|[17;2H+-------------------------------------------------------------------------+[m
Use the ^ and v keys to select which entry is highlighted.
Press enter to boot the selected OS, 'e' to edit the
commands before booting, or 'c' for a command-line.[5;78H [m[7m[5;3H CentOS (2.6.32-504.el6.x86_64) [5;75H[m[m[6;3H CentOS (2.6.32-431.29.2.el6.x86_64) [6;75H[m[m[7;3H [7;75H[m[m[8;3H [8;75H[m[m[9;3H [9;75H[m[m[10;3H [10;75H[m[m[11;3H [11;75H[m[m[12;3H [12;75H[m[m[13;3H [13;75H[m[m[14;3H [14;75H[m[m[15;3H [15;75H[m[m[16;3H [16;75H[m[16;78H [5;75H[23;4H The highlighted entry will be booted automatically in 1 seconds. [5;75H[H[J Booting 'CentOS (2.6.32-504.el6.x86_64)'
root (hd0,0)
Filesystem type is ext2fs, partition type 0x83
kernel /boot/vmlinuz-2.6.32-504.el6.x86_64 ro root=LABEL=_ console=ttyS0,115200
crashkernel=no SYSFONT=latarcyrheb-sun16 LANG=en_US.UTF-8 KEYTABLE=us
initrd /boot/initramfs-2.6.32-504.el6.x86_64.img
============= Init TPM Front ================
Tpmfront:Error Unable to read device/vtpm/0/backend-id during tpmfront initialization! error = ENOENT
Tpmfront:Info Shutting down tpmfront
Before resizing the filesystem by "resize2fs" command you should first resize your partition:
let's list block devices attached to our box:
lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 16G 0 disk
└─xvda1 202:1 0 8G 0 part /
As you can see /dev/xvda1 is only 8 GiB partition on a 16 GiB device and there are no other partitions on the volume.
step-1) We will use "growpart" to resize 8G partition up to 16G:
# install "cloud-guest-utils" if it is not installed already
apt install cloud-guest-utils
# resize partition
growpart /dev/xvda 1
Let's check the result (you can see /dev/xvda1 is now 16G):
lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 16G 0 disk
└─xvda1 202:1 0 16G 0 part /
Lots of SO answers suggest to use fdisk with delete / recreate partitions, which is nasty, risky, error-prone process especially when we change boot drive.
step-2) resize file system to grow all the way to fully use new partition space
# Check before resizing ("Avail" shows 1.1G):
df -h
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 7.8G 6.3G 1.1G 86% /
# resize filesystem
resize2fs /dev/xvda1
# Check after resizing ("Avail" now shows 8.7G!-):
df -h
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 16G 6.3G 8.7G 42% /
And by the way, there's no need to stop instance and detach EBS volume to resize it anymore! 13-Feb-2017 Amazon announced: "Amazon EBS Update – New Elastic Volumes Change Everything" See my other SO answer for details.
Update: Use sudo xfs_growfs /dev/xvda1 instead of resize2fs when XFS filesystem
This answer is dangerous, hasn't been verified since 2016, and has the potential to delete your partition if you're not aware of what's happening. Use with caution, and please reference #Dmitry's answer below as well.
To expand on JD's answer, here's exactly what to do:
df -h #print the name of your boot partition
lsblk #show info on all your block devices
You'll see from that output what the name of the disk is of your root partition. For example, you probably see something like this:
xvde 202:64 0 32G 0 disk
└─xvde1 202:65 0 8G 0 part /
Our goal is to make xvde1 use the whole available space from xvde.
Here's how to resize your partition:
fdisk /dev/xvda (the disk name, not your partition)
This enters into the fdisk utility.
u #Change the display to sectors
p #Print info
d #Delete the partition
n #New partition
p #Primary partition
1 #Partition number
2048 #First sector
Press Enter to accept the default
p #Print info
a #Toggle the bootable flag
1 #Select partition 1
w #Write table to disk and exit
Now, reboot your instance:
reboot
After it comes back do:
resize2fs /dev/xvde1 (the name of your partition, not the block device)
And finally verify the new disk size:
df -h
After searching and searching with no answer here, i FINALLY came across the answer!
"fdisk, put it into 'units' mode by typing 'u' then 'p' to print the partition table as it is now and write down the starting sector of the existing partition. Then delete that partition and make a new one, with the same partition number and starting on exactly the same sector and ending at the end of the disk, make sure that partition is 'active' then save your changes and reboot. Once you reboot after that, you should be able to resize2fs the existing filesystem to take up all space. Backups are recommended and it's your data to lose!!"
Putting it into sectors via Units mode helped me select the proper start and end of the FS!!
Credit: https://www.centos.org/forums/viewtopic.php?t=4783
I know the question is answered already. But still, if someone is stuck with the problem and need a more detailed step by step explanation. You can check out the official Amazon docs. This has the steps to increase the size and specific commands if you are using the "ec2-user (amazon ami)" instance.
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/recognize-expanded-volume-linux.html
also if you are using windows instance. You can visit
"For information about extending a Windows file system, see Extending a Windows file system after resizing a volume in the Amazon EC2 User Guide for Windows Instances."
https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/recognize-expanded-volume-windows.html
None of the above answers helped me. Here is something to consider for centos.
I wanted to extend my root volume from 8GB to 16GB
[root#ip-10-0-0-218 ~]# cat /etc/centos-release
CentOS Linux release 8.2.2004 (Core)
Determine the current state
[root#ip-10-0-0-218 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
nvme0n1 259:0 0 60G 0 disk
├─nvme0n1p1 259:1 0 600M 0 part /boot/efi
└─nvme0n1p2 259:2 0 7.8G 0 part /
First attempt to increase space (failed)
[root#ip-10-0-0-218 /]# xfs_growfs -d /dev/nvme0n1p2
meta-data=/dev/nvme0n1p2 isize=512 agcount=4, agsize=508800 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=0
= reflink=1
data = bsize=4096 blocks=2035200, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data size unchanged, skipping
Use Parted
[root#ip-10-0-0-218 ~]# parted
GNU Parted 3.2
Using /dev/nvme0n1
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) resizepart 2 +20GiB
Warning: Partition /dev/nvme0n1p2 is being used. Are you sure you want to continue?
Yes/No? Yes
End? [8966MB]? 16966MB
quit
Now extend the size (success)
[root#ip-10-0-0-218 ~]# xfs_growfs /dev/nvme0n1p2
meta-data=/dev/nvme0n1p2 isize=512 agcount=4, agsize=508800 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=0
= reflink=1
data = bsize=4096 blocks=2035200, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 2035200 to 3988233
Verify
[root#ip-10-0-0-218 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 1.7G 0 1.7G 0% /dev
tmpfs 1.7G 0 1.7G 0% /dev/shm
tmpfs 1.7G 22M 1.7G 2% /run
tmpfs 1.7G 0 1.7G 0% /sys/fs/cgroup
/dev/nvme0n1p2 16G 7.1G 8.2G 47% /
/dev/nvme0n1p1 599M 6.4M 593M 2% /boot/efi
tmpfs 345M 0 345M 0% /run/user/1000
1. Confirm the kernel.
~]# uname -r
2.6.32-431.29.2.el6.x86_64
2. Confirm the initial allocated size
]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 7.9G 797M 6.7G 11% /
tmpfs 498M 0 498M 0% /dev/shm
# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 **15G 0 disk**
└─xvda1 202:1 0 **8G 0 part /**
3. Install EPEL6 Repo
~]# wget http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
~]# rpm -ivh epel-release-6-8.noarch.rpm
3. Install the dracut & cloud-utils growpart modules-growroot
~]# yum install -y dracut-modules-growroot cloud-utils-growpart
4. The initrd needs to be rebuilt after installing the dracut-modules-growroot.
Create a backup copy of the current initramfs:
~]# cp -p /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r).img.bak
(ii)Create the initramfs for the current kernel:
~]# dracut -f
4. Result after reboot
~]# reboot
~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 **15G 0 disk**
└─xvda1 202:1 0 **15G 0 part /**
~]# resize2fs /dev/xvda1
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/xvda1 is mounted on /; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 1
Performing an on-line resize of /dev/xvda1 to 3931652 (4k) blocks.
The filesystem on /dev/xvda1 is now 3931652 blocks long.
~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 **15G** 932M 14G 7% /
tmpfs 498M 0 498M 0% /dev/shm

Resizing disk space on vagrant box

I'd like to give my box some more disk space. I'm trying to do this through the vagrantfile as follows:
Vagrant::Config.run do |config|
# ..
config.vm.customize ["modifyvm", :id, "--memory", 1024]
config.vm.customize ["modifyhd", :id, "--resize", 4096]
end
This gives me the error:
A customization command failed:
["modifyhd", "e87d8786-88be-4805-9c2a-45e88b8e0e56", "--resize", "4096"]
The following error was experienced:
VBoxManage: error: The given path 'e87d8786-88be-4805-9c2a-45e88b8e0e56' is not fully qualified
VBoxManage: error: Details: code VBOX_E_FILE_ERROR (0x80bb0004), component Medium, interface IMedium, callee nsISupports
VBoxManage: error: Context: "OpenMedium(Bstr(pszFilenameOrUuid).raw(), enmDevType, enmAccessMode, fForceNewUuidOnOpen, pMedium.asOutParam())" at line 178 of file VBoxManageDisk.cpp
Please fix this customization and try again.
I'm trying to piece the information together from http://docs.vagrantup.com/v1/docs/config/vm/customize.html
http://www.virtualbox.org/manual/ch08.html#vboxmanage-modifyvdi
You are sending modifyhd the UUID of the VM (provided by vagrant) while it expects the UUID of the VDI.
You will need to use the absolute path to the actual VDI file or its UUID. You can use the following command to get the UUID of the VDI: VBoxManage showhdinfo <filename> (see virtualbox - how to check what is the uuid of a vdi?)
I created a new disk, added and extended the older.
My Vagrantfile:
Vagrant.configure(2) do |config|
config.vm.box = "bseller/oracle-standard"
config.vm.define :oracle do |oracle|
oracle.vm.hostname = 'oraclebox'
oracle.vm.synced_folder ".", "/vagrant", owner: "oracle", group: "oinstall"
oracle.vm.network :private_network, ip: '192.168.33.13'
oracle.vm.network :forwarded_port, guest: 1521, host: 1521
oracle.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", "4096"]
vb.customize ["modifyvm", :id, "--name", "oraclebox"]
if !File.exist?("disk/oracle.vdi")
vb.customize [
'createhd',
'--filename', 'disk/oracle',
'--format', 'VDI',
'--size', 60200
]
vb.customize [
'storageattach', :id,
'--storagectl', "SATA",
'--port', 1, '--device', 0,
'--type', 'hdd', '--medium', 'disk/oracle.vdi'
]
end
end
oracle.vm.provision "shell", path: "shell/add-oracle-disk.sh"
oracle.vm.provision "shell", path: "shell/provision.sh"
end
end
This will create new disk in
disk
|-- oracle.vdi
shell
|-- provision.sh
Vagrantfile
and add in your box. The new disk is of 60GB
My shell provision.sh
set -e
set -x
if [ -f /etc/disk_added_date ] ; then
echo "disk already added so exiting."
exit 0
fi
sudo fdisk -u /dev/sdb <<EOF
n
p
1
t
8e
w
EOF
sudo pvcreate /dev/sdb1
sudo vgextend VolGroup /dev/sdb1
sudo lvextend -L50GB /dev/VolGroup/lv_root
sudo resize2fs /dev/VolGroup/lv_root
date > /etc/disk_added_date
This script was adapted from SHC to box bseller/oracle-standard. For full code, see my project oraclebox in GitHub
I've been looking at this, and I haven't found any way to actually do this directly. However, you can achieve the effect using Ansible as a provisioner. First of all, it is definitely possible with Vagrant to create and add a second disk, which you can then add and mount any way you like using Ansible.
However, Ansible also has the ability to run local commands (on the host). This is with Ansible's local_action feature. I used it here to reboot a Vagrant VM after a kernel upgrade and tell the host to wait until it has restarted, but you could use this with the command or shell actions to find the HD identifier, shutdown the VM, and configure the hard disk, then reboot. At least in theory.
Although the question is old but I saw no answer accepted.
The given path 'e87d8786-88be-4805-9c2a-45e88b8e0e56' is not fully qualified shows up because the UUID e87d8... is VirtualBox vm UUID, not your SATA storage disk device UUID. You an find the storage device UUID by VBoxManage showvminfo e87d8786-88be-4805-9c2a-45e88b8e0e56|grep vdi. The replace :id with the SATA storage UUID in Vagrantfile modifyhd line.
It solved my problem.
OK... Solved...
VBoxManage.exe wan't in my path so what I did was go to (you have to go to that path):
C:\Program Files\Oracle\VirtualBox
then used the command:
VBoxManage.exe modifyhd "C:\Users\MyUser\VirtualBox VMs\MachineName\HDName.vdi " --resize 20480
For 20 GB size a HD
This DON'T work:
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" modifyhd "C:\Users\MyUser\VirtualBox VMs\MachineName\HDName.vdi " --resize 20480
You have to be in the path: C:\Program Files\Oracle\VirtualBox
You can add new disk instead.
First use virtual box GUI to add another
virtual disk
then use fdisk to create a primary disk partion
root#linux-dev:/# fdisk -l
Disk /dev/sdb: 20 GiB, 21474836480 bytes, 41943040 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/sda: 9.9 GiB, 10632560640 bytes, 20766720 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
Disklabel type: dos
Disk identifier: 0x83312a2b
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 19816447 19814400 9.5G 83 Linux
/dev/sda2 19818494 20764671 946178 462M 5 Extended
/dev/sda5 19818496 20764671 946176 462M 82 Linux swap / Solaris
root#linux-dev:/# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.25.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0x5eb328b9.
Command (m for help): m
Help:
DOS (MBR)
a toggle a bootable flag
b edit nested BSD disklabel
c toggle the dos compatibility flag
Generic
d delete a partition
l list known partition types
n add a new partition
p print the partition table
t change a partition type
v verify the partition table
Misc
m print this menu
u change display/entry units
x extra functionality (experts only)
Save & Exit
w write table to disk and exit
q quit without saving changes
Create a new label
g create a new empty GPT partition table
G create a new empty SGI (IRIX) partition table
o create a new empty DOS partition table
s create a new empty Sun partition table
Command (m for help): p
Disk /dev/sdb: 20 GiB, 21474836480 bytes, 41943040 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
Disklabel type: dos
Disk identifier: 0x5eb328b9
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-41943039, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-41943039, default 41943039):
Created a new partition 1 of type 'Linux' and of size 20 GiB.
Command (m for help): p
Disk /dev/sdb: 20 GiB, 21474836480 bytes, 41943040 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
Disklabel type: dos
Disk identifier: 0x5eb328b9
Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 41943039 41940992 20G 83 Linux
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
Make newly created disk partition a ext4 filesystem
root#linux-dev:/# mkfs.ext4 /dev/sdb1
mke2fs 1.42.12 (29-Aug-2014)
Creating filesystem with 5242624 4k blocks and 1310720 inodes
Filesystem UUID: 0301b56a-1d80-42de-9334-cc49e4eaf7b2
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
Mount the disk partition to a directory
root#linux-dev:/# mount -t ext4 /dev/sdb1 /home/chenchun
root#linux-dev:/# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 9.2G 3.3G 5.5G 38% /
udev 10M 0 10M 0% /dev
tmpfs 74M 4.4M 70M 6% /run
tmpfs 185M 0 185M 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 185M 0 185M 0% /sys/fs/cgroup
none 372G 240G 133G 65% /vagrant
/dev/sdb1 20G 44M 19G 1% /home/chenchun