How to recursively chmod all directories Or files

 How to recursively chmod all directories Or files

To recursively give directories read&execute privileges:

find /path/to/base/dir -type d -exec chmod 755 {} +

To recursively give files read privileges:

find /path/to/base/dir -type f -exec chmod 644 {} +

Or, if there are many objects to process:

chmod 755 $(find /path/to/base/dir -type d)
chmod 644 $(find /path/to/base/dir -type f)

Note these recipes may not work correctly if you have whitespace in your input [also true of the xargs examples below].


Or, to reduce chmod spawning:

find /path/to/base/dir -type d -print0 | xargs -0 chmod 755 
find /path/to/base/dir -type f -print0 | xargs -0 chmod 644
Đọc thêm..

How to fix ‘$MFTMirr does not match $MFT (record 0)’

 

How to fix ‘$MFTMirr does not match $MFT (record 0)’

Sometimes, when you are executing a file transfer between your computer hard drive and an external drive and your computer shutdown for some reason (in my case, no battery/ac power) it’s pretty common to get some errors on external drives that uses NTFS as they file system.

The most common message is:

Error mounting: mount exited with exit code 13: $MFTMirr does not match $MFT (record 0).
Failed to mount ‘/dev/sdb3’: Input/output error
NTFS is either inconsistent, or there is a hardware fault, or it’s a
SoftRAID/FakeRAID hardware. In the first case run chkdsk /f on Windows
then reboot into Windows twice. The usage of the /f parameter is very
important! If the device is a SoftRAID/FakeRAID then first activate
it and mount a different device under the /dev/mapper/ directory, (e.g.
/dev/mapper/nvidia_eahaabcc1). Please see the ‘dmraid’ documentation
for more details.

One workaround for this issue is to do as the message says, boot on Windows and try to use the awesome NTFS tool that Windows offer. But a perfect solution for a Linux users is to use the ntfsprogs utility.

UPDATE: On some recent Linux releases, you need to install ntfs-3g utilties.  Try sudo apt-get install ntfs-3g or download from http://www.tuxera.com/community/ntfs-3g-download/

ntfsprogs is a suite of NTFS utilities based around a shared library. The tools are available for free and come with full source code.

  • mkntfs: Create an NTFS volume on a partition
  • ntfscat: Print a file on the standard output
  • ntfsclone: Efficiently backup/restore a volume at the sector level
  • ntfscluster: Given a cluster, or sector, find the file
  • ntfsfix: Forces Windows to check NTFS at boot time
  • ntfsinfo: Dump a file’s attributes, completely
  • ntfslabel: Display or set a volume’s label
  • ntfslib: Move all the common code into a shared library
  • ntfsls: List directory contents
  • ntfsresize: Resize an NTFS volume
  • ntfsundelete: Find files that have been deleted and recover them
  • ntfswipe: Write zeros over the unused parts of the disk
  • ntfsdefrag: Defragment files, directories and the MFT
  • ntfsck: Perform consistancy checks on a volume
  • nttools: Command-line tools to view/change an offline NTFS volume, e.g. ntfscp, ntfsgrep, ntfstouch, ntfsrm, ntfsrmdir, ntfsmkdir
  • ntfsdiskedit: Walk the tree of NTFS ondisk structures (and alter them)

Be careful with these utilities, they might damage the filesystem, or your hard disk !

With ntfsprogs installed (sudo apt-get install ntfsprogs) you should execute the following commands in a terminal:

sudo ntfsfix /dev/partitionName

After this command you should expect the following output:

~$ sudo ntfsfix /dev/sdb3
Mounting volume... FAILED
Attempting to correct errors...
Processing $MFT and $MFTMirr...
Reading $MFT... OK
Reading $MFTMirr... OK
Comparing $MFTMirr to $MFT... FAILED
Correcting differences in $MFTMirr record 0...OK
Processing of $MFT and $MFTMirr completed successfully.
Setting required flags on partition... OK
Going to empty the journal ($LogFile)... OK
NTFS volume version is 3.1.
NTFS partition /dev/sdb3 was processed successfully.

