LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Desktop (https://www.linuxquestions.org/questions/linux-desktop-74/)
-   -   /dev/sda2 is almost full. How can I remove files from it and put these files elsewhere there is lots of space? (https://www.linuxquestions.org/questions/linux-desktop-74/dev-sda2-is-almost-full-how-can-i-remove-files-from-it-and-put-these-files-elsewhere-there-is-lots-of-space-4175625003/)

e041110 03-05-2018 03:28 PM

/dev/sda2 is almost full. How can I remove files from it and put these files elsewhere there is lots of space?
 
/dev/sda2 keeps getting filled up and I cannot run my other software.
df -h gives
[exx@localhost ~]$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 210G 199G 5.0M 100% /
devtmpfs 16G 0 16G 0% /dev
tmpfs 16G 43M 16G 1% /dev/shm
tmpfs 16G 34M 16G 1% /run
tmpfs 16G 0 16G 0% /sys/fs/cgroup
/dev/sda1 477M 285M 163M 64% /boot
/dev/sdb1 1.8T 77M 1.7T 1% /data
tmpfs 3.2G 36K 3.2G 1% /run/user/1000

Can move some the files from sda2 to /data?

I cleared the history in my web browser, emptied my trash.

petelq 03-05-2018 03:52 PM

Who owns the files? I assume they're your data files and you have full access. If they're system files you'll have problems.
If they're yours, just check 'man mv' in a terminal and use 'mv' to move source file(s) to destination. Or in your file manager select all the files and drag them to their destination folder.
You can also set up a symlink within the original folder to the /data folder so you could still see/access them in the original folder.

If you wanted to check it all out first, you could copy (cp) instead of mv.

yancek 03-05-2018 05:48 PM

What is it filling up with? You have a root partition of 210 GB. 10% of that is usually more than enough to run any Linux system so I expect most of it is data. Why not use sdb1 which is basically empty. We can't tell how large your primary drive (sda) is as you posted the output of df -h which only shows mounted partitions. Do you have other partitions on sda?

frankbell 03-05-2018 08:21 PM

I tend to agree that, if you don't know why the drive is filling up, it's important to find out to make sure nothing has run amok.

Code:

$ du -d 1 -h
will give you a quick readout of where the file growth may be occurring at the level of one directory. See man du for more options.

You can use the mv (move) command to move files, if you have the rights to move them. See man mv for more.

e041110 03-06-2018 10:38 AM

here is the result of du -d 1 -h
[exx@localhost ~]$ du -d 1 -h
1.4M ./Pictures
1.6M ./.local
4.0K ./Music
7.1M ./.mozilla
1.6M ./.config
4.0K ./Downloads
4.0K ./Videos
4.0K ./Templates
4.0K ./Public
32M ./.cache
4.0K ./Desktop
4.0K ./Documents
44M .
It appears that ./.cache is 32 M and . is 44M. Is it safe to delete all the cache files? and how do I inspect and perhaps remove the . files?

scasey 03-06-2018 11:12 AM

Looks like you ran that in your home directory, there's only 44M there, you're looking for 199G...you need to run it for /
Code:

du -d 1 -h /
or maybe
Code:

sudo du -d 1 -h /

e041110 03-06-2018 11:45 AM

here is the result of du -d 1 -h /
[rt@localhost ~]$ sudo du -d 1 -h /
[sudo] password for rt:
17G /root
283M /boot
du: cannot access ‘/run/user/1001/gvfs’: Permission denied
9.6M /run
164G /home
4.0K /media
508K /data
0 /dev
du: cannot access ‘/proc/6821/task/6821/fd/4’: No such file or directory
du: cannot access ‘/proc/6821/task/6821/fdinfo/4’: No such file or directory
du: cannot access ‘/proc/6821/fd/4’: No such file or directory
du: cannot access ‘/proc/6821/fdinfo/4’: No such file or directory
0 /proc
1.4G /var
0 /sys
44M /etc
85M /tmp
17G /usr
8.0K /mnt
16K /lost+found
896M /opt
4.0K /srv
200G /
[rt@localhost ~]$

scasey 03-06-2018 01:11 PM

Quote:

Originally Posted by e041110 (Post 5827991)
here is the result of du -d 1 -h /
[rt@localhost ~]$ sudo du -d 1 -h /
[sudo] password for rt:
17G /root
283M /boot
9.6M /run
164G /home
4.0K /media
508K /data
0 /dev
0 /proc
1.4G /var
0 /sys
44M /etc
85M /tmp
17G /usr
8.0K /mnt
16K /lost+found
896M /opt
4.0K /srv
200G /
[rt@localhost ~]$

So, /home and /root is where most of the space is being consumed (181G of the 200G available)

You probably can't move everything out of those spaces, because /home is where (probably) your user home directories are...I'm not sure what'd be that big in /root, which is the root user's home directory.

That said, you now need to investigate what's in those directories to see why they're so full and what you could move to /data, where you have lots of space. I'm guessing there are pictures or movies there...something really big.

[My production server with more than 100 users and ~40 websites only consumes 38G, so you've got LOTS of something big in /home]

syg00 03-06-2018 05:10 PM

In a situation like this, no-one cares about /root - too much chance of messing things up. There's a couple of terrabytes waiting on /dev/sdb1.
If there is nothing on /data that you need, simply move /home to /dev/sdb1, and fix fstab. Problem solved. There are a bunch of good articles on how to do it on the web - generally for Ubuntu, but applicable to whatever you are running.

Edit: is that sdb a drive in the machine, or an external ?.

ondoho 03-07-2018 01:43 AM

comparing output posted in post #5 and post #7, something is strange (44M vs 164G)... can you run
Code:

sudo du -d 1 -h /home
one more time to get more clarity?

Shadow_7 03-07-2018 06:57 AM

Can you take the system OFFLINE to change it?

If YES, then it's easy.

With a larger disk (storage), and a live image to boot to treat files on a filesystem as such, $(cd /mnt/old/ && rsync -aRXHv ./* /mnt/new/), then change the /etc/fstab on the new location, some bootloader stuff, and boot from the larger disk. Baring a larger disk, you can use MORE disks, and move various places (like /usr/share/doc) to it's own device. The /home/ places are not really used until a user logs in, so you can mount manually those other devices, with root since it's not under /home/. But generally you should manage /etc/fstab to do those migrations at boot time. It makes things more complex, and you'll need to be aware of that. Like having /boot/ as it's own place means that you need to mount /boot/ before doing an upgrade that affects the kernel. Something you could be blissfully ignorant about if everything is just under /. Obviously skipping over the partitioning, filesystem creation, mounting and such (like many origami instructions do).

scasey 03-08-2018 02:15 PM

Quote:

Originally Posted by ondoho (Post 5828190)
comparing output posted in post #5 and post #7, something is strange (44M vs 164G)... can you run
Code:

sudo du -d 1 -h /home
one more time to get more clarity?

I'd agree that's the next step for the OP, since /home is where the disk usage is.

But, to clarify, #5 was run in the user's home directory, presumably /home/exx, while
#7 was run over the root directory (/) -- which showed that /home was where the problem is.


All times are GMT -5. The time now is 02:23 AM.