diff --git a/sbin/mount/mount_ufs.c b/sbin/mount/mount_ufs.c
index 1af7efa..d2eb5df 100644
--- a/sbin/mount/mount_ufs.c
+++ b/sbin/mount/mount_ufs.c
@@ -38,11 +38,13 @@
 
 #include <sys/param.h>
 #include <sys/mount.h>
+#include <sys/sysctl.h>
 
 #include <err.h>
 #include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <unistd.h>
 
 #include <vfs/ufs/ufsmount.h>
@@ -59,6 +61,7 @@ static struct mntopt mopts[] = {
 	MOPT_SYNC,
 	MOPT_UPDATE,
 	MOPT_IGNORE,
+	MOPT_TRIM,
 	MOPT_NULL
 };
 
@@ -98,6 +101,28 @@ mount_ufs(int argc, const char **argv)
 	else
 		args.export.ex_flags = 0;
 
+	if (mntflags & MNT_TRIM){
+		char sysctl_name[64];
+		int trim_enabled = 0;
+		size_t olen = sizeof(trim_enabled);
+		char *dev_name = strdup(args.fspec);
+		dev_name = strtok(dev_name + strlen("/dev/da"),"s");
+		sprintf(sysctl_name, "kern.cam.da.%s.trim_enabled", 
+			dev_name);
+		sysctlbyname(sysctl_name, &trim_enabled, &olen, NULL, 0);
+		if(errno == ENOENT) {
+			printf("Device:%s does not support the TRIM command\n",
+			       args.fspec);
+			ufs_usage();
+		}
+		if(!trim_enabled) {
+			printf("Online TRIM selected, but sysctl (%s) "
+			       "is not enabled\n",sysctl_name);
+			ufs_usage();
+
+		}
+	}
+
 	error = getvfsbyname("ufs", &vfc);
 	if (error && vfsisloadable("ufs")) {
 		if (vfsload("ufs")) {
diff --git a/sbin/newfs/mkfs.c b/sbin/newfs/mkfs.c
index c007689..96c38c2 100644
--- a/sbin/newfs/mkfs.c
+++ b/sbin/newfs/mkfs.c
@@ -38,6 +38,7 @@
 #include "defs.h"
 
 #include <stdlib.h>
+#include <sys/ioctl_compat.h>
 
 /*
  * make file system for cylinder-group style file systems
@@ -70,6 +71,8 @@ extern int	Lflag;		/* add a volume label */
 extern int	Nflag;		/* run mkfs without writing file system */
 extern int	Oflag;		/* format as an 4.3BSD file system */
 extern int	Uflag;		/* enable soft updates for file system */
+extern int	Eflag;		/* erase contents using TRIM */
+extern uint64_t slice_offset;	/* Pysical device slice offset */
 extern u_long	fssize;		/* file system size */
 extern int	ntracks;	/* # tracks/cylinder */
 extern int	nsectors;	/* # sectors/track */
@@ -136,6 +139,7 @@ void parentready(int);
 void rdfs(daddr_t, int, char *);
 void setblock(struct fs *, unsigned char *, int);
 void started(int);
+void erfs(off_t, off_t);
 void wtfs(daddr_t, int, char *);
 void wtfsflush(void);
 
@@ -236,6 +240,7 @@ mkfs(char *fsys, int fi, int fo, const char *mfscopy)
 		sblock.fs_flags |= FS_DOSOFTDEP;
 	if (Lflag)
 		strlcpy(sblock.fs_volname, volumelabel, MAXVOLLEN);
+
 	/*
 	 * Validate the given file system size.
 	 * Verify that its last block can actually be accessed.
@@ -677,6 +682,15 @@ next:
 			sblock.fs_flags & FS_DOSOFTDEP ? " SOFTUPDATES" : "");
 #undef B2MBFACTOR
 	}
+	
+	if (Eflag && !Nflag) {
+		printf("Erasing sectors [%ld --- %ld]\n",
+		    (SBOFF+ slice_offset)/sectorsize,
+		    fsbtodb(&sblock,sblock.fs_size) + ((SBOFF + slice_offset)/ sectorsize) - 1);
+		erfs(SBOFF+ slice_offset,
+		    (fsbtodb(&sblock,sblock.fs_size) + ((SBOFF + slice_offset)/ sectorsize) - 1) *
+			(unsigned long long)sectorsize);
+	}
 	/*
 	 * Now build the cylinders group blocks and
 	 * then print out indices of cylinder groups.
@@ -1246,6 +1260,18 @@ wtfsflush(void)
 }
 
 /*
+ * Issue ioctl to erase range of sectors using TRIM
+ */
+void
+erfs(off_t byte_start, off_t size)
+{
+	off_t ioarg[2];
+	ioarg[0] = byte_start;
+	ioarg[1] = size;
+	ioctl(fsi, IOCTLTRIM , ioarg);
+}
+
+/*
  * write a block to the file system
  */
 void
diff --git a/sbin/newfs/newfs.8 b/sbin/newfs/newfs.8
index 693eb66..cee48f3 100644
--- a/sbin/newfs/newfs.8
+++ b/sbin/newfs/newfs.8
@@ -43,7 +43,7 @@
 .Sh SYNOPSIS
 .Nm
 .Op Fl L Ar volname
-.Op Fl NCOU
+.Op Fl NCOURE
 .Op Fl S Ar sector-size
 .Op Fl T Ar disktype
 .Op Fl a Ar maxcontig
@@ -172,6 +172,10 @@ instead of trying to get geometry information from the
 storage device.
 .It Fl U
 Enables soft updates on the new filesystem.
+.It Fl E
+Use TRIM to erase the device's data before creating the file system. The
+underlying device must have the Trim sysctl enabled. Only devices that support
+TRIM will have such a sysctl option (kern.cam.da.X.trim_enabled).
 .It Fl a Ar maxcontig
 Specify the maximum number of contiguous blocks that will be
 laid out before forcing a rotational delay (see the
diff --git a/sbin/newfs/newfs.c b/sbin/newfs/newfs.c
index 714b750..f35955f 100644
--- a/sbin/newfs/newfs.c
+++ b/sbin/newfs/newfs.c
@@ -44,6 +44,7 @@
 #include <sys/diskslice.h>
 #include <sys/file.h>
 #include <sys/mount.h>
+#include <sys/sysctl.h>
 
 #include <vfs/ufs/dir.h>
 #include <vfs/ufs/dinode.h>
@@ -163,6 +164,8 @@ int	Nflag;			/* run without writing file system */
 int	Oflag;			/* format as an 4.3BSD file system */
 int	Cflag;			/* copy underlying filesystem (mfs only) */
 int	Uflag;			/* enable soft updates for file system */
+int	Eflag;			/* erase contents using TRIM */
+uint64_t slice_offset;		/* Pysical device slice offset */
 u_long	fssize;			/* file system size */
 int	ntracks = NTRACKS;	/* # tracks/cylinder */
 int	nsectors = NSECTORS;	/* # sectors/track */
@@ -237,9 +240,12 @@ main(int argc, char **argv)
 
 	opstring = mfs ?
 	    "L:NCF:T:Ua:b:c:d:e:f:g:h:i:m:o:s:v" :
-	    "L:NOS:T:Ua:b:c:d:e:f:g:h:i:k:l:m:n:o:p:r:s:t:u:vx:";
+	    "L:NREOS:T:Ua:b:c:d:e:f:g:h:i:k:l:m:n:o:p:r:s:t:u:vx:";
 	while ((ch = getopt(argc, argv, opstring)) != -1) {
 		switch (ch) {
+		case 'E':
+			Eflag = 1;
+			break;
 		case 'L':
 			volumelabel = optarg;
 			i = -1;
@@ -425,6 +431,30 @@ main(int argc, char **argv)
 	if (stat(special, &st) < 0 && special[0] && special[0] != '/')
 		asprintf(&special, "/dev/%s", special);
 
+	if (Eflag) {
+		char sysctl_name[64];
+		int trim_enabled = 0;
+		size_t olen = sizeof(trim_enabled);
+		char *dev_name = strdup(special);
+
+		dev_name = strtok(dev_name + strlen("/dev/da"),"s");
+		sprintf(sysctl_name, "kern.cam.da.%s.trim_enabled", 
+			dev_name);
+
+		sysctlbyname(sysctl_name, &trim_enabled, &olen, NULL, 0);
+
+		if(errno == ENOENT) {
+			printf("Device:%s does not support the TRIM command\n",
+			       special);
+			usage();
+		}
+		if(!trim_enabled) {
+			printf("Erase device option selected, but sysctl (%s) "
+			       "is not enabled\n",sysctl_name);
+			usage();
+			  
+		}
+	}
 	if (Nflag) {
 		fso = -1;
 	} else {
@@ -505,6 +535,7 @@ main(int argc, char **argv)
 			/* geom.d_ncylinders not used */
 			geom.d_media_blocks = pinfo.media_blocks;
 			geom.d_media_size = pinfo.media_size;
+			slice_offset = pinfo.media_offset;
 		}
 		if (geom.d_media_blocks == 0 || geom.d_media_size == 0) {
 			fatal("%s: is unavailable", argv[0]);
@@ -716,10 +747,12 @@ usage(void)
 #endif
 	fprintf(stderr, "where fsoptions are:\n");
 	fprintf(stderr, "\t-C (mfs) Copy the underlying filesystem to the MFS mount\n");
+	fprintf(stderr, "\t-E erase file system contents using TRIM\n");
 	fprintf(stderr, "\t-L volume name\n");
 	fprintf(stderr,
 	    "\t-N do not create file system, just print out parameters\n");
 	fprintf(stderr, "\t-O create a 4.3BSD format filesystem\n");
+	fprintf(stderr, "\t-R enable TRIM\n");
 	fprintf(stderr, "\t-S sector size\n");
 #ifdef COMPAT
 	fprintf(stderr, "\t-T disktype\n");