After this step you should be able to access your external drive partition as usual, mount or use nautilus to access your files.

Source:  http://gnuwin32.sourceforge.net/packages/ntfsprogs.htm

https://wmarkito.wordpress.com/2010/12/29/how-to-fix-mftmirr-does-not-match-mft-record-0/

 

Đọc thêm..

How to Fix NTFS Partition Failed to Mount Error in Linux

How to Fix NTFS Partition Failed to Mount Error in Linux

In this article, we will show how to fix NTFS failed to mount errors such as “Failed to mount ‘/dev/sdax’: Input/output error, NTFS is either inconsistent, or there is a hardware fault, or it’s a SoftRAID/FakeRAID hardware”.

The following screenshot shows an example of an NTFS failed to mount error.

NTFS - Failed to mount ‘/dev/sdax’: Input/output error
NTFS – Failed to mount ‘/dev/sdax’: Input/output error

To fix this error, you can use ntfsfix, a tiny and useful utility that fixes some common NTFS problems. A ntfsfix is part of the ntfs-3g package (an open-source implementation of NTFS) and it repairs several fundamental NTFS inconsistencies, resets the NTFS journal file, and schedules an NTFS consistency check for the first boot into Windows.

To run it on our computer, you need to install the ntfs-3g package as follows.

----------- On Debian, Ubuntu & Mint ----------- 
$ sudo apt-get install ntfs-3g

----------- On RHEL, CentOS & Fedora -----------
$ sudo yum install epel-release
$ sudo yum install ntfs-3g

Once you have the ntfs-3g package installed, run the ntfsfix command, provide the NTFS partition that has issues as an argument as shown.

$ sudo ntfsfix /dev/sda5
Fix NTFS Failed to Mount Error
Fix NTFS Failed to Mount Error

To perform a dry-run where ntfsfix doesn’t write anything but only shows what would have been done, use the -n or --no-action option.

$ sudo ntfsfix -n /dev/sda5

A ntfsfix has another useful switch -b or --clear-bad-sectors for clearing the list of bad sectors. This feature is particularly useful after cloning an old disk with bad sectors to a new disk.

$ sudo ntfsfix -b /dev/sda5

Also, ntfsfix supports clearing the volume dirty flag if the volume can be fixed and mounted. You can invoke this feature bypassing the -d option as shown.

$ sudo ntfsfix -d /dev/sda5
Note: ntfsfix can only repair some NTFS partition errors. If it fails, chkdsk will probably succeed. If you have windows installed, you can also load Windows and run its disk checking program, chkdsk.

A nftsfix is a useful tool for fixing some common NTFS problems.

https://www.tecmint.com/fix-ntfs-partition-failed-to-mount-error/

 

 

Đọc thêm..

How to Increase VMware Virtual Disk Size LVM

 

Introduction:

In this post, I will explain how to expand disk space on a Linux system using Logical Volume Manager (LVM). Whether you’re dealing with a physical or virtual disk, this step-by-step tutorial will help you make the most of your storage without the need for a system reboot.

Step 1: Increase Disk Size

The first step is to increase the size of the disk that your Linux OS uses. This can be done by expanding the virtual disk in virtualization platforms like VMWare, KVM or Hyper-V. For this post, we’ll extend a 16 GB disk to 30 GB.

My Lab Details:

Hypervisor: VMware ESXi
VM: Ubuntu 22.04.1 LTS
expand-disk

root@ubuntu-test:~# df -h
Filesystem                         Size  Used Avail Use% Mounted on
tmpfs                               98M  1.3M   96M   2% /run
/dev/mapper/ubuntu--vg-ubuntu--lv  9.8G  6.7G  2.6G  73% /
tmpfs                              486M     0  486M   0% /dev/shm
tmpfs                              5.0M     0  5.0M   0% /run/lock
/dev/sda2                          1.7G  247M  1.4G  16% /boot
tmpfs                               98M  4.0K   98M   1% /run/user/1000

