How to increase the hard disk space of thin provisioning vm - linux

Created thin provisioning vm(centos 7) with 50 GB hard disk. But it doesnt automatically increase the space when there is a need. Can someone please tell how to increase the space of "/" directory.
[oracle#localhost ~]$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 14G 14G 16K 100% /
devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs 1.9G 912M 985M 49% /dev/shm
tmpfs 1.9G 17M 1.9G 1% /run
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/sda1 497M 147M 351M 30% /boot
tmpfs 380M 0 380M 0% /run/user/1001
tmpfs 380M 0 380M 0% /run/user/1002
Below are the output of pvs command.
[root#inches-rmdev01 ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 centos lvm2 a-- 15.51g 40.00m
Below are the output of vgs command.
[root#inches-rmdev01 ~]# vgs
VG #PV #LV #SN Attr VSize VFree
centos 1 2 0 wz--n- 15.51g 40.00m
Below are the output of lvs command.
[root#inches-rmdev01 ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root centos -wi-ao---- 13.87g
swap centos -wi-ao---- 1.60g
Below are the output of fdisk command.
[root#inches-rmdev01 ~]# fdisk -l
Disk /dev/sda: 53.7 GB, 53687091200 bytes, 104857600 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: 0x0009a61a
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 1026047 512000 83 Linux
/dev/sda2 1026048 33554431 16264192 8e Linux LVM
/dev/sda3 33554432 104857599 35651584 8e Linux LVM
Disk /dev/mapper/centos-root: 14.9 GB, 14889779200 bytes, 29081600 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: 1719 MB, 1719664640 bytes, 3358720 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

In the fdisk -l output you can see that you have a 35GB disk /dev/sda3. To extend your root volume you can add this disk to LVM (Logical Volume Manager):
pvcreate /dev/sda3
This will add the unused disk /dev/sda3 as a new pv (physical volume) to LVM.
Next step is to extend your root vg (volumegroup). In your case it is easy since you've got only one vg:
vgextend centos /dev/sda3
Now you have added the 35GB disk to your vg and you can distribute it to your lv's (logical volume).
Finaly you can add as much space as you need (up to 35GB) to your root-volume with the lvextend command:
If you want to use the whole 35GB you can use:
lvextend -l +100%FREE /dev/mapper/centos-root
If you only want to add a certain ammount (i.e 1G) you can use this:
lvextend -L +1G /dev/mapper/centos-root
And finaly resize your filesystem:
resize2fs /dev/mapper/centos-root
The LVM logic is:
1. Harddisk fdisk -l
2. Physical Volume pvs
3. Volume Group vgs
4. Logical Volume lvs

Related

Why does my primary partition not reflect the total disk space?

I remotely ssh'd and resized my primary partition with parted (rebooted as well and updated /etc/fstab) to give it more space.
Why on earth is my primary ext4 partition not reflecting the free space?
~# df -h
Filesystem Size Used Avail Use% Mounted on
udev 985M 0 985M 0% /dev
tmpfs 200M 3.5M 197M 2% /run
/dev/sda1 7.8G 7.5G 0 100% /
tmpfs 999M 0 999M 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 999M 0 999M 0% /sys/fs/cgroup
tmpfs 200M 0 200M 0% /run/user/0
~# fdisk -l
Disk /dev/sda: 20 GiB, 21474836480 bytes, 41943040 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x010920b9
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 41943039 41940992 20G 83 Linux
Any ideas? I must have forgotten something really simple.
Execute parted and then print free. This will print free space of your system.

Using SD card as external storage for Beaglebone Black

After following instructions found here:
http://elinux.org/Beagleboard:MicroSD_As_Extra_Storage
and here:
http://electronicsembedded.blogspot.com/2014/10/beaglebone-black-using-sd-card-as-extra.html?showComment=1434418179676#c2761158033046523777
I am still having trouble. I use the code it says to use and followed the instructions, I get 3 solid LED on the board upon load up with the SD inserted, and Windows 7 doesn't detect it at all.
The board works fine without the SD inserted, I can boot up and login via SSH and it is detected by Windows.
The code for my uEnv.txt is as follows:
mmcdev=1
bootpart=1:2
mmcroot=/dev/mmcblk1p2 ro
optargs=quiet
and I also added to the fstab file:
/dev/mmcblk0p1 /media/card auto auto,rw,async,user,nofail 0 0
Some results from checking the filesystem, my drive is called 'BBB_Ext'. This is after booting without the SD in it, and then putting it in after bootup:
root#beaglebone:~# df -h
Filesystem Size Used Avail Use% Mounted on
rootfs 3.5G 1.8G 1.5G 55% /
/dev/root 3.5G 1.8G 1.5G 55% /
devtmpfs 250M 0 250M 0% /dev
tmpfs 250M 4.0K 250M 1% /dev/shm
tmpfs 250M 248K 250M 1% /run
tmpfs 250M 0 250M 0% /sys/fs/cgroup
tmpfs 250M 4.0K 250M 1% /tmp
/dev/mmcblk0p1 70M 54M 16M 78% /media/card
/dev/mmcblk1p1 15G 16K 15G 1% /media/BBB_Ext_
Here is more details on the fdisk:
root#beaglebone:~# fdisk -l
Disk /dev/mmcblk0: 3867 MB, 3867148288 bytes, 7553024 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/mmcblk0p1 * 63 144584 72261 c W95 FAT32 (LBA)
/dev/mmcblk0p2 144585 7550549 3702982+ 83 Linux
Disk /dev/mmcblk0boot1: 2 MB, 2097152 bytes, 4096 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/mmcblk0boot0: 2 MB, 2097152 bytes, 4096 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/mmcblk1: 15.9 GB, 15931539456 bytes, 31116288 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/mmcblk1p1 2048 31115263 15556608 c W95 FAT32 (LBA)
Any help would be appreciated. I figured since this is Linux related that the question is applicable to SO, if it's better off in SE plz let me know.
For what I got, the uEnv.txt should be (saved on your SD card):
mmcdev=1
bootpart=1:2
mmcroot=/dev/mmcblk1p2 ro
optargs=quiet
And add below line in /etc/fstab
/dev/mmcblk0p1 /media/data auto rw 0 0
Ok I believe I resolved the issue (for anyone who cares)
After looking at the fdisk log I realized that I needed to change the fstab line to be:
/dev/mmcblk1p1 /media/card auto rw 0 0
and then I also changed the uEnv.txt to be:
mmcdev=1
bootpart=1:2
mmcroot=/dev/mmcblk0p2 ro
optargs=quiet
From my understanding it was trying to boot off of a disk that wasn't there and that caused the problem. In addition, I didn't fix the fstab to be the correct port for the drive, which can be seen at the bottom of the fdisk check:
Device Boot Start End Blocks Id System
/dev/mmcblk1p1 2048 31115263 15556608 c W95 FAT32 (LBA)

Docker cgroup.procs no space left on device

After some problem with Docker and my dedicated server with a Debian (the provider give some OS image without some features needed by Docker, so I recompiled Linux kernel yesterday and activate the features needed, I followed some instruction in blog).
Now I was happy to have success with docker I tried to create image... and I have an error.
$ docker run -d -t -i phusion/baseimage /sbin/my_init -- bash -l
Unable to find image 'phusion/baseimage:latest' locally
Pulling repository phusion/baseimage
5a14c1498ff4: Download complete
511136ea3c5a: Download complete
53f858aaaf03: Download complete
837339b91538: Download complete
615c102e2290: Download complete
b39b81afc8ca: Download complete
8254ff58b098: Download complete
ec5f59360a64: Download complete
2ce4ac388730: Download complete
2eccda511755: Download complete
Status: Downloaded newer image for phusion/baseimage:latest
0bd93f0053140645a930a3411972d8ea9a35385ac9fafd94012c9841562beea8
FATA[0039] Error response from daemon: Cannot start container 0bd93f0053140645a930a3411972d8ea9a35385ac9fafd94012c9841562beea8: [8] System error: write /sys/fs/cgroup/docker/0bd93f0053140645a930a3411972d8ea9a35385ac9fafd94012c9841562beea8/cgroup.procs: no space left on device
More informations :
$ docker info
Containers: 3
Images: 12
Storage Driver: devicemapper
Pool Name: docker-8:1-275423-pool
Pool Blocksize: 65.54 kB
Backing Filesystem: extfs
Data file: /dev/loop0
Metadata file: /dev/loop1
Data Space Used: 814.4 MB
Data Space Total: 107.4 GB
Data Space Available: 12.22 GB
Metadata Space Used: 1.413 MB
Metadata Space Total: 2.147 GB
Metadata Space Available: 2.146 GB
Udev Sync Supported: false
Data loop file: /var/lib/docker/devicemapper/devicemapper/data
Metadata loop file: /var/lib/docker/devicemapper/devicemapper/metadata
Library Version: 1.02.82-git (2013-10-04)
Execution Driver: native-0.2
Kernel Version: 3.19.0-xxxx-std-ipv6-64
Operating System: Debian GNU/Linux 8 (jessie)
CPUs: 4
Total Memory: 7.691 GiB
Name: ns3289160.ip-5-135-180.eu
ID: JK54:ZD2Q:F75Q:MBD6:7MPA:NGL6:75EP:MLAN:UYVU:QIPI:BTDP:YA2Z
System :
$ df -h
Filesystem Size Used Avail Use% Mounted on
udev 10M 0 10M 0% /dev
tmpfs 788M 456K 788M 1% /run
/dev/sda1 20G 7.8G 11G 43% /
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 1.7G 4.0K 1.7G 1% /dev/shm
/dev/sda2 898G 11G 842G 2% /home
Edit: command du -sk /var
# du -sk /var
3927624 /var
Edit: command fdisk -l
# fdisk -l
Disk /dev/loop0:
100 GiB, 107374182400 bytes, 209715200 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/loop1: 2 GiB, 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/sda: 931.5 GiB, 1000204886016 bytes, 1953525168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x00060a5c
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 4096 40962047 40957952 19.5G 83 Linux
/dev/sda2 40962048 1952471039 1911508992 911.5G 83 Linux
/dev/sda3 1952471040 1953517567 1046528 511M 82 Linux swap / Solaris
Disk /dev/mapper/docker-8:1-275423-pool: 100 GiB, 107374182400 bytes, 209715200 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 65536 bytes / 65536 byte
You should not remove cgroup support in docker. Otherwise you may get warning like WARNING: Your kernel does not support memory swappiness capabilities, memory swappiness discarded. when you run a docker container.
A simple command should do the trick.
sudo echo 1 > /sys/fs/cgroup/docker/cgroup.clone_children
If it still does not work, run below commands and restart docker service:
sudo echo 0 > /sys/fs/cgroup/docker/cpuset.mems
sudo echo 0 > /sys/fs/cgroup/docker/cpuset.cpus
I installed docker via docker-lxc in the debian repos, I followed a tuto. I tried another solution (with success), I updated my source.list /etc/apt/source.list from jessie to sid, I removed docker-lxc with a purge and I installed docker.io.
The error changed. It was mkdir -p /sys/... can't create dir : access denied
So I find a comment in a blog and I tried the solution it was to comment this line previously added by the tutorial :
## file /etc/fstab
# cgroup /sys/fs/cgroup cgroup defaults 0 0
and reboot the server.
yum install -y libcgroup libcgroup-devel libcgroup-tools
cgclear
service cgconfig restart
mount -t cgroup none /cgroup
vi /etc/fstab
cgroup /sys/fs/cgroup cgroup defaults 0 0

How to mount an attached EC2 volume in CLI?

I just recovered data from an ec2 snapshot and created a volume with the data, i also attached the volume to my working instance, but I have problems mounting the new volume. On ec2-describe-volumes, I do get the find new volume created.
i-14305121 /dev/sdi
How do I mount this /dev/sdi on to a directory so that I can access the files on it? I tried mount /dev/sdi, but I got an error: mount: special device /dev/sdi does not exist.
On running lsblk from terminal, i get this
dev1#ip-10-244-164-7:/$ lsblk /dev/sdi
lsblk: /dev/sdi: not a block device
dev1#ip-10-244-164-7:/$ lsblk /dev/xvdi
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvdi 202:128 0 8G 0 disk
On running mount /dev/xvdi, I also get this error. Other details of fdisk, mtab are also given here:
dev1#ip-10-244-164-7:/$ sudo mount /dev/xvdi /backup
mount: can't find /backup in /etc/fstab or /etc/mtab
dev1#ip-10-244-164-7:/$ cat /etc/fstab
LABEL=cloudimg-rootfs / ext4 defaults 0 0
dev1#ip-10-244-164-7:/$ cat etc/mtab
/dev/xvda1 / ext4 rw 0 0
proc /proc proc rw,noexec,nosuid,nodev 0 0
sysfs /sys sysfs rw,noexec,nosuid,nodev 0 0
none /sys/fs/cgroup tmpfs rw 0 0
none /sys/fs/fuse/connections fusectl rw 0 0
none /sys/kernel/debug debugfs rw 0 0
none /sys/kernel/security securityfs rw 0 0
udev /dev devtmpfs rw,mode=0755 0 0
devpts /dev/pts devpts rw,noexec,nosuid,gid=5,mode=0620 0 0
tmpfs /run tmpfs rw,noexec,nosuid,size=10%,mode=0755 0 0
none /run/lock tmpfs rw,noexec,nosuid,nodev,size=5242880 0 0
none /run/shm tmpfs rw,nosuid,nodev 0 0
none /run/user tmpfs rw,noexec,nosuid,nodev,size=104857600,mode=0755 0 0
dev1#ip-10-244-164-7:/$ sudo fdisk -l
Disk /dev/xvda1: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders, total 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 identifier: 0x00000000
Disk /dev/xvda1 doesn't contain a valid partition table
Disk /dev/xvdi: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders, total 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 identifier: 0x00000000
Disk /dev/xvdi doesn't contain a valid partition table
dev1#ip-10-244-164-7:/$
I'm not sure if this is a good answer, try running:
lsblk /dev/sdi
And it may list partitions that exists on that drive like this:
sdi
|--sdi1
|--sdi2
|--sdi3
If you have something like sdi1 you can try to mount it:
mount /dev/sdi1 /your/folder/here
Hope it helps.
I think you should try
mount /dev/xvdi /your/folder
In EC2 devices are named differently from what they promise in AWS console. See EC2: EBS device id confusion (/dev/sdf vs. /dev/xvdf)

vmware enlarging space for linux

Its maybe stupid question but how can i enlarge my linux machine from 20 to 40gb? i need to increase my / space. I made it on vmware and its says 40gb now but if i make :
df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/zabbix-root 19G 17G 789M 96% /
udev 489M 4.0K 489M 1% /dev
tmpfs 200M 276K 199M 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 498M 0 498M 0% /run/shm
/dev/sda1 228M 25M 192M 12% /boot
or
fdisk -l
Disk /dev/mapper/zabbix-root: 20.1 GB, 20124270592 bytes
255 heads, 63 sectors/track, 2446 cylinders, total 39305216 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
Disk /dev/mapper/zabbix-root doesn't contain a valid partition table
Disk /dev/mapper/zabbix-swap_1: 1069 MB, 1069547520 bytes
255 heads, 63 sectors/track, 130 cylinders, total 2088960 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
i still se only 20gb... How can i mount another 20gb?
Thanks a lot.
Depending on your distribution, probably something like that:
reboot or echo "- - -" > /sys/class/scsi_host/host0/rescan
Now that Linux is aware of the disk size change, use pvextend to extend you PV.
Using vgdisplay, make sure that you have free space on your VG.
Extend your LV using lvextend and finally, use resize2fs to change your FS.

Resources