How to clear dev/md2
Hi guys, how to clear /dev/md2 mounted to /
It shows that is 100% full... but I don't know which folders belongs to that. I cant start mysql coz it show that this is full? How to know which folders to check and what to do to fee space on that?
Here is df
[root@lajkula ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
devtmpfs 16261964 0 16261964 0% /dev
tmpfs 16274252 0 16274252 0% /dev/shm
tmpfs 16274252 10780 16263472 1% /run
tmpfs 16274252 0 16274252 0% /sys/fs/cgroup
/dev/md2 102283476 100417112 20 100% /
/dev/sda1 522984 3648 519336 1% /boot/efi
/dev/md4 3742685384 1377251424 2175245828 39% /home2
/dev/loop0 3997376 22628 3765036 1% /tmp
tmpfs 3254852 0 3254852 0% /run/user/0
-
/dev/md2 is a software raid. If you look at the very end of the line "/" is mounted there. Based on your other mounts, it's anything other than /home2. My guess is it would either be something in /var/log or your MySQL databases. 0 -
/dev/md2 is a software raid. If you look at the very end of the line "/" is mounted there. Based on your other mounts, it's anything other than /home2. My guess is it would either be something in /var/log or your MySQL databases.
So you say tha I need to need to delete files feom /home2 or mysql database to clear space on that softvare raid partition or?0 -
No, /home2 is only 39% full. If you do this: du --max-depth=1 -h / you see what folders are using most space. Probably /home /var and /usr are using most of the space. 0 -
That output shows that the "/" partition itself is what is full. This is the root of the server, and on your machine that contains everything except /home2. Like @quietFinn said, you'll want to fun that command from / itself so you can see where the most space is being used, and then you can make decisions from there. We have some additional details on this process here: 0 -
I recently had this problem on two mission critical servers. Below are the steps if using XFS. If you are using something different google for the process. Is this a VM or metal? If metal slot a new drive then expand the filesystem to use the new drive. If VM expand or add a new virtual disk. The process is the same once the drive is added or expanded. I also assume you are using a RHEL derivative distro. If you use Ubuntu the process may be slightly different due to slight differences in configuration locations. But you should be able to figure it out. Root is required so sudo -i
if not already root. Verify Filesystem and Partitions Run the following command to verify your server is using XFS.df -Th
Check to see how many primary partitions there are for the partition you want to expand. If there are already 4 you will need to add a new primary.fdisk -l
Option 1: Expand the existing disk size Warning: This option will require the VM to be shutdown in some Virtual Hosts in order to expand the existing drive. Once you have expanded the drive boot into the VM if it was required to shutdown. Note: If you had to boot into the VM you do not need to rescan your SCSI devices as that happens on boot. If your VM host does not require reboot then you can do live drive expansion. Run the following process to rescan your SCSI devices. First check the name(s) of your SCSI devices. [code=bash]ls /sys/clas/scsi_device/ 0:0:0:0 1:0:0:0 2:0:0:0 2:0:1:0 2:0:2:0
Then rescan the SCSI bus. On this example there are four devices. Execute the following commands to re-scan them all. [code=bash]echo 1 > /sys/class/scsi_device/0\:0\:0\:0/device/rescan echo 1 > /sys/class/scsi_device/1\:0\:0\:0/device/rescan echo 1 > /sys/class/scsi_device/2\:0\:1\:0/device/rescan echo 1 > /sys/class/scsi_device/2\:0\:2\:0/device/rescan
Executefdisk -l
to check if new size is visible. Option 2: If you've added a new disk Option 2 is required if you already have four primary partitions. After adding a new disk on the server, the actions are similar to those described above. But instead of rescanning an already existing SCSI bus, you have to rescan the host to detect the new SCSI bus as you have added a new disk. You may have multiple hosts. Also, you should not need to reboot your VM or metal if you added a new disk. Note: Again this depends on the host type. [code=bash]ls /sys/class/scsi/host/ host0
You may need to scan the different host bus if there are more listed from the previous command for the new drive to show up. [code=bash]echo "- - -" > /sys/class/scsi_host/host0/scan
It will not show any output, but runningfdisk -l
will show the new disk and extra space. Create New Partition Using fdisk create a new partition on the new/dev/sd?
where ? is the new SCSI device. Entern
to create a new partition.p
for primary. Select partition number,t
to change type.8e
for Linux LVM.w
to write table. The example below shows the process in action. [code=bash]fdisk /dev/sdc 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-6291455, default 2048): Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-6291455, default 6291455): Created a new partition 1 of type 'Linux' and of size 3 GiB. Command (m for help): t Selected partition 1 Hex code or alias (type L to list all): 8e Changed type of partition 'Linux' to 'Linux LVM'. Command (m for help): w The partition table has been altered. Calling ioctl() to re-read partition table. Syncing disks.
Run the following to scan for the newly created partition:partprobe -s
Afterwards you can see the newly created partitoin with fdisk. [code=bash]fdisk -l ... Disk /dev/sdc: 3 GiB, 3221225472 bytes, 6291456 sectors Disk model: VMware Virtual S 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: 0x801fbd21
Extend the Logical Volume with the new partition Create the physical volume as a basis for your LVM with pvcreate./dev/sdc1
is the example drive. Change to what is listed on your system. [code=bash]pvcreate /dev/sdc1
Now find out how your Volume Group is named with vgdisplay. [code=bash]vgdisplay --- Volume group --- VG Name cs
Let's Extend the Volume Group by adding the newly created physical volume to it with vgextend. [code=bash]vgextend cs /dev/sdc1
With pvscan, we can see the newly added physical volume, and the usable space (3 GB in this case). [code=bash]pvscan PV /dev/sda3 VG cs lvm2 [18.41 GiB / 0 free] PV /dev/sdb1 VG cs lvm2 [<10.00 GiB / 0 free] PV /dev/sdc1 VG cs lvm2 [<3.00 GiB / <3.00 GiB free] Total: 3 [31.40 GiB] / in use: 3 [31.40 GiB] / in no VG: 0 [0 ]
Now we can extend Logical Volume (as opposed to the Physical Volume we added to the group earlier). First, check the logical volumes available on system command withls /dev/VolGroup/Name
where VolGroupName was identified from vgdisplay command. [code=bash]ls /dev/cs root swap
We have root and swap logical volumes. To extend the logical volume root, execute the following. [code=bash] lvextend /dev/cs/root /dev/sdc1 Size of logical volume cs/root changed from <26.41 GiB (6760 extents) to 29.40 GiB (7527 extents). Logical volume cs/root successfully resized.
Resizing the File System All that remains now, is to resize the file system to the volume group, so we can use the space. Execute xfs_growfs command as shown below. Replace the cs-root with the volume group name on your system. [code=bash]xfs_growfs /dev/mapper/cs-root meta-data=/dev/mapper/cs-root isize=512 agcount=7, agsize=1075456 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=1, sparse=1, rmapbt=0 = reflink=1 bigtime=1 inobtcount=1 data = bsize=4096 blocks=6922240, 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 6922240 to 7707648
Executedf -h
to confirm the new disk size is available to the server partition. To see the distribution of the block devices runlsblk
. [code=bash]lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT fd0 2:0 1 4K 0 disk sda 8:0 0 300G 0 disk ??sda1 8:1 0 1G 0 part /boot ??sda2 8:2 0 299G 0 part ??cs-root 253:0 0 249.2G 0 lvm / ??cs-swap 253:1 0 15.8G 0 lvm [SWAP] ??cs-home 253:2 0 134G 0 lvm /home sdb 8:16 0 100G 0 disk ??sdb1 8:17 0 100G 0 part ??cs-root 253:0 0 249.2G 0 lvm /0 -
@plateau_dustind - while that would definitely work, I don't believe that is the best course of action for this particular user. Freeing up a bit of space from / would be much easier than trying to repartition a live system. 0 -
Growing a partition is not a drastic change to the system. It is used when you cannot delete anymore files, unable to shrink a database down any lower to reduce the size on the partition or adding more storage drives. Depending on how fast you can type and if you need to reboot, the process takes less than 20 minutes. 0 -
@plateau_dustind I think you are making an assumption that these are LVM. Without more digging there is no way of know if /dev/md2 is LVM or just a physical partition. If it's a VM the physical partition could be grown and then the file system could be grown. 0 -
Yes. I am assuming OP is running a modern RHEL based distro installed between 2014 and 2023 like AlmaLinux, CloudLinux or something similar. If that is not the case, then I would have hoped my second sentence where I said to google if different would have been followed. But sometimes it is hard to identify the correct search term to help with a problem when under pressure to get services back up. So if OP is not running RHEL based distro and instead using Ubuntu based with ext2/3/4 and without LVM 0
Please sign in to leave a comment.
Comments
9 comments