Disk is still not visible/listed

Step 2: Rescan the Disk

After resizing the disk, you may need to prompt Linux to recognize the additional free space. To check for free space, run the cfdisk command and see if it lists free space. Use “q” to exit when done. If there’s no free space listed, initiate a rescan for /dev/sda with the command:

echo 1 > /sys/class/block/sda/device/rescan

Stage 2: Modify the partition within the VM

(Note: It is time to stop, if you have not backup all your data, or if you are not sure about what you are doing.)

Step 6: type the following command, find Disk /dev/sda, and confirm the size (of step 3).

$ sudo fdisk -l

Step 7: Run the command

$ sudo fdisk /dev/sda

Step 8: Type 'p' to check the partition info.

(Warning: if you have more than one partitions, STOP using this guide.)

Step 9: Type 'd' to delete Partition 1.

Step 10: Type 'p', and confirm the changes

Step 11: Type 'n', hit 'Enter' 4 times to use defaults ([Partition type], [Partition number], [first sector], and [last sector]), and type 'n'. (You might not need the last 'n'.)

Note: Chose [N]

Partition #3 contains a LVM2_member signature.

Do you want to remove the signature? [Y]es/[N]o: n


 

Step 12: Type 'p', confirm the changes, and then type 'w'

Step 13: Restart the virtual machine.

Stage 3: Resize the disk space within the VM

Step 14: Run following command

$ sudo resize2fs /dev/sda1


Step 4: Extend the Physical Volume (PV)

With the LVM partition backing up the /dev/sda3 PV extended, it’s time to extend the PV itself.

Run

pvresize /dev/sda3

to accomplish this, and then use pvdisplay to verify the new size. In our example, the PV has increased from 14.2GB to 28.2G.

Step 5: Check Volume Group (VG) Free Space

Now, check the VG’s free space using vgdisplay. In our case, there’s 18.25 GiB of free space available within the VG.

Step 6: Extend Logical Volume (LV)

Use lvdisplay to verify the size of your upstream Logical Volume (LV). Extend the LV to use all available VG free space with the below command

lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv

Check the LV one more time with lvdisplay to ensure it’s been extended.

root@ubuntu-test:~# lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
  Size of logical volume ubuntu-vg/ubuntu-lv changed from 10.00 GiB (2560 extents) to <28.25 GiB (7231 extents).
  Logical volume ubuntu-vg/ubuntu-lv successfully resized.
root@ubuntu-test:~# lvdisplay
  --- Logical volume ---
  LV Path                /dev/ubuntu-vg/ubuntu-lv
  LV Name                ubuntu-lv
  VG Name                ubuntu-vg
  LV UUID                xL1oCY-qBRL-cT86-jRRr-0cWK-0P4W-U0Y1Dp
  LV Write Access        read/write
  LV Creation host, time ubuntu-server, 2023-04-12 11:44:17 +0000
  LV Status              available
  # open                 1
  LV Size                <28.25 GiB
  Current LE             7231
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0

Step 7: Resize the File System

At this point, the block volume supporting your root filesystem has been expanded, but the filesystem itself needs resizing. Run df -h to check the current filesystem size. Use the below command to resize it, and run df -h once more to confirm the new available space.

resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv 

Following the above steps, you can successfully expand your Linux Machine/VM physical or virtual disk space using LVM. This allows you to efficiently manage your storage resources and accommodate growing storage needs without disrupting your system. Hope this helps.

Đọc thêm..

Backup - Restore Remmina on Ubuntu

 

Installed Remmina on Ubuntu 16.04 and had to reinstall Ubuntu after a while because it wasn't running the best. On my first install, the location of all the Remmina connection files was /home/$USER/.local/share/remmina/ folder ($USER is the current user).

