Filesystems
Filesystems¶
Reducing wasted space¶
Older systems (and maybe some new ones) will reserve 5% of space for root. This is sort of useful on small root disks but if you have a 10TB data drive it's daft to have 500GB unusable. Set the percentage reserved to 1% with this:
tune2fs -m 1 /dev/sda1
m can be zero.
Reload partition table¶
If you add a disk to a system, eg in VMWare, KVM or in cloud, you may need to rescan the partitions:
partprobe or partx -a /dev/sdX
The old school way is to poke the scsi driver with something like this:
- New disks:
echo "- - -" >> /sys/class/scsi_host/host0/scan(there may be a host1, host2 etc) - Resized disks:
echo 1 >> /sys/class/block/sd?/device/rescan(replace?with the letter of your drive)
To Sum all file sizes over 'n' days old¶
EG to get file sizes that are 1 year, 6 months, 3 months and one month old:
for i in 365 180 90 30
do
echo -n "$i == " ;
find . -type f -mtime +$i -printf '%s\n' | awk '{a+=$1;} END {printf "%.1f GB\n", a/2**30;}'
done
Setting date format in ls¶
Getting a consistent date stamp from ls can be done with the --time-style= option. eg:
ls -lR --time-style=+%s
will always return epoch. By default the style depends on the age of the file.