![]() ![]() This option removes libs and packages that were installed automatically to satisfy the dependencies of an installed package. If you read the apt-get commands guide, you might have come across the apt-get command option ‘autoremove’. Get rid of packages that are no longer required If you prefer videos, I have made a video to show you how to clean Ubuntu. I am using Ubuntu while writing this tutorial but you can use the same steps for Ubuntu versions, Linux Mint, elementary OS, and other Ubuntu-based Linux distributions. Not that you cannot use them, but it’s better to avoid them if you don’t know what you are doing. While I have mentioned several ways here, if you are a beginner, avoid the ones marked as ‘expert’. I have discussed several command-line tricks here followed by some GUI options. There are several ways you clean up disk space in Ubuntu and other Ubuntu-based system. Last time it happened to me it was a late saturday night and, while I really love my job, I can come up with many better ways to spend my saturday night.How to free up disk space in Ubuntu and Linux Mint The important thing is that your script takes every important aspect into account and warns you immediately when the database space drops below your threshold, not when the available space is over. I am sure that there are smarter scripts around that calculate it correctly and I am also sure that there are other ways to obtain the same results (PowerShell, to name one). ,SUM(available_space) AS available_space_mb WHEN -1 THEN (mbfree, size_mb, growth, is_percent_growth) RETURN report database filegroups with less than 20% available space IF OBJECT_ID('tempdb.calculateAvailableSpace') IS NOT NULLĮXEC _executesql N'DROP FUNCTION calculateAvailableSpace'ĭECLARE AS float = < = + * / 100.0 create a scalar function to simulate the growth of the database in the drive's available space SET = 'EXEC ' + + '.sys.sp_executesql sp_executesql nvarchar(max)', NEXT FROM c INTO c (SELECT name FROM sys.data_spaces WHERE data_space_id = mf.data_space_id), SET emptyspace_mb = size_mb - FILEPROPERTY(name,''SpaceUsed'') / 128, ![]() iterate through all databases to calculate empty space for its filesĭECLARE c CURSOR FORWARD_ONLY READ_ONLY STATIC LOCAL add an "emptyspace" column to hold empty space for each fileĪLTER TABLE #masterfiles ADD emptyspace_mb int NULL WHEN max_size = 268435456 AND type_desc = 'LOG' THEN -1ĬROSS APPLY sys.dm_os_volume_stats(database_id, file_id) AS d and correlate each file to its logical volume extract file information from sys.master_files IF OBJECT_ID('tempdb.#masterfiles') IS NOT NULL create a temporary table to hold data from sys.master_files ![]() That said, here is my script, I hope you find it useful. ![]() You can change that threshold to whatever you find appropriate (for instance, less than 20% AND less than 20 GB) 20% of a huge database can be lots of space.Make sure you’re monitoring that as well. NTFS performance start degrading when the drive free space drops below 20%. Database free space alone is not enough.Use sys.dm_os_volume_stats to include mount points in your calculation (unless you’re running SQL Server versions prior to 2012). Some scripts found in blogs and books don’t account for mount points.If percent growth is used, you have to calculate recursively how much your database file will grow before taking all the space in the drive.If fixed growth is used, there must be enough space in the drive to accomodate the growth amount you set.Hard set limits for file growth have to be considered: a drive with lots of space is useless if the database file cannot grow and take it.I was so upset that I decided to code my own monitoring script. I was actively evaluating one of those tools when one of my production databases ran out of space without any sort of warning. Lately I spent some time evaluating some monitoring tools for SQL Server and one thing that struck me very negatively is how none of them (to date) has been reporting database free space correctly. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |