Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: =?UTF-8?Q?Josef_M=C3=B6llers?= Newsgroups: alt.os.linux.ubuntu Subject: Re: Zerofree won't run with LiveCD Date: Tue, 31 Mar 2026 14:38:40 +0200 Lines: 113 Message-ID: References: <10qenet$2pmir$1@dont-email.me> <10qf3r5$2u1jp$1@dont-email.me> <10qg0uu$362r5$1@dont-email.me> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: individual.net JLC8DtZCrVhXYWo61GYffAiyL/jFtCwot5s0bTufco5eKjsywJ Cancel-Lock: sha1:qyN82A1crDMq5yfXb9fX7ccbJgQ= sha256:gGhnV8vlpYu0wiYYw6De+TLpUb4nL+C9QS4s/qa+lHU= User-Agent: Mozilla Thunderbird Content-Language: en-US In-Reply-To: <10qg0uu$362r5$1@dont-email.me> Xref: csiph.com alt.os.linux.ubuntu:212498 On 31.03.26 10:34, George Garth wrote: > On 3/30/26 8:17 PM, Paul wrote: >> On Mon, 3/30/2026 4:46 PM, George Garth wrote: >>> One of my other tasks, aside from the cleansing of Win drives using >>> Sdelete and other tools, was to also cleanse the free space of Ubuntu >>> partitions. >>> >>> A prior post mentioned the use of Zerofree, but it has to be done on >>> unmounted partitions.  Today, I brought out an old LiveDVD with 16.04 >>> on it then installed Zerofree via apt.  I then  listed the partitions >>> and found the one I needed, /dev/sdb2, but trying to run sudo >>> zerofree /dev/sdb2, I get the following error:  failed to open file >>> system: /dev/sdb2.  I then tried to create a mount point (mkdir: / >>> mnt/temp) and then mounted /dev/sdb2 onto that point, but a new error >>> about something not in GRUB. >>> >>> Suggestions welcome for getting this up and running and thanks in >>> advance. >> >> My notes file says: >> >> sudo zerofree -v /dev/sdb1  # fill with zeros, before compaction in host >>                              # /dev/sdb1 should not be mounted when >> you run it >> >> ******* >> >> Do a "df" or a "cat /etc/mtab" and check what is mounted, as >> /dev/sdb1 should not be mounted for the example to work. >> >> ******* >> >> https://manpages.ubuntu.com/manpages/focal/man8/zerofree.8.html >> >>         zerofree - zero free blocks from ext2, ext3 and ext4 file-systems >> >>         -n         Perform a dry run  (do not modify the file-system); >> >>         -v         Be verbose: show the number of blocks modified by >> zerofree (or that would be modified, in  case >>                    the -n is used), the number of free blocks and the >> total number of blocks on the filesystem; >> >>         -f value   Specify the octet value to fill empty blocks with >> (defaults to 0). Argument must be within the >>                    range 0 to 255. >> >>     Paul > > Ok, well, I finally got it to run.... sort of.  I'll try to explain. I'm > not all that well versed in Linux particulars other than plug and play, > but here goes.... > > Booted into Ubuntu from a USB for a session. Did a "df" as suggested to > find: > > https://imgur.com/a/1RR4Yna > > Unmount /dev/sda2 to be sure and then tried to run Zerofree: > > https://imgur.com/a/IkkZCWb > > > The only way I could get Zerofree to run was to do: > > sudo zerofree -v /dev/sda8 and then the same except for sda7. > > Tried the swap as well but to no avail: > > https://imgur.com/a/r6eaAoT > > > So, my guess is that the program is not recognizing the extended sda2 > for some reason.  I'm going to assume that since I was able to use it on > sda7 & 8, I should be ok, but why not working for the swap? First of all: access to the (raw) disks is allowed to the administrator (called "root" in Linux) ONLY. Otherwise anybody could get around the protection mechanisms the file systems provide (*). So running "zerofree" with "sudo" (run the command as "root") is correct. Re /dev/sda2: According to the first screen shot, "sda2" is the extended partition and, as such, does not by itself hold a file system. Instead it holds "logical partitions" which tehn can hold file systems. Since the only two partitions that hold anything that looks like Linux file systems are "sda7" and "sda8", these two are the only partitions that you can run "zerofree" on. "sda5" is a (Linux) swap-partition and does not hold a file system, so you cannot fill any free space with zeroes. Thus said, if you run off a USB stick and you reallyreally want to also wipe the swap partition, then you could wipe the entire swap partition using "sudo dd if=/dev/zero of=/dev/sda5 bs=128k" and wait until that is done, this might just take some time. IMPORTANT NOTE: CHECK THE COMMAND LINE SEVERAL TIMES TO MAKE SURE YOU ACTUALLY SPECIFY THE SWAP PARTITION!!!! MAYBE ASK SOMEONE ELSE TO CHECK AS WELL. Also check if the system you run off the stick is not using the swap partition by running "cat /proc/swaps" (no "sudo" required, checking what is used as swap is not anything privileged) and check if "/dev/sda5" is not mentioned. If it is, run "sudo swapoff /dev/sda5" to turn that off. Hope this helps, Josef (*) When studying CS in the late 70s, one of the tasks in "Operating Systems" was to inspect the file system structure and dump the block addresses of a given disk file. To do that, "/dev/sda" and "/dev/sdb" were both readable by anybody ("world readable"). It was just a small step to the dump the contents of those blocks and thus access files that were not readable by anybody but the owner of the file ;-)