After I reinstalled my new setup of Ubuntu put all the connection files in the same location /home/$USER/.local/share/remmina/ and started up Remmina I had no connection. After reading this post, I created a new connection and seen a new folder created under /home/$USER/.remmina/ with that connection, so I copied all my connections into that folder /home/$USER/.remmina/.

sudo cp -r /home/$USER/.local/share/remmina/* /home/$USER/.remmina/
Đọc thêm..

Manager NFS volumes on Esxi

I. Method 1:

- Run this command to list the mounted datastores:

esxcli storage filesystem list 

 - Run this command to unmount the NFS datastore:

Unmount the datastore by running this command:

esxcli storage filesystem unmount [-u UUID | -l label | -p path ]

For example, use one of these commands to unmount the LUN01 datastore:

esxcli storage filesystem unmount -l LUN01
esxcli storage filesystem unmount -u 4e414917-a8d75514-6bae-0019b9f1ecf4
esxcli storage filesystem unmount -p /vmfs/volumes/4e414917-a8d75514-6bae-0019b9f1ecf4

II. Method 2:

- Run this command to list the mounted datastores:

esxcli storage nfs list  

- Run this command to unmount the NFS datastore:

esxcli storage nfs remove -v NFS1

exam: NFS1 is datastore

After running the esxcli storage nfs remove -v NFS1 command and it fails with this error similar to:

Unable to complete Sysinfo operation. Please see the VMkernel log file for more details.: Sysinfo error: BusySee VMkernel log for details.

- To resolve this issue: 

Isolate the UUID of the NFS mount by running this command:

vmkfstools -Ph -v10 /vmfs/volumes/NFS1

Example: 

vmkfstools -Ph -v10 /vmfs/volumes/NFS1/ 
 
 

NFS-1.00 (Raw Major Version: 0) file system spanning 1 partitions.
File system label (if any): NFS1
Mode: public
Capacity 86.5 GB, 86.5 GB available, file block size 4 KB, max supported file size 16777216 TB
Disk Block Size: 512/512/0
UUID: 003e96eb-9f51034a-0000-000000000000
Logical device: 192.168.10.120 /mnt/Prod/NFS1
Partitions spanned (on "notDCS"):
        nfs:003e96eb-9f51034a -----> UUID 
NAS VAAI Supported: NO
Is Native Snapshot Capable: NO
OBJLIB-LIB: ObjLib cleanup done.
WORKER: asyncOps=0 maxActiveOps=0 maxPending=0 maxCompleted=0

  1. List out the open files under this UUID by running this command:

    lsof | grep 003e96eb-9f51034a

    Example:

    lsof | grep 003e96eb-9f51034a
    2101956     sh                    cwd                        -1   

     
  2. Stop the process by running this command:

    kill -9 PID

    Example:

    kill -9 2101956
     
  3. You should now be able to remove the NFS mount successfully.

  

Đọc thêm..

Mysql Making a Differential or Incremental Backup

Mysql Making a Differential or Incremental Backup

https://dev.mysql.com/doc/mysql-enterprise-backup/8.0/en/mysqlbackup.incremental.html

https://snapshooter.com/learn/mysql/mysql-incremental-backup

https://www.cloudpanel.io/tutorial/how-to-set-up-mysql-incremental-backups/

 

Note: mysql 8

 

Đọc thêm..

Auto generate css

Auto generate css

 https://animista.net/play/basic

Đọc thêm..

Backup Proxmox Server add NFS share

 fstab in PBS VM:

Code:
#NFS PBS
192.168.49.4:/mnt/HDDpool/VeryLongDatasetName/VLT/NRM/PBS /mnt/pbs  nfs      defaults,nfsvers=3    0       0

datastore.cfg:
Code:
cat /etc/proxmox-backup/datastore.cfg
datastore: PBS_DS1
        comment for weekly and manual stop backups
        gc-schedule sun 07:00
        path /mnt/pbs
 
note: 
- Create .chunks folder in mount point.
- Grant permission on mount point
- User on PBS is backup 
Đọc thêm..