[Tip and tricks] Cleaning Linux partitions in TrueOS and w/o Linux distro


#1

Cleaning Linux partitions using e2fsck in a Linux compatible environment for TrueOS helps to fix issues like ‘‘operation not permitted’’ errors mounting as rw w/o any Linux distro.:sunglasses:
Install a Linux compatible environment,

sudo pkg install -y linux-c7 linux-kernel linux_libusb archivers/rpm4 fusefs-ext2 fusefs-lkl

Then show your partitions,

[hd_scania@trueos] ~% sudo gpart show
=>       34  976773101  ada0  GPT  (466G)
       2048   58484736     1  freebsd-zfs  (28G)
   58722304   16777216     2  freebsd-swap  (8.0G)
   75499520   58720256     3  freebsd-zfs  (28G)
  134219776    2097152     4  efi  (1.0G)
  572524544   57200640    19  freebsd-zfs  (27G)
  631244800    2097152    20  freebsd-boot  (1.0G)
  633341952   58720256    21  freebsd-zfs  (28G)
  692062208   16777216    22  freebsd-swap  (8.0G)
  708839424  267933696    23  linux-data  (128G)
[hd_scania@trueos] ~% sudo e2fsck -pv /dev/ada0p23
data was not cleanly unmounted, check forced.
data: /lost+found not found.  CREATED.

        1315 inodes used (0.02%, out of 8380416)
         733 non-contiguous files (55.7%)
           0 non-contiguous directories (0.0%)
             # of inodes with ind/dind/tind blocks: 771/97/0
    11140592 blocks used (33.26%, out of 33491712)
           0 bad blocks
          10 large files

        1161 regular files
         144 directories
           0 character device files
           0 block device files
           0 fifos
           0 links
           0 symbolic links (0 fast symbolic links)
           0 sockets
------------
        1305 files                                                                                                                                                                              
[hd_scania@trueos] ~% sudo mount -t ext2fs -w /dev/ada0p23 /data && ls -la /data
total 57                                                                                                                                                                                        
drwxr-xr-x  13 hd_scania  wheel  4096 18 Jan 15:22 .                                                                                                                                            
drwxr-xr-x  22 root       wheel    44 25 Jan 18:57 ..                                                                                                                                           
drwx------   5 hd_scania  1000   4096 17 Jan 14:36 .Trash-1000                                                                                                                                  
drwxrwxr-x   2 hd_scania  1000   4096 17 Jan 20:24 amd64                                                                                                                                        
drwxr-xr-x   2 hd_scania  wheel  4096 14 Sep 11:45 exe                                                                                                                                          
drwxr-xr-x   4 hd_scania  wheel  4096  4 Dec 16:06 git                                                                                                                                          
drwxr-xr-x  13 hd_scania  wheel  4096 13 Jan 16:48 lib                                                                                                                                          
drwx------   2 root       wheel  4096 25 Jan 19:26 lost+found                                                                                                                                   
drwxr-xr-x   2 hd_scania  wheel  4096 14 Sep 11:41 obs                                                                                                                                          
drwxr-xr-x  11 hd_scania  wheel  4096  2 Jan 19:37 terminal                                                                                                                                     
drwxr-xr-x   3 hd_scania  wheel  4096  9 Jan 14:41 tg                                                                                                                                           
drwxr-xr-x   2 hd_scania  wheel  4096 14 Sep 11:44 three.com                                                                                                                                    
drwxr-xr-x   2 hd_scania  wheel  4096 17 Jan 20:26 vm                                                                                                                                           
[hd_scania@trueos] ~% cd /data && rm -rf .Trash* && ls -la
total 53                                                                                                                                                                                        
drwxr-xr-x  12 hd_scania  wheel  4096 25 Jan 19:31 .                                                                                                                                            
drwxr-xr-x  22 root       wheel    44 25 Jan 18:57 ..                                                                                                                                           
drwxrwxr-x   2 hd_scania  1000   4096 17 Jan 20:24 amd64                                                                                                                                        
drwxr-xr-x   2 hd_scania  wheel  4096 14 Sep 11:45 exe                                                                                                                                          
drwxr-xr-x   4 hd_scania  wheel  4096  4 Dec 16:06 git
drwxr-xr-x  13 hd_scania  wheel  4096 13 Jan 16:48 lib
drwx------   2 root       wheel  4096 25 Jan 19:26 lost+found
drwxr-xr-x   2 hd_scania  wheel  4096 14 Sep 11:41 obs
drwxr-xr-x  11 hd_scania  wheel  4096  2 Jan 19:37 terminal
drwxr-xr-x   3 hd_scania  wheel  4096  9 Jan 14:41 tg
drwxr-xr-x   2 hd_scania  wheel  4096 14 Sep 11:44 three.com
drwxr-xr-x   2 hd_scania  wheel  4096 17 Jan 20:26 vm
[hd_scania@trueos] /data%

All well done and you are here.:sun_with_face:


TrueOS Tips, Tricks, and FAQ
#2

can you add that to the pinned “TrueOS Tips, Tricks, and FAQ” thread?


#3

À propos: “using e2fsck in a Linux compatible environment for TrueOS”

a. gpart
b. mount
c. ls
d. rm
e. e2fsck

are all part of the FreeBSD Base System.

Where and what is the Linux compatible environment in this?

As far as I can see, Linux compatibility stuff was installed in the beginning, but not used, afterwards. Correct me, if I’m wrong.


#4

Is e2fsck part of base? Do a find . -name “e2fsck” -print in a base source tree doesn’t give me anything. find . -name “fsck” -print goes msdosfs and ffs versions of source, but not “e2” or ext versions. I could be wrong.


#5

a. Present:
~% which e2fsck
/sbin/e2fsck

b. but not package:
% pkg which /sbin/e2fsck
/sbin/e2fsck was not found in the database

c. ergo: BaseSystem

d. And “/sbin/…” is Base System, anyway.


#6

I’ll take that. I’d expect to see it in source somewhere. Maybe in a linux compat somewhere… No big deal.


#7

I had to check it myself. Didn’t know it before. But checked it.


#8

The other commands dnt require a Linux compatible environment in the FreeBSD userland but e2fsck is a part under this environment.


#9

% ls -l /compat/linux/usr/sbin/e2fsck
-rwxr-xr-x 5 root wheel 190344 Mar 23 2017 /compat/linux/usr/sbin/e2fsck*

% ls -l /sbin/e2fsck
-r-xr-xr-x 5 root wheel 624152 Dec 10 12:48 /sbin/e2fsck*

% echo $PATH
/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/usr/home/<accountname>/bin

It’s not in Your PATH. (If You didn’t add it. Did You?).
Therefore, You didn’t use it.